コード例 #1
0
  /**
   * Sets the entry author.
   *
   * <p>This method is a convenience method, it maps to the Dublin Core module creator.
   *
   * <p>
   *
   * @param author the entry author to set, <b>null</b> if none.
   */
  public void setAuthor(String author) {
    // Get the DCModule so that we can check to see if "creator" is already
    // set.
    DCModule dcModule = getDCModule();
    String currentValue = dcModule.getCreator();

    if ((currentValue == null) || (currentValue.length() == 0)) {
      getDCModule().setCreator(author);
    }
  }
コード例 #2
0
ファイル: RomeFeedFetcher.java プロジェクト: wanghl/Roller
  // build a SubscriptionEntry from Rome SyndEntry and SyndFeed
  private SubscriptionEntry buildEntry(SyndEntry romeEntry) {

    // if we don't have a permalink then we can't continue
    if (romeEntry.getLink() == null) {
      return null;
    }

    SubscriptionEntry newEntry = new SubscriptionEntry();

    newEntry.setTitle(romeEntry.getTitle());
    newEntry.setPermalink(romeEntry.getLink());

    // Play some games to get the author
    DCModule entrydc = (DCModule) romeEntry.getModule(DCModule.URI);
    if (romeEntry.getAuthor() != null) {
      newEntry.setAuthor(romeEntry.getAuthor());
    } else {
      newEntry.setAuthor(entrydc.getCreator()); // use <dc:creator>
    }

    // Play some games to get the updated date
    if (romeEntry.getUpdatedDate() != null) {
      newEntry.setUpdateTime(new Timestamp(romeEntry.getUpdatedDate().getTime()));
    }
    // TODO: should we set a default update time here?

    // And more games getting publish date
    if (romeEntry.getPublishedDate() != null) {
      newEntry.setPubTime(new Timestamp(romeEntry.getPublishedDate().getTime())); // use <pubDate>
    } else if (entrydc != null && entrydc.getDate() != null) {
      newEntry.setPubTime(new Timestamp(entrydc.getDate().getTime())); // use <dc:date>
    } else {
      newEntry.setPubTime(newEntry.getUpdateTime());
    }

    // get content and unescape if it is 'text/plain'
    if (romeEntry.getContents().size() > 0) {
      SyndContent content = (SyndContent) romeEntry.getContents().get(0);
      if (content != null && content.getType().equals("text/plain")) {
        newEntry.setText(StringEscapeUtils.unescapeHtml(content.getValue()));
      } else if (content != null) {
        newEntry.setText(content.getValue());
      }
    }

    // no content, try summary
    if (newEntry.getText() == null || newEntry.getText().trim().length() == 0) {
      if (romeEntry.getDescription() != null) {
        newEntry.setText(romeEntry.getDescription().getValue());
      }
    }

    // copy categories
    if (romeEntry.getCategories().size() > 0) {
      List list = new ArrayList();
      Iterator cats = romeEntry.getCategories().iterator();
      while (cats.hasNext()) {
        SyndCategory cat = (SyndCategory) cats.next();
        list.add(cat.getName());
      }
      newEntry.setCategoriesString(list);
    }

    return newEntry;
  }