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:com.jci.job.apis.ApiClient.java

/**
 * Gets the items./*from   w  ww. j  ava  2s  .  co m*/
 *
 * @param apikey the apikey
 * @param plant the plant
 * @param erp the erp
 * @param region the region
 * @return the items
 */
@RequestMapping(value = "/parts", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE })
public ResponseEntity<ItemDetailsRes> getItems(@RequestParam("apikey") String apikey,
        @RequestParam("plant") String plant, @RequestParam("erp") String erp,
        @RequestParam("region") String region);

From source file:com.orange.cepheus.cep.controller.AdminController.java

@RequestMapping(value = "/config", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
public synchronized ResponseEntity<?> configuration(@Valid @RequestBody final Configuration configuration)
        throws ConfigurationException, PersistenceException {
    logger.info("Update configuration");

    String configurationId = TenantFilter.DEFAULT_TENANTID;
    if (tenantScope != null) {
        configurationId = tenantScope.getConversationId();

        // Force tenant information to configuration
        injectTenant(configuration);//from w  w w . j  av  a  2s.  c  o  m
    }

    /*
     * Try to apply a new configuration, in case of configuration error
     * try to restore the previous configuration if any
     */
    final Configuration previousConfiguration = complexEventProcessor.getConfiguration();
    try {
        complexEventProcessor.setConfiguration(configuration);
        eventMapper.setConfiguration(configuration);
        subscriptionManager.setConfiguration(configuration);
        persistence.saveConfiguration(configurationId, configuration);
    } catch (ConfigurationException e) {
        // try to restore previous configuration
        if (previousConfiguration != null) {
            complexEventProcessor.restoreConfiguration(previousConfiguration);
            eventMapper.setConfiguration(previousConfiguration);
            subscriptionManager.setConfiguration(previousConfiguration);
        }
        throw e;
    }

    return new ResponseEntity<>(HttpStatus.CREATED);
}

From source file:com.mycompany.springrest.controllers.RoleController.java

@RequestMapping(value = "/role/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Void> createRole(@RequestBody Role role, UriComponentsBuilder ucBuilder) {
    logger.info("Creating Role " + role.getName());
    if (roleService.isRoleExist(role)) {
        logger.info("A Role with name " + role.getName() + " already exist");
        return new ResponseEntity<Void>(HttpStatus.CONFLICT);
    }//w  w  w  . jav  a 2s .c  o  m
    roleService.addRole(role);

    HttpHeaders headers = new HttpHeaders();
    headers.setLocation(ucBuilder.path("/role/{id}").buildAndExpand(role.getId()).toUri());
    return new ResponseEntity<Void>(headers, HttpStatus.CREATED);
}

From source file:com.javafxpert.wikibrowser.WikiVisGraphController.java

/**
 * Query Neo4j for all relationships between given set of item IDs
 * @param items//from   w  w w.  j av a  2  s .  c  om
 * @return
 */
@RequestMapping(value = "/visgraph", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Object> search(@RequestParam(value = "items", defaultValue = "") String items) {
    // Example endpoint usage is graph?items=Q24, Q30, Q23, Q16, Q20
    // Scrub the input, and output a string for the Cypher query similar to the following:
    // 'Q24','Q30','Q23','Q16','Q20'
    String argStr = WikiBrowserUtils.scrubItemIds(items, true);

    log.info("argStr=" + argStr);

    VisGraphResponseNear visGraphResponseNear = null;

    if (argStr.length() == 0) {
        // TODO: Consider handling an invalid items argument better than the way it is handled here
        //argStr = "'Q2'"; // If the items argumentisn't valid, pretend Q2 (Earth) was entered
    }

    if (argStr.length() > 0) {
        String neoCypherUrl = wikiBrowserProperties.getNeoCypherUrl();

        /*  Example Cypher query POST
        {
          "statements" : [ {
            "statement" : "MATCH (a)-[r]->(b) WHERE a.itemId IN ['Q24', 'Q30', 'Q23', 'Q16', 'Q20'] AND b.itemId IN ['Q24', 'Q30', 'Q23', 'Q16', 'Q20'] RETURN a, b, r",
            "resultDataContents" : ["graph" ]
          } ]
        }
        */

        /*
        MATCH (a:Item), (b:Item)
        WHERE a.itemId IN ['Q2', 'Q24', 'Q30'] AND b.itemId IN ['Q2', 'Q24', 'Q30']
        WITH a, b
        OPTIONAL MATCH (a)-[rel]-(b)
        RETURN a, b, collect(rel)
                
        was:
        MATCH (a:Item)
        WHERE a.itemId IN ['Q2', 'Q24', 'Q30']
        OPTIONAL MATCH (a:Item)-[rel]-(b:Item)
        WHERE b.itemId IN ['Q2', 'Q24', 'Q30']
        RETURN a, b, collect(rel)
        */

        String qa = "{\"statements\":[{\"statement\":\"MATCH (a:Item), (b:Item) WHERE a.itemId IN [";
        String qb = argStr; // Item IDs
        String qc = "] AND b.itemId IN [";
        String qd = argStr; // Item IDs
        String qe = "] WITH a, b OPTIONAL MATCH (a)-[rel]-(b) RETURN a, b, collect(rel)\",";
        String qf = "\"resultDataContents\":[\"graph\"]}]}";

        /*
        String qa = "{\"statements\":[{\"statement\":\"MATCH (a:Item) WHERE a.itemId IN [";
        String qb = argStr; // Item IDs
        String qc = "] OPTIONAL MATCH (a:Item)-[rel]-(b:Item) WHERE b.itemId IN [";
        String qd = argStr; // Item IDs
        String qe = "] RETURN a, b, collect(rel)\",";
        String qf = "\"resultDataContents\":[\"graph\"]}]}";
        */

        String postString = qa + qb + qc + qd + qe + qf;

        visGraphResponseNear = queryProcessSearchResponse(neoCypherUrl, postString);
    }

    return Optional.ofNullable(visGraphResponseNear).map(cr -> new ResponseEntity<>((Object) cr, HttpStatus.OK))
            .orElse(new ResponseEntity<>("visgraph query unsuccessful", HttpStatus.INTERNAL_SERVER_ERROR));
}

From source file:com.orange.cloud.servicebroker.filter.core.service.ServiceInstanceServiceClient.java

@RequestMapping(value = "/v2/service_instances/{instanceId}", method = RequestMethod.PATCH, produces = {
        MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<UpdateServiceInstanceResponse> updateServiceInstance(
        @PathVariable("instanceId") String serviceInstanceId,
        @Valid @RequestBody UpdateServiceInstanceRequest request,
        @RequestParam(value = "accepts_incomplete", required = false) boolean acceptsIncomplete);

From source file:io.curly.gathering.list.GatheringController.java

@RequestMapping(value = "", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public DeferredResult<HttpEntity<List<SimpleGatheringList>>> listNames(@GitHubAuthentication User user) {
    return defer(storage.findUsersList(user)
            .map(gatheringLists -> gatheringLists.stream().map(SimpleGatheringList::from).collect(toList()))
            .map(ResponseEntity::ok));//from   w ww . j  a va  2s . c  o m
}

From source file:com.logsniffer.web.controller.sniffer.SnifferEventsResourceController.java

@RequestMapping(value = "/sniffers/{snifferId}/events", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody//from   w  ww .j  a  v a2 s . co  m
PageableResult<AspectEvent> getEvents(final Model model, @PathVariable("snifferId") final long snifferId,
        @RequestParam(value = "_offset", defaultValue = "0", required = false) final long offset,
        @RequestParam(value = "_size", defaultValue = "25", required = false) final int size,
        @RequestParam(value = "_from", defaultValue = "-1", required = false) final long occurrenceFrom,
        @RequestParam(value = "_to", defaultValue = "-1", required = false) final long occurrenceTo,
        @RequestParam(value = "_histogram", defaultValue = "true", required = false) final boolean withHistogram) {
    EventQueryBuilder qb = eventPersistence.getEventsQueryBuilder(snifferId, offset, size);
    if (withHistogram) {
        qb = qb.withEventCountTimeHistogram(60);
    }
    qb = qb.sortByEntryTimestamp(false);
    if (occurrenceFrom >= 0) {
        qb.withOccurrenceFrom(new Date(occurrenceFrom));
    }
    if (occurrenceTo >= 0) {
        qb.withOccurrenceTo(new Date(occurrenceTo));
    }
    final PageableResult<AspectEvent> events = qb.list();
    return events;
}

From source file:com.logsniffer.web.controller.sniffer.SniffersResourceController.java

@RequestMapping(value = "/sniffers/{snifferId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
protected Sniffer getSniffer(@PathVariable("snifferId") final long snifferId) throws ResourceNotFoundException {
    final Sniffer activeSniffer = snifferPersistence.getSniffer(snifferId);
    if (activeSniffer == null) {
        throw new ResourceNotFoundException(Sniffer.class, snifferId, "Sniffer not found for id: " + snifferId);
    }//from w w w .  ja va  2 s . c om
    return activeSniffer;
}

From source file:org.jm.spring.controller.EndpointDocumentationController.java

/**
 * Should return a listing of available operations like 
 * http://petstore.swagger.wordnik.com/api/resources.json
 * //from  ww  w  . ja v a2 s . c  o m
 * @param httpServletRequest
 * @return
 * @throws Exception
 */
@RequestMapping(value = "/resources.json", method = RequestMethod.GET, produces = {
        MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody Documentation showAvailableResources(HttpServletRequest httpServletRequest)
        throws Exception {

    UrlPathHelper urlPathHelper = new UrlPathHelper();

    String basePath = getBasePath(httpServletRequest);

    SpringMVCAPIReader springMVCAPIReader = new SpringMVCAPIReader("0.1", "1.1-SHAPSHOT.121026", basePath,
            urlPathHelper.getContextPath(httpServletRequest));

    Documentation document = springMVCAPIReader.createResources(handlerMapping);

    return document;
}

From source file:com.github.lynxdb.server.api.http.handlers.EpStats.java

@RequestMapping(path = "/threads", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity threads() {
    return ResponseEntity.status(HttpStatus.NOT_IMPLEMENTED).build();
}