Search in sources :

Example 6 with Path

use of org.apache.sling.api.resource.path.Path in project sling by apache.

the class BasicObservationReporterTest method testSpecificPathProvider.

@Test
public void testSpecificPathProvider() {
    ResourceChangeListenerInfo allPathListener = resourceChangeListenerInfo("/");
    ResourceChangeListenerInfo appsPathListener = resourceChangeListenerInfo("/apps");
    ResourceChangeListenerInfo appsApp2PathListener = resourceChangeListenerInfo("/apps/app2");
    ResourceChangeListenerInfo globListener = resourceChangeListenerInfo("glob:/apps/**/*.html");
    BasicObservationReporter underTest = new BasicObservationReporter(SEARCH_PATHS, ImmutableList.of(allPathListener, appsPathListener, appsApp2PathListener, globListener), new Path("/apps/app1"), PathSet.EMPTY_SET);
    underTest.reportChanges(changes("/apps/app1/path1.html"), false);
    assertListener(allPathListener, "/apps/app1/path1.html");
    assertListener(appsPathListener, "/apps/app1/path1.html");
    assertListener(appsApp2PathListener);
    assertListener(globListener, "/apps/app1/path1.html");
}
Also used : Path(org.apache.sling.api.resource.path.Path) Test(org.junit.Test)

Example 7 with Path

use of org.apache.sling.api.resource.path.Path in project sling by apache.

the class JspRuntimeContext method handleModification.

/**
     * Handle jsp modifications
     */
public boolean handleModification(final String scriptName, final boolean isRemove) {
    if (log.isDebugEnabled()) {
        log.debug("Handling modification " + scriptName);
    }
    final JspServletWrapper wrapper = jsps.remove(scriptName);
    if (wrapper == null && isRemove) {
        boolean removed = false;
        final Path path = new Path(scriptName);
        final Iterator<Map.Entry<String, JspServletWrapper>> iter = jsps.entrySet().iterator();
        while (iter.hasNext()) {
            final Map.Entry<String, JspServletWrapper> entry = iter.next();
            if (path.matches(entry.getKey())) {
                iter.remove();
                removed |= handleModification(entry.getKey(), entry.getValue());
            }
        }
        return removed;
    } else {
        return handleModification(scriptName, wrapper);
    }
}
Also used : JspServletWrapper(org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper) Path(org.apache.sling.api.resource.path.Path) HashMap(java.util.HashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 8 with Path

use of org.apache.sling.api.resource.path.Path in project sling by apache.

the class BasicObservationReporterTest method testRootProvider.

@Test
public void testRootProvider() {
    ResourceChangeListenerInfo allPathListener = resourceChangeListenerInfo("/");
    ResourceChangeListenerInfo appsPathListener = resourceChangeListenerInfo("/apps");
    ResourceChangeListenerInfo appsApp2PathListener = resourceChangeListenerInfo("/apps/app2");
    ResourceChangeListenerInfo globListener = resourceChangeListenerInfo("glob:/apps/**/*.html");
    BasicObservationReporter underTest = new BasicObservationReporter(SEARCH_PATHS, ImmutableList.of(allPathListener, appsPathListener, appsApp2PathListener, globListener), new Path("/"), PathSet.EMPTY_SET);
    underTest.reportChanges(changes("/apps/app1/path1.html"), false);
    underTest.reportChanges(changes("/content/path2/jcr:content"), false);
    assertListener(allPathListener, "/apps/app1/path1.html", "/content/path2/jcr:content");
    assertListener(appsPathListener, "/apps/app1/path1.html");
    assertListener(appsApp2PathListener);
    assertListener(globListener, "/apps/app1/path1.html");
}
Also used : Path(org.apache.sling.api.resource.path.Path) Test(org.junit.Test)

Aggregations

Path (org.apache.sling.api.resource.path.Path)8 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 Resource (org.apache.sling.api.resource.Resource)3 List (java.util.List)2 Map (java.util.Map)2 Test (org.junit.Test)2 File (java.io.File)1 Field (java.lang.reflect.Field)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 BidiMap (org.apache.commons.collections4.BidiMap)1 TreeBidiMap (org.apache.commons.collections4.bidimap.TreeBidiMap)1 LoginException (org.apache.sling.api.resource.LoginException)1 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)1 ValueMap (org.apache.sling.api.resource.ValueMap)1 PathSet (org.apache.sling.api.resource.path.PathSet)1 VanityPathConfig (org.apache.sling.resourceresolver.impl.mapping.MapConfigurationProvider.VanityPathConfig)1 Mapping (org.apache.sling.resourceresolver.impl.mapping.Mapping)1