SLING-12739 - better naming
diff --git a/src/main/java/org/apache/sling/servlets/resolver/api/ResourcePredicate.java b/src/main/java/org/apache/sling/servlets/resolver/api/IgnoredResourcePredicate.java
similarity index 94%
rename from src/main/java/org/apache/sling/servlets/resolver/api/ResourcePredicate.java
rename to src/main/java/org/apache/sling/servlets/resolver/api/IgnoredResourcePredicate.java
index 891ab96..e0f7200 100644
--- a/src/main/java/org/apache/sling/servlets/resolver/api/ResourcePredicate.java
+++ b/src/main/java/org/apache/sling/servlets/resolver/api/IgnoredResourcePredicate.java
@@ -32,5 +32,5 @@
* the servlets resolver.
*/
@ConsumerType
-public interface ResourcePredicate extends Predicate<Resource> {
+public interface IgnoredResourcePredicate extends Predicate<Resource> {
}
diff --git a/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java b/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java
index 7d74c6d..daf9573 100644
--- a/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java
+++ b/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java
@@ -54,7 +54,7 @@
import org.apache.sling.api.servlets.ServletResolver;
import org.apache.sling.api.servlets.ServletResolverConstants;
import org.apache.sling.serviceusermapping.ServiceUserMapped;
-import org.apache.sling.servlets.resolver.api.ResourcePredicate;
+import org.apache.sling.servlets.resolver.api.IgnoredResourcePredicate;
import org.apache.sling.servlets.resolver.internal.defaults.DefaultErrorHandlerServlet;
import org.apache.sling.servlets.resolver.internal.defaults.DefaultServlet;
import org.apache.sling.servlets.resolver.internal.helper.AbstractResourceCollector;
@@ -137,7 +137,7 @@
policy = ReferencePolicy.DYNAMIC,
cardinality = ReferenceCardinality.OPTIONAL
)
- private volatile ResourcePredicate resourceHidingPredicate;
+ private volatile IgnoredResourcePredicate ignoredResourcePredicate;
/**
* The allowed execution paths.
@@ -452,11 +452,11 @@
return res;
}
- /** @return true if the given Resource is hidden by our resourceHidingPredicate */
- private boolean isHidden(@NotNull Resource r) {
- final boolean result = r != null && resourceHidingPredicate != null && resourceHidingPredicate.test(r);
+ /** @return true if the IgnoredResourcePredicate is set and returns true for the supplied Resource */
+ private boolean ignoreResource(@NotNull Resource r) {
+ final boolean result = r != null && ignoredResourcePredicate != null && ignoredResourcePredicate.test(r);
if(result && LOGGER.isDebugEnabled()) {
- LOGGER.debug("Resource hidden by resource hiding predicate: {}", r.getPath());
+ LOGGER.debug("IgnoredResourcePredicate causes Resource to be ignored: {}", r.getPath());
}
return result;
}
@@ -487,7 +487,7 @@
final String scriptPath = ResourceUtil.normalize(scriptNameOrResourceType);
if (scriptPath != null && isPathAllowed(scriptPath, this.executionPaths.get()) ) {
final Resource res = AbstractResourceCollector.getResourceOrNull(resolver,scriptPath,useResourceCaching);
- servlet = isHidden(res) ? null : this.getServlet(res);
+ servlet = ignoreResource(res) ? null : this.getServlet(res);
if (servlet != null && !pathBasedServletAcceptor.accept(request, servlet)) {
if(LOGGER.isDebugEnabled()) {
LOGGER.debug("Servlet {} rejected by {} returning FORBIDDEN status", RequestUtil.getServletName(servlet),
@@ -555,7 +555,7 @@
}
final Collection<Resource> candidates = locationUtil.getServlets(resolver, localCache.getScriptEngineExtensions());
- candidates.removeIf(r -> isHidden(r));
+ candidates.removeIf(r -> ignoreResource(r));
if (LOGGER.isDebugEnabled()) {
if (candidates.isEmpty()) {
diff --git a/src/test/java/org/apache/sling/servlets/resolver/internal/AbsoluteResourceTypeTest.java b/src/test/java/org/apache/sling/servlets/resolver/internal/AbsoluteResourceTypeTest.java
index 6fe873e..147c033 100644
--- a/src/test/java/org/apache/sling/servlets/resolver/internal/AbsoluteResourceTypeTest.java
+++ b/src/test/java/org/apache/sling/servlets/resolver/internal/AbsoluteResourceTypeTest.java
@@ -39,7 +39,7 @@
import org.apache.sling.api.resource.PersistenceException;
import org.osgi.framework.Bundle;
-import org.apache.sling.servlets.resolver.api.ResourcePredicate;
+import org.apache.sling.servlets.resolver.api.IgnoredResourcePredicate;
import org.apache.sling.servlets.resolver.internal.resource.MockServletResource;
public class AbsoluteResourceTypeTest extends SlingServletResolverTestBase {
@@ -114,8 +114,8 @@
@Test
public void testAbsolutePathHiddenByPredicate() throws Exception {
- final ResourcePredicate hideAbsolutePath = r -> r.getPath().equals(absolutePath);
- final Field f = servletResolver.getClass().getDeclaredField("resourceHidingPredicate");
+ final IgnoredResourcePredicate hideAbsolutePath = r -> r.getPath().equals(absolutePath);
+ final Field f = servletResolver.getClass().getDeclaredField("ignoredResourcePredicate");
f.setAccessible(true);
f.set(servletResolver, hideAbsolutePath);
try {
diff --git a/src/test/java/org/apache/sling/servlets/resolver/internal/resourcehiding/ServletHidingTest.java b/src/test/java/org/apache/sling/servlets/resolver/internal/resourcehiding/ServletHidingTest.java
index afb6a78..2f84636 100644
--- a/src/test/java/org/apache/sling/servlets/resolver/internal/resourcehiding/ServletHidingTest.java
+++ b/src/test/java/org/apache/sling/servlets/resolver/internal/resourcehiding/ServletHidingTest.java
@@ -35,7 +35,7 @@
import org.apache.sling.api.resource.ResourceUtil;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
import org.apache.sling.commons.testing.sling.MockSlingHttpServletRequest;
-import org.apache.sling.servlets.resolver.api.ResourcePredicate;
+import org.apache.sling.servlets.resolver.api.IgnoredResourcePredicate;
import org.apache.sling.servlets.resolver.internal.SlingServletResolverTestBase;
import org.apache.sling.servlets.resolver.internal.helper.HelperTestBase;
import org.apache.sling.servlets.resolver.internal.resource.MockServletResource;
@@ -58,8 +58,8 @@
}
}
- private void setServletHidingFilter(ResourcePredicate predicate) throws Exception {
- final Field predicateField = servletResolver.getClass().getDeclaredField("resourceHidingPredicate");
+ private void setServletHidingFilter(IgnoredResourcePredicate predicate) throws Exception {
+ final Field predicateField = servletResolver.getClass().getDeclaredField("ignoredResourcePredicate");
predicateField.setAccessible(true);
predicateField.set(servletResolver, predicate);
}
@@ -101,7 +101,7 @@
@Test
public void testHideAndSeek() throws Exception {
final AtomicBoolean hide = new AtomicBoolean();
- final ResourcePredicate pred = r -> hide.get();
+ final IgnoredResourcePredicate pred = r -> hide.get();
// No filtering
setServletHidingFilter(null);
diff --git a/src/test/java/org/apache/sling/servlets/resolver/it/resourcehiding/ResourceHidingITBase.java b/src/test/java/org/apache/sling/servlets/resolver/it/resourcehiding/ResourceHidingITBase.java
index 8124125..baaf774 100644
--- a/src/test/java/org/apache/sling/servlets/resolver/it/resourcehiding/ResourceHidingITBase.java
+++ b/src/test/java/org/apache/sling/servlets/resolver/it/resourcehiding/ResourceHidingITBase.java
@@ -21,7 +21,7 @@
import java.util.UUID;
import org.apache.sling.api.resource.Resource;
-import org.apache.sling.servlets.resolver.api.ResourcePredicate;
+import org.apache.sling.servlets.resolver.api.IgnoredResourcePredicate;
import org.apache.sling.servlets.resolver.it.ServletResolverTestSupport;
import org.apache.sling.servlets.resolver.it.TestServlet;
import org.junit.Before;
@@ -64,8 +64,8 @@
.register(bundleContext);
}
- protected void registerPredicate(ResourcePredicate p) {
- final ResourcePredicate wrappedPredicate = new ResourcePredicate() {
+ protected void registerPredicate(IgnoredResourcePredicate p) {
+ final IgnoredResourcePredicate wrappedPredicate = new IgnoredResourcePredicate() {
@Override
public boolean test(Resource r) {
final boolean result = p.test(r);
@@ -75,6 +75,6 @@
return result;
}
};
- bundleContext.registerService(ResourcePredicate.class.getName(), wrappedPredicate, null);
+ bundleContext.registerService(IgnoredResourcePredicate.class.getName(), wrappedPredicate, null);
}
}
\ No newline at end of file