Thursday 26 April 2018

How to use System user to access the crx repository?

System user is configured in the user mapper configuration in the felix console. In the below example datawrite is the system user.
The below code demonstrates the way in which we can use a system user to access the repository to make changes to it.

Map<String, Object> paramsMap = new HashMap<String, Object>();
paramsMap.put(ResourceResolverFactory.SUBSERVICE, "datawrite");
ResourceResolver resourceResolver = null;
resourceResolver = resourceResolverFactory.getServiceResourceResolver(paramsMap);
Resource res = resourceResolver.getResource("<Path in the repository>");
//Write logic to make changes to the resource.
//Then commit the changes done to the repository.
res.getResourceResolver().commit();

No comments:

Post a Comment

extraClientlibs Usage

The purpose of property "extraClientlibs" is to selectively load client library for a dialog. This prevents the unnecessary load o...