Featured

Tuesday, 10 July 2012

How to get Repository access in cq5

@Reference private SlingRepository repository;
@SuppressWarnings("deprecation")
@Reference
private JcrResourceResolverFactory resolverFactory;

private ResourceResolver resolver;
private Session session;

session = repository.loginAdministrative(null);
resolver = this.resolverFactory.getResourceResolver(session);

From here you will get the root node whichever you wants---
rootNodePath="/content/dam";
Node rootNode = session.getNode(rootNodePath);

From this rootNode you can trace all the sub nodes...


Hope it helps :)
Thanks,
SonyCharan

No comments: