Search in sources :

Example 1 with TreeFilteringResourceVisitor

use of com.adobe.acs.commons.util.visitors.TreeFilteringResourceVisitor in project acs-aem-commons by Adobe-Consulting-Services.

the class FolderRelocator method validateAllAcls.

private void validateAllAcls(ActionManager step1) {
    TreeFilteringResourceVisitor folderVisitor = new TreeFilteringResourceVisitor();
    folderVisitor.setBreadthFirstMode();
    folderVisitor.setResourceVisitor((resource, level) -> step1.deferredWithResolver(rr -> checkNodeAcls(rr, resource.getPath(), requiredFolderPrivileges)));
    folderVisitor.setLeafVisitor((resource, level) -> step1.deferredWithResolver(rr -> checkNodeAcls(rr, resource.getPath(), requiredNodePrivileges)));
    sourceToDestination.keySet().forEach(sourcePath -> beginStep(step1, sourcePath, folderVisitor));
}
Also used : ResourceResolver(org.apache.sling.api.resource.ResourceResolver) ProcessDefinition(com.adobe.acs.commons.mcp.ProcessDefinition) HashMap(java.util.HashMap) SimpleFilteringResourceVisitor(com.adobe.acs.commons.util.visitors.SimpleFilteringResourceVisitor) StringUtils(org.apache.commons.lang3.StringUtils) Failure(com.adobe.acs.commons.fam.Failure) Level(java.util.logging.Level) RepositoryException(javax.jcr.RepositoryException) Map(java.util.Map) ActionBatch(com.adobe.acs.commons.fam.actions.ActionBatch) FormField(com.adobe.acs.commons.mcp.form.FormField) PersistenceException(org.apache.sling.api.resource.PersistenceException) Actions(com.adobe.acs.commons.fam.actions.Actions) PathfieldComponent(com.adobe.acs.commons.mcp.form.PathfieldComponent) Session(javax.jcr.Session) Resource(org.apache.sling.api.resource.Resource) RadioComponent(com.adobe.acs.commons.mcp.form.RadioComponent) ActionManager(com.adobe.acs.commons.fam.ActionManager) Logger(java.util.logging.Logger) Serializable(java.io.Serializable) Objects(java.util.Objects) LoginException(org.apache.sling.api.resource.LoginException) List(java.util.List) TreeFilteringResourceVisitor(com.adobe.acs.commons.util.visitors.TreeFilteringResourceVisitor) Optional(java.util.Optional) AccessControlManager(javax.jcr.security.AccessControlManager) Pattern(java.util.regex.Pattern) Privilege(javax.jcr.security.Privilege) ProcessInstance(com.adobe.acs.commons.mcp.ProcessInstance) TreeFilteringResourceVisitor(com.adobe.acs.commons.util.visitors.TreeFilteringResourceVisitor)

Example 2 with TreeFilteringResourceVisitor

use of com.adobe.acs.commons.util.visitors.TreeFilteringResourceVisitor in project acs-aem-commons by Adobe-Consulting-Services.

the class PageRelocator method validateAllAcls.

protected void validateAllAcls(ActionManager step1) {
    SimpleFilteringResourceVisitor pageVisitor;
    if (extensiveACLChecks) {
        pageVisitor = new SimpleFilteringResourceVisitor();
        pageVisitor.setLeafVisitor((resource, level) -> step1.deferredWithResolver(rr -> checkNodeAcls(rr, resource.getPath(), requiredPrivileges)));
    } else {
        pageVisitor = new TreeFilteringResourceVisitor(NameConstants.NT_PAGE);
    }
    pageVisitor.setBreadthFirstMode();
    pageVisitor.setResourceVisitor((resource, level) -> step1.deferredWithResolver(rr -> checkNodeAcls(rr, resource.getPath(), requiredPrivileges)));
    beginStep(step1, sourcePath, pageVisitor);
}
Also used : ResourceResolver(org.apache.sling.api.resource.ResourceResolver) FieldUtils(org.apache.commons.lang.reflect.FieldUtils) ProcessDefinition(com.adobe.acs.commons.mcp.ProcessDefinition) ReplicationActionType(com.day.cq.replication.ReplicationActionType) HashMap(java.util.HashMap) SimpleFilteringResourceVisitor(com.adobe.acs.commons.util.visitors.SimpleFilteringResourceVisitor) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) ReplicationStatus(com.day.cq.replication.ReplicationStatus) ManagedProcess(com.adobe.acs.commons.mcp.model.ManagedProcess) RepositoryException(javax.jcr.RepositoryException) ReplicationException(com.day.cq.replication.ReplicationException) Map(java.util.Map) ReferenceSearch(com.day.cq.wcm.commons.ReferenceSearch) FormField(com.adobe.acs.commons.mcp.form.FormField) PersistenceException(org.apache.sling.api.resource.PersistenceException) ReplicationOptions(com.day.cq.replication.ReplicationOptions) Actions(com.adobe.acs.commons.fam.actions.Actions) PathfieldComponent(com.adobe.acs.commons.mcp.form.PathfieldComponent) EnumMap(java.util.EnumMap) Session(javax.jcr.Session) Replicator(com.day.cq.replication.Replicator) Resource(org.apache.sling.api.resource.Resource) RadioComponent(com.adobe.acs.commons.mcp.form.RadioComponent) PageManagerFactory(com.day.cq.wcm.api.PageManagerFactory) ActionManager(com.adobe.acs.commons.fam.ActionManager) Field(java.lang.reflect.Field) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) PageManager(com.day.cq.wcm.api.PageManager) LoginException(org.apache.sling.api.resource.LoginException) List(java.util.List) GenericReport(com.adobe.acs.commons.mcp.model.GenericReport) Stream(java.util.stream.Stream) TreeMap(java.util.TreeMap) TreeFilteringResourceVisitor(com.adobe.acs.commons.util.visitors.TreeFilteringResourceVisitor) NameConstants(com.day.cq.wcm.api.NameConstants) TextfieldComponent(com.adobe.acs.commons.mcp.form.TextfieldComponent) AccessControlManager(javax.jcr.security.AccessControlManager) CheckboxComponent(com.adobe.acs.commons.mcp.form.CheckboxComponent) Pattern(java.util.regex.Pattern) Privilege(javax.jcr.security.Privilege) ProcessInstance(com.adobe.acs.commons.mcp.ProcessInstance) TreeFilteringResourceVisitor(com.adobe.acs.commons.util.visitors.TreeFilteringResourceVisitor) SimpleFilteringResourceVisitor(com.adobe.acs.commons.util.visitors.SimpleFilteringResourceVisitor)

Example 3 with TreeFilteringResourceVisitor

use of com.adobe.acs.commons.util.visitors.TreeFilteringResourceVisitor in project acs-aem-commons by Adobe-Consulting-Services.

the class PageRelocator method movePages.

protected void movePages(ActionManager step2) {
    TreeFilteringResourceVisitor pageVisitor = new TreeFilteringResourceVisitor(NameConstants.NT_PAGE);
    pageVisitor.setBreadthFirstMode();
    pageVisitor.setResourceVisitor((resource, level) -> step2.deferredWithResolver(rr -> movePage(rr, resource.getPath())));
    beginStep(step2, sourcePath, pageVisitor);
}
Also used : ResourceResolver(org.apache.sling.api.resource.ResourceResolver) FieldUtils(org.apache.commons.lang.reflect.FieldUtils) ProcessDefinition(com.adobe.acs.commons.mcp.ProcessDefinition) ReplicationActionType(com.day.cq.replication.ReplicationActionType) HashMap(java.util.HashMap) SimpleFilteringResourceVisitor(com.adobe.acs.commons.util.visitors.SimpleFilteringResourceVisitor) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) ReplicationStatus(com.day.cq.replication.ReplicationStatus) ManagedProcess(com.adobe.acs.commons.mcp.model.ManagedProcess) RepositoryException(javax.jcr.RepositoryException) ReplicationException(com.day.cq.replication.ReplicationException) Map(java.util.Map) ReferenceSearch(com.day.cq.wcm.commons.ReferenceSearch) FormField(com.adobe.acs.commons.mcp.form.FormField) PersistenceException(org.apache.sling.api.resource.PersistenceException) ReplicationOptions(com.day.cq.replication.ReplicationOptions) Actions(com.adobe.acs.commons.fam.actions.Actions) PathfieldComponent(com.adobe.acs.commons.mcp.form.PathfieldComponent) EnumMap(java.util.EnumMap) Session(javax.jcr.Session) Replicator(com.day.cq.replication.Replicator) Resource(org.apache.sling.api.resource.Resource) RadioComponent(com.adobe.acs.commons.mcp.form.RadioComponent) PageManagerFactory(com.day.cq.wcm.api.PageManagerFactory) ActionManager(com.adobe.acs.commons.fam.ActionManager) Field(java.lang.reflect.Field) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) PageManager(com.day.cq.wcm.api.PageManager) LoginException(org.apache.sling.api.resource.LoginException) List(java.util.List) GenericReport(com.adobe.acs.commons.mcp.model.GenericReport) Stream(java.util.stream.Stream) TreeMap(java.util.TreeMap) TreeFilteringResourceVisitor(com.adobe.acs.commons.util.visitors.TreeFilteringResourceVisitor) NameConstants(com.day.cq.wcm.api.NameConstants) TextfieldComponent(com.adobe.acs.commons.mcp.form.TextfieldComponent) AccessControlManager(javax.jcr.security.AccessControlManager) CheckboxComponent(com.adobe.acs.commons.mcp.form.CheckboxComponent) Pattern(java.util.regex.Pattern) Privilege(javax.jcr.security.Privilege) ProcessInstance(com.adobe.acs.commons.mcp.ProcessInstance) TreeFilteringResourceVisitor(com.adobe.acs.commons.util.visitors.TreeFilteringResourceVisitor)

