List of usage examples for org.springframework.http ResponseEntity ResponseEntity
public ResponseEntity(MultiValueMap<String, String> headers, HttpStatus status)
From source file:hr.softwarecity.osijek.controllers.MosquitoController.java
@RequestMapping(value = "/create", method = RequestMethod.POST) public ResponseEntity<List<Mosquito>> createMosquito(@RequestBody Mosquito mosquito) { Logger.getLogger("MosquitoController.java").log(Logger.Level.INFO, "Recognized POST request to /create path"); Logger.getLogger("MosquitoController.java").log(Logger.Level.INFO, "Received mosquito " + mosquito.toString()); mosquitoRepository.save(mosquito);/*from w ww. ja va2 s .com*/ Logger.getLogger("MosquitoController.java").log(Logger.Level.INFO, "Successfully saved mosquito " + mosquito.toString()); return new ResponseEntity(mosquitoRepository.findAll(), HttpStatus.OK); }
From source file:io.github.microcks.web.KeycloakConfigController.java
@RequestMapping(value = "/config", method = RequestMethod.GET) public ResponseEntity<?> getConfig() { final Config config = new Config(keycloakRealmName, keycloakServerUrl); log.debug("Returning '{}' realm config, for {}", keycloakRealmName, keycloakServerUrl); return new ResponseEntity<>(config, HttpStatus.OK); }
From source file:su90.mybatisdemo.web.endpoints.EmployeesEndpoints.java
@RequestMapping(value = "/getall", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_UTF8_VALUE }) public ResponseEntity<List<EmployeeOut>> getAll() { List<EmployeeOut> result = employeesService.getWebBeans(); if (result.isEmpty()) { return new ResponseEntity<>(result, HttpStatus.NO_CONTENT); }//from w w w .j a va2s . c o m return new ResponseEntity<>(result, HttpStatus.OK); }
From source file:org.esupportail.dining.web.controllers.WebWidgetController.java
@RequestMapping("/WebWidget.js") public ResponseEntity<String> renderWebWidgetJs(HttpServletRequest request, HttpServletResponse response, Model model) throws Exception { String html = renderView(request, "WebWidget", model); String js = "document.write(" + new ObjectMapper().writeValueAsString(html) + ");"; response.setContentType("application/x-javascript"); return new ResponseEntity<String>(js, HttpStatus.OK); }
From source file:com.arya.latihan.controller.CustomerController.java
@RequestMapping(value = "/{id}", method = RequestMethod.PUT) @Transactional(readOnly = false)/*from w w w . ja v a 2 s.c o m*/ public ResponseEntity<Customer> editCustomer(@PathVariable("id") String id, @Valid Customer customer) { customer.setId(id); customer = customerRepository.save(customer); return new ResponseEntity<Customer>(customer, HttpStatus.OK); }
From source file:com.gopivotal.cla.github.GitHubConditionalTest.java
@Test public void noLinks() { ResponseEntity<Set> response = new ResponseEntity<Set>(Sets.asSet(), HttpStatus.OK); when(this.restOperations.exchange(URL, HttpMethod.GET, REQUEST_ENTITY, Set.class)).thenReturn(response); this.gitHubType.getTrigger(); assertTrue(this.gitHubType.initializedCalled); }
From source file:de.sainth.recipe.backend.rest.controller.FoodController.java
@Secured("ROLE_ADMIN") @RequestMapping(method = RequestMethod.POST) HttpEntity<Food> add(@Valid @RequestBody Food food) { Food f = repository.save(food);// w w w . j av a 2 s . co m return new ResponseEntity<>(f, HttpStatus.CREATED); }
From source file:com.opensearchserver.hadse.index.IndexController.java
@RequestMapping(method = RequestMethod.PUT, value = "/{index_name}") @ResponseBody/*from www . ja v a 2s .c om*/ public HttpEntity<?> createIndex(@PathVariable String index_name, @RequestParam(value = "shards", required = false, defaultValue = "5") Integer shards, @RequestParam(value = "replicats", required = false, defaultValue = "1") Integer replicas) { try { return IndexCatalog.create(index_name, shards, replicas); } catch (Throwable e) { return new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } }
From source file:com.citibanamex.api.locator.atm.exceptions.GlobalExceptionHandler.java
/** * This method is to handle BadRequestException category * //from w w w . j a va 2 s . c o m * @param BadRequestException * @return Response */ @ResponseStatus(HttpStatus.BAD_REQUEST) @ExceptionHandler(value = BadRequestException.class) public ResponseEntity<?> handleBadRequestException(BadRequestException ex) { Response respObj = new Response(); respObj.setTimeStamp(new Date().getTime()); respObj.setStatus("FAILURE"); respObj.setErrorCode(HttpStatus.BAD_REQUEST.value()); respObj.setMessage("Bad Request"); respObj.setDescription("Invalid 'radius' or/and 'address' parameters"); logger.info("Http response -" + respObj.getErrorCode() + "-" + respObj.getDescription() + "-" + respObj.getMessage()); return new ResponseEntity<Response>(respObj, HttpStatus.BAD_REQUEST); }
From source file:net.eusashead.hateoas.response.impl.PostResponseBuilderImpl.java
@Override public ResponseEntity<Void> build() { if (this.headers.getLocation() == null) { throw new RuntimeException("Location header must be set before calling create()."); }//from w w w .j a v a2 s. com return new ResponseEntity<Void>(headers, HttpStatus.CREATED); }