use of org.apache.sling.servlets.resolver.internal.helper.AbstractResourceCollector in project sling by apache.
the class SlingServletResolver method resolveServletInternal.
/**
* Resolve an appropriate servlet for a given request and resource type
* using the provided ResourceResolver
*/
private Servlet resolveServletInternal(final SlingHttpServletRequest request, final Resource resource, final String scriptName, final ResourceResolver resolver) {
Servlet servlet = null;
// path of a servlet (or script)
if (scriptName.charAt(0) == '/') {
final String scriptPath = ResourceUtil.normalize(scriptName);
if (this.isPathAllowed(scriptPath)) {
final Resource res = resolver.getResource(scriptPath);
servlet = this.getServlet(res);
if (servlet != null && LOGGER.isDebugEnabled()) {
LOGGER.debug("Servlet {} found using absolute resource type {}", RequestUtil.getServletName(servlet), scriptName);
}
} else {
if (request != null) {
request.getRequestProgressTracker().log("Will not look for a servlet at {0} as it is not in the list of allowed paths", scriptName);
}
}
}
if (servlet == null) {
// the resource type is not absolute, so lets go for the deep search
final AbstractResourceCollector locationUtil;
if (request != null) {
locationUtil = ResourceCollector.create(request, this.executionPaths, this.defaultExtensions);
} else {
locationUtil = NamedScriptResourceCollector.create(scriptName, resource, this.executionPaths);
}
servlet = getServletInternal(locationUtil, request, resolver);
if (servlet != null && LOGGER.isDebugEnabled()) {
LOGGER.debug("getServletInternal returns servlet {}", RequestUtil.getServletName(servlet));
}
}
return servlet;
}
Aggregations