Wednesday, February 3, 2016

How to use getAdministrativeResourceResolver()

Problem: How to use getAdministrativeResourceResolver() in AEM 6.0 and above. Since method has been deprecated.


Solutions : 
You have to create a system user (rep:SystemUser) and need to assign the admin privileges. then we will use this user to get the admin resolver.

Below follow the below steps to get resolver.

1.   Go to Felix Console configuration tab i.e. http://localhost:4502/system/console/configMgr

2. Search for User Mapping as shown in figure-
Adobe Configuration Manager
User Mapper Configuration



1.   Click on this service to edit it’s configuration.
Here you have to add one entry and the syntax of the entry is –
“Bundle symbolic Name”:”SubServieName”=”User Name”

1. “Bundle symbolic Name :-  Here you have to add the bundle symbolic name where you are creating service.

2. “SubServieName”:- This is the name you provided as a value of  ResourceResolverFactory.SUBSERVICE property i.e. “testService”.

3. “User Name” :- This  is the user name for ex. “admin”So in my case this configuration field value becomes“com.blog.blog-bundles:testService=admin”

After adding this entry your configuration looks like-

User Mapper Configuration







For creating System User, follow these steps-
2.   Login as Administrator i.e. using “admin:admin”
3.   Click on “User Administration”, you will see a screen just like this –



System admin user
rep:SystemUser

4.   Here you will see a option of “Create System User”, Click on this button.
5.   Add a value for User Id field for ex. “AdminUser”
6.   Click on green button.
7.   Close the window.

8.   Go to CRXDE Lite, your “AdminUser” will be created under /home/system directory. If you are not able to find then search for “AdminUser” in home screen. You will get the location.