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:web.rufer.swisscom.sms.api.factory.HeaderFactory.java

public static HttpHeaders createHeaders(String apiKey) {
    HttpHeaders headers = new HttpHeaders();
    headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
    headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE);
    headers.set(CLIENT_ID, apiKey);//w  w w  . ja va  2  s.c om
    return headers;
}

From source file:monkeys.web.MonkeysController.java

@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody//from   ww w  . ja v  a2 s  .  c  o  m
public ResponseEntity<Void> createMonkey(@RequestBody Monkey monkey) {
    monkeyRepository.save(monkey);
    HttpHeaders headers = new HttpHeaders();
    return new ResponseEntity<>(headers, HttpStatus.CREATED);
}

From source file:monkeys.web.BananasController.java

@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody//w  ww. j av  a2 s. c o m
public ResponseEntity<Void> createBanana(@RequestBody Banana banana) {
    bananaRepository.save(banana);
    HttpHeaders headers = new HttpHeaders();
    return new ResponseEntity<>(headers, HttpStatus.CREATED);
}

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

@RequestMapping(value = "/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public final Map<String, String> getResources() {

    Map<String, String> resourcesMap = new HashMap<>();
    resourcesMap.put("rooms_uri", "/room");
    return Collections.unmodifiableMap(resourcesMap);
}

From source file:com.emc.licensekey.activation.controller.SiteController.java

@RequestMapping(value = "list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody String getSiteDetails(@RequestParam String userId) {
    try {//from ww  w . j  av a2s . c o m
        return JsonUtil.getJSonString(siteService.getUserSiteDetails(userId));
    } catch (JsonGenerationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (JsonMappingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
}

From source file:fr.epsi.controllers.rest.ProductController.java

@RequestMapping(value = "/product/{reference}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody Product order(@PathVariable("reference") String reference, HttpServletResponse resp) {

    try {//from   w ww .  j  a v  a 2 s  .  com
        Products productModel = Products.getInstance();

        // On recupere le produit par reference
        Product product = productModel.findByRef(reference);

        if (product != null) {
            return product;
        } else {
            resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
        }
        return null;
    } catch (Exception e) {
        resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        return null;
    }
}

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

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

From source file:com.melayer.camzia.controller.MeControllerAdmin.java

@RequestMapping(path = "/check", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
public Callable<ResponseEntity<Map<String, Object>>> checkWebServices() {

    return () -> {

        entityMap.clear();//from  w  w  w  .  j a  v a  2 s. c  o  m
        entityMap.put("status", "working fine");

        ResponseEntity<Map<String, Object>> entity = new ResponseEntity<>(entityMap, HttpStatus.OK);

        return entity;
    };
}

From source file:com.mycompany.spring2explore.restcontroller.PersonRestcontroller.java

@RequestMapping(value = "/rest/get-person", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public List<MPerson> mPersons() {
    List<MPerson> listPersons = personService.listPersons();
    System.out.println("lewat get-person");
    System.out.println("List<MPerson> : " + listPersons);
    return listPersons;
}

From source file:com.eatcodesleep.web.MailRestController.java

@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
public String sendMail(@RequestBody final TextEmail textEmail) {
    javaMailSender.send((MimeMessage mimeMessage) -> {
        mimeMessage.setFrom(textEmail.getFromAddress());
        mimeMessage.setRecipients(Message.RecipientType.TO, textEmail.getToAddressesAsCommaSeparatedString());
        mimeMessage.setText(textEmail.getMessage());
    });//from   w  w  w  .j a  v  a 2  s  .  c  om
    return "Success!!!";
}