Example usage for org.springframework.http MediaType APPLICATION_ATOM_XML_VALUE

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

Introduction

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

Prototype

String APPLICATION_ATOM_XML_VALUE

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

Click Source Link

Document

A String equivalent of MediaType#APPLICATION_ATOM_XML .

Usage

From source file:org.leandreck.endpoints.case1.NoJsonMultiple.java

@RequestMapping(value = "/int", method = GET, produces = { MediaType.IMAGE_PNG_VALUE,
        MediaType.APPLICATION_ATOM_XML_VALUE, MediaType.APPLICATION_OCTET_STREAM_VALUE })
public @ResponseBody int getInt() {
    return 1;/*from w w w  .  j  a  va2 s. com*/
}

From source file:kr.steelheart.site.blog.web.FeedController.java

@RequestMapping(value = {
        "/feed" }, method = RequestMethod.GET, produces = MediaType.APPLICATION_ATOM_XML_VALUE)
@ResponseBody/*from  w w  w.j a va 2 s.c om*/
public Callable<Void> feed(final HttpServletRequest request) {
    return new Callable<Void>() {

        @Override
        public Void call() {
            PageRequest pageable = new PageRequest(0, 20, Direction.DESC, "created");
            Page<Post> posts = postRepository.findAll(QPost.post.publish.isTrue(), pageable);

            String host = "http://" + request.getAttribute("host") + "/";

            Feed feed = new Feed();

            List<SyndPerson> authors = new ArrayList<>();
            Person author = new Person();
            author.setName("Sungha Jun");
            author.setUri(host);
            authors.add(author);

            feed.setId(host);
            feed.setTitle("steelheart*Rocks!");
            feed.setAuthors(authors);
            feed.setCopyright("http://creativecommons.org/licenses/by/3.0/deed.en");

            for (Post post : posts) {
                Date updated = null;
                if (post.getUpdated() == null) {
                    updated = post.getCreated();
                } else {
                    updated = post.getUpdated();
                }

                if (feed.getUpdated() == null || updated.compareTo(feed.getUpdated()) > 0) {
                    feed.setUpdated(updated);
                }
            }

            if (feed.getUpdated() == null) {
                feed.setUpdated(new Date());
            }

            Link link = new Link();
            link.setType(MediaType.TEXT_HTML_VALUE);
            link.setHref(host + "feed");

            List<Link> links = new ArrayList<>();
            links.add(link);

            feed.setAlternateLinks(links);
            feed.setLogo(host + "img/logo@2x.png");

            return null;
        }
    };
}

From source file:org.energyos.espi.datacustodian.web.api.ReadingTypeRESTController.java

@RequestMapping(value = Routes.ROOT_READING_TYPE_COLLECTION, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody//  w w w .jav  a2  s  .co  m
public void index(HttpServletResponse response, @RequestParam Map<String, String> params)
        throws IOException, FeedException {

    response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);
    exportService.exportReadingTypes(response.getOutputStream(), new ExportFilter(params));
}

From source file:org.energyos.espi.datacustodian.web.api.ApplicationInformationRESTController.java

@RequestMapping(value = Routes.ROOT_APPLICATION_INFORMATION_COLLECTION, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody//from   www .  j  ava  2 s.  c o m
public void index(HttpServletResponse response, @RequestParam Map<String, String> params)
        throws IOException, FeedException {

    response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);
    exportService.exportApplicationInformations(response.getOutputStream(), new ExportFilter(params));
}

From source file:org.energyos.espi.thirdparty.web.BatchRESTController.java

@RequestMapping(value = Routes.BATCH_DOWNLOAD_MY_DATA_COLLECTION, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody/*from   w ww .ja  v  a2s.  c  om*/
public void download_collection(HttpServletResponse response, @PathVariable Long retailCustomerId,
        @RequestParam Map<String, String> params) throws IOException, FeedException {

    response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);
    response.addHeader("Content-Disposition", "attachment; filename=GreenButtonDownload.xml");
    try {
        // TODO -- need authorization hook
        exportService.exportUsagePointsFull(0L, retailCustomerId, response.getOutputStream(),
                new ExportFilter(params));

    } catch (Exception e) {
        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
    }

}

