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:com.consol.citrus.samples.todolist.TodoListIT.java
@Test @CitrusTest//from ww w . j a v a 2 s . co m public void testObjectMapping() { final UUID uuid = UUID.randomUUID(); variable("todoId", uuid.toString()); variable("todoName", "citrus:concat('todo_', citrus:randomNumber(4))"); variable("todoDescription", "Description: ${todoName}"); http().client(todoClient).send().post("/todolist").contentType("application/json") .payload(new TodoEntry(uuid, "${todoName}", "${todoDescription}"), objectMapper); http().client(todoClient).receive().response(HttpStatus.OK).messageType(MessageType.PLAINTEXT) .payload("${todoId}"); http().client(todoClient).send().get("/todo/${todoId}").accept("application/json"); http().client(todoClient).receive().response(HttpStatus.OK) .validationCallback(new JsonMappingValidationCallback<TodoEntry>(TodoEntry.class, objectMapper) { @Override public void validate(TodoEntry todoEntry, Map<String, Object> headers, TestContext context) { Assert.assertNotNull(todoEntry); Assert.assertEquals(todoEntry.getId(), uuid); } }); }
From source file:be.bittich.quote.controller.impl.AuthorController.java
@RequestMapping(value = "/autocomplete", method = { RequestMethod.GET }) @ResponseStatus(HttpStatus.OK) public List<LastnameFirstnameVO> autoCompletion() { return this.getService().autoCompleteLastNameFirstName(); }
From source file:org.openbaton.vnfm.api.RestMediaServer.java
/** * Returns the number of MediaServers of a specific VNFR * * @param vnfrId : ID of VNFR/*w w w .j a v a2s . c om*/ */ @RequestMapping(value = "number", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public int queryNumber(@PathVariable("vnfrId") String vnfrId) throws NotFoundException { return mediaServerManagement.queryByVnrfId(vnfrId).size(); }
From source file:com.ar.dev.tierra.api.controller.FacturaController.java
@RequestMapping(value = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<?> getAll() { List<Factura> list = facadeService.getFacturaDAO().getAll(); if (!list.isEmpty()) { return new ResponseEntity<>(list, HttpStatus.OK); } else {// w ww .jav a2 s . co m return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } }
From source file:com.fabionoth.rest.RobotRest.java
/** * * @param command//from ww w . j a v a 2 s . co m * @return */ @RequestMapping(value = { "rest/mars/", "/rest/mars/{command}" }, method = { RequestMethod.GET, RequestMethod.POST }) public ResponseEntity<String> sendCommand(@PathVariable Optional<String> command) { Robot robot; robot = new Robot(new Long(1), 0, 0, CardinalPoints.N); HttpHeaders responseHeaders = new HttpHeaders(); responseHeaders.setContentType(MediaType.TEXT_HTML); if (command.isPresent()) { try { robot = new RobotController(robot, command.get()).getRobot(); } catch (Exception ex) { Logger.getLogger(RobotRest.class.getName()).log(Level.SEVERE, null, ex); return new ResponseEntity<>("Erro", responseHeaders, HttpStatus.BAD_REQUEST); } } String response = "(" + robot.getX() + ", " + robot.getY() + ", " + robot.getC().toString() + ")"; return new ResponseEntity<>(response, responseHeaders, HttpStatus.OK); }
From source file:com.graphaware.module.resttest.RestTestApi.java
@RequestMapping(value = "/clear", method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) public void clearDatabase() { try (Transaction tx = database.beginTx()) { GraphUnit.clearGraph(database);// w w w.j av a 2s .c o m tx.success(); } }
From source file:org.energyos.espi.thirdparty.repository.impl.ResourceRESTRepositoryImplTests.java
@SuppressWarnings("unchecked") @Before/*from w w w .ja v a2 s.c om*/ public void before() { repository = new ResourceRESTRepositoryImpl(); marshaller = mock(Jaxb2Marshaller.class); template = mock(RestTemplate.class); ResponseEntity<String> response = new ResponseEntity<String>(HttpStatus.OK); when(template.exchange(anyString(), eq(HttpMethod.GET), any(HttpEntity.class), any(Class.class))) .thenReturn(response); repository.setRestTemplate(template); repository.setJaxb2Marshaller(marshaller); authorization = new Authorization(); authorization.setAccessToken("token"); uri = Routes.DATA_CUSTODIAN_REST_USAGE_POINT_GET; }
From source file:com.sentinel.web.controllers.AdminController.java
@RequestMapping(value = "/users/{userId}/grant/role", method = RequestMethod.POST) @PreAuthorize(value = "hasRole('SUPER_ADMIN_PRIVILEGE')") @ResponseBody//from w w w.j av a 2 s.c om public ResponseEntity<String> grantSimpleRole(@PathVariable Long userId) { User user = userRepository.findOne(userId); LOG.debug("Allow user for Simle user permissions"); if (user == null) { return new ResponseEntity<String>("invalid user id", HttpStatus.UNPROCESSABLE_ENTITY); } Role role = roleRepository.findByName("ROLE_SIMPLE_USER"); userService.grantRole(user, role); user.setEnabled(true); userRepository.saveAndFlush(user); return new ResponseEntity<String>("role granted", HttpStatus.OK); }
From source file:de.zib.gndms.taskflows.interslicetransfer.server.logic.InterSliceTransferQuoteCalculator.java
/** * Prepares the source url/*from w ww. j a va2s . c o m*/ * * If the url is present in the order this does nothing else * it fetches the GridFTP-url for source slice. * * @param order An order delegate with the interSlice transfer order. * @param sliceClient A slice-client with a valid rest template instance. */ public static void prepareSourceUrl(DelegatingOrder<InterSliceTransferOrder> order, SliceClient sliceClient) { InterSliceTransferOrder ist = order.getOrderBean(); if (ist.getSourceURI() == null) { try { final ResponseEntity<String> responseEntity = sliceClient.getGridFtpUrl(ist.getSourceSlice(), order.getDNFromContext()); if (HttpStatus.OK.equals(responseEntity.getStatusCode())) ist.setSourceURI(responseEntity.getBody()); else throw new UnsatisfiableOrderException("Invalid source slice specifier"); } catch (ResourceAccessException e) { throw new UnsatisfiableOrderException("Could not connect to source slice specifier"); } } }
From source file:io.github.autsia.crowly.controllers.rest.AuthenticationController.java
@RequestMapping(value = "/register", method = RequestMethod.POST) public ResponseEntity<String> register(@RequestBody CrowlyUser user, HttpServletResponse response) { try {/* www .j av a 2s . c om*/ authenticationManager.addUser(user); return new ResponseEntity<>(HttpStatus.OK); } catch (Exception e) { logger.warn("User creation failed: " + e.getMessage()); return new ResponseEntity<>(HttpStatus.UNAUTHORIZED); } }