I am getting null resourcefrom the resource resolver. Here is the function I am calling, when I debugged I found path and resourseResolver is not null.
when I am at Resource resource = resourceResolver.getResource(path); I am getting resource as null. Attaching screenshot from eclipse
private Asset getDamAssets(String path, ResourceResolver resourceResolver)
throws RepositoryException {
Asset asset = null;
LOG.info("...getDamAssets at " + path);
Resource resource = resourceResolver.getResource(path);
if (resource != null) {
// Convert resource to asset, returns null if not an asset
asset = resource.adaptTo(Asset.class);
}
return asset;
}
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
Usually that would indicate that either (a) the resource at that path does not exist or (b) it does exist and the user doesn't have read access to it.
Regards,
Justin
Views
Replies
Total Likes
Try resourceResolver.resolve(Path) it will work.
//This takes absolute path, you might be providing absolute path.
Hi,
path looks fine but I think that resource is not available at the given path and hence its throwing null. Please check if that resource exists at the give path. Also refer here [1]
Views
Replies
Total Likes
Hi,
Usually that would indicate that either (a) the resource at that path does not exist or (b) it does exist and the user doesn't have read access to it.
Regards,
Justin
Views
Replies
Total Likes
resourceResolver.resolve(Path) works but following line now returns null
asset = resource.adaptTo(Asset.class);
resource is not null, it is going into if loop but it seems that adaptTo Asset returns null now.
Views
Replies
Total Likes
Views
Likes
Replies