List of usage examples for org.springframework.http HttpStatus CREATED
HttpStatus CREATED
To view the source code for org.springframework.http HttpStatus CREATED.
Click Source Link
From source file:technology.tikal.accounts.service.imp.AccountsImp.java
@Override @RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public void createAccount(@Valid @RequestBody final Account account, final BindingResult result, final HttpServletRequest request, final HttpServletResponse response) { if (result.hasErrors()) { throw new NotValidException(result); }/* www. j a va 2s .co m*/ accountsController.createAccount(account); response.setHeader("Location", request.getRequestURI() + "/" + account.getUser()); }
From source file:technology.tikal.gae.system.service.imp.SystemAccountServiceImp.java
@Override @RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public void createSystemAccount(@Valid @RequestBody final SystemUser account, final BindingResult result, final HttpServletRequest request, final HttpServletResponse response) { if (result.hasErrors()) { throw new NotValidException(result); }/*ww w . j a v a 2 s . c o m*/ if (account.getUsername() == null) { throw new MessageSourceResolvableException(new DefaultMessageSourceResolvable( new String[] { "NotNull.systemUser.username" }, new String[] {}, "Null username")); } if (account.getPassword() == null) { throw new MessageSourceResolvableException(new DefaultMessageSourceResolvable( new String[] { "NotNull.systemUser.password" }, new String[] {}, "Null password User")); } try { this.systemUserDao.consultar(account.getUsername()); throw new MessageSourceResolvableException(new DefaultMessageSourceResolvable( new String[] { "Duplicated.SystemAccountServiceImp.createSystemAccount" }, new String[] { account.getUsername() }, "Duplicated User")); } catch (NotFoundException e) { this.systemUserDao.guardar(account); response.setHeader("Location", request.getRequestURI() + "/" + account.getUsername()); } }
From source file:com.acc.controller.CustomerGroupsController.java
/** * Web service for creating new customer group.<br> * Sample call: https://localhost:9002/rest/v1/mysite/customergroups<br> * Method requires authentication and is restricted <code>HTTPS</code> channel.<br> * Method type : <code>POST</code>. <br> * Method response with 201 Created./* w ww . j ava 2s . c o m*/ * */ @ResponseStatus(value = HttpStatus.CREATED) @RequestMapping(method = RequestMethod.POST) @Secured("ROLE_CUSTOMERMANAGERGROUP") public void createNewCustomerGroup(@RequestParam final String uid, @RequestParam(required = false) final String localizedName) { customerGroupFacade.createCustomerGroup(uid, localizedName); }
From source file:com.agroservices.restcontrollers.DespachoRest.java
@RequestMapping(value = "/{id}/seRecogio", method = RequestMethod.POST) public ResponseEntity<?> modificarEstadoRecogida(@PathVariable int id, @RequestBody Despacho des) { boolean ans = df.setEstadoRecogida(id, des.isSeRecogio()); if (ans) {/*from ww w. ja v a 2s .c o m*/ return new ResponseEntity<>(HttpStatus.CREATED); } return new ResponseEntity<>(HttpStatus.CONFLICT); }
From source file:org.ow2.proactive.workflow_catalog.rest.controller.BucketController.java
@ApiOperation(value = "Creates a new bucket") @RequestMapping(value = "/buckets", method = POST) @ResponseStatus(HttpStatus.CREATED) public BucketMetadata create(@RequestParam(value = "name", required = true) String bucketName, @ApiParam(value = "The name of the user that will own the Bucket") @RequestParam(value = "owner", required = true) String ownerName) { return bucketService.createBucket(bucketName, ownerName); }
From source file:com.abixen.platform.core.interfaces.web.common.ImageLibraryController.java
@RequestMapping(value = "layout/{fileName}/", method = RequestMethod.GET) public ResponseEntity<byte[]> getImage(@PathVariable String fileName) throws IOException { log.debug("fileName: " + fileName); InputStream in;/* w w w.j av a2 s.co m*/ try { in = new FileInputStream(platformResourceConfigurationProperties.getImageLibraryDirectory() + "/layout-miniature/" + fileName); } catch (FileNotFoundException e) { in = new FileInputStream(platformResourceConfigurationProperties.getImageLibraryDirectory() + "/layout-miniature/default-layout-icon.png"); } byte[] b = IOUtils.toByteArray(in); in.close(); final HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.IMAGE_PNG); return new ResponseEntity<byte[]>(b, headers, HttpStatus.CREATED); }
From source file:io.curly.gathering.item.ItemController.java
/** * Method that handle user's intent to add a new item to a list * @param body valid body for request//w ww . j av a2s . co m * @param listId list to be added to * @param user current user on context * @param bindingResult result of validation of body * @return 400 if result returns errors or 201 if ok */ @RequestMapping(value = "/add/artifact", method = { RequestMethod.PUT, RequestMethod.POST }) public Callable<HttpEntity<?>> addItem(@Valid @RequestBody AddableItemBody body, @PathVariable String listId, @GitHubAuthentication User user, BindingResult bindingResult) { if (bindingResult.hasErrors()) { return () -> new ResponseEntity<Object>(new ModelErrors(bindingResult), HttpStatus.BAD_REQUEST); } else { return () -> { this.interaction.addItem(new AddableItem(body.getItem(), listId, ItemType.ARTIFACT), user); return new ResponseEntity<>(HttpStatus.CREATED); }; } }
From source file:fr.mby.opa.pics.web.controller.AlbumController.java
@ResponseBody @ResponseStatus(value = HttpStatus.CREATED) @RequestMapping(method = RequestMethod.POST) public Album createAlbumJson(@Valid @RequestBody final Album album) throws Exception { Assert.notNull(album, "No Album supplied !"); album.setCreationTime(new Timestamp(System.currentTimeMillis())); album.setLocked(false);/*from ww w .j ava2 s. c o m*/ this.albumDao.createAlbum(album); return album; }
From source file:reconf.server.services.component.UpsertComponentService.java
@RequestMapping(value = "/product/{prod}/component/{comp}", method = RequestMethod.PUT) @Transactional// www. j av a 2s .co m public ResponseEntity<ComponentResult> doIt(@PathVariable("prod") String productId, @PathVariable("comp") String componentId, @RequestParam(value = "desc", required = false) String description, HttpServletRequest request, Authentication auth) { ComponentKey key = new ComponentKey(productId, componentId); Component reqComponent = new Component(key, description); List<String> errors = DomainValidator.checkForErrors(key); if (!errors.isEmpty()) { return new ResponseEntity<ComponentResult>(new ComponentResult(reqComponent, errors), HttpStatus.BAD_REQUEST); } Product product = products.findOne(key.getProduct()); if (product == null) { return new ResponseEntity<ComponentResult>(new ComponentResult(reqComponent, Product.NOT_FOUND), HttpStatus.NOT_FOUND); } HttpStatus status = null; Component dbComponent = components.findOne(key); if (dbComponent == null) { dbComponent = new Component(key, description); components.save(dbComponent); status = HttpStatus.CREATED; } else { dbComponent.setDescription(description); status = HttpStatus.OK; } return new ResponseEntity<ComponentResult>( new ComponentResult(dbComponent, CrudServiceUtils.getBaseUrl(request)), status); }
From source file:io.curly.gathering.list.GatheringController.java
@RequestMapping(value = "", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) public Callable<HttpEntity<?>> createList(@Valid @RequestBody ListBody body, @GitHubAuthentication User user, BindingResult bindingResult) {//from w w w . j a va 2 s. com if (bindingResult.hasErrors()) { return () -> new ResponseEntity<>(new ModelErrors(bindingResult), HttpStatus.BAD_REQUEST); } else { return () -> { storage.save(new GatheringList(body.getName(), user.getId())); return new ResponseEntity<>(HttpStatus.CREATED); }; } }