List of usage examples for org.springframework.http HttpStatus OK
HttpStatus OK
To view the source code for org.springframework.http HttpStatus OK.
Click Source Link
From source file:org.openmrs.module.patientimage.rest.controller.PatientImageController.java
/** * @param patientid int/* w w w . j av a2 s .com*/ * @param pageid int * @return ResponseEntity<byte[]> containing image binary data with JPEG * image header. * @throws ResponseException * @throws IOException */ @RequestMapping(value = "/{patientid}/{pageid}", method = RequestMethod.GET) public ResponseEntity<byte[]> retrieve(@PathVariable("patientid") String patientIdStr, @PathVariable("pageid") String pageIdStr, HttpServletRequest request) throws IOException { //RequestContext context = RestUtil.getRequestContext(request); int patientId = Integer.parseInt(patientIdStr); int pageId = Integer.parseInt(pageIdStr); final HttpHeaders headers = new HttpHeaders(); byte[] imageData = null; HttpStatus status = null; headers.setContentType(MediaType.IMAGE_JPEG); status = HttpStatus.OK; return new ResponseEntity<byte[]>(imageData, headers, status); }
From source file:github.priyatam.springrest.resource.DriverResource.java
@RequestMapping(method = RequestMethod.GET, value = "/driver/{licenseNo}") @ResponseBody//from w ww. j a v a 2 s.c om public ResponseEntity<Driver> getDriver(@PathVariable String licenseNo) { logger.debug(String.format("Retrieving Driver %s :", licenseNo)); Driver driver = persistenceHelper.loadDriverByLicenseNum(licenseNo); if (driver == null) { logger.warn("No Driver found"); return new ResponseEntity<Driver>(null, new HttpHeaders(), HttpStatus.NOT_FOUND); } // Convert to Restful Resource, update ETag and HATEOAS references responseBuilder.toDriver(Lists.newArrayList(driver)); return new ResponseEntity<Driver>(driver, HttpStatus.OK); }
From source file:hr.foi.rsc.controllers.PersonController.java
/** * gets all users from database/*from w w w . j a va 2 s. c om*/ * @return all users in json format with HTTP 200 */ @RequestMapping(value = "/", method = RequestMethod.GET) public ResponseEntity<List<Person>> retrieveAll() { Logger.getLogger("PersonController.java").log(Level.INFO, "GET on /person -- retrieving full list of users"); return new ResponseEntity(this.personRepository.findAll(), HttpStatus.OK); }
From source file:io.pivotal.strepsirrhini.chaoslemur.state.AbstractRestControllerStateProvider.java
@RequestMapping(method = RequestMethod.POST, value = "/state", consumes = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<?> changeState(@RequestBody Map<String, String> payload) { String value = payload.get(STATUS_KEY); if (value == null) { return new ResponseEntity<>(HttpStatus.BAD_REQUEST); }// w w w . j a v a 2 s. com try { set(State.valueOf(value.toUpperCase())); return new ResponseEntity<>(HttpStatus.OK); } catch (IllegalArgumentException e) { return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } }
From source file:hr.foi.sis.controllers.TestDataController.java
@RequestMapping(value = "/", method = RequestMethod.GET) @PreAuthorize("hasRole('ROLE_ADMIN')") public ResponseEntity<List<TestData>> retrieveAll() { Logger.getLogger("TestDataController.java").log(Level.INFO, "GET on /testData -- retrieving full list of testData"); return new ResponseEntity(this.testDataRepository.findAll(), HttpStatus.OK); }
From source file:com.ar.dev.tierra.api.controller.FacturaProductoController.java
@RequestMapping(value = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<?> getAll() { List<FacturaProducto> list = facadeService.getFacturaProductoDAO().getAll(); if (!list.isEmpty()) { return new ResponseEntity<>(list, HttpStatus.OK); } else {/*from w w w. ja v a2 s . c o m*/ return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } }
From source file:hello.SayHelloApplicationTests.java
@Test public void shouldReturn200WhenSendingRequestToRoot() throws Exception { @SuppressWarnings("rawtypes") ResponseEntity<String> entity = this.testRestTemplate.getForEntity("http://localhost:" + this.port + "/", String.class); then(entity.getStatusCode()).isEqualTo(HttpStatus.OK); then(entity.getBody()).isEqualTo("Hi!"); }
From source file:za.ac.cput.project.universalhardwarestorev2.api.ItemApi.java
@RequestMapping(value = "/items/", method = RequestMethod.GET) public ResponseEntity<List<Item>> listAllItems() { List<Item> Items = service.findAll(); if (Items.isEmpty()) { return new ResponseEntity<List<Item>>(HttpStatus.NO_CONTENT);//You many decide to return HttpStatus.NOT_FOUND }//from w w w . ja v a 2 s . c om return new ResponseEntity<List<Item>>(Items, HttpStatus.OK); }
From source file:org.cloudfoundry.identity.uaa.integration.VarzEndpointIntegrationTests.java
/** * tests a happy-day flow of the <code>/varz</code> endpoint *///from ww w. j av a 2 s . com @Test public void testHappyDay() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.add("Authorization", testAccounts.getVarzAuthorizationHeader()); ResponseEntity<String> response = serverRunning.getForString("/varz", headers); assertEquals(HttpStatus.OK, response.getStatusCode()); String map = response.getBody(); assertTrue(map.contains("spring.application")); assertTrue(map.contains("Catalina")); }
From source file:org.khmeracademy.btb.auc.pojo.controller.Topup_controller.java
@RequestMapping(value = "/add-topup-log", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Map<String, Object>> add_topup_log(@RequestBody Topup_log topup) { Map<String, Object> map = new HashMap<String, Object>(); try {/*from ww w . j a va2 s. c o m*/ if (topup_service.add(topup)) { map.put("MESSAGE", "User has been inserted."); map.put("STATUS", true); } else { map.put("MESSAGE", "Topup log has not been inserted."); map.put("STATUS", false); } } catch (Exception e) { map.put("MESSAGE", "Error!"); map.put("STATUS", false); e.printStackTrace(); } return new ResponseEntity<Map<String, Object>>(map, HttpStatus.OK); }