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:org.mitre.openid.connect.view.JWKSetView.java
@Override protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) {/*from w ww . j a v a2 s. c o m*/ response.setContentType(MediaType.APPLICATION_JSON_VALUE); //BiMap<String, PublicKey> keyMap = (BiMap<String, PublicKey>) model.get("keys"); Map<String, JWK> keys = (Map<String, JWK>) model.get("keys"); JWKSet jwkSet = new JWKSet(new ArrayList<>(keys.values())); try { Writer out = response.getWriter(); out.write(jwkSet.toString()); } catch (IOException e) { logger.error("IOException in JWKSetView.java: ", e); } }
From source file:org.trustedanalytics.h2oscoringengine.rest.H2oScoringEngineController.java
/** * Using POST method due to potential large input data size. *//*from ww w . j a v a2s. co m*/ @RequestMapping(method = RequestMethod.POST, value = POST_H2O_MODEL_URL, produces = MediaType.APPLICATION_JSON_VALUE, consumes = "application/json") public double[] score(@RequestBody(required = true) double[] data) { return model.score(data); }
From source file:com.jci.po.apis.FlatFileClient.java
/** * Process error item flat files./* w ww. java2 s .c o m*/ * * @param req the req * @return the response entity */ @RequestMapping(value = "/processErrorItemFlatFiles", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = { MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity<ProcessErrorRes> processErrorItemFlatFiles(@RequestBody ProcessErrorReq req);
From source file:tds.assessment.web.endpoints.AccommodationController.java
@GetMapping(value = "{clientName}/assessments/accommodations", produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody// w w w. j a v a2 s. co m ResponseEntity<List<Accommodation>> findAccommodations(@PathVariable final String clientName, @RequestParam(required = false) final String assessmentKey, @RequestParam(required = false) final String assessmentId) { if (StringUtils.isNotEmpty(assessmentKey)) { return ResponseEntity .ok(accommodationsService.findAccommodationsByAssessmentKey(clientName, assessmentKey)); } else if (StringUtils.isNotEmpty(assessmentId)) { return ResponseEntity .ok(accommodationsService.findAccommodationsByAssessmentId(clientName, assessmentId)); } else { throw new IllegalArgumentException("Must provide an assessmentKey or an assessmentId"); } }
From source file:com.todo.backend.web.rest.UserApi.java
@RequestMapping(value = "/user/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @Timed//from w w w . j a v a2s. co m @Transactional(readOnly = true) @PreAuthorize("hasAuthority('ADMIN')") public ResponseEntity<ReadUserResponse> readUser(@PathVariable Long id) { log.debug("GET /user/{}", id); final Optional<User> result = Optional.ofNullable(userRepository.findOne(id)); if (result.isPresent()) { return ResponseEntity.ok().body(convertToReadUserResponse(result.get())); } return new ResponseEntity<>(HttpStatus.NOT_FOUND); }
From source file:es.javier.services.resource.BreweryController.java
/** * This method returns a brewery JSON by id given * /*from w ww . j av a2s . c o m*/ * @param id * @return BreweryDto */ @RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<BreweryDto> getById(@PathVariable("id") String id) { Brewery brewery = this.breweryService.find(id); if (brewery == null) { return new ResponseEntity<BreweryDto>(HttpStatus.NOT_FOUND); } return new ResponseEntity<BreweryDto>(this.dtoBuilder.buildBreweryDto(brewery), HttpStatus.OK); }
From source file:be.ehb.restservermetdatabase.webservice.AchievementController.java
@RequestMapping(value = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ArrayList<Achievement> getAchievements( @RequestParam(value = "user_id", defaultValue = "0") int user_id) { // http://localhost:8080/achievements/list?user_id=1 // http://localhost:8080/achievements/list if (user_id == 0) { ArrayList<Achievement> achievements = AchievementDao.getAchievements(); for (int i = 0; i < achievements.size(); i++) { achievements.get(i).setIcon(getImg(achievements.get(i).getIcon())); }// w w w . j a v a2s. c o m return achievements; } else { ArrayList<Achievement> achievements = UserAchievementDao.getPersonalAchievements(user_id); for (int i = 0; i < achievements.size(); i++) { achievements.get(i).setIcon(getImg(achievements.get(i).getIcon())); } return achievements; } }
From source file:org.openbaton.nfvo.api.RestVimInstances.java
/** * Adds a new VNF software Image to the datacenter repository * * @param vimInstance : Image to add//from ww w .j a v a2 s. co m * @return datacenter: The datacenter filled with values from the core */ @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.CREATED) public VimInstance create(@RequestBody @Valid VimInstance vimInstance, @RequestHeader(value = "project-id") String projectId) throws VimException, PluginException, EntityUnreachableException, IOException { return vimManagement.add(vimInstance, projectId); }
From source file:org.cloudfoundry.identity.uaa.error.JsonAwareAccessDeniedHandler.java
@Override public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException authException) throws IOException, ServletException { String accept = request.getHeader("Accept"); boolean json = false; if (StringUtils.hasText(accept)) { for (MediaType mediaType : MediaType.parseMediaTypes(accept)) { if (mediaType.includes(MediaType.APPLICATION_JSON)) { json = true;//from w w w. j a v a 2 s . c o m break; } } } if (json) { response.setStatus(HttpServletResponse.SC_FORBIDDEN); response.setContentType(MediaType.APPLICATION_JSON_VALUE); response.getWriter().append(String.format("{\"error\":\"%s\"}", authException.getMessage())); } else { response.sendError(HttpServletResponse.SC_FORBIDDEN, authException.getMessage()); } }
From source file:com.github.lynxdb.server.api.http.handlers.EpAggregators.java
@RequestMapping(path = "", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity root() { return ResponseEntity.ok(allAggregators.get().keySet()); }