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.example.notes.NotesController.java
@ResponseStatus(HttpStatus.CREATED) @RequestMapping(method = RequestMethod.POST) HttpHeaders create(@RequestBody NoteInput noteInput) { Note note = new Note(); note.setTitle(noteInput.getTitle()); note.setBody(noteInput.getBody());//from w w w .ja v a2 s . c om note.setTags(getTags(noteInput.getTagUris())); this.noteRepository.save(note); HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.setLocation(linkTo(NotesController.class).slash(note.getId()).toUri()); return httpHeaders; }
From source file:reconf.server.services.product.UpsertProductService.java
@RequestMapping(value = "/product/{prod}", method = RequestMethod.PUT) @Transactional/*from w w w.j a va2 s . c om*/ public ResponseEntity<ProductResult> doIt(@PathVariable("prod") String product, @RequestParam(value = "user", required = false) List<String> users, @RequestParam(value = "desc", required = false) String description, HttpServletRequest request, Authentication auth) { if (!ApplicationSecurity.isRoot(auth)) { return new ResponseEntity<ProductResult>(HttpStatus.FORBIDDEN); } Product reqProduct = new Product(product, description); ResponseEntity<ProductResult> errorResponse = checkForErrors(auth, reqProduct, users); if (errorResponse != null) { return errorResponse; } HttpStatus status = null; Product dbProduct = products.findOne(reqProduct.getName()); if (dbProduct != null) { userProducts.deleteByKeyProduct(reqProduct.getName()); dbProduct.setDescription(description); status = HttpStatus.OK; } else { dbProduct = new Product(reqProduct.getName(), reqProduct.getDescription()); dbProduct.setDescription(description); products.save(dbProduct); status = HttpStatus.CREATED; } dbProduct.setUsers(users); users = CollectionUtils.isEmpty(users) ? Collections.EMPTY_LIST : users; for (String user : users) { if (ApplicationSecurity.isRoot(user)) { continue; } userProducts.save(new UserProduct(new UserProductKey(user, reqProduct.getName()))); } return new ResponseEntity<ProductResult>(new ProductResult(dbProduct, CrudServiceUtils.getBaseUrl(request)), status); }
From source file:net.paulgray.mocklti2.tools.LtiToolController.java
@RequestMapping(value = "/api/tools", method = RequestMethod.POST) public ResponseEntity addTool(@RequestBody LtiTool tool) { return new ResponseEntity(ltiToolService.addTool(tool), HttpStatus.CREATED); }
From source file:edu.eci.cosw.restcontrollers.RestControladorRegistrarReserva.java
@RequestMapping(value = "/alquilercliente", method = RequestMethod.POST) public ResponseEntity<?> registrarAlquilerCliente(@RequestBody Alquiler a) { //Reservacion r=(Reservacion)consultarReservacion(a.getReservacion().getIdReservacion()).getBody(); logica.crearEnsayoAlquiler(a.getEnsayo().getCliente().getIdCliente(), a.getReservacion(), a.getEnsayo().getDescripcion()); return new ResponseEntity<>(HttpStatus.CREATED); }
From source file:nl.flotsam.calendar.web.CalendarController.java
@RequestMapping(method = RequestMethod.PUT, value = "/calendars/{key}") @ResponseStatus(HttpStatus.CREATED) public void createCalendar(@PathVariable("key") String key, @RequestBody List<URI> feeds, HttpServletRequest request) throws URISyntaxException, MalformedURLException { logger.info("Creating calendar for key '" + key + "' and feeds: " + StringUtils.join(feeds, ", ")); Calendar calendar = repository.putCalendar(key, feeds); }
From source file:ca.qhrtech.controllers.ResultController.java
@ApiMethod(description = "Create a new Game Result") @RequestMapping(value = "/result", method = RequestMethod.POST) public ResponseEntity<GameResult> createResult(@RequestBody GameResult result) { if (!resultService.doesResultExist(result)) { GameResult newResult = resultService.saveResult(result); return new ResponseEntity<>(newResult, HttpStatus.CREATED); }/*from w ww . j a v a 2s . c o m*/ return new ResponseEntity<>(HttpStatus.CONFLICT); }
From source file:com.yoncabt.ebr.ws.ReportWS.java
@RequestMapping(value = { "/ws/1.0/status/{requestId}" }, method = RequestMethod.GET, produces = "application/json") public ResponseEntity<ReportResponse> status(@PathVariable("requestId") String requestId) { Status status = reportService.status(requestId); if (status == null) {//balamam logManager.info("status query :YOK !!! " + requestId); return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); }//from ww w. j av a2s.co m logManager.info("status query :" + requestId); switch (status) { case WAIT: logManager.info("status query :" + requestId + " :balam"); return ResponseEntity.status(HttpStatus.CREATED).body(null); case RUN: logManager.info("status query :" + requestId + " :devam ediyor"); return ResponseEntity.status(HttpStatus.PROCESSING).body(null); case EXCEPTION: logManager.info("status query :" + requestId + " :hata"); return ResponseEntity.status(420).body(null);// 420 Method Failure case FINISH: logManager.info("status query :" + requestId + " :bitmi"); return ResponseEntity.status(HttpStatus.OK).body(null); case CANCEL: logManager.info("status query :" + requestId + " :iptal"); return ResponseEntity.status(HttpStatus.OK).body(null); case SCHEDULED: logManager.info("status query :" + requestId + " :balam"); return ResponseEntity.status(HttpStatus.CREATED).body(null); default: throw new IllegalArgumentException(status.name()); } }
From source file:com.auditbucket.fortress.endpoint.FortressEP.java
@RequestMapping(value = "/", produces = "application/json", consumes = "application/json", method = RequestMethod.POST) @ResponseBody/*from w w w.j a v a 2 s .c o m*/ public ResponseEntity<Fortress> registerFortress(@RequestBody FortressInputBean fortressInputBean, String apiKey) { Company company = securityHelper.getCompany(apiKey); Fortress fortress = fortressService.registerFortress(company, fortressInputBean, true); fortressInputBean.setFortressKey(fortress.getFortressKey()); return new ResponseEntity<>(fortress, HttpStatus.CREATED); }
From source file:com.trafficfine.controller.TrafficFineController.java
/** * //from www. j av a 2s .c o m * @param infraction * @param ucBuilder * @return */ @RequestMapping(value = "/api/infracao/", method = RequestMethod.POST) public ResponseEntity<Void> createInfraction(@RequestBody Infraction infraction, UriComponentsBuilder ucBuilder) { logger.info("Creating infraction: " + infraction.getPlaca()); if (trafficFineService.isInfractionExist(infraction)) { logger.info("A infraction with license plate " + infraction.getPlaca() + " already exist"); return new ResponseEntity<Void>(HttpStatus.CONFLICT); } trafficFineService.saveInfraction(infraction); HttpHeaders header = new HttpHeaders(); header.setLocation(ucBuilder.path("/").buildAndExpand(infraction.getId()).toUri()); return new ResponseEntity<Void>(header, HttpStatus.CREATED); }
From source file:reconf.server.services.property.UpsertRestrictedPropertyService.java
@RequestMapping(value = "/product/{prod}/component/{comp}/property/{prop}/rule/{rule}", method = RequestMethod.PUT) @Transactional/*from w w w . j a v a2 s . com*/ public ResponseEntity<PropertyRuleResult> restricted(@PathVariable("prod") String product, @PathVariable("comp") String component, @PathVariable("prop") String property, @PathVariable("rule") String ruleName, @RequestBody String value, @RequestParam(value = "desc", required = false) String description, @RequestParam(value = "rpriority", required = false) Integer rulePriority, @RequestParam(value = "rexpr", required = false) String ruleRegexp, HttpServletRequest request, Authentication auth) { PropertyKey key = new PropertyKey(product, component, property, ruleName); Property reqProperty = new Property(key, value, description, rulePriority, ruleRegexp); ResponseEntity<PropertyRuleResult> errorResponse = checkForErrors(reqProperty); if (errorResponse != null) { return errorResponse; } HttpStatus status = null; Property dbProperty = properties.findOne(key); if (dbProperty != null) { dbProperty.setValue(value); dbProperty.setDescription(description); status = HttpStatus.OK; } else { dbProperty = reqProperty; properties.save(dbProperty); status = HttpStatus.CREATED; } return new ResponseEntity<PropertyRuleResult>( new PropertyRuleResult(dbProperty, CrudServiceUtils.getBaseUrl(request)), status); }