Example 4 with TreeFilteringResourceVisitor

use of com.adobe.acs.commons.util.visitors.TreeFilteringResourceVisitor in project acs-aem-commons by Adobe-Consulting-Services.

the class AssetReport method evaluateStructure.

public void evaluateStructure(ActionManager manager) {
    TreeFilteringResourceVisitor visitor = new TreeFilteringResourceVisitor();
    visitor.setBreadthFirstMode();
    visitor.setTraversalFilter(r -> visitor.isFolder(r) && getDepth(r.getPath()) < depthLimit);
    visitor.setLeafVisitor((r, depth) -> {
        if (isAsset(r)) {
            tabulate(getParentPath(r.getPath()), Column.asset_count, 1);
            assetList.add(r.getPath());
        } else if (visitor.isFolder(r)) {
            tabulate(getParentPath(r.getPath()), Column.subfolder_count, 1);
            setValue(r.getPath(), Column.level, depth + 1);
            folderList.add(r.getPath());
        }
    });
    visitor.setResourceVisitor((r, depth) -> {
        setValue(r.getPath(), Column.level, depth + 1);
        tabulate(getParentPath(r.getPath()), Column.subfolder_count, 1);
    });
    manager.deferredWithResolver(rr -> visitor.accept(rr.getResource(baseFolder)));
}
Also used : TreeFilteringResourceVisitor(com.adobe.acs.commons.util.visitors.TreeFilteringResourceVisitor)

Example 5 with TreeFilteringResourceVisitor

use of com.adobe.acs.commons.util.visitors.TreeFilteringResourceVisitor in project acs-aem-commons by Adobe-Consulting-Services.

the class AssetReport method evaluateDeepStructure.

public void evaluateDeepStructure(ActionManager manager) {
    folderList.stream().peek(folderList::remove).forEach(folder -> {
        manager.deferredWithResolver(rr -> {
            Actions.setCurrentItem(folder);
            TreeFilteringResourceVisitor visitor = new TreeFilteringResourceVisitor();
            visitor.setBreadthFirstMode();
            visitor.setLeafVisitor((r, depth) -> {
                if (isAsset(r)) {
                    tabulate(getParentPath(r.getPath()), Column.asset_count, 1);
                    assetList.add(r.getPath());
                }
            });
            visitor.setResourceVisitor((r, depth) -> {
                tabulate(getParentPath(r.getPath()), Column.subfolder_count, 1);
            });
            visitor.accept(rr.getResource(folder));
        });
    });
}
Also used : TreeFilteringResourceVisitor(com.adobe.acs.commons.util.visitors.TreeFilteringResourceVisitor)

Aggregations

TreeFilteringResourceVisitor (com.adobe.acs.commons.util.visitors.TreeFilteringResourceVisitor)11 Resource (org.apache.sling.api.resource.Resource)6 ProcessInstance (com.adobe.acs.commons.mcp.ProcessInstance)5 List (java.util.List)5 Map (java.util.Map)5 LoginException (org.apache.sling.api.resource.LoginException)5 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)5 ActionManager (com.adobe.acs.commons.fam.ActionManager)4 Actions (com.adobe.acs.commons.fam.actions.Actions)4 ProcessDefinition (com.adobe.acs.commons.mcp.ProcessDefinition)4 FormField (com.adobe.acs.commons.mcp.form.FormField)4 PathfieldComponent (com.adobe.acs.commons.mcp.form.PathfieldComponent)4 RadioComponent (com.adobe.acs.commons.mcp.form.RadioComponent)4 SimpleFilteringResourceVisitor (com.adobe.acs.commons.util.visitors.SimpleFilteringResourceVisitor)4 HashMap (java.util.HashMap)4 Level (java.util.logging.Level)4 Logger (java.util.logging.Logger)4 Pattern (java.util.regex.Pattern)4 RepositoryException (javax.jcr.RepositoryException)4 Session (javax.jcr.Session)4