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:se.skltp.cooperation.web.rest.v1.controller.ServiceProducerController.java

/**
 * GET /serviceProducers/:id -> get the "id" serviceProducer.
 *//*from w w  w .j av  a 2 s.  c  om*/
@RequestMapping(value = { "/{id}", "/{id}.json", "/{id}.xml" }, method = RequestMethod.GET, produces = {
        MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
public ServiceProducerDTO get(@PathVariable Long id) {
    log.debug("REST request to get ConnectionPoint : {}", id);

    ServiceProducer serviceProducer = serviceProducerService.find(id);
    if (serviceProducer == null) {
        log.debug("Service Producer with id {} not found", id);
        throw new ResourceNotFoundException("Service Producer with id " + id + " not found");

    }
    return toDTO(serviceProducer);
}

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

@ApiMethod(path = "/services/musicinfo?pluginName=xxxx&songName=xxxx&albumName=xxxx&authorName=xxxxx", verb = ApiVerb.GET, description = "Get Music Info for album/song/author using the plugin called like the pluginName parameter. If no pluginName parameter is presented, then this will return all the availables plugins names that can be used.", produces = {
        MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
@ApiErrors(apierrors = { @ApiError(code = UnknownMessicRESTException.VALUE, description = "Unknown error"),
        @ApiError(code = NotAuthorizedMessicRESTException.VALUE, description = "Forbidden access") })
@RequestMapping(value = "", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)/*from  w  ww  .  j ava  2s  .c  o  m*/
@ResponseBody
@ApiResponseObject
public MusicInfo getInfo(
        @RequestParam(value = "pluginName", required = false) @ApiParam(name = "pluginName", description = "Name of the plugin to obtain information.. if this information is not present, the function will return all the plugin names availables at the system.", paramType = ApiParamType.QUERY, required = false) String pluginName,
        @RequestParam(value = "songName", required = false) @ApiParam(name = "songName", description = "Name of the song to search", paramType = ApiParamType.QUERY, required = false) String songName,
        @RequestParam(value = "albumName", required = false) @ApiParam(name = "albumName", description = "Name of the album to search", paramType = ApiParamType.QUERY, required = false) String albumName,
        @RequestParam(value = "authorName", required = false) @ApiParam(name = "authorName", description = "Name of the author to search.. is required only if a pluginName is presented, if not, it's not necessary.", paramType = ApiParamType.QUERY, required = true) String authorName,
        Locale locale) throws UnknownMessicRESTException, NotAuthorizedMessicRESTException {
    try {
        if (pluginName != null) {
            return musicInfoAPI.getMusicInfo(locale, pluginName, authorName, albumName, songName);
        } else {
            MusicInfo mi = new MusicInfo("");
            mi.setProviders(musicInfoAPI.getMusicInfoPlugins());
            return mi;
        }
    } catch (Exception e) {
        log.error("failed!", e);
        throw new UnknownMessicRESTException(e);
    }
}

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

@ApiMethod(path = "/services/albums?filterGenreSid=xxxx&filterAuthorSid=xxxx&filterName=xxxx&songsInfo=true|false&authorInfo=true|false", verb = ApiVerb.GET, description = "Get all albums. They can be filtered by authorSid or by genreSid (not combined). You can also espcify what information should be returned (with songs information or not, for exmaple)", produces = {
        MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
@ApiErrors(apierrors = { @ApiError(code = UnknownMessicRESTException.VALUE, description = "Unknown error"),
        @ApiError(code = NotAuthorizedMessicRESTException.VALUE, description = "Forbidden access") })
@RequestMapping(value = "", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)/*from ww  w .j a va  2 s  .co m*/
@ResponseBody
@ApiResponseObject
public List<Album> getAll(
        @RequestParam(value = "filterGenreSid", required = false) @ApiParam(name = "filterGenreSid", description = "SID of the genre to filter albums", paramType = ApiParamType.QUERY, required = false) Integer filterGenreSid,
        @RequestParam(value = "filterAuthorSid", required = false) @ApiParam(name = "filterAuthorSid", description = "SID of the author to filter albums", paramType = ApiParamType.QUERY, required = false) Integer filterAuthorSid,
        @RequestParam(value = "filterName", required = false) @ApiParam(name = "filterName", description = "partial name of the album to search", paramType = ApiParamType.QUERY, required = false) String filterName,
        @RequestParam(value = "authorInfo", required = false) @ApiParam(name = "authorInfo", description = "flag to return also the author info of the albums or not. By default, true", paramType = ApiParamType.QUERY, required = false, allowedvalues = {
                "true", "false" }, format = "Boolean") Boolean authorInfo,
        @RequestParam(value = "songsInfo", required = false) @ApiParam(name = "songsInfo", description = "flag to return also the songs info of the albums or not. By default, false", paramType = ApiParamType.QUERY, required = false, allowedvalues = {
                "true", "false" }, format = "Boolean") Boolean songsInfo,
        @RequestParam(value = "resourcesInfo", required = false) @ApiParam(name = "resourcesInfo", description = "flag to return also the artworks and others info of the albums or not. By default, the same value of songsInfo", paramType = ApiParamType.QUERY, required = false, allowedvalues = {
                "true", "false" }, format = "Boolean") Boolean resourcesInfo)
        throws UnknownMessicRESTException, NotAuthorizedMessicRESTException {
    User user = SecurityUtil.getCurrentUser();

    try {
        List<Album> albums = null;
        if (filterAuthorSid == null && filterName == null & filterGenreSid == null) {
            albums = albumAPI.getAll(user, (authorInfo != null ? authorInfo : true),
                    (songsInfo != null ? songsInfo : false),
                    (resourcesInfo != null ? resourcesInfo : (songsInfo != null ? songsInfo : false)));
        } else {
            if (filterAuthorSid != null && filterName == null) {
                albums = albumAPI.getAll(user, filterAuthorSid, (authorInfo != null ? authorInfo : true),
                        (songsInfo != null ? songsInfo : false),
                        (resourcesInfo != null ? resourcesInfo : (songsInfo != null ? songsInfo : false)));
            }
            if (filterGenreSid != null) {
                albums = albumAPI.getAllOfGenre(user, filterGenreSid, (authorInfo != null ? authorInfo : true),
                        (songsInfo != null ? songsInfo : false),
                        (resourcesInfo != null ? resourcesInfo : (songsInfo != null ? songsInfo : false)));
            } else {
                albums = albumAPI.findSimilar(user, filterAuthorSid, filterName,
                        (authorInfo != null ? authorInfo : true), (songsInfo != null ? songsInfo : false),
                        (resourcesInfo != null ? resourcesInfo : (songsInfo != null ? songsInfo : false)));
            }
        }

        return albums;
    } catch (Exception e) {
        log.error("failed!", e);
        throw new UnknownMessicRESTException(e);
    }
}

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

@RequestMapping(method = RequestMethod.POST, value = "/contextEntities/{entityID}/attributes/{attributeName}", consumes = {
        MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
final public ResponseEntity<StatusCode> appendContextAttributeValue(@PathVariable String entityID,
        @PathVariable String attributeName, @RequestBody UpdateContextAttribute updateContextAttribute,
        HttpServletRequest httpServletRequest) throws Exception {
    registerIntoDispatcher(httpServletRequest);
    ngsiValidation.checkUpdateContextAttribute(entityID, attributeName, null, updateContextAttribute);
    return new ResponseEntity<>(appendContextAttribute(entityID, attributeName, updateContextAttribute),
            HttpStatus.OK);//from ww  w .  j av  a2s.co m
}

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

@ApiMethod(path = "/services/playlists", verb = ApiVerb.POST, description = "Create or Update a playlist", produces = {
        MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
@ApiErrors(apierrors = { @ApiError(code = UnknownMessicRESTException.VALUE, description = "Unknown error"),
        @ApiError(code = DuplicatedMessicRESTException.VALUE, description = "Duplicated playlist name"),
        @ApiError(code = NotFoundMessicRESTException.VALUE, description = "some sid has not been found") })
@RequestMapping(value = "", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.OK)/*  w ww.  jav a2 s. c  o  m*/
@ResponseBody
@ApiResponseObject
public void createOrUpdate(@ApiBodyObject @RequestBody Playlist playlist) throws UnknownMessicRESTException,
        NotAuthorizedMessicRESTException, NotFoundMessicRESTException, DuplicatedMessicRESTException {
    User user = SecurityUtil.getCurrentUser();

    try {
        playlistAPI.createOrUpdate(user, playlist);
    } catch (SidNotFoundMessicException e) {
        throw new NotFoundMessicRESTException(e);
    } catch (ExistingMessicException e) {
        throw new DuplicatedMessicRESTException(e);
    } catch (Exception e) {
        log.error("failed!", e);
        throw new UnknownMessicRESTException(e);
    }
}

From source file:se.skltp.cooperation.web.rest.v1.controller.ServiceContractController.java

/**
 * GET /serviceContracts/:id -> get the "id" serviceContract.
 *///from  w ww.  j a  va 2  s .  c om
@RequestMapping(value = { "/{id}", "/{id}.json", "/{id}.xml" }, method = RequestMethod.GET, produces = {
        MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
public ServiceContractDTO get(@PathVariable Long id) {
    log.debug("REST request to get ServiceContract : {}", id);

    ServiceContract cp = serviceContractService.find(id);
    if (cp == null) {
        log.debug("Connection point with id {} not found", id);
        throw new ResourceNotFoundException("Connection point with id " + id + " not found");
    }
    return toDTO(cp);
}

From source file:com.orange.ngsi.client.UpdateContextRequestTest.java

@Test
public void performPostWith200_XML() throws Exception {

    protocolRegistry.registerHost(brokerUrl);

    HttpHeaders httpHeaders = ngsiClient.getRequestHeaders(brokerUrl);
    Assert.assertEquals("application/xml", httpHeaders.getFirst("Content-Type"));
    Assert.assertEquals("application/xml", httpHeaders.getFirst("Accept"));

    httpHeaders.add("Fiware-Service", serviceName);
    httpHeaders.add("Fiware-ServicePath", servicePath);

    String responseBody = xml(xmlConverter, createUpdateContextResponseTempSensor());

    this.mockServer.expect(requestTo(brokerUrl + "/ngsi10/updateContext")).andExpect(method(HttpMethod.POST))
            .andExpect(header("Content-Type", MediaType.APPLICATION_XML_VALUE))
            .andExpect(header("Accept", MediaType.APPLICATION_XML_VALUE))
            .andExpect(header("Fiware-Service", serviceName))
            .andExpect(header("Fiware-ServicePath", servicePath))
            .andExpect(xpath("updateContextRequest/updateAction").string(UpdateAction.UPDATE.getLabel()))
            .andExpect(xpath("updateContextRequest/contextElementList/contextElement/entityId/id").string("S1"))
            .andExpect(xpath(//ww w.j a  v  a  2s . c o  m
                    "updateContextRequest/contextElementList/contextElement/contextAttributeList/contextAttribute/name")
                            .string("temp"))
            .andExpect(xpath(
                    "updateContextRequest/contextElementList/contextElement/contextAttributeList/contextAttribute/type")
                            .string("float"))
            .andExpect(xpath(
                    "updateContextRequest/contextElementList/contextElement/contextAttributeList/contextAttribute/contextValue")
                            .string("15.5"))
            .andRespond(withSuccess(responseBody, MediaType.APPLICATION_XML));

    ngsiClient.updateContext(brokerUrl, httpHeaders, createUpdateContextTempSensor(0)).get();

    this.mockServer.verify();
}

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

@RequestMapping(value = "/unsubscribeContext", method = RequestMethod.POST, consumes = {
        MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
final public ResponseEntity<UnsubscribeContextResponse> unsubscribeContextRequest(
        @RequestBody final UnsubscribeContext unsubscribeContext, HttpServletRequest httpServletRequest)
        throws Exception {
    ngsiValidation.checkUnsubscribeContext(unsubscribeContext);
    registerIntoDispatcher(httpServletRequest);
    return new ResponseEntity<>(unsubscribeContext(unsubscribeContext), HttpStatus.OK);
}

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

@RequestMapping(value = "/claimsxml", method = RequestMethod.GET, produces = MediaType.APPLICATION_XML_VALUE)
public ResponseEntity<Object> renderClaimsXml(@RequestParam(value = "id", defaultValue = "Q7259") String itemId,
        @RequestParam(value = "lang") String lang) {

    String language = wikiBrowserProperties.computeLang(lang);
    ClaimsSparqlResponse claimsSparqlResponse = callClaimsSparqlQuery(itemId, language);
    ClaimsResponse claimsResponse = convertSparqlResponse(claimsSparqlResponse, language, itemId);

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

}

From source file:se.skltp.cooperation.web.rest.v1.controller.CooperationController.java

/**
 * GET /cooperations/:id -> get the "id" cooperation.
 *///w  w  w  .  j  av a  2 s. c  o m
@RequestMapping(value = { "/{id}", "/{id}.json", "/{id}.xml" }, method = RequestMethod.GET, produces = {
        MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
public CooperationDTO get(@PathVariable Long id) {
    log.debug("REST request to get ConnectionPoint : {}", id);

    Cooperation coop = cooperationService.find(id);
    if (coop == null) {
        log.debug("Cooperation with id {} not found", id);
        throw new ResourceNotFoundException("Cooperation with id " + id + " not found");
    }
    return toDTO(coop);
}