Example usage for org.springframework.http MediaType APPLICATION_XML_VALUE

List of usage examples for org.springframework.http MediaType APPLICATION_XML_VALUE

Introduction

In this page you can find the example usage for org.springframework.http MediaType APPLICATION_XML_VALUE.

Prototype

String APPLICATION_XML_VALUE

To view the source code for org.springframework.http MediaType APPLICATION_XML_VALUE.

Click Source Link

Document

A String equivalent of MediaType#APPLICATION_XML .

Usage

From source file:ru.anr.base.facade.web.api.CommandUtils.java

/**
 * Building a command with data extracted from {@link HttpServletRequest}
 * (method, headers)./*from ww  w . jav  a  2  s . c  om*/
 * 
 * 
 * @param commandId
 *            Identifier of Command
 * @param apiVersion
 *            API Version
 * @param request
 *            Http request
 * @return A command instance
 */
public static APICommand build(String commandId, String apiVersion, HttpServletRequest request) {

    APICommand cmd = new APICommand(commandId, apiVersion);

    if (MediaType.APPLICATION_XML_VALUE.equals(request.getContentType())) {
        cmd.setRequestFormat(RawFormatTypes.XML);
    } else {
        cmd.setRequestFormat(RawFormatTypes.JSON);
    }
    if (MediaType.APPLICATION_XML_VALUE.equals(request.getHeader("Accept"))) {
        cmd.setResponseFormat(RawFormatTypes.XML);
    } else {
        cmd.setResponseFormat(RawFormatTypes.JSON);
    }
    cmd.method(request.getMethod());
    return cmd;
}

From source file:com.mycompany.bootcamelrestdsl.web.UserController.java

@RequestMapping(name = "/users/count", produces = MediaType.APPLICATION_XML_VALUE, method = RequestMethod.GET)
public String getUsersCount() {

    return "<data>ABCS</data>";
}

From source file:com.slatz.dynamicroutetest.controllers.MyRestController.java

@CrossOrigin
@ApiOperation(httpMethod = "POST", value = "")
@RequestMapping(value = "/api/slattum/test", produces = MediaType.APPLICATION_XML_VALUE, method = RequestMethod.GET)
public MyProcList getProcessList(@RequestParam(value = "test") String test) throws Exception {

    MyProcList ProcList = ProcListGenerator.getInstance().getProcessList();

    return ProcList;
}

From source file:com.traveltainment.itea.bernat.jsongreeting.controller.GreetingController.java

@RequestMapping(path = "xml", method = RequestMethod.GET, produces = MediaType.APPLICATION_XML_VALUE)
public @ResponseBody Greeting sayXmlHello(
        @RequestParam(value = "name", required = false, defaultValue = "Stranger") String name) {
    return new Greeting(counter.incrementAndGet(), String.format(template, name));
}

From source file:com.searshc.mygarage.controllers.mock.NCDBVinNumberSearchControllerMock.java

@RequestMapping(value = "/vinnumber", method = RequestMethod.POST, produces = MediaType.APPLICATION_XML_VALUE)
@ResponseBody//from w w  w. j  a  va 2s  .  c om
public ResponseEntity<String> getVehiclesByVINNumberMock(@RequestBody final String request) {
    log.info("Request with data: " + request);
    String response = "<VehiclesResponse xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><TrackingEnvelope><ClientTrackingID></ClientTrackingID><ServiceTrackingID>7fc122c9-cee1-46aa-8054-c12436551991</ServiceTrackingID><GeneratedBy>SearsAutomotiveRESTServices</GeneratedBy></TrackingEnvelope><VehicleCount>20</VehicleCount><Vehicles><Vehicle><ID>25433</ID><Year>2002</Year><Make>GMC TRUCK</Make><Model>SIERRA 3500 PICKUP</Model><Engine>V8-364  6.0L</Engine><VIN>1GDJC34U52E205180</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>27117</ID><Year>2005</Year><Make>LEXUS TRUCK</Make><Model>RX 330</Model><Engine>V6-3311 3.3L DOHC</Engine><VIN>2T2HA31U25C040754</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>90109</ID><Year>2008</Year><Make>CHEVROLET TRUCK</Make><Model>TAHOE HYBRID</Model><Engine>V8-364  6.0L</Engine><VIN>1GNFK13528R241168</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>76494</ID><Year>2010</Year><Make>FORD-MEDIUM DUTY</Make><Model>E450 VAN</Model><Engine>V8-363  6.0L Dsl</Engine><VIN>1FDXE4FP1ADA27998</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>25348</ID><Year>2002</Year><Make>CHEVROLET TRUCK</Make><Model>AVALANCHE 1500</Model><Engine>V8-325  5.3L</Engine><VIN>3GNEK13T32G290123</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>87823</ID><Year>2014</Year><Make>GMC TRUCK</Make><Model>SIERRA 1500 PICKUP</Model><Engine>V8-325  5.3L</Engine><VIN>3GTU2VEC4EG430631</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>79922</ID><Year>2011</Year><Make>BUICK</Make><Model>LACROSSE</Model><Engine>V6-3564 3.6L DOHC</Engine><VIN>1G4GA5ED0BF355556</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>90138</ID><Year>2007</Year><Make>TOYOTA TRUCK</Make><Model>HIGHLANDER HYBRID</Model><Engine>V6-3311 3.3L DOHC</Engine><VIN>JTEGW21A770021112</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>18502</ID><Year>1999</Year><Make>LINCOLN</Make><Model>CONTINENTAL</Model><Engine>V8-281  4.6L DOHC</Engine><VIN>1LNHM97VXXY719437</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>0</ID><Year>2008</Year><Make>HARLEY DAVIDSON</Make><Model>FLHT ELECTRA GLIDE</Model><Engine> </Engine><VIN>1HD1FMM118Y615438</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>0</ID><Year>2012</Year><Make>HARLEY DAVIDSON</Make><Model>FLHP ROAD KNG POLICE</Model><Engine> </Engine><VIN>1HD1FHM11CB686416</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>91154</ID><Year>2014</Year><Make>HONDA</Make><Model>CIVIC</Model><Engine> 4-1799 1.8L SOHC</Engine><VIN>19XFB2F83EE224116</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>31304</ID><Year>2007</Year><Make>CHEVROLET</Make><Model>IMPALA</Model><Engine>V6-213  3.5L</Engine><VIN>2G1WB58K979345379</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>27586</ID><Year>2006</Year><Make>FORD TRUCK</Make><Model>E350 VAN</Model><Engine>V8-363  6.0L Dsl</Engine><VIN>1FDSS34PX6HA52009</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>76494</ID><Year>2010</Year><Make>FORD-MEDIUM DUTY</Make><Model>E450 VAN</Model><Engine>V8-363  6.0L Dsl</Engine><VIN>1FDXE4FP5ADA16034</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>82443</ID><Year>2012</Year><Make>AUDI</Make><Model>A7</Model><Engine>V6-2995 3.0L DOHC</Engine><VIN>WAUSGAFC1CN023495</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>96095</ID><Year>2015</Year><Make>MERCEDES BENZ TRUCK</Make><Model>GLK350</Model><Engine>V6-3498 3.5L DOHC</Engine><VIN>WDCGG8JB2FG346585</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>34089</ID><Year>2009</Year><Make>TOYOTA TRUCK</Make><Model>RAV4</Model><Engine>V6-3456 3.5L DOHC</Engine><VIN>2T3BK31V29W009399</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>31291</ID><Year>2007</Year><Make>CADILLAC</Make><Model>DTS</Model><Engine>V8-279  4.6L DOHC</Engine><VIN>1G6KD57Y37U227226</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>85370</ID><Year>2013</Year><Make>CHEVROLET</Make><Model>VOLT</Model><Engine> 4-1398 1.4L DOHC</Engine><VIN>1G1RA6E40DU147560</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle></Vehicles></VehiclesResponse>";
    return new ResponseEntity<String>(response, null, HttpStatus.OK);
}

