Java Code Examples for org.springframework.web.bind.annotation.RequestMethod#HEAD

The following examples show how to use org.springframework.web.bind.annotation.RequestMethod#HEAD . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@RequestMapping(method = RequestMethod.HEAD)
public ResponseEntity<Object> checkSupported(
		@PathVariable("windowId") final String windowIdStr,
		@PathVariable("documentId") final String documentIdStr_NOTUSED,
		@PathVariable("tabId") final String tabIdStr)
{
	userSession.assertLoggedIn();

	final WindowId windowId = WindowId.fromJson(windowIdStr);
	final DocumentEntityDescriptor includedDocumentDescriptor = documentsCollection.getDocumentEntityDescriptor(windowId)
			.getIncludedEntityByDetailId(DetailId.fromJson(tabIdStr));

	if (quickInputDescriptors.hasQuickInputEntityDescriptor(includedDocumentDescriptor))
	{
		return new ResponseEntity<>(HttpStatus.OK);
	}
	else
	{
		return new ResponseEntity<>(HttpStatus.NOT_FOUND);
	}

}
 
Example 2
/**
 * Error handler.
 *
 * @return Unauthorized (401), Forbidden (403) or Not Found (404) with no body.
 */
@RequestMapping(value = "/error", method = {RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT,
        RequestMethod.DELETE, RequestMethod.HEAD, RequestMethod.OPTIONS, RequestMethod.PATCH, RequestMethod.TRACE})
public ResponseEntity<?> error() {

    Map<String, Object> requestErrorAttributes = errorAttributes.getErrorAttributes(
            new ServletWebRequest(request), ErrorAttributeOptions.defaults());
    HttpStatus errorStatus = HttpStatus.valueOf((Integer) requestErrorAttributes.get("status"));

    if (HttpStatus.UNAUTHORIZED.equals(errorStatus) || HttpStatus.FORBIDDEN.equals(errorStatus)) {
        session.invalidate();
        return new ResponseEntity<>(errorStatus);
    } else {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }

}
 
Example 3
Source Project: lemon   File: OssRestController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 判断文件是否存在.
 */
@RequestMapping(method = RequestMethod.HEAD)
public void doesObjectExist(HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    logger.info("head");

    OssAccess ossAccess = this.checkAuthorization(request, response);

    if (ossAccess == null) {
        return;
    }

    try {
        OssConfigDTO ossConfigDto = this.processConfig(request);
        OssDTO ossDto = ossService.doesObjectExist(
                ossConfigDto.getBucketName(), ossConfigDto.getObjectName());

        BaseDTO baseDto = new BaseDTO();
        baseDto.setCode(200);
        baseDto.setData(ossDto != null);

        response.setContentType("application/json");
        response.getWriter().write(jsonMapper.toJson(baseDto));
    } catch (Exception ex) {
        this.sendError(response, ex);
    }
}
 
Example 4
Source Project: zstack   File: RestServerController.java    License: Apache License 2.0 5 votes vote down vote up
@RequestMapping(
        value = RestConstants.ALL_PATH,
        method = {
                RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE,
                RequestMethod.GET, RequestMethod.HEAD,
        }
)
public void api(HttpServletRequest request, HttpServletResponse response) throws IOException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
    server.handle(request, response);
}
 
Example 5
Source Project: eagle   File: ConsoleIndex.java    License: Apache License 2.0 5 votes vote down vote up
@ResponseBody
@RequestMapping(value = "/user", method = RequestMethod.HEAD)
public void getLoginUser(HttpServletResponse response) {
    UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    String userName = userDetails.getUsername();
    if (Strings.isNullOrEmpty(userName)) {
        AuthenticatUtil.needAuthenticate(response);
        return;
    }
    AuthenticatUtil.authenticateSuccess(response, userName);
}
 
Example 6
@RequestMapping(value = "/ads/{id}/publishing", method = RequestMethod.HEAD)
@ResponseBody
public void publishHead(@PathVariable("id") Long id) {
    Ad ad = adService.findOne(id);
    if (ad == null || ad.getStatus() != Ad.Status.NEW) {
        throw new ResourceNotFoundException();
    }
}
 