From source file:org.energyos.espi.datacustodian.web.api.TimeConfigurationRESTController.java

@RequestMapping(value = Routes.ROOT_TIME_CONFIGURATION_COLLECTION, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody// w  w  w  .j  ava2  s . c o  m
public void index(HttpServletResponse response, @RequestParam Map<String, String> params)
        throws IOException, FeedException {

    response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);
    exportService.exportTimeConfigurations(response.getOutputStream(), new ExportFilter(params));
}

From source file:org.energyos.espi.datacustodian.web.api.ServiceStatusRESTController.java

@RequestMapping(value = Routes.ROOT_SERVICE_STATUS, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody/*from  www  . jav  a  2  s .c o m*/
public void index(HttpServletRequest request, HttpServletResponse response,
        @RequestParam Map<String, String> params) throws IOException, FeedException {

    response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);
    DateTimeType updated = DateConverter.toDateTimeType(new Date());
    String temp = updated.getValue().toXMLFormat();
    String uuid = UUID.randomUUID().toString();

    response.getOutputStream().println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    response.getOutputStream().println(
            "<ServiceStatus xmlns=\"http://naesb.org/espi\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://naesb.org/espi espiDerived.xsd\">");
    response.getOutputStream().println(
            "  <currentStatus>" + getApplicationStatus(request) + "</currentStatus>\n</ServiceStatus>");

}

From source file:org.energyos.espi.datacustodian.web.api.ReadingTypeRESTController.java

@RequestMapping(value = Routes.ROOT_READING_TYPE_MEMBER, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody//from ww  w  . j av a2 s  . com
public void show(HttpServletResponse response, @PathVariable Long readingTypeId,
        @RequestParam Map<String, String> params) throws IOException, FeedException {

    response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);
    exportService.exportReadingType(readingTypeId, response.getOutputStream(), new ExportFilter(params));
}

From source file:org.energyos.espi.datacustodian.web.api.AuthorizationRESTController.java

@RequestMapping(value = Routes.ROOT_AUTHORIZATION_COLLECTION, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody//www .j a  v  a  2 s  . c o m
public void index(HttpServletRequest request, HttpServletResponse response,
        @RequestParam Map<String, String> params) throws IOException, FeedException {

    response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);
    String accessToken = request.getHeader("authorization").replace("Bearer ", "");
    Authorization authorization = authorizationService.findByAccessToken(accessToken);

    // we know this is a client-access-token or a datacustodian-access-token
    // if it is a datacustodian-access-token, it can get everything

    if (authorization.getApplicationInformation().getClientId().equals("data_custodian_admin")) {
        exportService.exportAuthorizations(response.getOutputStream(), new ExportFilter(params));
    } else {
        // anything else that gets here is a third party
        // (client-access-token) and needs to be
        // restricted in access scope
        exportService.exportAuthorizations(authorization, response.getOutputStream(), new ExportFilter(params));
    }
}

From source file:org.energyos.espi.datacustodian.web.api.RetailCustomerRESTController.java

@RequestMapping(value = Routes.RETAIL_CUSTOMER_COLLECTION, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody//www .  jav  a2s . c  o  m
public void index(HttpServletRequest request, HttpServletResponse response,
        @RequestParam Map<String, String> params) throws IOException, FeedException {

    Long subscriptionId = getSubscriptionId(request);

    response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);
    try {
        exportService.exportRetailCustomers(subscriptionId, response.getOutputStream(),
                new ExportFilter(params));
    } catch (Exception e) {
        System.out.printf("***** Error Caused by RetailCustomer.x.IndentifiedObject need: %s", e.toString());
        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
    }
}