public int compare(Alias o1, Alias o2) { // Sort by date, then by ID to assure consistent order. return o1.getCreatedTime().compareTo(o2.getCreatedTime()) * 10 + o1.getId().compareTo(o2.getId()); }
public void commit(AliasEdit edit) { super.commitResource(edit, fields(edit.getId(), edit, true), edit.getProperties()); }
/** * @inheritDoc */ public String getRssUrl(Reference ref) { String alias = null; List aliasList = aliasService.getAliases( ref.getReference() ); if ( ! aliasList.isEmpty() ) alias = ((Alias)aliasList.get(0)).getId(); StringBuilder rssUrlString = new StringBuilder(); rssUrlString.append( m_serverConfigurationService.getAccessUrl() ); rssUrlString.append(getAccessPoint(true)); rssUrlString.append(Entity.SEPARATOR); rssUrlString.append(REF_TYPE_ANNOUNCEMENT_RSS); rssUrlString.append(Entity.SEPARATOR); if ( alias != null) rssUrlString.append(alias); else rssUrlString.append(ref.getContext()); return rssUrlString.toString(); }
/** * Count all the aliases with id or target matching criteria. * * @param criteria * The search criteria. * @return The count of all aliases with id or target matching criteria. */ public int countSearch(String criteria) { List all = super.getAllResources(); Vector rv = new Vector(); for (Iterator i = all.iterator(); i.hasNext();) { Alias a = (Alias) i.next(); if (StringUtil.containsIgnoreCase(a.getId(), criteria) || StringUtil.containsIgnoreCase(a.getTarget(), criteria)) { rv.add(a); } } return rv.size(); }
private Site getSite(String siteId) { Site site = null; try{ // is it a site id? site = M_ss.getSite(siteId); }catch(IdUnusedException e1){ // is it an alias? try{ String alias = siteId; String target = M_as.getTarget(alias); if(target != null) { String newSiteId = M_em.newReference(target).getId(); LOG.debug(alias + " is an alias targetting site id: "+newSiteId); site = M_ss.getSite(newSiteId); }else{ throw new IdUnusedException(siteId); } }catch(IdUnusedException e2){ // not a valid site LOG.debug(siteId + " is not a valid site.", e2); } }catch(Exception ex) { // not a valid site LOG.debug(siteId + " is not a valid site.", ex); } return site; }
List target = aliasService.getAliases( "/site/" + siteId); target = aliasService.getAliases( "/mailarchive/channel/" + siteId + "/main"); siteId = alias.getId();
try AliasEdit a = m_storage.edit(alias.getId()); if (a != null) eventTrackingService().post(eventTrackingService().newEvent(SECURE_REMOVE_ALIAS, a.getReference(), true));
rv[1] = edit.getTarget(); ResourceProperties props = edit.getProperties(); rv[2] = StringUtil.trimToZero(((BaseAliasEdit) edit).m_createdUserId); rv[3] = StringUtil.trimToZero(((BaseAliasEdit) edit).m_lastModifiedUserId); rv[4] = edit.getCreatedTime(); rv[5] = edit.getModifiedTime();
aliasService.removeTargetAliases(deletedResource); } catch ( RuntimeException e ) { if ( propagateExceptions ) {
if (!edit.isActiveEdit()) unlock(SECURE_REMOVE_ALIAS, edit.getReference()); eventTrackingService().post(eventTrackingService().newEvent(SECURE_REMOVE_ALIAS, edit.getReference(), true));
/** * Cancel the changes made to a AliasEdit object, and release the lock. The AliasEdit is disabled, and not to be used after this call. * * @param user * The AliasEdit object to commit. */ public void cancel(AliasEdit edit) { // check for closed edit if (!edit.isActiveEdit()) { try { throw new Exception(); } catch (Exception e) { log.warn("cancel(): closed AliasEdit", e); } return; } // release the edit lock m_storage.cancel(edit); // close the edit object ((BaseAliasEdit) edit).closeEdit(); } // cancel
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; }
/** * Search for aliases with id or target matching criteria, in range. * * @param criteria * The search criteria. * @param first * The first record position to return. * @param last * The last record position to return. * @return The List (BaseAliasEdit) of all alias. */ public List search(String criteria, int first, int last) { List all = super.getAllResources(); List rv = new Vector(); for (Iterator i = all.iterator(); i.hasNext();) { Alias a = (Alias) i.next(); if (StringUtil.containsIgnoreCase(a.getId(), criteria) || StringUtil.containsIgnoreCase(a.getTarget(), criteria)) { rv.add(a); } } Collections.sort(rv); // subset by position if (first < 1) first = 1; if (last >= rv.size()) last = rv.size(); rv = rv.subList(first - 1, last); return rv; }
public SitePage lookupAliasToPage(String alias, Site site) { //Shortcut if we aren't using page aliases. if (!lookForPageAliases) { return null; } SitePage page = null; if (alias != null && alias.length() > 0) { try { // Use page#{siteId}:{pageAlias} So we can scan for fist colon and alias can contain any character String refString = aliasService.getTarget(buildAlias(alias, site)); String aliasPageId = EntityManager.newReference(refString).getId(); page = (SitePage) site.getPage(aliasPageId); } catch (IdUnusedException e) { log.debug("Alias does not resolve {}", e.getMessage()); } } return page; }
List target = aliasService.getAliases( "/site/" + siteId); target = aliasService.getAliases( "/mailarchive/channel/" + siteId + "/main"); siteId = alias.getId();
public int compare(Alias o1, Alias o2) { // Sort by date, then by ID to assure consistent order. return o1.getCreatedTime().compareTo(o2.getCreatedTime()) * 10 + o1.getId().compareTo(o2.getId()); }
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; }
public int countSearch(String criteria) { // if we have to be concerned with old stuff, we cannot let the db do the search and count if (m_checkOld) { List all = getAll(); List rv = new Vector(); for (Iterator i = all.iterator(); i.hasNext();) { Alias a = (Alias) i.next(); if (StringUtil.containsIgnoreCase(a.getId(), criteria) || StringUtil.containsIgnoreCase(a.getTarget(), criteria)) { rv.add(a); } } return rv.size(); } Object[] fields = new Object[2]; fields[0] = "%" + criteria.toUpperCase() + "%"; fields[1] = fields[0]; int rv = super.countSelectedResources("UPPER(ALIAS_ID) LIKE ? OR UPPER(TARGET) LIKE ?", fields); return rv; }
public SitePage lookupAliasToPage(String alias, Site site) { //Shortcut if we aren't using page aliases. if (!lookForPageAliases) { return null; } SitePage page = null; if (alias != null && alias.length() > 0) { try { // Use page#{siteId}:{pageAlias} So we can scan for fist colon and alias can contain any character String refString = aliasService.getTarget(buildAlias(alias, site)); String aliasPageId = EntityManager.newReference(refString).getId(); page = (SitePage) site.getPage(aliasPageId); } catch (IdUnusedException e) { log.debug("Alias does not resolve {}", e.getMessage()); } } return page; }
List<Alias> all = aliasService.getAliases(channel); if (!all.isEmpty()) email = ((Alias) all.get(0)).getId();