List of usage examples for org.springframework.http ResponseEntity notFound
public static HeadersBuilder<?> notFound()
From source file:com.epages.checkout.CartController.java
@GetMapping("/{cartId}") public ResponseEntity<Resource<Cart>> getCart(@PathVariable Long cartId) { return Optional.ofNullable(cartRepository.findOne(cartId)) .map(cart -> new Resource<>(cart, entityLinks.linkForSingleResource(cart).withSelfRel())) .map(ResponseEntity::ok).orElse(ResponseEntity.notFound().build()); }
From source file:com.saasovation.identityaccess.resource.NotificationResource.java
@GetMapping(produces = OvationsMediaType.ID_OVATION_TYPE) public ResponseEntity<String> getCurrentNotificationLog() { NotificationLog currentNotificationLog = this.notificationApplicationService().currentNotificationLog(); if (currentNotificationLog == null) { return ResponseEntity.notFound().build(); }/* w w w .j a va2 s.c o m*/ return this.currentNotificationLogResponse(currentNotificationLog); }
From source file:org.moserp.product.rest.ProductCatalogController.java
@ResponseBody @RequestMapping(method = RequestMethod.PUT, value = "/{catalogId}/products") public ResponseEntity<?> updateProducts(@PathVariable String catalogId, @RequestBody List<Product> products) { ProductCatalog productCatalog = productCatalogRepository.findOne(catalogId); if (productCatalog == null) { return ResponseEntity.notFound().build(); }//from ww w .j ava 2 s . com for (Product newProduct : products) { Product product = productRepository.findByExternalId(newProduct.getExternalId()); if (product == null) { product = newProduct; } else { domainObjectMerger.merge(newProduct, product, DomainObjectMerger.NullHandlingPolicy.IGNORE_NULLS); } product.setCatalog(productCatalog); productRepository.save(product); } return ResponseEntity.ok().build(); }
From source file:org.moserp.product.rest.ProductController.java
@ResponseBody @RequestMapping(method = RequestMethod.GET, value = "/{productId}/ean") public ResponseEntity<?> getProductEAN(@PathVariable String productId) throws WriterException, IOException { Product product = repository.findOne(productId); if (product == null) { return ResponseEntity.notFound().build(); }/*w ww .ja v a 2 s . com*/ EAN13Writer ean13Writer = new EAN13Writer(); BitMatrix matrix = ean13Writer.encode(product.getEan(), BarcodeFormat.EAN_13, 300, 200); BufferedImage bufferedImage = MatrixToImageWriter.toBufferedImage(matrix); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(bufferedImage, "png", baos); byte[] imageData = baos.toByteArray(); ByteArrayResource byteArrayResource = new ByteArrayResource(imageData); return ResponseEntity.ok().contentType(MediaType.IMAGE_PNG).body(byteArrayResource); }
From source file:com.saasovation.identityaccess.resource.UserResource.java
@GetMapping(value = "{username}/autenticatedWith/{password}", produces = OvationsMediaType.ID_OVATION_TYPE) public ResponseEntity<String> getAuthenticUser(@PathVariable("tenantId") String aTenantId, @PathVariable("username") String aUsername, @PathVariable("password") String aPassword) { UserDescriptor userDescriptor = this.identityApplicationService() .authenticateUser(new AuthenticateUserCommand(aTenantId, aUsername, aPassword)); if (userDescriptor.isNullDescriptor()) { return ResponseEntity.notFound().build(); }/*from w ww . j a v a 2s .co m*/ return this.userDescriptorResponse(userDescriptor); }
From source file:com.epages.checkout.CartController.java
@PutMapping("/{cartId}") public ResponseEntity<Resource<Cart>> addLineItem(@PathVariable Long cartId, @RequestBody @Valid AddLineItemRequest addLineItemRequest) { return Optional.ofNullable(cartRepository.findOne(cartId)) .map(cart -> addLineItemOrIncrementQuantity(cart, addLineItemRequest)) .map(cart -> cartRepository.saveAndFlush(cart)) .map(cart -> new Resource<>(cart, entityLinks.linkForSingleResource(cart).withSelfRel())) .map(ResponseEntity::ok).orElse(ResponseEntity.notFound().build()); }
From source file:com.saasovation.identityaccess.resource.NotificationResource.java
@GetMapping(value = "{notificationId}", produces = OvationsMediaType.ID_OVATION_TYPE) public ResponseEntity<String> getNotificationLog(@PathVariable("notificationId") String aNotificationId) { NotificationLog notificationLog = this.notificationApplicationService().notificationLog(aNotificationId); if (notificationLog == null) { return ResponseEntity.notFound().build(); }// w w w . j a va 2 s . c o m return this.notificationLogResponse(notificationLog); }
From source file:org.kelvmiao.sevenwonders.web.controller.UserController.java
@RequestMapping(method = RequestMethod.POST, value = "/login") ResponseEntity login(@RequestBody LoginRequest request) { User user = userService.login(request.getName(), request.getPassword()); if (user != null) { httpSession.setAttribute("uid", user.getUid()); httpSession.setAttribute("userName", user.getName()); return ResponseEntity.ok(user); }//www.ja v a2 s.co m return ResponseEntity.notFound().build(); }
From source file:com.couchbase.trombi.controllers.CoworkerController.java
@RequestMapping(value = "/{coworkerId}", method = RequestMethod.GET) public ResponseEntity<?> coworker(@PathVariable("coworkerId") int id) { Coworker c = repository.findOne(CoworkerRepository.PREFIX + id); if (c == null) return ResponseEntity.notFound().build(); else/* w w w. ja v a 2 s . c o m*/ return ResponseEntity.ok(c); }
From source file:de.dominikschadow.javasecurity.controller.IndexController.java
@GetMapping("download") @ResponseBody/*from w w w. j a v a2s . c o m*/ public ResponseEntity<Resource> download(@RequestParam("name") String name) { try { String originalName = resourceService.getFileByIndirectReference(name).getName(); String contentType = URLConnection.guessContentTypeFromName(originalName); Resource resource = resourceService.loadAsResource(originalName); return ResponseEntity.ok().contentType(MediaType.parseMediaType(contentType)).body(resource); } catch (MalformedURLException | AccessControlException ex) { log.error(ex.getMessage(), ex); } return ResponseEntity.notFound().build(); }