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:com.blstream.patronage.ctf.web.controller.trusted.AddPlayerController.java
/** * This method create new player in data base. * * Request context: /api/players/add//from w w w . j av a 2s .c om * Request method: POST * Request consumes: JSON * Response produces: JSON * * @param playerUI * @return MessageUI */ @RequestMapping(value = "/add", method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE }, produces = { MediaType.APPLICATION_JSON_VALUE }) @ResponseStatus(HttpStatus.CREATED) public @ResponseBody MessageUI addNewPlayer(@RequestBody PlayerUI playerUI) { if (logger.isDebugEnabled()) { logger.debug("---- addNewPlayer method invoked ----"); } Assert.notNull(playerUI, "PlayerUI cannot be null"); MessageUI message = new MessageUI(); try { Player player = playerService.createNewPlayer(playerUI); if (logger.isDebugEnabled()) { logger.debug( String.format("Player %s was created successfully", player.getPortalUser().getUsername())); } // TODO: get message from properties file: error-codes.properties // message.setMessage(SUCCESS); message.setErrorCode(ErrorCodeType.SUCCESS); } catch (AlreadyExistsException e) { if (logger.isWarnEnabled()) { logger.warn("New player was not created."); } // TODO: get message from properties file: error-codes.properties message.setError(ErrorCodeType.PLAYER_ALREADY_EXISTS.toString()); message.setErrorDescription(e.getMessage()); message.setErrorCode(ErrorCodeType.PLAYER_ALREADY_EXISTS); } catch (Exception e) { if (logger.isErrorEnabled()) { logger.error("New player was not created.", e); } // TODO: get message from properties file: error-codes.properties message.setError(ErrorCodeType.CANNOT_CREATE_NEW_PLAYER.toString()); message.setErrorDescription(e.getMessage()); message.setErrorCode(ErrorCodeType.CANNOT_CREATE_NEW_PLAYER); } return message; }
From source file:com.tsg.cms.BlogPostController.java
@RequestMapping(value = "/blogPost/{id}", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @ResponseBody//from ww w . j a v a 2s . c om public BlogPostContainer updateBlogPost(@PathVariable("id") int id, @RequestBody BlogPost blogPost) { blogPost.setPostId(id); return blogPostDao.updateBlogPost(blogPost); }
From source file:fr.esiea.windmeal.controller.crud.CrudCommentCtrl.java
@Secured("ROLE_USER") @RequestMapping(value = "/provider/{id}", method = RequestMethod.POST, consumes = "application/json;charset=UTF-8") @ResponseStatus(HttpStatus.CREATED) public void create(@RequestBody Comment comment, @PathVariable("id") String providerId) throws ServiceException, DaoException { LOGGER.info("[Controller] Querying to add a comment to the provider : " + providerId + "\""); crudService.addComment(providerId, comment); }
From source file:edu.kit.scc.RestServiceController.java
/** * SCIM create user endpoint.//from w w w.j a v a 2 s .c o m * * @param authorizationHeader basic or bearer HTTP authorization * @param scimUser (optional) the SCIM user to create * @return the created {@link ScimUser} */ @RequestMapping(path = "/Users", method = RequestMethod.POST, consumes = "application/scim+json", produces = "application/scim+json") public ResponseEntity<?> createUser(@RequestHeader("Authorization") String authorizationHeader, @RequestBody(required = false) ScimUser scimUser) { ScimUser user = userGenerator.createUser(scimUser); if (user != null) { return new ResponseEntity<ScimUser>(user, HttpStatus.CREATED); } return new ResponseEntity<ScimUser>(scimUser, HttpStatus.BAD_REQUEST); }
From source file:org.ala.spatial.web.services.LayerDistancesWSController.java
@RequestMapping(value = "/layers/analysis/inter_layer_association_rawnames.csv", method = RequestMethod.GET) public ResponseEntity<String> CSVrawnames(HttpServletRequest req) { String csv = makeCSV("name"); HttpHeaders responseHeaders = new HttpHeaders(); responseHeaders.setContentType(MediaType.parseMediaType("text/csv")); return new ResponseEntity<String>(csv, responseHeaders, HttpStatus.CREATED); }
From source file:com.billkoch.examples.people.controllers.PeopleController.java
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Person> create(@RequestBody Person person) { Person persistedPerson = peopleRepository.save(person); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}") .buildAndExpand(person.getId()).toUri()); return new ResponseEntity<>(persistedPerson, headers, HttpStatus.CREATED); }
From source file:com.envision.envservice.rest.PictureUploadResource.java
@POST @Consumes(MediaType.APPLICATION_JSON)/*w w w.ja v a2s . co m*/ @Produces(MediaType.APPLICATION_JSON) public Response addNew(ClgPictureBo clgPicture) throws Exception { HttpStatus status = HttpStatus.CREATED; String response = StringUtils.EMPTY; if (!checkParam(clgPicture)) { status = HttpStatus.BAD_REQUEST; response = FailResult.toJson(Code.PARAM_ERROR, "?"); } else { List<ClgPicture> list = ClgPictureService.addClgPicture(clgPicture); List<Map> maplist = new ArrayList<Map>(); for (int i = 0; i < list.size(); i++) { Map map = new HashMap(); map.put("id", list.get(i).getId().toString()); maplist.add(map); } response = JSONObject.toJSONString(maplist, JSONFilter.UNDERLINEFILTER); return Response.status(status.value()).entity(response).build(); } return null; }
From source file:com.envision.envservice.rest.UserCasePriseResource.java
@POST @Consumes(MediaType.APPLICATION_JSON)/* w ww. j a v a2 s.c o m*/ @Produces(MediaType.APPLICATION_JSON) public Response prise(UserCasePriseBo userCasePrise) throws Exception { HttpStatus status = HttpStatus.CREATED; String response = StringUtils.EMPTY; if (!checkParam(userCasePrise)) { status = HttpStatus.BAD_REQUEST; response = FailResult.toJson(Code.PARAM_ERROR, "?"); } else { userCasePriseService.prise(userCasePrise); } return Response.status(status.value()).entity(response).build(); }
From source file:am.ik.categolj2.api.link.LinkRestController.java
@RequestMapping(method = RequestMethod.POST, headers = Categolj2Headers.X_ADMIN) public ResponseEntity<LinkResource> postLinks(@RequestBody @Validated LinkResource linkResource) { Link link = beanMapper.map(linkResource, Link.class); Link created = linkService.create(link); LinkResource resource = beanMapper.map(created, LinkResource.class); return new ResponseEntity<>(resource, HttpStatus.CREATED); }
From source file:de.sainth.recipe.backend.rest.controller.BasicUnitController.java
@Secured("ROLE_ADMIN") @RequestMapping(method = RequestMethod.POST) HttpEntity<BasicUnit> add(@Valid @RequestBody BasicUnit basicUnit) { BasicUnit bu = repository.save(basicUnit); return new ResponseEntity<>(bu, HttpStatus.CREATED); }