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.tribuo.backend.controllers.ProductosController.java
/** * * @param p//from ww w . j a va 2 s . co m * @return */ @RequestMapping(value = "/insert", method = RequestMethod.POST) public ResponseEntity<Void> insertProducto(@RequestBody Productos p) { se.createProducto(p); return new ResponseEntity<>(HttpStatus.CREATED); }
From source file:org.trustedanalytics.kafka.adminapi.api.ApiController.java
@RequestMapping(method = RequestMethod.POST, value = "/topics", consumes = "application/json") @ResponseStatus(HttpStatus.CREATED) public void createTopic(@RequestBody TopicDescription topicDescription) { LOG.info("createTopic invoked: {}", topicDescription); if (StringUtils.isEmpty(topicDescription.getTopic())) { throw new InvalidTopicException("Missing mandatory topic name"); }/* w w w . j a v a 2 s.c o m*/ Topic.validate(topicDescription.getTopic()); if (topicDescription.getPartitions() <= 0) { throw new InvalidTopicException("Number of partitions must be larger than 0"); } kafkaService.createTopic(topicDescription); }
From source file:technology.tikal.ventas.service.catalogo.LineaProductoService.java
@RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public void crear(@PathVariable final Long idCatalogo, @Valid @RequestBody final LineaDeProductos request, final BindingResult result, final HttpServletRequest httpRequest, final HttpServletResponse httpResponse) { if (result.hasErrors()) { throw new NotValidException(result); }//from w w w. j ava 2s .c o m LineaDeProductos nuevo = lineaProductoController.crear(idCatalogo, request); httpResponse.setHeader("Location", httpRequest.getRequestURI() + "/" + nuevo.getId()); }
From source file:com.artivisi.belajar.restful.ui.controller.UserController.java
@RequestMapping(value = "/user", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public void create(@RequestBody @Valid User x, HttpServletRequest request, HttpServletResponse response) { belajarRestfulService.save(x);//from www. j av a2s.c o m String requestUrl = request.getRequestURL().toString(); URI uri = new UriTemplate("{requestUrl}/{id}").expand(requestUrl, x.getId()); response.setHeader("Location", uri.toASCIIString()); }
From source file:technology.tikal.ventas.service.catalogo.ProductoDeLineaService.java
@RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public void crear(@PathVariable final Long idCatalogo, @PathVariable final Long lineaProductoId, @Valid @RequestBody final ProductoDeLinea request, final BindingResult result, final HttpServletRequest httpRequest, final HttpServletResponse httpResponse) { if (result.hasErrors()) { throw new NotValidException(result); }//from ww w.j a va 2 s.c o m ProductoDeLinea nuevo = productoDeLineaController.crear(idCatalogo, lineaProductoId, request); httpResponse.setHeader("Location", httpRequest.getRequestURI() + "/" + nuevo.getId()); }
From source file:com.artivisi.belajar.restful.ui.controller.PermissionController.java
@RequestMapping(value = "/permission", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public void create(@RequestBody @Valid Permission x, HttpServletRequest request, HttpServletResponse response) { belajarRestfulService.save(x);/*from www.j av a2 s .c o m*/ String requestUrl = request.getRequestURL().toString(); URI uri = new UriTemplate("{requestUrl}/{id}").expand(requestUrl, x.getId()); response.setHeader("Location", uri.toASCIIString()); }
From source file:com.carlomicieli.jtrains.infrastructure.web.ResponsesTests.java
@Test public void shouldCreateResponsesForCreated() { ResponseEntity<Void> resp = Responses.created(new Link("http://localhost", "self")); assertThat(resp).isNotNull();//from w ww .j ava 2 s. com assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.CREATED); assertThat(resp.getHeaders()).containsEntry("Location", Arrays.asList("http://localhost")); }
From source file:rest.TorneoRestController.java
@RequestMapping(value = "/{id}/ronda", method = RequestMethod.POST) public ResponseEntity<?> guardarRondaEnTorneo(@PathVariable int id, @RequestBody InfoRonda ir) { logicaTorneo.registrarRondaEnTorneo(ir, id); return new ResponseEntity<>(HttpStatus.CREATED); }
From source file:org.openbaton.nfvo.api.RestUsers.java
/** * Adds a new User to the Users repository * * @param user//from ww w . j ava2 s . c om * @return user */ @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.CREATED) public User create(@RequestBody @Valid User user) throws PasswordWeakException, NotAllowedException, BadRequestException, NotFoundException { log.info("Adding user: " + user.getUsername()); return userManagement.add(user); }
From source file:plbtw.klmpk.barang.hilang.controller.RoleController.java
@RequestMapping(method = RequestMethod.POST, produces = "application/json") public CustomResponseMessage addRole(@RequestBody RoleRequest roleRequest) { try {//from ww w.j a v a2 s.co m Role role = new Role(); role.setRole(roleRequest.getRole()); roleService.addRole(role); return new CustomResponseMessage(HttpStatus.CREATED, "Role Has Been Created"); } catch (Exception ex) { return new CustomResponseMessage(HttpStatus.BAD_REQUEST, ex.toString()); } }