Example usage for org.springframework.http HttpStatus OK

List of usage examples for org.springframework.http HttpStatus OK

Introduction

In this page you can find the example usage for org.springframework.http HttpStatus OK.

Prototype

HttpStatus OK

To view the source code for org.springframework.http HttpStatus OK.

Click Source Link

Document

200 OK .

Usage

From source file:bg.vitkinov.edu.services.JokeCategoryService.java

@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public ResponseEntity<?> getCategory(@PathVariable Long id) {
    Category category = repository.findOne(id);
    return category == null ? new ResponseEntity<>(HttpStatus.NOT_FOUND)
            : new ResponseEntity<>(category, HttpStatus.OK);
}

From source file:io.fourfinanceit.homework.controller.ClientController.java

@RequestMapping(value = "/client/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Client> getClient(@PathVariable("id") Long id) {

    Client client = clientRepository.findOne(id);

    if (client == null) {
        return new ResponseEntity<Client>(HttpStatus.NOT_FOUND);
    }//from w  w w .  j  av  a  2 s . c om

    return new ResponseEntity<Client>(client, HttpStatus.OK);
}

From source file:br.com.hyperclass.snackbar.restapi.CashierController.java

@RequestMapping(value = "/cashier", method = RequestMethod.GET)
public ResponseEntity<ProductsWrapper> orderItemProducts() {
    return new ResponseEntity<ProductsWrapper>(new ProductsWrapper(cashier.productsInCashier()), HttpStatus.OK);
}

From source file:com.digitalriver.artifact.NickArtifactServerTests.java

public void testCss() throws Exception {
    ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
            "http://localhost:" + this.port + "/webjars/bootstrap/3.0.3/css/bootstrap.min.css", String.class);
    assertEquals(HttpStatus.OK, entity.getStatusCode());
    assertTrue("Wrong body:\n" + entity.getBody(), entity.getBody().contains("body"));
    assertEquals("Wrong content type:\n" + entity.getHeaders().getContentType(), MediaType.valueOf("text/css"),
            entity.getHeaders().getContentType());
}

From source file:io.github.robwin.swagger2markup.petstore.controller.UserController.java

@RequestMapping(method = POST)
@ResponseBody// w w  w.  jav a  2s  .  c o  m
@ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.")
public ResponseEntity<User> createUser(
        @RequestBody @ApiParam(value = "Created user object", required = true) User user) {

    userRepository.add(user);
    return new ResponseEntity<User>(user, HttpStatus.OK);
}

From source file:com.jiwhiz.rest.author.AuthorAccountRestController.java

@RequestMapping(method = RequestMethod.GET, value = URL_AUTHOR)
@Transactional(readOnly = true)//from  ww  w.ja va 2  s.co  m
public HttpEntity<AuthorAccountResource> getCurrentAuthorAccount() {
    UserAccount currentUser = getCurrentAuthenticatedAuthor();
    return new ResponseEntity<>(authorAccountResourceAssembler.toResource(currentUser), HttpStatus.OK);
}

From source file:com.hypersocket.auth.json.LogonController.java

@RequestMapping(value = "logon/reset", method = RequestMethod.GET, produces = "application/json")
@ResponseBody/*w  w w.ja  v  a  2s.  c om*/
@ResponseStatus(value = HttpStatus.OK)
public AuthenticationResult resetLogon(HttpServletRequest request, HttpServletResponse response,
        @RequestParam(required = false) Boolean redirect)
        throws AccessDeniedException, UnauthorizedException, IOException, RedirectException {
    AuthenticationState state = (AuthenticationState) request.getSession()
            .getAttribute(AUTHENTICATION_STATE_KEY);
    return resetLogon(request, response,
            state == null ? AuthenticationServiceImpl.BROWSER_AUTHENTICATION_RESOURCE_KEY
                    : state.getScheme().getResourceKey(),
            redirect);
}

From source file:com.smallpay.workflow.service.api.model.ModelSaveRestResource.java

@RequestMapping(value = "/service/model/{modelId}/save", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
@ResponseStatus(value = HttpStatus.OK)
public void saveModel(@PathVariable String modelId, @RequestParam MultiValueMap<String, String> values) {
    try {//from ww w . ja  va  2 s.  c  o m

        Model model = repositoryService.getModel(modelId);

        ObjectNode modelJson = (ObjectNode) objectMapper.readTree(model.getMetaInfo());

        modelJson.put(MODEL_NAME, values.getFirst("name"));
        modelJson.put(MODEL_DESCRIPTION, values.getFirst("description"));
        model.setMetaInfo(modelJson.toString());
        model.setName(values.getFirst("name"));

        repositoryService.saveModel(model);

        repositoryService.addModelEditorSource(model.getId(), values.getFirst("json_xml").getBytes("utf-8"));

        InputStream svgStream = new ByteArrayInputStream(values.getFirst("svg_xml").getBytes("utf-8"));
        TranscoderInput input = new TranscoderInput(svgStream);

        PNGTranscoder transcoder = new PNGTranscoder();
        // Setup output
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        TranscoderOutput output = new TranscoderOutput(outStream);

        // Do the transformation
        transcoder.transcode(input, output);
        final byte[] result = outStream.toByteArray();
        repositoryService.addModelEditorSourceExtra(model.getId(), result);
        outStream.close();

    } catch (Exception e) {
        LOGGER.error("Error saving model", e);
        throw new ActivitiException("Error saving model", e);
    }
}

From source file:net.jkratz.igdb.controller.ESRBRatingController.java

/**
 * Returns all ESRB ratings in database/*  w ww .j  a  v  a  2 s .  co  m*/
 * 
 * @return List of ESRBRating objects
 * @see ESRBRating
 */
@RequestMapping(value = { "", "/" }, method = RequestMethod.GET)
public ResponseEntity<List<ESRBRating>> getESRBRatings() {
    List<ESRBRating> esrbRatings = esrbRatingService.getESRBRatings();
    return new ResponseEntity<>(esrbRatings, HttpStatus.OK);
}

From source file:com.bradley.musicapp.test.restapi.PersonRestControllerTest.java

@Test
public void tesCreate() {
    Name name = new Name();
    name.setFirstName("bradley");
    name.setLastName("bradley");

    Person p = new Person.Builder().name(name).build();

    System.out.println("rest Template = " + restTemplate);
    HttpEntity<Person> requestEntity = new HttpEntity<>(p, getContentType());
    //       Make the HTTP POST request, marshaling the request to JSON, and the response to a String

    ResponseEntity<String> responseEntity = restTemplate.exchange(URL + "api/person/create", HttpMethod.POST,
            requestEntity, String.class);
    System.out.println(" THE RESPONSE BODY " + responseEntity.getBody());
    System.out.println(" THE RESPONSE STATUS CODE " + responseEntity.getStatusCode());
    System.out.println(" THE RESPONSE IS HEADERS " + responseEntity.getHeaders());

    Assert.assertEquals(responseEntity.getStatusCode(), HttpStatus.OK);

}