Example usage for org.springframework.http MediaType APPLICATION_JSON_VALUE

List of usage examples for org.springframework.http MediaType APPLICATION_JSON_VALUE

Introduction

In this page you can find the example usage for org.springframework.http MediaType APPLICATION_JSON_VALUE.

Prototype

String APPLICATION_JSON_VALUE

To view the source code for org.springframework.http MediaType APPLICATION_JSON_VALUE.

Click Source Link

Document

A String equivalent of MediaType#APPLICATION_JSON .

Usage

From source file:com.mgp.controller.RestController.java

@RequestMapping(value = "/create", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody Status addUsuario(@RequestBody Usuario usuario) {
    try {//  w ww . j  ava 2 s .c  o m
        usuarioServices.addEntity(usuario);
        return new Status(1, "Usuario adicionado com sucesso!");
    } catch (Exception e) {
        return new Status(0, e.toString());
    }
}

From source file:com.github.prajan.controller.UniversityController.java

@RequestMapping(value = "/university/{pk}", produces = {
        MediaType.APPLICATION_JSON_VALUE }, method = RequestMethod.GET)
@ApiOperation(value = "Get University by PK", notes = "Get University based on PK.")
@ApiResponses(value = { @ApiResponse(code = 404, message = "University not found") })
public UniversityDTO getUniversity(@ApiParam(value = "university PK", required = true) @PathVariable String pk,
        @ApiParam(value = "Response Template Name", required = false) @RequestParam(required = false) String templateName) {
    return new UniversityDTO();
}

From source file:business.controllers.ProfileController.java

@RequestMapping(value = "/profile", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ProfileRepresentation getOwnProfile(UserAuthenticationToken user) {
    // Query user's profile
    log.info("GET profile for user with id " + user.getId());

    // Return the representation
    return new ProfileRepresentation(userService.findOne(user.getId()));
}

From source file:ip.ip.rest.controller.BookRestController.java

@RequestMapping(method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
public void updateBook(@RequestBody Book book) {
    service.updateBook(book);
}

From source file:com.dimitri.controllers.TasksPriorityEnumRestController.java

@RequestMapping(value = "/populateTasksPriorities", method = RequestMethod.GET, produces = {
        MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody Collection<Priority> populateTasksPriorities() {
    return new ArrayList<Priority>(Arrays.asList(Priority.values()));
}

From source file:io.curly.artifact.integration.service.NotifierClient.java

@RequestMapping(value = "/notify/artifact", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<?> postNotification(@Valid @RequestBody Artifact artifact);

From source file:com.myproject.onlinecounter.controller.ProductController.java

@RequestMapping(value = "/{productId}", produces = {
        MediaType.APPLICATION_JSON_VALUE }, method = RequestMethod.GET)
public @ResponseBody Product getProduct(@PathVariable String productId) {
    System.out.println("++++ productid " + productId);
    System.out.println("++++ productService " + productService);
    return productService.getProduct(Integer.valueOf(productId));
}

From source file:com.culturedear.counterpoint.XmlRestController.java

@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_XML_VALUE)
public ResponseEntity<Object> write(@RequestBody CounterpointModel counterpointModel) {

    // prepare response XML out
    CounterpointGenerator cg = new CounterpointGenerator();
    cg.fillRhyPat();/*w w w  .j  av a2  s  .  c  o m*/
    int[] cf = counterpointModel.getMainMelody();
    cg.setCantusFirmus(cf);
    int[] vbs = counterpointModel.getPartsInitialNotes();

    CounterpointSolution counterpointSolution = cg.anySpecies(counterpointModel.getScaleMode(), vbs, cf.length,
            counterpointModel.getCounterpointSpecies(), counterpointModel.getRulePenalties());

    ScorePartwise scorePartwise = null;

    try {
        scorePartwise = counterpointSolution.toScorePartwise();
    } catch (NullPointerException ex) {
        scorePartwise = null;
    }

    return Optional.ofNullable(scorePartwise).map(cm -> new ResponseEntity<>((Object) cm, HttpStatus.OK))
            .orElse(new ResponseEntity<>("Could not compute the counterpoint.",
                    HttpStatus.INTERNAL_SERVER_ERROR));
}

From source file:org.sharetask.controller.DummyController.java

@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public String getSimpleData() {
    return "OK";
}

From source file:cz.muni.fi.pa165.rest.controllers.RoomController.java

/**
 * Get list of Products curl -i -X GET http://localhost:8080/pa165/rest/room
 *
 * @return RoomDTO// ww w. jav a2  s .  co m
 */
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public final Collection<RoomDto> getRooms() {
    return roomFacade.getAllRooms();
}