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:fr.epsi.controllers.rest.ProductController.java
@RequestMapping(value = "/product", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Product[] order(HttpServletResponse resp) { try {/*from w ww. j a va2 s . c o m*/ Products productModel = Products.getInstance(); // On recupere le produit par reference Product[] product = productModel.getAllProduct(); 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:io.fourfinanceit.homework.controller.LoanControler.java
@RequestMapping(value = "/loan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Iterable<LoanApplication>> getLoanApplications() { Iterable<LoanApplication> loanApplications = loanApplicationRepository.findAll(); return new ResponseEntity<Iterable<LoanApplication>>(loanApplications, HttpStatus.OK); }
From source file:org.cloudfoundry.identity.uaa.error.JsonAwareAuthenticationEntryPointTests.java
@Test public void testCommenceWithJson() throws Exception { request.addHeader("Accept", MediaType.APPLICATION_JSON_VALUE); entryPoint.commence(request, response, new BadCredentialsException("Bad")); assertEquals(HttpServletResponse.SC_UNAUTHORIZED, response.getStatus()); assertEquals("{\"error\":\"Bad\"}", response.getContentAsString()); assertEquals(null, response.getErrorMessage()); }
From source file:com.jci.job.apis.ApiClientController.java
/** * Get PO Details scheduler./*from ww w. ja v a 2 s . c o m*/ * * @param plant the plant * @param erp the erp * @param region the region * @return the po details */ @RequestMapping(value = "/getPoDetails", method = RequestMethod.GET, consumes = MediaType.APPLICATION_JSON_VALUE, produces = { MediaType.APPLICATION_JSON_VALUE }) public String getPoDetails(@RequestParam("plant") String plant, @RequestParam("erp") String erp, @RequestParam("region") String region) { String response = service.getPoDetails(plant, erp, region); LOG.info("response-->" + response); return response; }
From source file:com.mycompany.springrest.controllers.RoleController.java
@RequestMapping(value = "/role", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<List<Role>> listRoles() { List<Role> roles = roleService.listRoles(); if (roles.isEmpty()) { return new ResponseEntity<List<Role>>(HttpStatus.NO_CONTENT); }/*from www . j ava2 s .c o m*/ return new ResponseEntity<List<Role>>(roles, HttpStatus.OK); }
From source file:com.orange.clara.pivotaltrackermirror.controllers.MirrorReferenceController.java
@ApiOperation(value = "Register a mirror reference", response = MirrorReference.class) @RequestMapping(method = RequestMethod.POST, value = "", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<?> register(@RequestBody MirrorReferenceRequest mirrorReferenceRequest) throws ConvertException, CannotFindConverterException, SchedulerException { MirrorReference mirrorReference = mirrorReferenceRequest.toMirrorReference(); mirrorReference.setUpdatedAt(null);/*w ww.ja v a 2 s .c o m*/ mirrorReference = this.mirrorReferenceRepo.save(mirrorReference); JobDetail job = JobBuilder.newJob(MirrorJob.class) .withIdentity(MirrorJob.JOB_KEY_NAME + mirrorReference.getId(), MirrorJob.JOB_KEY_GROUP) .usingJobData(MirrorJob.JOB_MIRROR_REFERENCE_ID_KEY, String.valueOf(mirrorReference.getId())) .usingJobData(MirrorJob.JOB_MIRROR_TOKEN_KEY, mirrorReferenceRequest.getToken()).build(); Trigger trigger = TriggerBuilder.newTrigger() .withIdentity(MirrorJob.TRIGGER_KEY_NAME + mirrorReference.getId(), MirrorJob.TRIGGER_KEY_GROUP) .startNow().withSchedule(SimpleScheduleBuilder.simpleSchedule() .withIntervalInMinutes(refreshMirrorMinutes).repeatForever()) .build(); scheduler.scheduleJob(job, trigger); return ResponseEntity.created(URI.create(appUrl + "/api/task/" + mirrorReference.getId() + "/status")) .body(mirrorReference); }
From source file:business.controllers.ProfileController.java
@RequestMapping(value = "/hublabs", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public List<Lab> getProfileHubLabs(UserAuthenticationToken user) { // Query user's profile log.info("GET labs profile for user with id " + user.getId()); ProfileRepresentation profileRepresentation = new ProfileRepresentation(userService.findOne(user.getId())); // Return the representation return labService.findAll(profileRepresentation.getHubLabIds()); }
From source file:org.openbaton.nfvo.api.RestConfiguration.java
/** * Adds a new Configuration to the Configurations repository * * @param configuration/*ww w .j ava2s . c o m*/ * @return configuration */ @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.CREATED) public Configuration create(@RequestBody @Valid Configuration configuration, @RequestHeader(value = "project-id", required = false) String projectId) { log.trace("Adding Configuration: " + configuration); configuration.setProjectId(projectId); log.debug("Adding Configuration"); return configurationManagement.add(configuration); }
From source file:com.boxedfolder.carrot.web.client.EventResource.java
@JsonView(View.Client.class) @ResponseStatus(HttpStatus.OK)/*from ww w . j av a2s. c om*/ @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public List<Event> getAll() { EventList list = new EventList(); list.addAll(service.findAll()); return list; }
From source file:test.phoenixnap.oss.plugin.naming.testclasses.MultipleContentTypeTestController.java
@RequestMapping(value = "/base/endpoint", method = { RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE }) public String secondEndpoint() { return null; }