Example 7
Source Project: spring-openapi   File: DummyController.java    License: MIT License 4 votes vote down vote up
@RequestMapping(path = "/{id}", method = RequestMethod.HEAD)
public ResponseEntity<Void> isPresent(@PathVariable("id") Integer id) {
	return null;
}
 
Example 8
@RequestMapping(value = "/admin/agent", method = RequestMethod.HEAD)
public void checkAgentVersion(HttpServletResponse response) {
    response.setHeader("Content-MD5", agentChecksum);
    setOtherHeaders(response);
}
 
Example 9
@RequestMapping(path = "/stores", method = RequestMethod.HEAD)
public ResponseEntity<Void> headResource() {
	return ResponseEntity.ok().header("h1", "v1").build();
}
 
Example 10
@RequestMapping(value = "/ba*", method = { RequestMethod.GET, RequestMethod.HEAD })
public void bar() {
}
 
Example 11
/**
 * Mapping to the HTTP request method `HEAD` is safe as long as no state-changing operations are performed within this method.
 */
@RequestMapping(value = "/request-mapping-head", method = RequestMethod.HEAD)
public void requestMappingHead() {
}
 
Example 12
@RequestMapping(method = RequestMethod.HEAD, path = "/head")
ResponseEntity<Void> head() {
	return ResponseEntity.ok().build();
}
 
Example 13
@RequestMapping(value = "/myPath.do", method = RequestMethod.HEAD)
public void head() {
}
 
Example 14
@RequestMapping(value = {"/", "/catalog.html"}, method = {RequestMethod.GET, RequestMethod.HEAD})
public String redirectRootCatalog() {
  return "redirect:/catalog/catalog.html";
}
 
Example 15
@RequestMapping(method = RequestMethod.HEAD, path = "/head")
ResponseEntity<Void> head() {
	return ResponseEntity.ok().build();
}
 
Example 16
Source Project: tutorials   File: FooController.java    License: MIT License 4 votes vote down vote up
@RequestMapping(method = RequestMethod.HEAD, value = "/foos")
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public Foo headFoo() {
    return new Foo(1, randomAlphabetic(4));
}
 
Example 17
/**
 * Mapping to several HTTP request methods is not OK if it's a mix of unprotected and protected HTTP request methods.
 */
@RequestMapping(value = "/request-mapping-all-unprotected-methods-and-one-protected-method",
        method = {RequestMethod.GET, RequestMethod.HEAD, RequestMethod.TRACE, RequestMethod.OPTIONS, RequestMethod.PATCH})
public void requestMappingAllUnprotectedMethodsAndOneProtectedMethod() {
}
 
Example 18
@RequestMapping(path = "/stores", method = RequestMethod.HEAD)
public ResponseEntity<Void> headResource() {
	return ResponseEntity.ok().header("h1", "v1").build();
}
 
Example 19
@RequestMapping(value = "/admin/tfs-impl.jar", method = RequestMethod.HEAD)
public void checkTfsImplVersion(HttpServletResponse response) {
    response.setHeader("Content-MD5", tfsSdkChecksum);
    setOtherHeaders(response);
}
 
Example 20
/**
 * 所以端点的请求代理入口:/admin/instances/{instanceId}/actuator/**
 * @author xujin
 * @param instanceId
 * @param servletRequest
 * @param servletResponse
 * @return
 * @throws IOException
 */
@ResponseBody
@RequestMapping(path = HALO_REQUEST_MAPPING_PATH, method = {RequestMethod.GET, RequestMethod.HEAD, RequestMethod.POST, RequestMethod.PUT, RequestMethod.PATCH, RequestMethod.DELETE, RequestMethod.OPTIONS})
public Mono<Void> endpointProxy(@PathVariable("instanceId") String instanceId,
                                HttpServletRequest servletRequest,
                                HttpServletResponse servletResponse) throws IOException {
   return super.endpointProxy(instanceId, servletRequest, servletResponse);
}