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:demo.service.RemoteVehicleDetailsServiceWireMockTest.java
@Test public void getVehicleDetailsWhenResultIsSuccessShouldReturnDetails() throws Exception { this.wireMock.stubFor(get(urlEqualTo("/vehicle/" + VIN + "/details")).willReturn( aResponse().withStatus(200).withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) .withBody(getClassPathResource("vehicledetails.json")))); VehicleDetails details = this.service.getVehicleDetails(new VehicleIdentificationNumber(VIN)); assertThat(details.getMake()).isEqualTo("Honda"); assertThat(details.getModel()).isEqualTo("Civic"); }
From source file:org.openbaton.nfvo.api.RestVirtualNetworkFunctionDescriptor.java
/** * Removes multiple VirtualNetworkFunctionDescriptor from the VirtualNetworkFunctionDescriptors * repository/*from w w w .j a va 2s . c o m*/ * * @param ids */ @RequestMapping(value = "/multipledelete", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.NO_CONTENT) public void multipleDelete(@RequestBody @Valid List<String> ids, @RequestHeader(value = "project-id") String projectId) { for (String id : ids) vnfdManagement.delete(id, projectId); }
From source file:com.orange.ngsi.server.NgsiBaseController.java
@RequestMapping(value = "/registerContext", method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE }) final public ResponseEntity<RegisterContextResponse> registerContextRequest( @RequestBody final RegisterContext registerContext, HttpServletRequest httpServletRequest) throws Exception { ngsiValidation.checkRegisterContext(registerContext); registerIntoDispatcher(httpServletRequest); return new ResponseEntity<>(registerContext(registerContext), HttpStatus.OK); }
From source file:com.redhat.coolstore.api_gateway.ProductGateway.java
@Override public void configure() throws Exception { try {//from w w w. jav a 2 s .c om getContext().setTracing(Boolean.parseBoolean(env.getProperty("ENABLE_TRACER", "false"))); } catch (Exception e) { LOG.error("Failed to parse the ENABLE_TRACER value: {}", env.getProperty("ENABLE_TRACER", "false")); } JacksonDataFormat productFormatter = new ListJacksonDataFormat(); productFormatter.setUnmarshalType(Product.class); rest("/products/").description("Product Catalog Service").produces(MediaType.APPLICATION_JSON_VALUE) // Handle CORS Pre-flight requests .options("/").route().id("productsOptions").end().endRest() .get("/").description("Get product catalog").outType(Product.class).route().id("productRoute") .hystrix().id("Product Service").hystrixConfiguration() .executionTimeoutInMilliseconds(hystrixExecutionTimeout).groupKey(hystrixGroupKey) .circuitBreakerEnabled(hystrixCircuitBreakerEnabled).end().setBody(simple("null")) .removeHeaders("CamelHttp*") .recipientList(simple("http4://{{env:CATALOG_ENDPOINT:catalog:8080}}/api/products")).end() .onFallback() //.setHeader(Exchange.HTTP_RESPONSE_CODE, constant(Response.Status.SERVICE_UNAVAILABLE.getStatusCode())) .to("direct:productFallback").stop().end().choice().when(body().isNull()) .to("direct:productFallback").end().unmarshal(productFormatter).split(body()).parallelProcessing() .enrich("direct:inventory", new InventoryEnricher()).enrich("direct:rating", new RatingEnricher()) .end().endRest(); from("direct:productFallback").id("ProductFallbackRoute").transform().constant( Collections.singletonList(new Product("0", "Unavailable Product", "Unavailable Product", 0, null))); //.marshal().json(JsonLibrary.Jackson, List.class); from("direct:inventory").id("inventoryRoute").setHeader("itemId", simple("${body.itemId}")).hystrix() .id("Inventory Service").hystrixConfiguration() .executionTimeoutInMilliseconds(hystrixExecutionTimeout).groupKey(hystrixGroupKey) .circuitBreakerEnabled(hystrixCircuitBreakerEnabled).end().setBody(simple("null")) .removeHeaders("CamelHttp*") .recipientList(simple( "http4://{{env:INVENTORY_ENDPOINT:inventory:8080}}/api/availability/${header.itemId}")) .end().onFallback() //.setHeader(Exchange.HTTP_RESPONSE_CODE, constant(Response.Status.SERVICE_UNAVAILABLE.getStatusCode())) .to("direct:inventoryFallback").end().choice().when(body().isNull()).to("direct:inventoryFallback") .end().setHeader("CamelJacksonUnmarshalType", simple(Inventory.class.getName())).unmarshal() .json(JsonLibrary.Jackson, Inventory.class); from("direct:inventoryFallback").id("inventoryFallbackRoute").transform() .constant(new Inventory("0", 0, "Local Store", "http://developers.redhat.com")).marshal() .json(JsonLibrary.Jackson, Inventory.class); from("direct:rating").id("ratingRoute").setHeader("itemId", simple("${body.itemId}")) .setBody(simple("null")).removeHeaders("CamelHttp*") .setHeader(Exchange.HTTP_METHOD, HttpMethods.GET) .setHeader(Exchange.HTTP_URI, simple("http://{{env:RATING_ENDPOINT:rating:8080}}/api/rating/${header.itemId}")) .hystrix().id("Rating Service").hystrixConfiguration().executionTimeoutInMilliseconds(5000) .circuitBreakerSleepWindowInMilliseconds(10000).end().to("http4://DUMMY2").onFallback() .to("direct:ratingFallback").end().choice().when(body().isNull()).to("direct:ratingFallback").end() .setHeader("CamelJacksonUnmarshalType", simple(Rating.class.getName())).unmarshal() .json(JsonLibrary.Jackson, Rating.class); from("direct:ratingFallback").id("ratingFallbackRoute").transform().constant(new Rating("0", 2.0, 1)) .marshal().json(JsonLibrary.Jackson, Rating.class); }
From source file:org.apache.ambari.view.registry.web.controller.ApplicationController.java
/** * Returns all the applications. Can be filtered with 'after' query params * @return List of applications/* w w w .j a va 2 s . c om*/ */ @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) public ApplicationsWrapper getAll(@RequestParam(value = "after") Optional<Long> after, @RequestParam("like") Optional<String> appNameLike, @RequestParam(value = "embed", defaultValue = "false") String embed) { List<Application> applications = service.findApplications(appNameLike, after); return new ApplicationsWrapper(applications); }
From source file:cern.jarrace.controller.rest.controller.AgentContainerController.java
@RequestMapping(value = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public Set<AgentContainer> listContainers() { Set<AgentContainer> allAgentContainers = agentContainerManager.findAllAgentContainers(); return allAgentContainers; }
From source file:org.ow2.proactive.procci.rest.SwarmRest.java
@RequestMapping(value = "{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<ResourceRendering> getSwarm(@PathVariable("id") String id) { logger.debug("Get Swarm " + id); try {/* www . j a va 2s. co m*/ return instanceService.getEntity(id, transformerManager.getTransformerProvider(TransformerType.SWARM)) .map(swar -> new ResponseEntity<>(((Swarm) swar).getRendering(), HttpStatus.OK)) .orElse(new ResponseEntity(HttpStatus.NOT_FOUND)); } catch (ClientException e) { logger.error(this.getClass().getName(), e); return new ResponseEntity(e.getJsonError(), HttpStatus.BAD_REQUEST); } catch (ServerException e) { logger.error(this.getClass().getName(), e); return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); } }
From source file:com.mentat.rest.web.GamesController.java
@RequestMapping(method = RequestMethod.GET, value = "/{gameId}", produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_XML_VALUE })/*from w w w .j a va 2s.c o m*/ ResponseEntity<Resource<Game>> showGame(@PathVariable Integer gameId) throws GameDoesNotExistException { Game game = this.gameRepository.retrieve(gameId); Resource<Game> resource = this.gameResourceAssembler.toResource(game); return new ResponseEntity<>(resource, HttpStatus.OK); }
From source file:info.losd.galen.api.GalenApiController.java
@RequestMapping(value = "/healthchecks", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody// w w w . j a v a 2s .c o m public HttpEntity<List<HealthcheckApiDTO>> getHealthcheckList() { List<HealthcheckApiDTO> result = new LinkedList<>(); repo.getHealthchecks().forEach(healthcheck -> { result.add(new HealthcheckApiDTO(healthcheck.getName())); }); return new ResponseEntity<>(result, HttpStatus.OK); }
From source file:com.btmatthews.leabharlann.controller.LibraryController.java
/** * The endpoint that creates a new sub-folder in a workspace. * * @param workspaceName The workspace name. * @param node The node identifier of the parent folder. * @param folder The {@link Folder} descriptor for the new folder. * @return The {@link Folder} for the newly created node. */// w w w.j ava 2 s.c o m @RequestMapping(value = "workspaces/{workspace}/folders/{node}/folder", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.CREATED) @ResponseBody public Folder createFolder(@PathVariable("workspace") final String workspaceName, @PathVariable("node") final String node, @RequestBody final Folder folder) { final Workspace workspace = libraryService.getWorkspace(workspaceName); return libraryService.createFolder(workspace, node, folder.getName()); }