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.javafxpert.wikibrowser.WikiThumbnailController.java

@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Object> locatorEndpoint(
        @RequestParam(value = "title", defaultValue = "") String articleTitle,
        @RequestParam(value = "id", defaultValue = "") String itemId,
        @RequestParam(value = "lang") String lang) {

    String language = wikiBrowserProperties.computeLang(lang);

    String thumbnailUrlStr = null;
    if (!articleTitle.equals("")) {
        // Check cache for thumbnail
        thumbnailUrlStr = ThumbnailCache.getThumbnailUrlByTitle(articleTitle, language);

        if (thumbnailUrlStr == null) {
            log.info(/* w  ww  .j  av  a  2 s .c  o  m*/
                    "Thumbnail NOT previously requested for articleTitle: " + articleTitle + ", lang: " + lang);

            thumbnailUrlStr = title2Thumbnail(articleTitle, language);
            ThumbnailCache.setThumbnailUrlByTitle(articleTitle, language, thumbnailUrlStr);
        }
    } else if (!itemId.equals("")) {
        ItemInfoResponse itemInfoResponse = null;

        // Check cache for thumbnail
        thumbnailUrlStr = ThumbnailCache.getThumbnailUrlById(itemId, language);

        if (thumbnailUrlStr == null) {
            log.info("Thumbnail NOT previously requested for itemId: " + itemId + ", lang: " + lang);

            try {
                String url = this.wikiBrowserProperties.getLocatorServiceUrl(itemId, lang);
                itemInfoResponse = new RestTemplate().getForObject(url, ItemInfoResponse.class);

                //log.info(itemInfoResponse.toString());

                if (itemInfoResponse != null) {
                    thumbnailUrlStr = title2Thumbnail(itemInfoResponse.getArticleTitle(), language);
                } else {
                    thumbnailUrlStr = "";
                }

                ThumbnailCache.setThumbnailUrlById(itemId, language, thumbnailUrlStr);

            } catch (Exception e) {
                e.printStackTrace();
                log.info("Caught exception when calling /locator?id=" + itemId + " : " + e);
            }

        }
    }

    return Optional.ofNullable(thumbnailUrlStr).map(cr -> new ResponseEntity<>((Object) cr, HttpStatus.OK))
            .orElse(new ResponseEntity<>("Wikipedia thumbnail query unsuccessful",
                    HttpStatus.INTERNAL_SERVER_ERROR));
}

From source file:aka.pirana.springsecurity.web.controllers.UserResource.java

