List of usage examples for org.springframework.http MediaType APPLICATION_JSON_VALUE
String APPLICATION_JSON_VALUE
To view the source code for org.springframework.http MediaType APPLICATION_JSON_VALUE.
Click Source Link
From source file:io.openshift.booster.service.FruitController.java
@ResponseBody @GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE) public Fruit get(@PathVariable("id") Integer id) { verifyFruitExists(id);/*from w w w . j av a 2s. co m*/ return repository.findOne(id); }
From source file:com.javafxpert.wikibrowser.WikiLangLinksController.java
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> locatorEndpoint(@RequestParam(value = "title") String articleTitle, @RequestParam(value = "lang") String lang) { String language = wikiBrowserProperties.computeLang(lang); LangLinksResponseNear langLinksResponseNear = null; if (!articleTitle.equals("")) { langLinksResponseNear = retrieveLangLinks(articleTitle, language); }/*from w w w. j a v a 2 s . c om*/ return Optional.ofNullable(langLinksResponseNear) .map(cr -> new ResponseEntity<>((Object) cr, HttpStatus.OK)) .orElse(new ResponseEntity<>("Wikipedia query unsuccessful", HttpStatus.INTERNAL_SERVER_ERROR)); }
From source file:io.ignitr.dispatchr.manager.controller.subscription.SubscriptionsController.java
/** * * @param topicName//from w ww . j a v a 2 s . c om * @param httpRequest * @return */ @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public DeferredResult<ResponseEntity<FindSubscriptionsResponse>> findAll(@PathVariable("name") String topicName, HttpServletRequest httpRequest) { final DeferredResult<ResponseEntity<FindSubscriptionsResponse>> deferredResult = new DeferredResult<>(); topicService.findOne(topicName).lift(new RequestContextStashOperator<>()).flatMap(topicMetadata -> { List<Subscription> subscriptionMetadatas = new ArrayList<>(); return subscriptionService.findAll(topicMetadata.getName()).collect(() -> subscriptionMetadatas, List::add); }).map(FindSubscriptionsResponse::from).subscribeOn(Schedulers.io()).subscribe(body -> { deferredResult.setResult(ResponseEntity.ok(body)); }, error -> { deferredResult.setErrorResult(errorHandler.handleError(httpRequest, error)); }); return deferredResult; }
From source file:net.gbmb.collector.StatusController.java
@RequestMapping(value = "/status/{cid}", produces = MediaType.APPLICATION_JSON_VALUE) public EntryView collectionStatus(@PathVariable("cid") String cid) { return collectionMap.getEntryView(cid); }
From source file:ip.ip.rest.controller.AuthorRestController.java
@RequestMapping(value = "/addBook/{id}", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) public void addBook(Book book, @PathVariable long id) { service.addBookToAuthor(service.getAuthorById(id), book); }
From source file:com.nec.harvest.rest.RESTHeadquatersMessage.java
/** * RESTfull web service which allow get a list of headquarters message by * offset/*from w w w . ja v a 2 s. com*/ * * @param position * First position * @param offset * Max of result * @return A list of messages */ @RequestMapping(value = "/headquaters/{position}/{offset}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody List<HeadquartersMessageBean> findHeadquaterMessagesByOffset( @PathVariable final int position, @PathVariable final int offset) { return headquartersService.findByOffset(position, offset); }
From source file:org.note.application.NoteController.java
/** * This will add the note into map for later use * @param note/* ww w . j a va 2 s .c o m*/ * @return * @throws ServiceException * @throws IOException */ @ExceptionHandler(ServiceException.class) @RequestMapping(value = "/add", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public ArrayList<Note> add(@RequestBody Note note) throws ServiceException, IOException { LOGGER.info(" Started adding note "); ArrayList<Note> notes = service.addNote(note); LOGGER.info("Successfully added the note"); return notes; }
From source file:net.paslavsky.springrest.HttpHeadersHelperTest.java
@DataProvider public Object[][] data() { DateFormat dateFormat = createDateFormat(); final long currentTime = System.currentTimeMillis(); final String currentTimeStr = dateFormat.format(new Date(currentTime)); return new Object[][] { new Object[] { "Other", new Object[] { 123 }, "123" }, new Object[] { "Other", new Object[] { "123" }, "123" }, new Object[] { "Other", new String[] { "123" }, "123" }, new Object[] { "Other", Arrays.asList("123"), "123" }, new Object[] { "Other", "123", "123" }, new Object[] { "Accept", MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON_VALUE }, new Object[] { "Accept", Arrays.asList(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), MediaType.APPLICATION_JSON_VALUE + ", " + MediaType.APPLICATION_XML_VALUE }, new Object[] { "Accept-Charset", java.nio.charset.Charset.forName("UTF-8"), "utf-8" }, new Object[] { "Allow", HttpMethod.GET, "GET" }, new Object[] { "Allow", new TreeSet<HttpMethod>(Arrays.asList(HttpMethod.PUT, HttpMethod.POST)), "POST,PUT" }, new Object[] { "Connection", "close", "close" }, new Object[] { "Content-Disposition", "form-data; name=\"AttachedFile1\"; filename=\"photo-1.jpg\"", "form-data; name=\"AttachedFile1\"; filename=\"photo-1.jpg\"" }, new Object[] { "Content-Disposition", new String[] { "AttachedFile1", "photo-1.jpg" }, "form-data; name=\"AttachedFile1\"; filename=\"photo-1.jpg\"" }, new Object[] { "Content-Disposition", "AttachedFile1", "form-data; name=\"AttachedFile1\"" }, new Object[] { "Content-Length", 123l, "123" }, new Object[] { "Content-Type", MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON_VALUE }, new Object[] { "Content-Type", MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, new Object[] { "Date", currentTime, currentTimeStr }, new Object[] { "ETag", "W/\"123456789\"", "W/\"123456789\"" }, new Object[] { "Expires", currentTime, currentTimeStr }, new Object[] { "If-Modified-Since", currentTime, currentTimeStr }, new Object[] { "If-None-Match", "737060cd8c284d8af7ad3082f209582d", "737060cd8c284d8af7ad3082f209582d" }, new Object[] { "Last-Modified", currentTime, currentTimeStr }, new Object[] { "Location", "http://example.com/", "http://example.com/" }, new Object[] { "Location", URI.create("http://example.com/"), "http://example.com/" }, new Object[] { "Origin", "www.a.com", "www.a.com" }, new Object[] { "Pragma", "no-cache", "no-cache" }, new Object[] { "Upgrade", "HTTP/2.0, SHTTP/1.3, IRC/6.9, RTA/x11", "HTTP/2.0, SHTTP/1.3, IRC/6.9, RTA/x11" }, }; }
From source file:io.fourfinanceit.homework.controller.ClientController.java
@RequestMapping(value = "/client", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<LoanApplication> createClient(@RequestBody Client client, HttpServletRequest request) { LoanApplication loanApplication = null; while (client.getLoanApplications().iterator().hasNext()) { loanApplication = client.getLoanApplications().iterator().next(); loanApplication.setIpAddress(ipAddressDefiner.getIpAddress(request)); }//from ww w.ja v a2s . c o m Client savedClient = clientRepository.save(client); while (savedClient.getLoanApplications().iterator().hasNext()) { if (!savedClient.getLoanApplications().iterator().hasNext()) { loanApplication = savedClient.getLoanApplications().iterator().next(); } } if (loanApplication.getStatus() == LoanApplicationStatusEnum.ACTIVE.getStatus()) { return new ResponseEntity<LoanApplication>(loanApplication, HttpStatus.CREATED); } else { return new ResponseEntity<LoanApplication>(loanApplication, HttpStatus.FORBIDDEN); } }
From source file:com.orange.ngsi.server.NgsiRestBaseController.java
@RequestMapping(method = RequestMethod.POST, value = { "/contextEntities/{entityID}", "/contextEntities/{entityID}/attributes" }, consumes = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE }) final public ResponseEntity<AppendContextElementResponse> appendContextElement(@PathVariable String entityID, @RequestBody AppendContextElement appendContextElement, HttpServletRequest httpServletRequest) throws Exception { ngsiValidation.checkAppendContextElement(appendContextElement); registerIntoDispatcher(httpServletRequest); return new ResponseEntity<>(appendContextElement(entityID, appendContextElement), HttpStatus.OK); }