Beispiel #1
0
  protected void visitLayout(Element element, Layout layout, ThemeDisplay themeDisplay)
      throws PortalException, SystemException {

    UnicodeProperties typeSettingsProperties = layout.getTypeSettingsProperties();

    if (!PortalUtil.isLayoutSitemapable(layout)
        || !GetterUtil.getBoolean(typeSettingsProperties.getProperty("sitemap-include"), true)) {

      return;
    }

    String layoutFullURL = PortalUtil.getLayoutFullURL(layout, themeDisplay);

    layoutFullURL = PortalUtil.getCanonicalURL(layoutFullURL, themeDisplay, layout);

    addURLElement(
        element,
        layoutFullURL,
        typeSettingsProperties,
        layout.getModifiedDate(),
        layoutFullURL,
        getAlternateURLs(layoutFullURL, themeDisplay, layout));

    Locale[] availableLocales = LanguageUtil.getAvailableLocales(layout.getGroupId());

    if (availableLocales.length > 1) {
      Locale defaultLocale = LocaleUtil.getSiteDefault();

      for (Locale availableLocale : availableLocales) {
        if (availableLocale.equals(defaultLocale)) {
          continue;
        }

        String alternateURL =
            PortalUtil.getAlternateURL(layoutFullURL, themeDisplay, availableLocale, layout);

        addURLElement(
            element,
            alternateURL,
            typeSettingsProperties,
            layout.getModifiedDate(),
            layoutFullURL,
            getAlternateURLs(layoutFullURL, themeDisplay, layout));
      }
    }
  }
Beispiel #2
0
  protected Map<Locale, String> getAlternateURLs(
      String canonicalURL, ThemeDisplay themeDisplay, Layout layout)
      throws PortalException, SystemException {

    Map<Locale, String> alternateURLs = new HashMap<Locale, String>();

    Locale[] availableLocales = LanguageUtil.getAvailableLocales(layout.getGroupId());

    for (Locale availableLocale : availableLocales) {
      String alternateURL =
          PortalUtil.getAlternateURL(canonicalURL, themeDisplay, availableLocale, layout);

      alternateURLs.put(availableLocale, alternateURL);
    }

    return alternateURLs;
  }
Beispiel #3
0
  protected void visitArticles(Element element, Layout layout, ThemeDisplay themeDisplay)
      throws PortalException, SystemException {

    List<JournalArticle> journalArticles =
        JournalArticleServiceUtil.getArticlesByLayoutUuid(layout.getGroupId(), layout.getUuid());

    if (journalArticles.isEmpty()) {
      return;
    }

    Set<String> processedArticleIds = new HashSet<String>();

    for (JournalArticle journalArticle : journalArticles) {
      if (processedArticleIds.contains(journalArticle.getArticleId())
          || (journalArticle.getStatus() != WorkflowConstants.STATUS_APPROVED)) {

        continue;
      }

      String portalURL = PortalUtil.getPortalURL(layout, themeDisplay);

      String groupFriendlyURL =
          PortalUtil.getGroupFriendlyURL(
              GroupLocalServiceUtil.getGroup(journalArticle.getGroupId()), false, themeDisplay);

      StringBundler sb = new StringBundler(4);

      if (!groupFriendlyURL.startsWith(portalURL)) {
        sb.append(portalURL);
      }

      sb.append(groupFriendlyURL);
      sb.append(JournalArticleConstants.CANONICAL_URL_SEPARATOR);
      sb.append(journalArticle.getUrlTitle());

      String articleURL = PortalUtil.getCanonicalURL(sb.toString(), themeDisplay, layout);

      addURLElement(
          element,
          articleURL,
          null,
          journalArticle.getModifiedDate(),
          articleURL,
          getAlternateURLs(articleURL, themeDisplay, layout));

      Locale[] availableLocales = LanguageUtil.getAvailableLocales(layout.getGroupId());

      if (availableLocales.length > 1) {
        Locale defaultLocale = LocaleUtil.getSiteDefault();

        for (Locale availableLocale : availableLocales) {
          if (!availableLocale.equals(defaultLocale)) {
            String alternateURL =
                PortalUtil.getAlternateURL(articleURL, themeDisplay, availableLocale, layout);

            addURLElement(
                element,
                alternateURL,
                null,
                journalArticle.getModifiedDate(),
                articleURL,
                getAlternateURLs(articleURL, themeDisplay, layout));
          }
        }
      }

      processedArticleIds.add(journalArticle.getArticleId());
    }
  }