コード例 #1
0
ファイル: SoftwareAtomFeed.java プロジェクト: jaksco/bloatit
  @Override
  public void generate() {
    boolean first = true;
    for (final Feature feature : software.getFeaturesByCreationDate()) {
      final Translation translation =
          feature
              .getDescription()
              .getTranslationOrDefault(Language.fromLocale(Context.getLocalizator().getLocale()));
      final String featureTitle = translation.getTitle();
      final Software software = feature.getSoftware();
      String title;
      if (software == null) {
        title = Context.tr("New software") + " – " + featureTitle;
      } else {
        title = software.getName() + " – " + featureTitle;
      }

      String translationText = MemoryCache.getInstance().get(translation.getText());
      if (translationText == null) {
        final MarkdownParser parser = new MarkdownParser();
        try {
          translationText = parser.parse(HtmlTools.escape(translation.getText()));
          MemoryCache.getInstance().cache(translation.getText(), translationText);
        } catch (final ParsingException e) {
          throw new BadProgrammerException("An error occured during markdown parsing", e);
        }
      }

      final FeedEntry entry =
          new FeedEntry(
              title,
              new FeaturePageUrl(feature, FeatureTabKey.description).externalUrlString(),
              new FeaturePageUrl(feature, FeatureTabKey.description).externalUrlString(),
              feature.getCreationDate(),
              translationText,
              feature.getMember().getDisplayName(),
              new MemberPageUrl(feature.getMember()).externalUrlString());
      addFeedEntry(entry, Position.LAST);
      if (first) {
        updateDate = feature.getCreationDate();
        first = false;
      }
    }
  }