コード例 #1
0
  @Override
  public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException {
    Writer writer = null;
    try {
      writer = res.getWriter();

      // Get the section placed in the request context by ApplicationDataInterceptor
      RequestContext requestContext = ThreadLocalRequestContext.getRequestContext();
      Section section = (Section) requestContext.getValue("section");
      WebSite webSite = (WebSite) requestContext.getValue("webSite");

      // Get the collection property from the page definition
      String collectionName = requestContext.getPage().getProperty("collection");
      if (collectionName == null)
        throw new WebScriptException("collectionName property must be supplied");

      // Fetch the named collection
      AssetCollection collection =
          (AssetCollection) collectionFactory.getCollection(section.getId(), collectionName);

      // Use ROME library to output the colleciton as a syndication feed
      SyndFeed feed = new SyndFeedImpl();
      feed.setFeedType(FEED_TYPE);

      feed.setTitle(section.getTitle());
      feed.setLink(urlUtils.getWebsiteDomain(webSite) + urlUtils.getUrl(section));
      feed.setDescription(section.getDescription());

      List<SyndEntry> entries = new ArrayList<SyndEntry>();
      for (Asset asset : collection.getAssets()) {
        SyndEntry entry = new SyndEntryImpl();
        entry.setTitle(asset.getTitle());
        entry.setLink(urlUtils.getWebsiteDomain(webSite) + urlUtils.getUrl(asset));
        entry.setUri(urlUtils.getWebsiteDomain(webSite) + urlUtils.getShortUrl(asset));
        entry.setPublishedDate((Date) asset.getProperties().get(Asset.PROPERTY_PUBLISHED_TIME));
        SyndContent description = new SyndContentImpl();
        description.setType("text/html");
        description.setValue(asset.getDescription());
        entry.setDescription(description);
        entries.add(entry);
      }
      feed.setEntries(entries);

      SyndFeedOutput output = new SyndFeedOutput();
      output.output(feed, writer);
      writer.flush();
    } catch (IOException e) {
      log.error("Unable to output rss", e);
    } catch (FeedException e) {
      log.error("Unable to output rss", e);
    }
  }
コード例 #2
0
 public List<String> getTags() {
   return delegate.getTags();
 }
コード例 #3
0
 public long getSize() {
   return delegate.getSize();
 }
コード例 #4
0
 public Map<String, List<Asset>> getRelatedAssets() {
   return delegate.getRelatedAssets();
 }
コード例 #5
0
 public List<Asset> getRelatedAssets(String relationshipName) {
   return delegate.getRelatedAssets(relationshipName);
 }
コード例 #6
0
 public Asset getRelatedAsset(String relationshipName) {
   return delegate.getRelatedAsset(relationshipName);
 }
コード例 #7
0
 public Serializable getProperty(String name) {
   return delegate.getProperty(name);
 }
コード例 #8
0
 @Override
 public Map<String, Rendition> getRenditions() {
   return delegate.getRenditions();
 }
コード例 #9
0
 public String getName() {
   return delegate.getName();
 }
コード例 #10
0
 public String getMimeType() {
   return delegate.getMimeType();
 }
コード例 #11
0
 public String getId() {
   return delegate.getId();
 }
コード例 #12
0
 public String getDescription() {
   return delegate.getDescription();
 }
コード例 #13
0
 public ContentStream getContentAsInputStream() {
   return delegate.getContentAsInputStream();
 }
コード例 #14
0
 public Section getContainingSection() {
   return delegate.getContainingSection();
 }
コード例 #15
0
 public String getTitle() {
   return delegate.getTitle();
 }
コード例 #16
0
 public Map<String, Serializable> getProperties() {
   return delegate.getProperties();
 }
コード例 #17
0
 @Override
 public String getType() {
   return delegate.getType();
 }