List of usage examples for org.springframework.http HttpStatus NOT_FOUND
HttpStatus NOT_FOUND
To view the source code for org.springframework.http HttpStatus NOT_FOUND.
Click Source Link
From source file:com.sms.server.controller.MediaController.java
@RequestMapping(value = "/{id}/contents", method = RequestMethod.GET) public ResponseEntity<List<MediaElement>> getMediaElementsByParentID(@PathVariable("id") Long id) { MediaElement parentDirectory = mediaDao.getMediaElementByID(id); if (parentDirectory == null) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); }/*ww w . j a v a 2 s .c o m*/ if (parentDirectory.getType() != MediaElementType.DIRECTORY) { return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE); } List<MediaElement> mediaElements = mediaDao.getMediaElementsByParentPath(parentDirectory.getPath()); if (mediaElements == null) { return new ResponseEntity<>(HttpStatus.NO_CONTENT); } return new ResponseEntity<>(mediaElements, HttpStatus.OK); }
From source file:reconf.server.services.property.UpsertRestrictedPropertyService.java
private ResponseEntity<PropertyRuleResult> checkForErrors(Property reqProperty) { List<String> errors = DomainValidator.checkForErrors(reqProperty); if (!errors.isEmpty()) { return new ResponseEntity<PropertyRuleResult>(new PropertyRuleResult(reqProperty, errors), HttpStatus.BAD_REQUEST); }/*from w w w . j ava2 s.com*/ if (!products.exists(reqProperty.getKey().getProduct())) { return new ResponseEntity<PropertyRuleResult>(new PropertyRuleResult(reqProperty, Product.NOT_FOUND), HttpStatus.NOT_FOUND); } if (!components .exists(new ComponentKey(reqProperty.getKey().getProduct(), reqProperty.getKey().getComponent()))) { return new ResponseEntity<PropertyRuleResult>(new PropertyRuleResult(reqProperty, Component.NOT_FOUND), HttpStatus.NOT_FOUND); } PropertyKey globalKey = new PropertyKey(reqProperty.getKey().getProduct(), reqProperty.getKey().getComponent(), reqProperty.getKey().getName()); if (!properties.exists(globalKey)) { return new ResponseEntity<PropertyRuleResult>( new PropertyRuleResult(reqProperty, Property.GLOBAL_NOT_FOUND), HttpStatus.NOT_FOUND); } if (StringUtils.equalsIgnoreCase(reqProperty.getKey().getRuleName(), Property.DEFAULT_RULE_NAME)) { return new ResponseEntity<PropertyRuleResult>( new PropertyRuleResult(reqProperty, Property.GLOBAL_UPDATE), HttpStatus.BAD_REQUEST); } return null; }
From source file:org.ff4j.spring.boot.exceptions.FF4jExceptionHandler.java
@ExceptionHandler(value = GroupNotExistsException.class) @ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "group does not exist") public void groupNotExistsException() { // Not necessary to handle this exception }
From source file:org.venice.piazza.servicecontroller.messaging.handlers.DeleteServiceHandler.java
/** * Handler for the DeleteServiceJob that was submitted. Stores the metadata * in MongoDB (non-Javadoc)/*from ww w. ja v a2 s . c om*/ * * @see org.venice.piazza.servicecontroller.messaging.handlers.Handler#handle( * model.job.PiazzaJobType) */ @Override public ResponseEntity<String> handle(PiazzaJobType jobRequest) { ResponseEntity<String> responseEntity; if (jobRequest != null) { coreLogger.log("Deleting a service", Severity.DEBUG); DeleteServiceJob job = (DeleteServiceJob) jobRequest; // Get the ResourceMetadata String resourceId = job.serviceID; coreLogger.log("deleteService serviceId=" + resourceId, Severity.INFORMATIONAL); String result = handle(resourceId, false); if ((result != null) && (result.length() > 0)) { String jobId = job.getJobId(); ArrayList<String> resultList = new ArrayList<>(); resultList.add(jobId); resultList.add(resourceId); responseEntity = new ResponseEntity<>(resultList.toString(), HttpStatus.OK); } else { coreLogger.log("No result response from the handler, something went wrong", Severity.ERROR); responseEntity = new ResponseEntity<>("DeleteServiceHandler handle didn't work", HttpStatus.NOT_FOUND); } } else { coreLogger.log("A null PiazzaJobRequest was passed in. Returning null", Severity.ERROR); responseEntity = new ResponseEntity<>("A Null PiazzaJobRequest was received", HttpStatus.BAD_REQUEST); } return responseEntity; }
From source file:com.github.vanroy.cloud.dashboard.controller.ApplicationController.java
/** * Proxy call instance with specific management method * @param id id of instance// ww w.jav a 2 s. c o m * @param method Management method name * @return Return directly from instance */ @RequestMapping(value = "/api/instance/{id}/{method}", method = RequestMethod.GET) public ResponseEntity<String> proxy(@PathVariable String id, @PathVariable String method) { String managementUrl = repository.getInstanceManagementUrl(id); if (managementUrl == null) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } try { HttpResponse response = httpClient.execute(new HttpGet(managementUrl + "/" + method)); return ResponseEntity.status(response.getStatusLine().getStatusCode()) .body(EntityUtils.toString(response.getEntity())); } catch (Exception e) { LOGGER.debug("Cannot proxy metrics to instance", e); } return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); }
From source file:org.cloudfoundry.identity.uaa.codestore.CodeStoreEndpoints.java
@RequestMapping(value = "/Codes/{code}", method = RequestMethod.GET) @ResponseBody/*from w w w. jav a2 s .c o m*/ public ExpiringCode retrieveCode(@PathVariable String code) { ExpiringCode result = null; try { result = expiringCodeStore.retrieveCode(code); } catch (NullPointerException e) { throw new CodeStoreException("code is required.", HttpStatus.BAD_REQUEST); } if (result == null) { throw new CodeStoreException("Code not found: " + code, HttpStatus.NOT_FOUND); } return result; }
From source file:de.hska.ld.content.controller.CommentControllerIntegrationTest.java
@Test public void testGetCommentsPageHttpNotFound() throws Exception { String invalidCommentPageUri = RESOURCE_COMMENT + "/-1" + "/comment"; HttpResponse response = UserSession.user().get(invalidCommentPageUri); Assert.assertEquals(HttpStatus.NOT_FOUND, ResponseHelper.getStatusCode(response)); }
From source file:de.hska.ld.content.controller.TagController.java
/** * <pre>//from w w w . j av a 2 s . c o m * Gets a page of tags. * * <b>Required roles:</b> ROLE_USER * <b>Path:</b> GET /api/tags?page-number=0&page-size=10&sort-direction=DESC&sort-property=createdAt * </pre> * * @param pageNumber the page number as a request parameter (default: 0) * @param pageSize the page size as a request parameter (default: 10) * @param sortDirection the sort direction as a request parameter (default: 'DESC') * @param sortProperty the sort property as a request parameter (default: 'createdAt') * @return <b>200 OK</b> and a tag page or <br> * <b>404 Not Found</b> if no tags exists or <br> * <b>403 Forbidden</b> if authorization failed */ @Secured(Core.ROLE_USER) @RequestMapping(method = RequestMethod.GET) public Callable getTagsPage(@RequestParam(value = "page-number", defaultValue = "0") Integer pageNumber, @RequestParam(value = "page-size", defaultValue = "10") Integer pageSize, @RequestParam(value = "sort-direction", defaultValue = "DESC") String sortDirection, @RequestParam(value = "sort-property", defaultValue = "createdAt") String sortProperty) { return () -> { Page<Tag> tagsPage = tagService.getTagsPage(pageNumber, pageSize, sortDirection, sortProperty); if (tagsPage != null) { return new ResponseEntity<>(tagsPage, HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } }; }
From source file:com.srinathavan.mwbng.rest.mvc.AccountController.java
/** * Method to account entry data by its id * /*w w w . j ava2 s . c o m*/ * @param accountId * @return */ @RequestMapping(value = "/{accountId}", method = RequestMethod.GET) public @ResponseBody ResponseEntity<Object> getAccountById(@PathVariable Long accountId) { Account account = accountService.findAccount(accountId); if (null != account) { return new ResponseEntity<Object>(account, HttpStatus.OK); } else { return new ResponseEntity<Object>(HttpStatus.NOT_FOUND); } }