@RequestMapping(value = "", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody//from w  w  w  . j a  v a 2  s.c om
public ResponseEntity<User> updateUser(@RequestBody User user) {
    System.out.println("aka.pirana.springsecurity.web.controllers.UserResource.updateUser()");
    User savedUser = userService.update(user);
    return new ResponseEntity<User>(savedUser, HttpStatus.OK);
}

From source file:io.github.microcks.web.ImportController.java

@RequestMapping(value = "/import", method = RequestMethod.POST)
public ResponseEntity<?> importRepository(@RequestParam(value = "file") MultipartFile file) {
    log.debug("Importing new services and resources definitions");
    if (!file.isEmpty()) {
        log.debug("Content type of " + file.getOriginalFilename() + " is " + file.getContentType());
        if (MediaType.APPLICATION_JSON_VALUE.equals(file.getContentType())) {
            try {
                byte[] bytes = file.getBytes();
                String json = new String(bytes);
                importExportService.importRepository(json);
            } catch (Exception e) {
                log.error(e.getMessage());
            }//w  w w  .j a v a2  s.c  om
        }
    }
    return new ResponseEntity<Object>(HttpStatus.CREATED);
}

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

@RequestMapping(value = "/sign-in", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Timed/*w  w w .j  a  v a2 s.  c  o m*/
@Transactional
public ResponseEntity<SignInResponse> signIn(@Valid @RequestBody SignInRequest request) {
    log.debug("POST /sign-in {}", request);
    final SignInResponse response = userService.signIn(request.getUsername(), request.getPassword());
    return ResponseEntity.ok().body(response);
}

From source file:com.unidev.polycms.hateoas.controller.StorageIndexController.java

@GetMapping(value = "/storage/{storage}", produces = MediaType.APPLICATION_JSON_VALUE)
public ResourceSupport index(@PathVariable("storage") String storage) {
    if (!polyCore.existTenant(storage)) {
        LOG.warn("Not found storage {}", storage);
        throw new StorageNotFoundException("Storage " + storage + " not found");
    }//from w  w w . j  a  v a2 s.  com
    HateoasResponse hateoasPolyIndex = hateoasResponse();

    hateoasPolyIndex.add(
            linkTo(StorageIndexController.class).slash("storage").slash(storage).slash("categories")
                    .withRel("categories"),
            linkTo(StorageIndexController.class).slash("storage").slash(storage).slash("tags").withRel("tags"),
            linkTo(StorageIndexController.class).slash("storage").slash(storage).slash("properties")
                    .withRel("properties"),
            linkTo(StorageIndexController.class).slash("storage").slash(storage).slash("metadata")
                    .withRel("metadata"),
            linkTo(StorageIndexController.class).slash("storage").slash(storage).slash("raw").withRel("raw"),
            linkTo(StorageQueryController.class).slash("storage").slash(storage).slash("query")
                    .withRel("query"));
    hateoasPolyIndex.data(storage);
    return hateoasPolyIndex;
}

From source file:org.appverse.web.framework.backend.frontfacade.rest.TestExceptionHandlingResource.java

@SuppressWarnings("unused")
@RequestMapping(value = "/exc", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public SimpleBean testExc() throws Exception {
    System.out.println("test");
    if (true) {//from  ww w  .ja va 2 s.c  o m
        throw new Exception("kk");
    }
    return null;
}

From source file:web.ClientsRESTController.java

/**
 * Gets a specific client's info based on a Client ID
 * @param id//from w  w  w .  jav  a  2s  .c  o  m
 * @return
 */
@RequestMapping(value = "/api/clients/clientinfo/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Clients> getClientInfo(@PathVariable("id") int id) {
    Clients client = null;
    //returns a NOT_FOUND error if no Client is tied to specific ClientID        
    try {
        client = dao.getClientByID(id);
    } catch (EmptyResultDataAccessException ex) {
        return new ResponseEntity<Clients>(HttpStatus.NOT_FOUND);
    }
    //otherwise returns specific Client's info
    return new ResponseEntity<Clients>(client, HttpStatus.OK);
}

From source file:com.github.lynxdb.server.api.http.handlers.EpStats.java

@RequestMapping(path = "/query", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity query() {
    return ResponseEntity.status(HttpStatus.NOT_IMPLEMENTED).build();
}

From source file:com.jci.supp.apis.SuppController.java

/**
 * Gets the supplier details./*from w  w  w  . j  av  a  2s .co  m*/
 *
 * @param request
 *            the request
 * @return the supplier details
 */
@HystrixCommand(commandProperties = { @HystrixProperty(name = "execution.isolation.strategy", value = "THREAD"),
        @HystrixProperty(name = "execution.timeout.enabled", value = "false"),
        @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "60000"),
        @HystrixProperty(name = "fallback.enabled", value = "false") })
@RequestMapping(value = "/getSegmentedMapicsSupplierDetails", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public SegmentedDetailRes getSegmentedMapicsSupplierDetails(@RequestBody SegmentedDetailReq request) {
    request.setTableName(supplierTableName);
    request.setPartition(AzureUtils.getPartitionKey(request.getErpName().toUpperCase()));
    request.setFirstRequest(false);
    SegmentedDetailRes response = new SegmentedDetailRes();

    try {
        response = poService.getSupplierResultSet(request);
    } catch (InvalidKeyException | URISyntaxException | StorageException e) {
        response.setError(true);
        response.setMessage(e.getMessage());

        LOG.error("### Exception in   ####", e);
    }
    return response;
}

From source file:com.capside.pokemondemo.PokemonCtrl.java

@RequestMapping(value = "/", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE })
@ResponseBody
Pokemon pokemon() {
    return pokemon;
}