List of usage examples for org.springframework.http ResponseEntity ResponseEntity
public ResponseEntity(MultiValueMap<String, String> headers, HttpStatus status)
From source file:com.chevres.rss.restapi.controller.LogoutController.java
@CrossOrigin @RequestMapping(path = "/logout", method = RequestMethod.POST) @ResponseBody//from w w w . j av a 2s. c o m public ResponseEntity<String> logout(@RequestHeader(value = "User-token") String userToken) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring.xml"); UserAuthDAO userAuthDAO = context.getBean(UserAuthDAO.class); UserAuth userAuth = userAuthDAO.findByToken(userToken); if (userAuth == null) { context.close(); return new ResponseEntity(new ErrorMessageResponse("invalid_token"), HttpStatus.BAD_REQUEST); } userAuthDAO.delete(userAuth); context.close(); return new ResponseEntity(new SuccessMessageResponse("success"), HttpStatus.OK); }
From source file:com.infinity.controller.ExpController.java
@RequestMapping(value = { "/exp/del/{expId}" }, method = RequestMethod.GET, produces = "application/json") public ResponseEntity delExpbyId(@PathVariable String expId) throws IOException { ResponseEntity<String> responseEntity = null; try {/*from w w w. j a v a 2s. c o m*/ expService.deleteById(expId); responseEntity = new ResponseEntity<>("OK ", HttpStatus.OK); } catch (Exception e) { LOG.error(e.getMessage()); responseEntity = new ResponseEntity<>("error ", HttpStatus.BAD_REQUEST); } return responseEntity; }
From source file:com.baidu.terminator.manager.action.LinkAction.java
/** * List all links.//w ww . ja v a 2 s.c o m * * @return all links */ @RequestMapping(method = RequestMethod.GET) @ResponseBody public ResponseEntity<List<Link>> getAllLink() { List<Link> allLink = linkService.getAllLink(); return new ResponseEntity<List<Link>>(allLink, HttpStatus.OK); }
From source file:com.monitor.controller.MessageController.java
@ApiOperation(value = "show", notes = "show a message") @RequestMapping(value = "/{id}", method = RequestMethod.GET) public ResponseEntity<Message> show(@PathVariable(name = "id", required = true) String id) { final Message messageFound = service.findOne(id); if (messageFound != null) { return new ResponseEntity<>(messageFound, HttpStatus.FOUND); } else {/*from w ww.j ava 2s .c o m*/ return new ResponseEntity<>(HttpStatus.NOT_FOUND); } }
From source file:fi.hsl.parkandride.front.SchemaController.java
@RequestMapping(method = GET, value = FACILITY_STATUSES) public ResponseEntity<List<FacilityStatus>> facilityStatuses() { return new ResponseEntity<>(asList(FacilityStatus.values()), OK); }
From source file:com.ewerk.prototype.api.GlobalErrorHandler.java
/** * Called upon internal error. Cannot be called asynchronously. * * @param exception The exception that was thrown internally. * @return A {@link org.springframework.http.ResponseEntity} with status 500 * (INTERNAL_SERVER_ERROR) and the exception message *//* w ww.java2 s . c o m*/ @ExceptionHandler(Exception.class) public ResponseEntity<String> handleException(@Nonnull Exception exception) { LOG.error("Internal server error", exception); return new ResponseEntity<>(exception.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); }
From source file:org.jtwig.acceptance.functions.RenderTest.java
@RequestMapping(value = "/parameters") public ResponseEntity<String> post(@RequestParam("title") String title) { return new ResponseEntity<>(title, HttpStatus.OK); }
From source file:md.ibanc.rm.controllers.rest.RestExchangeRateController.java
@RequestMapping(value = "/rest/valueExchangeRate", method = RequestMethod.GET) public ResponseEntity<List<ExchangeRate>> getAllExchangeRate() { ExchangeRate exchangeRate = new ExchangeRate(); exchangeRate.setBuyCurs(BigDecimal.ONE); exchangeRate.setDataIns(new Date()); exchangeRate.setOfficialCurs(BigDecimal.TEN); exchangeRate.setSellCurs(BigDecimal.TEN); exchangeRateService.save(exchangeRate); List<ExchangeRate> ExchangeRateRestList = (ArrayList<ExchangeRate>) exchangeRateService.findAll(); return new ResponseEntity<>(ExchangeRateRestList, HttpStatus.OK); }
From source file:reconf.server.services.component.DeleteComponentService.java
@RequestMapping(value = "/product/{prod}/component/{comp}", method = RequestMethod.DELETE) @Transactional//w w w . j a v a 2 s. com public ResponseEntity<ComponentResult> doIt(@PathVariable("prod") String productId, @PathVariable("comp") String componentId, Authentication auth) { ComponentKey key = new ComponentKey(productId, componentId); Component reqComponent = new Component(key); List<String> errors = DomainValidator.checkForErrors(key); if (!errors.isEmpty()) { return new ResponseEntity<ComponentResult>(new ComponentResult(reqComponent, errors), HttpStatus.BAD_REQUEST); } if (!products.exists(key.getProduct())) { return new ResponseEntity<ComponentResult>(new ComponentResult(reqComponent, Product.NOT_FOUND), HttpStatus.NOT_FOUND); } Component dbComponent = components.findOne(key); if (dbComponent == null) { return new ResponseEntity<ComponentResult>(new ComponentResult(reqComponent, Component.NOT_FOUND), HttpStatus.NOT_FOUND); } components.delete(dbComponent); properties.deleteByKeyProductAndKeyComponent(key.getProduct(), key.getName()); return new ResponseEntity<ComponentResult>(HttpStatus.OK); }
From source file:nu.yona.server.rest.StandardResourcesController.java
@RequestMapping(value = "/.well-known/apple-app-site-association", method = RequestMethod.GET) @ResponseBody/*from w ww . j a v a 2 s . c o m*/ public ResponseEntity<byte[]> getAppleAppSiteAssociation() { Context ctx = ThymeleafUtil.createContext(); ctx.setVariable("appleAppId", yonaProperties.getAppleAppId()); return new ResponseEntity<>( templateEngine.process("apple-app-site-association.json", ctx).getBytes(StandardCharsets.UTF_8), HttpStatus.OK); }