List of usage examples for org.springframework.http ResponseEntity ResponseEntity
public ResponseEntity(MultiValueMap<String, String> headers, HttpStatus status)
From source file:de.hska.ld.core.controller.ExceptionControllerAdvice.java
@ExceptionHandler(ApplicationException.class) public ResponseEntity<ApplicationError> exception(ApplicationException e) { return new ResponseEntity<>(e.getApplicationError(), e.getHttpStatus()); }
From source file:springfox.documentation.spring.web.dummy.controllers.ControllerWithNoRequestMappingService.java
@RequestMapping(value = "/no-request-mapping", method = RequestMethod.GET) public ResponseEntity<Example> exampleWithNoRequestMapping(UriComponentsBuilder builder) { return new ResponseEntity<Example>(new Example("Hello", 1, EnumType.ONE, new NestedType("test")), HttpStatus.OK);/*w ww.j ava 2 s. c om*/ }
From source file:br.com.hyperclass.snackbar.restapi.MenuController.java
@RequestMapping(value = "/menu", method = RequestMethod.GET) public ResponseEntity<ProductsWrapper> menuItemProducts() { return new ResponseEntity<>(new ProductsWrapper(menu.getProducts()), HttpStatus.OK); }
From source file:com.sentinel.web.controllers.LoginController.java
@RequestMapping(method = RequestMethod.GET, value = "/all/login_failure") public @ResponseBody ResponseEntity<String> handleLoginFailure(Principal principal) { return new ResponseEntity<>("Login failed", HttpStatus.UNAUTHORIZED); }
From source file:com.opensearchserver.hadse.cluster.ClusterController.java
/** * The list of registered nodes in the cluster * //from w ww .j a va 2 s . c o m * @return */ @RequestMapping(method = RequestMethod.GET, value = "/_cluster") @ResponseBody public HttpEntity<?> get() { return new ResponseEntity<Collection<NodeItem>>(ClusterCatalog.get(), HttpStatus.OK); }
From source file:com.opensearchserver.hadse.index.IndexController.java
@RequestMapping(method = RequestMethod.GET, value = "/{index_name}") @ResponseBody/*from w w w. j a va 2 s . c o m*/ public HttpEntity<?> indexExists(@PathVariable String index_name) { if (!IndexCatalog.exists(index_name)) return new ResponseEntity<String>("Index not found: " + index_name, HttpStatus.NOT_FOUND); return new ResponseEntity<String>("Index found", HttpStatus.FOUND); }
From source file:uta.ak.usttmp.console.controller.RestCheckController.java
@RequestMapping(value = "/foo/{id}", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE) public ResponseEntity<String> getFoo(@PathVariable("id") long id) { System.out.println("Fetching User with id " + id); // Foo foo=new Foo(); // foo.setId(id); // foo.setName("DFGHH"); // foo.setEmail("qwertyui@163.com"); return new ResponseEntity<String>("I am a foo " + id, HttpStatus.OK); }
From source file:pitayaa.nail.msg.core.license.controller.LicenseController.java
@RequestMapping(value = "licenses", method = RequestMethod.POST) public @ResponseBody ResponseEntity<?> createLicense(@RequestBody License licenseBody) throws Exception { License license = licenseService.saveLicense(licenseBody); return new ResponseEntity<>(license, HttpStatus.CREATED); }
From source file:com.mycompany.projetsportmanager.spring.rest.exceptions.SportManagerResponseEntityExceptionHandler.java
@ExceptionHandler(value = { DefaultSportManagerException.class }) protected ResponseEntity<ErrorResource> handleConflict(DefaultSportManagerException ex, WebRequest request) { return new ResponseEntity<>(ex.getErrorResource(), ex.getErrorResource().getStatus()); }
From source file:at.ac.tuwien.dsg.cloud.utilities.gateway.registry.RestUtilities.java
public <T> ResponseEntity<T> simpleRestExchange(RequestEntity reg, Class<T> respType) { HttpStatus failedCode;/* w w w. j a v a 2s . c o m*/ try { RestTemplate restTemplate = new RestTemplate(); return restTemplate.exchange(reg, respType); } catch (HttpStatusCodeException e) { String serverResp = e.getResponseBodyAsString(); failedCode = e.getStatusCode(); logger.error(String.format( "Exception from server! " + "With status code %s! " + "Following body was responded %s", failedCode.toString(), serverResp), e); } //todo: think of throwing an exception instead of returning a null object return new ResponseEntity(null, failedCode); }