Expand my Community achievements bar.

SOLVED

Using deprecated Profile or UserManager service in 5.6.1?

Avatar

Level 1

Hi guys,

I am using the Profile service and the UserManager factory, both of which have stopped working in the publisher in 5.6.1.

Is there an alternative, or solution which will allow me to continue using it?

My code below:

public IGProfile getUserProfile(String authorizableId) { if (!StringUtils.isEmpty(authorizableId)) { try { /** * Do not close the resolver in this case as IGProfile needs to read the props from the * SessionAndResolver, normally we need to close the SessionAndResolver. */ final SessionAndResolver sessionAndResolver = rmanager.getCurrentOrCreateNew(); final ResourceResolver resolver = sessionAndResolver.getResolver(); final Authorizable auth = userManagerFactory.createUserManager(sessionAndResolver.getSession()).get(authorizableId); final Resource profileResource = resolver.getResource(auth.getHomePath() + "/profile"); if (profileResource != null) { return profileResource.adaptTo(IGProfile.class); } } catch (NoSuchAuthorizableException e) { LOG.info("No such user '{}'", authorizableId); // No Authorizable for that ID exists so return null } catch (AccessDeniedException e) { LOG.warn("AccessDeniedExceptionto load user '{}'", authorizableId, e); } } return null; }

Thanks!

Sam

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi Sam,

I don't see any usage of the CQ Profile class. All I see is "IGProfile".

Regarding the UserManagerFactory, as documented, you should use the Jackrabbit UserManager instead of the CQ UserManager (https://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/security/UserManager.html). The easiest way to get a Jackrabbit UserManager based on the code above would be to write

UserManager userManager = resolver.adaptTo(UserManager.class);

Regards,

Justin

View solution in original post

2 Replies

Avatar

Correct answer by
Employee

Hi Sam,

I don't see any usage of the CQ Profile class. All I see is "IGProfile".

Regarding the UserManagerFactory, as documented, you should use the Jackrabbit UserManager instead of the CQ UserManager (https://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/security/UserManager.html). The easiest way to get a Jackrabbit UserManager based on the code above would be to write

UserManager userManager = resolver.adaptTo(UserManager.class);

Regards,

Justin

Avatar

Level 10

To follow up with what Justin stated -- you can read a community article that talks about how to use the Jackrabbit User Manager from an OSGi bundle:

http://helpx.adobe.com/experience-manager/using/developing-aem-osgi-bundles-jackrabbit.html

Hope this helps.