List of usage examples for org.springframework.http ResponseEntity notFound
public static HeadersBuilder<?> notFound()
From source file:com.crossover.trial.weather.endpoint.RestWeatherCollectorEndpoint.java
@Transactional @RequestMapping(path = "/collect/airport/{iata}", method = DELETE) @ApiResponses({ @ApiResponse(code = 204, message = "No Content"), @ApiResponse(code = 404, message = "Not Found"), @ApiResponse(code = 400, message = "Bad Request") }) public ResponseEntity<Void> deletAirport(@PathVariable("iata") IATA iata) { if (!airportRepository.exists(iata)) return ResponseEntity.notFound().build(); dataPointRepository.deleteAllMeasurements(iata); airportRepository.delete(iata);//from ww w .ja va2 s.c om return ResponseEntity.noContent().build(); }
From source file:org.openlmis.fulfillment.web.TransferPropertiesController.java
/** * Get chosen transfer properties./* w w w .ja v a 2s.com*/ * * @param id UUID of ftransfer properties whose we want to get * @return {@link TransferPropertiesDto}. */ @RequestMapping(value = "/transferProperties/{id}", method = RequestMethod.GET) public ResponseEntity retrieve(@PathVariable("id") UUID id) { LOGGER.debug("Checking right to view transfer properties"); permissionService.canManageSystemSettings(); TransferProperties properties = transferPropertiesRepository.findOne(id); return properties == null ? ResponseEntity.notFound().build() : ResponseEntity.ok(TransferPropertiesFactory.newInstance(properties, exporter)); }
From source file:org.openlmis.fulfillment.web.TransferPropertiesController.java
/** * Allows deleting transfer properties.//from w ww .ja v a2 s . c o m * * @param id UUID of transfer properties which we want to delete * @return ResponseEntity containing the HTTP Status */ @RequestMapping(value = "/transferProperties/{id}", method = RequestMethod.DELETE) public ResponseEntity delete(@PathVariable("id") UUID id) { LOGGER.debug("Checking right to delete transfer properties"); permissionService.canManageSystemSettings(); TransferProperties toDelete = transferPropertiesRepository.findOne(id); if (toDelete == null) { return ResponseEntity.notFound().build(); } else { transferPropertiesRepository.delete(toDelete); return ResponseEntity.noContent().build(); } }
From source file:org.openlmis.fulfillment.web.TransferPropertiesController.java
/** * Get transfer properties by facility ID. * * @param facility UUID of facility// w ww .ja va 2 s . c om * @return transfer properties related with the given facility */ @RequestMapping(value = "/transferProperties/search", method = RequestMethod.GET) public ResponseEntity search(@RequestParam("facility") UUID facility) { LOGGER.debug("Checking right to view transfer properties"); permissionService.canManageSystemSettings(); TransferProperties properties = transferPropertiesRepository.findFirstByFacilityId(facility); if (properties == null) { return ResponseEntity.notFound().build(); } else { return ResponseEntity.ok(TransferPropertiesFactory.newInstance(properties, exporter)); } }
From source file:jp.classmethod.aws.brian.web.TriggerController.java
/** * Delete specified trigger./*from w ww . j a va2 s .co m*/ * * @param triggerGroupName trigger group name * @param triggerName trigger name * @return wherther the trigger is removed * @throws SchedulerException */ @ResponseBody @RequestMapping(value = "/triggers/{triggerGroupName}/{triggerName}", method = RequestMethod.DELETE) public ResponseEntity<?> deleteTrigger(@PathVariable("triggerGroupName") String triggerGroupName, @PathVariable("triggerName") String triggerName) throws SchedulerException { logger.info("deleteTrigger {}.{}", triggerGroupName, triggerName); TriggerKey triggerKey = TriggerKey.triggerKey(triggerName, triggerGroupName); if (scheduler.checkExists(triggerKey) == false) { return ResponseEntity.notFound().build(); } boolean deleted = scheduler.unscheduleJob(triggerKey); if (deleted) { return ResponseEntity.ok(new BrianResponse<>(true, "ok")); } else { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body(new BrianResponse<>(false, "unschedule failed")); } }
From source file:com.spartasystems.holdmail.rest.MessageController.java
protected ResponseEntity serveContent(Object data, MediaType mediaType) { if (data == null) { return ResponseEntity.notFound().build(); }/* w ww. j av a 2s. c o m*/ return ResponseEntity.ok().contentType(mediaType).body(data); }
From source file:org.egov.infra.utils.FileStoreUtils.java
public ResponseEntity<InputStreamResource> fileAsResponseEntity(String fileStoreId, String moduleName, boolean toSave) { try {//from ww w . j a v a 2 s . c om Optional<FileStoreMapper> fileStoreMapper = getFileStoreMapper(fileStoreId); if (fileStoreMapper.isPresent()) { Path file = getFileAsPath(fileStoreId, moduleName); byte[] fileBytes = Files.readAllBytes(file); String contentType = isBlank(fileStoreMapper.get().getContentType()) ? Files.probeContentType(file) : fileStoreMapper.get().getContentType(); return ResponseEntity.ok().contentType(parseMediaType(defaultIfBlank(contentType, JPG_MIME_TYPE))) .cacheControl(CacheControl.noCache()).contentLength(fileBytes.length) .header(CONTENT_DISPOSITION, format(toSave ? CONTENT_DISPOSITION_ATTACH : CONTENT_DISPOSITION_INLINE, fileStoreMapper.get().getFileName())) .body(new InputStreamResource(new ByteArrayInputStream(fileBytes))); } return ResponseEntity.notFound().build(); } catch (IOException e) { LOGGER.error("Error occurred while creating response entity from file mapper", e); return ResponseEntity.badRequest().build(); } }
From source file:org.springframework.boot.actuate.endpoint.mvc.LogFileMvcEndpoint.java
private ResponseEntity<?> getResponse(boolean includeBody) { if (!isEnabled()) { return (includeBody ? DISABLED_RESPONSE : ResponseEntity.notFound().build()); }/*from w w w.j av a2s . co m*/ Resource resource = getLogFileResource(); if (resource == null) { return ResponseEntity.notFound().build(); } BodyBuilder response = ResponseEntity.ok().contentType(MediaType.TEXT_PLAIN); return (includeBody ? response.body(resource) : response.build()); }
From source file:org.springframework.cloud.function.test.RestConfiguration.java
@GetMapping("/") ResponseEntity<String> home() { logger.info("HOME"); if (this.outputs.hasNext()) { return ResponseEntity.ok(this.outputs.next()); }/* w w w. j a v a2s.co m*/ return ResponseEntity.notFound().build(); }
From source file:org.springframework.cloud.gateway.actuate.GatewayControllerEndpoint.java
@DeleteMapping("/routes/{id}") public Mono<ResponseEntity<Object>> delete(@PathVariable String id) { return this.routeDefinitionWriter.delete(Mono.just(id)) .then(Mono.defer(() -> Mono.just(ResponseEntity.ok().build()))).onErrorResume( t -> t instanceof NotFoundException, t -> Mono.just(ResponseEntity.notFound().build())); }