AEM 6.4 unable to access content path via resourceresolver/session | Community
Skip to main content
Level 9
May 17, 2018
Solved

AEM 6.4 unable to access content path via resourceresolver/session

  • May 17, 2018
  • 31 replies
  • 14157 views

Hey Guys,

I am trying to access the path under content structure and i see that the code keeps complaining that path under /content does not exist.

i have a system user with permissions to /content folder and i am trying to get the resourceresolver via the java code and check if the node exists at the path. The output is that the node does not exist for any path under /content. is there something i am missing? I see that session.nodeExists works if i test for path under apps.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by NitroHazeDev

Hi,

I had to alter the code discussing with Adobe

Try this:

Class extending WCMUsepojo

----------------

GetResourceResolverService getService = getSlingScriptHelper().getService(GetResourceResolverService.class);

if(getService ==null)

return;

resourceResolver= getService.getServiceResourceResolver("core-admin");// core-admin is the service name ,                                                                       //resourceResolverParams.put(ResourceResolverFactory.SUBSERVICE,"core-admin")

Resource resource = resourceResolver.resolve(resourcePath);

GetResourceResolverService  class

-----------------------------------------------

@component(name="",service=GetResourceResolverService  .class,immediate=true)

public class GetResourceResolverServiceImpl implements GetResourceResolverService {

@Reference

private ResourceResolverFactory resolverFactory;

private ResourceResolver resourceResolver;

@Override

public ResourceResolver getServiceResourceResolver(String subServiceName){

final Map<String,Object> serviceMap = new ConcurrentHashMap<>();

serviceMap.put(ResourceResolverFactory .SUBSERVICE,subServiceName);

try{

resourceResolver = resolverFactory.getServiceResourceResolver(serviceMap);

}catch(LoginException e)

}

}

31 replies

Level 9
May 17, 2018

Anyone please?

arunpatidar
Community Advisor
Community Advisor
May 17, 2018

Hi,

How are you getting session? Could you please share your code?

Arun Patidar
Level 9
May 17, 2018

So i am using the regular way of accessing it ... it says node exists for path under apps. This works in 6.2 and not in 6.4

In WCMUse pojo class:

ResourceResolverFactory rrf = getSlingScriptHelper().getService(ResourceResolverFactory.class);

resourceResolver = rrf.getServiceResourceResolver(resourceResolverParams);//pass subservice name

if(resourceResolver!=null)

        log.info("resourceresolver not null"); // not null

session = resourceResolver.adaptTo(Session.class);

if(session.nodeExists(path))

joerghoh
Adobe Employee
Adobe Employee
May 17, 2018

The only reason for the described behaviour is no read permissions on /content. Please double-check that.

Jörg

arunpatidar
Community Advisor
Community Advisor
May 17, 2018

yes Jorg is right, the issue is seems with permission.

Check permission of sling-scripting user for /content/ folder.

Arun Patidar
Level 9
May 17, 2018

Hey Guys,

The user does have read permissions under /content , /apps, /etc infact gave admin privilege for testing. So other than apps, it appears that node does not exist for any other path

Level 9
May 17, 2018

Sling scripting user had no read permission, thanks guys that did it.

akhoury
Adobe Employee
Adobe Employee
May 17, 2018

Since you found that a system user permission was missing you might want to repair all the system user permissions.  Somebody most likely installed a package containing ACLs which overwrote the out-of-the-box ones.  There are probably other users that might be missing their permissions.  See this article for a guide on how to repair system user ACLs: Fix missing system user ACLs

Level 9
May 18, 2018

Thanks .. but i see OOTB there are no permissions set for the sling-scripting user account. The code does not alter any permissions.

Attaching the snapshot i see OOTB where there are no permissions under /content

joerghoh
Adobe Employee
Adobe Employee
May 18, 2018

I wonder why the sling-scripting service user is used for your resourceResolver. How do your resourceResolverParams look like?

And btw: it's correct that the sling-scripting service-user does not have read access to /content. You should not change that permission.

kind regards,

Jörg