Package org.apache.oodt.cas.product.jaxrs.configurations

Examples of org.apache.oodt.cas.product.jaxrs.configurations.RssConfiguration


    String currentDate = dateFormatter.format(new Date());

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);

    RssConfiguration configuration = getConfiguration();

    try
    {
      Document doc = factory.newDocumentBuilder().newDocument();
      Element rss = XMLUtils.addNode(doc, doc, "rss");
      XMLUtils.addAttribute(doc, rss, "version", "2.0");
      XMLUtils.addAttribute(doc, rss, "xmlns:atom",
        "http://www.w3.org/2005/Atom");

      if (configuration != null)
      {
        // Add namespaces defined in the configuration file.
        for (RssNamespace namespace : configuration.getNamespaceList())
        {
          XMLUtils.addAttribute(doc, rss, "xmlns:" + namespace.getPrefix(),
            namespace.getUriString());
        }

        // Get channel link information, if specified in the configuration.
        String channelLink = configuration.getChannelLink();
        if (channelLink != null && !channelLink.equals(""))
        {
          Metadata channelMetadata = new Metadata();
          channelMetadata.addMetadata("ProductType", productTypeName);
          channelMetadata.addMetadata("ProductTypeId", productTypeId);
          channelMetadata.addMetadata("BaseUrl", base);

          idLink = PathUtils.replaceEnvVariables(channelLink, channelMetadata);
        }
      }

      Element channel = XMLUtils.addNode(doc, rss, "channel");
      XMLUtils.addNode(doc, channel, "title", productTypeName);

      Element atomLink = XMLUtils.addNode(doc, channel, "atom:link");
      XMLUtils.addAttribute(doc, atomLink, "href", selfLink);
      XMLUtils.addAttribute(doc, atomLink, "rel", "self");
      XMLUtils.addAttribute(doc, atomLink, "type", "application/rss+xml");

      XMLUtils.addNode(doc, channel, "link", idLink);
      XMLUtils.addNode(doc, channel, "description", productTypeName);

      XMLUtils.addNode(doc, channel, "language", LANGUAGE);
      XMLUtils.addNode(doc, channel, "copyright", COPYRIGHT);
      XMLUtils.addNode(doc, channel, "pubDate", currentDate);
      XMLUtils.addNode(doc, channel, "category", productTypeName);
      XMLUtils.addNode(doc, channel, "generator", GENERATOR);
      XMLUtils.addNode(doc, channel, "lastBuildDate", currentDate);

      for (ProductResource productResource : resource.getProductResources())
      {
        String productLink = getBaseUri() + "product?productId="
          + productResource.getProductId();
        Element item = XMLUtils.addNode(doc, channel, "item");
        XMLUtils.addNode(doc, item, "title", productResource.getProductName());
        XMLUtils.addNode(doc, item, "link", productLink);
        XMLUtils.addNode(doc, item, "description", productResource
          .getProductTypeName());
        XMLUtils.addNode(doc, item, "guid", productLink);

        Metadata metadata = productResource.getMetadataResource().getMetadata();
        Date productReceivedTime = DateConvert.isoParse(metadata
          .getMetadata("CAS.ProductReceivedTime"));
        if (productReceivedTime != null)
        {
          XMLUtils.addNode(doc, item, "pubDate", dateFormatter
            .format(productReceivedTime));
        }

        // Append additional tags defined in the configuration file.
        if (configuration != null)
        {
          configuration.appendTags(metadata, doc, item);
        }
      }

      XMLUtils.writeXmlToStream(doc, entityStream);
    }
View Full Code Here


              configuration.initialize(new File(value));
              rdfConfigurations.put(name, configuration);
            }
            else if ("rss".equals(format))
            {
              RssConfiguration configuration = new RssConfiguration();
              configuration.initialize(new File(value));
              rssConfigurations.put(name, configuration);
            }
          }
          catch (IOException e)
          {
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.product.jaxrs.configurations.RssConfiguration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.