use of org.apache.sling.api.resource.ParametrizableResourceProvider in project sling by apache.
the class LegacyResourceProviderAdapter method getResource.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Resource getResource(ResolveContext<Object> ctx, String path, ResourceContext resourceContext, Resource parent) {
Resource resourceCandidate;
if (rp instanceof ParametrizableResourceProvider) {
resourceCandidate = ((ParametrizableResourceProvider) rp).getResource(ctx.getResourceResolver(), path, resourceContext.getResolveParameters());
} else {
resourceCandidate = rp.getResource(ctx.getResourceResolver(), path);
}
ResourceProvider<?> parentProvider = ctx.getParentResourceProvider();
ResolveContext parentCtx = ctx.getParentResolveContext();
// Ask the parent provider
if (resourceCandidate == null && !ownsRoot && parentProvider != null) {
return parentProvider.getResource(parentCtx, path, resourceContext, parent);
}
// Support the INTERNAL_CONTINUE_RESOLVING flag
Resource fallbackResource = resourceCandidate;
if (resourceCandidate != null && parentProvider != null && isContinueResolving(resourceCandidate)) {
resourceCandidate = ctx.getParentResourceProvider().getResource(parentCtx, path, resourceContext, parent);
}
if (resourceCandidate != null) {
return resourceCandidate;
} else {
return fallbackResource;
}
}
Aggregations