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:org.openbaton.autoscaling.api.RestEventInterface.java

/**
 * Activates autoscaling for the passed NSR
 *
 * @param msg : NSR in payload to add for autoscaling
 */// w  ww  .j a v a 2 s  .  co m
@RequestMapping(value = "INSTANTIATE_FINISH", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public void activate(@RequestBody String msg) throws NotFoundException, VimException, SDKException {
    log.debug("========================");
    log.debug("msg=" + msg);
    JsonParser jsonParser = new JsonParser();
    JsonObject json = jsonParser.parse(msg).getAsJsonObject();
    Gson mapper = new GsonBuilder().create();
    Action action = mapper.fromJson(json.get("action"), Action.class);
    log.debug("ACTION=" + action);
    NetworkServiceRecord nsr = mapper.fromJson(json.get("payload"), NetworkServiceRecord.class);
    log.debug("NSR=" + nsr);
    elasticityManagement.activate(nsr.getId());
}

From source file:org.messic.server.facade.controllers.rest.CheckController.java

@ApiMethod(path = "/services/check", verb = ApiVerb.GET, description = "Check if the messic service is alive", produces = {
        MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
@ApiErrors(apierrors = { @ApiError(code = UnknownMessicRESTException.VALUE, description = "Unknown error") })
@RequestMapping(value = "", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)/*from ww w .  ja  v a2 s .c o m*/
@ResponseBody
@ApiResponseObject
public void wizardFileName() throws UnknownMessicRESTException {
    log.info("messic is alive");
    // doesn't anything, just to check that it's alive
}

From source file:tds.assessment.web.endpoints.AssessmentInfoController.java

@GetMapping(value = "/{clientName}/assessments", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody// w  ww .java  2s .c  om
ResponseEntity<List<AssessmentInfo>> findAssessmentInfos(@PathVariable final String clientName,
        @RequestParam(required = false) final String grade,
        @RequestParam(required = false) final String... assessmentKeys) {
    List<AssessmentInfo> assessmentInfos;

    if (grade == null && assessmentKeys.length == 0) {
        throw new IllegalArgumentException("Either assessmentKeys or grades query params must be present.");
    }

    assessmentInfos = (grade == null) ? assessmentInfoService.findAssessmentInfo(clientName, assessmentKeys)
            : assessmentInfoService.findAssessmentInfoForGrade(clientName, grade);

    return ResponseEntity.ok(assessmentInfos);
}

From source file:com.billkoch.examples.people.controllers.PeopleController.java

@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Person> create(@RequestBody Person person) {
    Person persistedPerson = peopleRepository.save(person);

    HttpHeaders headers = new HttpHeaders();
    headers.setLocation(ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}")
            .buildAndExpand(person.getId()).toUri());

    return new ResponseEntity<>(persistedPerson, headers, HttpStatus.CREATED);
}

From source file:com.todo.backend.web.rest.TodoApi.java

@RequestMapping(value = "/todo/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@Timed/* www. java2 s. c  o m*/
@Transactional(readOnly = true)
public ResponseEntity<ReadTodoResponse> readTodo(@PathVariable Long id) {
    log.debug("GET /todo/{}", id);
    final Optional<Todo> result = Optional.ofNullable(todoRepository.findOne(id));
    if (result.isPresent()) {
        return ResponseEntity.ok().body(convertToReadTodoResponse(result.get()));
    }
    return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}

From source file:com.ar.dev.tierra.api.controller.ProductoController.java

@RequestMapping(value = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getAll() {
    List<Producto> list = facadeService.getProductoDAO().getAll();
    if (!list.isEmpty()) {
        return new ResponseEntity<>(list, HttpStatus.OK);
    } else {/*from   w w  w.  j a v a2s.  c om*/
        return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
    }
}

From source file:org.ado.biblio.ServerController.java

@RequestMapping(method = RequestMethod.GET, value = "/status", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ServerStatusMessage> getServerStatus() {
    final ServerStatusMessage serverStatusMessage = new ServerStatusMessage(ServerStatusEnum.ONLINE);
    LOGGER.info("/status {}", serverStatusMessage);
    return new ResponseEntity<ServerStatusMessage>(serverStatusMessage, HttpStatus.OK);
}

From source file:sample.mvc.SessionController.java

/**
 * @param assembler//from   w  w w.ja v a 2s.co m
 * @param currentUser
 * @return
 */
@RequestMapping(value = "/sessions/", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE,
        "application/hal+json" })
public ResponseEntity<?> index(PersistentEntityResourceAssembler assembler, @CurrentUser User currentUser) {
    Collection<? extends ExpiringSession> usersSessions = sessions.findByPrincipalName(currentUser.getEmail())
            .values();

    List<SessionInfo> info = new ArrayList<SessionInfo>(usersSessions.size());
    for (ExpiringSession session : usersSessions) {
        info.add(new SessionInfo(session));
    }

    return new ResponseEntity<List<SessionInfo>>(info, HttpStatus.OK);
}

From source file:com.mycompany.springrest.controllers.UserController.java

@RequestMapping(value = "/user/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<User> getUser(@PathVariable("id") int id) {
    User user = userService.getUserById(id);
    logger.info("Fetching User with id " + id);
    if (user == null) {
        logger.info("User with id " + id + " not found");
        return new ResponseEntity<User>(HttpStatus.NOT_FOUND);
    }/*ww w  .ja va2 s.c o  m*/
    return new ResponseEntity<User>(user, HttpStatus.OK);
}

From source file:io.curly.tagger.controller.TagController.java

@Loggable
@RequestMapping(value = "/{tag}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public DeferredResult<ResponseEntity<Tag>> get(@PathVariable String tag) {
    return defer(readerCommand.get(tag).filter(Optional::isPresent).map(Optional::get).map(ResponseEntity::ok)
            .defaultIfEmpty(new ResponseEntity<>(NOT_FOUND)));
}