Hello,
I have the problem with locating the folder as resource from Sling Component.
The code looks like the following:
The line 36 gives not null resource object but line 37 gives null.
The folder "/apps/sling" exists initially but "/apps/myfolder" was manually created in JCR Repository Browser.
I compared the properties and access rules of "/apps/sling" and "/apps/myfolder" and was unable to see any difference.
Could you please help me to understand why the custom folder is invisible for resource resolver and how to reach this folder properly during component activation?
Thanks,
Pavel
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @pilmenkov
You are not obtaining the correct resource resolver here.
Please use the system user to get the resource resolver and ensure you are giving access to the system user for the path you want to perform any operation here i.e. /apps/myfolder.
Please refer the link here.
Thanks
Hi @pilmenkov ,
Can you please explain a bit about how you are creating "/apps/myfolder" .? and how it was created?
Make sure it doesn't get into Race Condition.
Thanks,
Aditya Ch
Hi @pilmenkov
You are not obtaining the correct resource resolver here.
Please use the system user to get the resource resolver and ensure you are giving access to the system user for the path you want to perform any operation here i.e. /apps/myfolder.
Please refer the link here.
Thanks
Hi @pilmenkov y
@reference
private ResourceResolverFactoryService resourceResolverFactoryService;
Map<String, Object> param = new HashMap<>();
param.put(ResourceResolverFactory.SUBSERVICE, "label");
param.put(ResourceResolverFactory.USER, "serviceUser");
resolver = resourceResolverFactory.getServiceResourceResolver(param);
try this, Hope it will work!
Shivam153, thank you for your example.
It works finally after setting up the system user as advised by Asutosh_Jena_
(Please note that ResourceResolverFactoryService uses in your code example does not exist in sling libraries, at least I was not able to find it)
yes correct, it was ResourceResolverFactory. I misspelled it.
Views
Likes
Replies
Views
Like
Replies