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.srinathavan.mwbng.rest.mvc.BlogEntryController.java
/** * /* w ww . j a v a 2 s. co m*/ * @param blogEntryId * @param requestBlogEntry * @return */ @RequestMapping(value = "/{blogEntryId}", method = RequestMethod.PUT) public ResponseEntity<Object> updateBlogEntry(@PathVariable Long blogEntryId, @RequestBody BlogEntry requestBlogEntry) { BlogEntry responseBlogEntry = blogEntryService.updateBlogEntry(blogEntryId, requestBlogEntry); if (null != responseBlogEntry) { return new ResponseEntity<Object>(responseBlogEntry, HttpStatus.OK); } else { return new ResponseEntity<Object>(HttpStatus.NOT_FOUND); } }
From source file:edu.eci.cosw.postresYa.controller.ActivityController.java
/** * Busca la imagen a un postre asociado por medio de un cdigo dado * @param code/* w w w. jav a2 s .c o m*/ * @return ResponseEntity */ @RequestMapping(value = "/{code}/picture", method = RequestMethod.GET) public ResponseEntity<InputStreamResource> getPostrePicture(@PathVariable String code) { try { return ResponseEntity.ok().contentType(MediaType.parseMediaType("image/jpg")) .body(new InputStreamResource(stub.getPostrePicture(code))); } catch (Exception e) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } }
From source file:org.fineract.module.stellar.controller.FederationServerController.java
@ExceptionHandler @ResponseStatus(HttpStatus.NOT_FOUND) public String handleInvalidNameFormatException( @SuppressWarnings("unused") final InvalidStellarAddressException ex) { return ex.getMessage(); }
From source file:com.sms.server.controller.MediaController.java
@RequestMapping(value = "/{id}", method = RequestMethod.GET) public ResponseEntity<MediaElement> getMediaElement(@PathVariable("id") Long id) { MediaElement mediaElement = mediaDao.getMediaElementByID(id); if (mediaElement == null) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); }/*from w w w . j a v a 2 s .c o m*/ return new ResponseEntity<>(mediaElement, HttpStatus.OK); }
From source file:io.syndesis.runtime.IntegrationsITCase.java
@Test public void createAndGetIntegration() { // Verify that the integration does not exist. get("/api/v1/integrations/2001", RestError.class, tokenRule.validToken(), HttpStatus.NOT_FOUND); // Create the integration. Integration integration = new Integration.Builder().id("2001").name("test") .desiredStatus(Integration.Status.Draft).currentStatus(Integration.Status.Draft).build(); post("/api/v1/integrations", integration, Integration.class); // Validate we can now fetch it. ResponseEntity<Integration> result = get("/api/v1/integrations/2001", Integration.class); assertThat(result.getBody().getName()).as("name").isEqualTo("test"); // Create another integration. integration = new Integration.Builder().id("2002").name("test2").desiredStatus(Integration.Status.Draft) .currentStatus(Integration.Status.Draft).build(); post("/api/v1/integrations", integration, Integration.class); // Check the we can list the integrations. ResponseEntity<IntegrationListResult> list = get("/api/v1/integrations", IntegrationListResult.class); assertThat(list.getBody().getTotalCount()).as("total count").isEqualTo(2); assertThat(list.getBody().getItems()).as("items").hasSize(2); // Lets delete it delete("/api/v1/integrations/2001"); // We should not be able to fetch it again.. get("/api/v1/integrations/2001", RestError.class, tokenRule.validToken(), HttpStatus.NOT_FOUND); // The list size should get smaller list = get("/api/v1/integrations", IntegrationListResult.class); assertThat(list.getBody().getTotalCount()).as("total count").isEqualTo(1); assertThat(list.getBody().getItems()).as("items").hasSize(1); }
From source file:fi.helsinki.opintoni.exception.GlobalExceptionHandlers.java
@ExceptionHandler(value = NotFoundException.class) public ResponseEntity<CommonError> handleNotFound() throws Exception { return new ResponseEntity<>(new CommonError("Not found"), HttpStatus.NOT_FOUND); }
From source file:org.kuali.mobility.emergencyinfo.controllers.EmergencyInfoController.java
@RequestMapping(value = "/{emergencyInfoId}", method = RequestMethod.GET, headers = "Accept=application/json") @ResponseBody// w w w . j a va 2s . c o m public Object get(@PathVariable("emergencyInfoId") Long emergencyInfoId) { EmergencyInfo emergencyInfo = emergencyInfoService.findEmergencyInfoById(emergencyInfoId); if (emergencyInfo == null) { return new ResponseEntity<String>(HttpStatus.NOT_FOUND); } return emergencyInfo.toJson(); }
From source file:web.EventLogRESTController.java
/** * Gets a specific event from the Event Log based on Event ID * @param id/*from w w w .j a v a 2 s .c om*/ * @return */ @RequestMapping(value = "/api/eventlog/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<EventLog> getEventInfo(@PathVariable("id") int id) { EventLog el = null; //returns a NOT_FOUND error if no Event is tied to specific EventID try { el = dao.getEventsById(id); } catch (EmptyResultDataAccessException ex) { return new ResponseEntity<EventLog>(HttpStatus.NOT_FOUND); } //otherwise returns specific Event's info return new ResponseEntity<EventLog>(el, HttpStatus.OK); }
From source file:com.aplikasi.penjualan.controller.DataPelangganController.java
@RequestMapping(value = "/pelanggan/{nik}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK)//from w w w . j av a2 s . co m public ResponseEntity<DataPelanggan> cariDataPelangganByNik(@PathVariable("kode") String kode) { DataPelanggan hasil = kd.findOne(kode); //menambahkan error 404 jika data yang dicari tidak ada if (hasil == null) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } return new ResponseEntity<>(hasil, HttpStatus.OK); }
From source file:com.opensearchserver.hadse.index.IndexCatalog.java
public final static ResponseEntity<?> delete(String indexName) throws IOException { File indexFile = new File(Hadse.data_dir, indexName); if (!indexFile.exists()) return new ResponseEntity<String>("Index not found:" + indexName, HttpStatus.NOT_FOUND); FileUtils.deleteDirectory(indexFile); if (indexFile.exists()) return new ResponseEntity<String>("Unable to delete the directory", HttpStatus.INTERNAL_SERVER_ERROR); IndexItem.remove(indexName);/*from w w w. j a va 2 s . c o m*/ return new ResponseEntity<String>("Index deleted: " + indexName, HttpStatus.OK); }