List of usage examples for org.springframework.http ResponseEntity notFound
public static HeadersBuilder<?> notFound()
From source file:com.saasovation.identityaccess.resource.UserResource.java
@GetMapping(value = "{username}", produces = OvationsMediaType.ID_OVATION_TYPE) public ResponseEntity<String> getUser(@PathVariable("tenantId") String aTenantId, @PathVariable("username") String aUsername) { User user = this.identityApplicationService().user(aTenantId, aUsername); if (user == null) { return ResponseEntity.notFound().build(); }// ww w. java2s. c o m return this.userResponse(user); }
From source file:org.springsource.restbucks.payment.web.PaymentController.java
/** * Accepts a payment for an {@link Order} * * @param order the {@link Order} to process the payment for. Retrieved from the path variable and converted into an * {@link Order} instance by Spring Data's {@link DomainClassConverter}. Will be {@literal null} in case no * {@link Order} with the given id could be found. * @param number the {@link CreditCardNumber} unmarshaled from the request payload. * @return/*from w w w. j a va 2 s . c o m*/ */ @RequestMapping(path = PaymentLinks.PAYMENT, method = PUT) ResponseEntity<?> submitPayment(@PathVariable("id") Order order, @RequestBody CreditCardNumber number) { if (order == null || order.isPaid()) { return ResponseEntity.notFound().build(); } CreditCardPayment payment = paymentService.pay(order, number); PaymentResource resource = new PaymentResource(order.getPrice(), payment.getCreditCard()); resource.add(entityLinks.linkToSingleResource(order)); return new ResponseEntity<>(resource, HttpStatus.CREATED); }
From source file:de.codecentric.boot.admin.notify.filter.web.NotificationFilterController.java
@RequestMapping(path = "/api/notifications/filters/{id}", method = { RequestMethod.DELETE }) public ResponseEntity<?> deleteFilter(@PathVariable("id") String id) { NotificationFilter deleted = filteringNotifier.removeFilter(id); if (deleted != null) { return ResponseEntity.ok(deleted); } else {//from www . j av a2s.c o m return ResponseEntity.notFound().build(); } }
From source file:de.codecentric.boot.admin.registry.web.RegistryController.java
/** * Get a single application out of the registry. * * @param id The application identifier. * @return The registered application.//from w ww. j a v a 2s .c o m */ @RequestMapping(value = "/api/applications/{id}", method = RequestMethod.GET) public ResponseEntity<?> get(@PathVariable String id) { LOGGER.debug("Deliver registered application with ID '{}'", id); Application application = registry.getApplication(id); if (application != null) { return ResponseEntity.ok(application); } else { return ResponseEntity.notFound().build(); } }
From source file:com.orange.clara.pivotaltrackermirror.controllers.MirrorReferenceController.java
@ApiOperation(value = "Get a specific mirror referenced by its id", response = MirrorReference.class) @RequestMapping(method = RequestMethod.GET, value = "/{id:[0-9]*}", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<?> get(@PathVariable Integer id) { MirrorReference mirrorReference = this.mirrorReferenceRepo.findOne(id); if (mirrorReference == null) { return ResponseEntity.notFound().build(); }//from w w w .j a v a 2 s. co m return ResponseEntity.ok(mirrorReference); }
From source file:org.springsource.restbucks.payment.web.PaymentController.java
/** * Shows the {@link Receipt} for the given order. * * @param order//w w w .j a v a2 s. c o m * @return */ @RequestMapping(path = PaymentLinks.RECEIPT, method = GET) HttpEntity<?> showReceipt(@PathVariable("id") Order order) { if (order == null || !order.isPaid() || order.isTaken()) { return ResponseEntity.notFound().build(); } return paymentService.getPaymentFor(order).// map(payment -> createReceiptResponse(payment.getReceipt())).// orElseGet(() -> new ResponseEntity<>(HttpStatus.NOT_FOUND)); }
From source file:com.greglturnquist.springagram.fileservice.mongodb.ApplicationController.java
@RequestMapping(method = RequestMethod.GET, value = "/files/{filename}") public ResponseEntity<?> getFile(@PathVariable String filename) { GridFsResource file = this.fileService.findOne(filename); if (file == null) { return ResponseEntity.notFound().build(); }/*from www . j a v a2 s . c o m*/ try { return ResponseEntity.ok().contentLength(file.contentLength()) .contentType(MediaType.parseMediaType(file.getContentType())) .body(new InputStreamResource(file.getInputStream())); } catch (IOException e) { return ResponseEntity.badRequest().body("Couldn't process the request"); } }
From source file:de.codecentric.boot.admin.registry.web.RegistryController.java
/** * Unregister an application within this admin application. * * @param id The application id.//from w ww . j av a2 s . c om * @return the unregistered application. */ @RequestMapping(value = "/api/applications/{id}", method = RequestMethod.DELETE) public ResponseEntity<?> unregister(@PathVariable String id) { LOGGER.debug("Unregister application with ID '{}'", id); Application application = registry.deregister(id); if (application != null) { return ResponseEntity.ok(application); } else { return ResponseEntity.notFound().build(); } }
From source file:com.orange.clara.tool.controllers.api.WatchedResourcesController.java
@RequestMapping(method = RequestMethod.GET, value = "/{id}") public ResponseEntity<?> getWatchedResource(@PathVariable Integer id) { User user = this.getCurrentUser(); WatchedResource watchedResource = this.watchedResourceRepo.findOne(id); if (!watchedResource.isPublic() && !watchedResource.hasUser(user)) { return ResponseEntity.notFound().build(); }/*from w w w .j ava2 s . c om*/ return ResponseEntity.ok(this.generateResource(watchedResource)); }
From source file:io.ignitr.dispatchr.manager.controller.topic.TopicController.java
/** * Checks whether or not the supplied topic is registered with Dispatchr. * * @param topicName the name of the topic to check * @param httpRequest http request/*w ww . j a va2 s . c o m*/ * @return an HTTP 204 response if the topic is registered; otherwise an HTTP 404 if the topic is not registered */ @RequestMapping(method = RequestMethod.GET, value = "/registered", produces = MediaType.APPLICATION_JSON_VALUE) public DeferredResult<ResponseEntity<?>> isRegistered(@PathVariable("name") String topicName, HttpServletRequest httpRequest) { final DeferredResult<ResponseEntity<?>> deferredResult = new DeferredResult<>(); service.isRegistered(topicName).lift(new RequestContextStashOperator<>()).last() .subscribeOn(Schedulers.io()).subscribe(isRegistered -> { if (isRegistered) { deferredResult.setResult(ResponseEntity.noContent().build()); } else { deferredResult.setResult(ResponseEntity.notFound().build()); } }, error -> { deferredResult.setErrorResult(errorHandler.handleError(httpRequest, error)); }); return deferredResult; }