示例#1
0
  /**
   * Format the to site email address.
   *
   * @param event The event that matched criteria to cause the notification.
   * @return the email address attribution for the site.
   */
  protected String getToSite(Event event) {
    Reference ref = EntityManager.newReference(event.getResource());

    // use either the configured site, or if not configured, the site (context) of the resource
    String siteId = (getSite() != null) ? getSite() : ref.getContext();

    // get a site title
    String title = siteId;
    String email = null;
    try {
      Site site = SiteService.getSite(siteId);
      title = site.getTitle();

      // check that the channel exists
      String channel = "/mailarchive/channel/" + siteId + "/main";
      EntityManager.newReference(channel);

      // find the alias for this site's mail channel
      List<Alias> all = AliasService.getAliases(channel);
      if (!all.isEmpty()) email = ((Alias) all.get(0)).getId();
    } catch (Exception ignore) {
    }

    // if for any reason we did not find an email, setup for the no-reply for email
    if (email == null) email = "no-reply";

    String rv =
        "\"" + title + "\" <" + email + "@" + ServerConfigurationService.getServerName() + ">";

    return rv;
  }
 public String lookupPageToAlias(String siteId, SitePage page) {
   // Shortcut if we aren't using page aliases.
   if (!lookForPageAliases) {
     return null;
   }
   String alias = null;
   List<Alias> aliases = AliasService.getAliases(page.getReference());
   if (aliases.size() > 0) {
     if (aliases.size() > 1 && log.isWarnEnabled()) {
       log.warn("More than one alias for: " + siteId + ":" + page.getId());
       // Sort on ID so it is consistent in the alias it uses.
       Collections.sort(aliases, getAliasComparator());
     }
     alias = aliases.get(0).getId();
     alias = parseAlias(alias, siteId);
   }
   return alias;
 }