From source file:com.culturedear.counterpoint.XmlRestController.java

@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_XML_VALUE)
public ResponseEntity<Object> write(@RequestBody CounterpointModel counterpointModel) {

    // prepare response XML out
    CounterpointGenerator cg = new CounterpointGenerator();
    cg.fillRhyPat();//from  w w w.ja va2s  . com
    int[] cf = counterpointModel.getMainMelody();
    cg.setCantusFirmus(cf);
    int[] vbs = counterpointModel.getPartsInitialNotes();

    CounterpointSolution counterpointSolution = cg.anySpecies(counterpointModel.getScaleMode(), vbs, cf.length,
            counterpointModel.getCounterpointSpecies(), counterpointModel.getRulePenalties());

    ScorePartwise scorePartwise = null;

    try {
        scorePartwise = counterpointSolution.toScorePartwise();
    } catch (NullPointerException ex) {
        scorePartwise = null;
    }

    return Optional.ofNullable(scorePartwise).map(cm -> new ResponseEntity<>((Object) cm, HttpStatus.OK))
            .orElse(new ResponseEntity<>("Could not compute the counterpoint.",
                    HttpStatus.INTERNAL_SERVER_ERROR));
}

From source file:com.nebhale.gpxconverter.ApplicationController.java

@RequestMapping(method = RequestMethod.POST, value = "", consumes = MediaType.APPLICATION_XML_VALUE, produces = MediaType.IMAGE_PNG_VALUE)
ResponseEntity<Void> image(@RequestBody DOMSource source,
        @RequestParam(defaultValue = "roadmap") String maptype,
        @RequestParam(defaultValue = "500") Integer width, @RequestParam(defaultValue = "500") Integer height) {
    this.logger.info("Rendering existing GPX file");
    List<Point> points = this.parser.parsePoints((Document) source.getNode());

    HttpHeaders headers = new HttpHeaders();
    headers.setLocation(this.mapBuilder.build(points, maptype, width, height));

    return new ResponseEntity<>(headers, HttpStatus.SEE_OTHER);
}

From source file:com.orange.ngsi.server.NgsiBaseController.java

@RequestMapping(value = "/notifyContext", method = RequestMethod.POST, consumes = {
        MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
final public ResponseEntity<NotifyContextResponse> notifyContextRequest(@RequestBody final NotifyContext notify,
        HttpServletRequest httpServletRequest) throws Exception {
    ngsiValidation.checkNotifyContext(notify);
    registerIntoDispatcher(httpServletRequest);
    return new ResponseEntity<>(notifyContext(notify), HttpStatus.OK);
}

From source file:org.messic.server.facade.controllers.rest.CheckController.java

@ApiMethod(path = "/services/check", verb = ApiVerb.GET, description = "Check if the messic service is alive", produces = {
        MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
@ApiErrors(apierrors = { @ApiError(code = UnknownMessicRESTException.VALUE, description = "Unknown error") })
@RequestMapping(value = "", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)//from  w  ww  .  ja  v a 2  s  .c om
@ResponseBody
@ApiResponseObject
public void wizardFileName() throws UnknownMessicRESTException {
    log.info("messic is alive");
    // doesn't anything, just to check that it's alive
}

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);
}