public synchronized void updateAliases(CmsObject cms, Collection<CmsAlias> toDelete, Collection<CmsAlias> toAdd)
    throws CmsException {

        checkPermissionsForMassEdit(cms);
        Set<CmsUUID> allKeys = new HashSet<CmsUUID>();
        Multimap<CmsUUID, CmsAlias> toDeleteMap = ArrayListMultimap.create();

        // first, group the aliases by structure id

        for (CmsAlias alias : toDelete) {
            toDeleteMap.put(alias.getStructureId(), alias);
            allKeys.add(alias.getStructureId());
        }

        Multimap<CmsUUID, CmsAlias> toAddMap = ArrayListMultimap.create();
        for (CmsAlias alias : toAdd) {
            toAddMap.put(alias.getStructureId(), alias);
            allKeys.add(alias.getStructureId());
        }

        // Do all the deletions first, so we don't run into duplicate key errors for the alias paths
        for (CmsUUID structureId : allKeys) {
            Set<CmsAlias> aliasesToSave = new HashSet<CmsAlias>(getAliasesForStructureId(cms, structureId));
            Collection<CmsAlias> toDeleteForId = toDeleteMap.get(structureId);
            if ((toDeleteForId != null) && !toDeleteForId.isEmpty()) {
                aliasesToSave.removeAll(toDeleteForId);
            }
            saveAliases(cms, structureId, new ArrayList<CmsAlias>(aliasesToSave));
        }
        for (CmsUUID structureId : allKeys) {
            Set<CmsAlias> aliasesToSave = new HashSet<CmsAlias>(getAliasesForStructureId(cms, structureId));
            Collection<CmsAlias> toAddForId = toAddMap.get(structureId);
            if ((toAddForId != null) && !toAddForId.isEmpty()) {
                aliasesToSave.addAll(toAddForId);
            }
            saveAliases(cms, structureId, new ArrayList<CmsAlias>(aliasesToSave));
        }
    }
public synchronized void updateAliases ( CmsObject cms , Collection < CmsAlias > toDelete , Collection < CmsAlias > toAdd ) throws CmsException { checkPermissionsForMassEdit ( cms ) ; Set < CmsUUID > allKeys = new HashSet < CmsUUID > ( ) ; Multimap < CmsUUID , CmsAlias > toDeleteMap = ArrayListMultimap . create ( ) ; for ( CmsAlias alias : toDelete ) { toDeleteMap . put ( alias . getStructureId ( ) , alias ) ; allKeys . add ( alias . getStructureId ( ) ) ; } Multimap < CmsUUID , CmsAlias > toAddMap = ArrayListMultimap . create ( ) ; for ( CmsAlias alias : toAdd ) { toAddMap . put ( alias . getStructureId ( ) , alias ) ; allKeys . add ( alias . getStructureId ( ) ) ; } for ( CmsUUID structureId : allKeys ) { Set < CmsAlias > aliasesToSave = new HashSet < CmsAlias > ( getAliasesForStructureId ( cms , structureId ) ) ; Collection < CmsAlias > toDeleteForId = toDeleteMap . get ( structureId ) ; if ( ( toDeleteForId != null ) && ! toDeleteForId . isEmpty ( ) ) { aliasesToSave . removeAll ( toDeleteForId ) ; } saveAliases ( cms , structureId , new ArrayList < CmsAlias > ( aliasesToSave ) ) ; } for ( CmsUUID structureId : allKeys ) { Set < CmsAlias > aliasesToSave = new HashSet < CmsAlias > ( getAliasesForStructureId ( cms , structureId ) ) ; Collection < CmsAlias > toAddForId = toAddMap . get ( structureId ) ; if ( ( toAddForId != null ) && ! toAddForId . isEmpty ( ) ) { aliasesToSave . addAll ( toAddForId ) ; } saveAliases ( cms , structureId , new ArrayList < CmsAlias > ( aliasesToSave ) ) ; } }
Updates the aliases in the database.<p>

@param cms the current CMS context
@param toDelete the collection of aliases to delete
@param toAdd the collection of aliases to add
@throws CmsException if something goes wrong