Extend the User Profile Information in Communities Components

monikaa6

25-01-2017

Hi All,

We are using AEM 6.2 communities Feature pack FP2. I am trying to extend some of communities components(activitystream,comments)

I was able to extend them, but both of these components retrive some of user information (avatar image, name etc).

We are storing the profile images of user at different place, so I want to change the logic of pulling the avatar image for these components.

What is the best way to do that so I just need to extend/override this logic at one place and that become available for all communities components we are using

I tried extending the "AbstractUser" class and bind it to "social/commons/components/author" resourceType in Factory, but that is not getting called.

Please suggest the best way to implement this.

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

monikaa6

05-05-2017

Bharath valse wrote...

monikaa6 wrote...

Yes,It worked for us after changing priority level to 200.

 

Hello Monika,

Could you please explain which classes did you extend to override to get a custom avatar URL and how the binding is done to a OOB component.

My requirement is to override a context variable "author.avatarUrl" which is being populated from some java class in the backend. Any pointers would be helpful as to how to get started with extending and modifying the context variables.

Thanks 

 

Hello Bharath,

I wrote the Component class which extends the "AbstractUser" class and implements the "User" class and then overridden the getAvatarUrl() method logic here.

and created the Factory class for the component class which extends AbstractSocialComponentFactory implements SocialComponentFactory.

In Factory Class did the binding on the "social/commons/components/author", so every OOB component which returns the USER object of this type will call this class (For e.g OOB activitystream and comment component)

Make sure the priority for this component should be kept higher, I kept it to 200 then only it worked.

Hope that helps!!

Thanks,

Monika

Answers (10)

Answers (10)

apanghal

Employee

12-04-2017

Try to work with priority level of your extended component ( AbstractUser) as ootb components get registered first and custom component need priority level higher than ootb.

Try adding this to your extended component class 

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

/** Priority level of the component. */

@Property(name = "priority", intValue = 200)

protected int priority;

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

Bharath_valse

09-05-2017

monikaa6 wrote...

Bharath valse wrote...

monikaa6 wrote...

Yes,It worked for us after changing priority level to 200.

 

Hello Monika,

Could you please explain which classes did you extend to override to get a custom avatar URL and how the binding is done to a OOB component.

My requirement is to override a context variable "author.avatarUrl" which is being populated from some java class in the backend. Any pointers would be helpful as to how to get started with extending and modifying the context variables.

Thanks 

 

Hello Bharath,

I wrote the Component class which extends the "AbstractUser" class and implements the "User" class and then overridden the getAvatarUrl() method logic here.

and created the Factory class for the component class which extends AbstractSocialComponentFactory implements SocialComponentFactory.

In Factory Class did the binding on the "social/commons/components/author", so every OOB component which returns the USER object of this type will call this class (For e.g OOB activitystream and comment component)

Make sure the priority for this component should be kept higher, I kept it to 200 then only it worked.

Hope that helps!!

Thanks,

Monika

 

Thanks Monika, it worked perfectly.

Bharath_valse

02-05-2017

monikaa6 wrote...

Yes,It worked for us after changing priority level to 200.

 

Hello Monika,

Could you please explain which classes did you extend to override to get a custom avatar URL and how the binding is done to a OOB component.

My requirement is to override a context variable "author.avatarUrl" which is being populated from some java class in the backend. Any pointers would be helpful as to how to get started with extending and modifying the context variables.

Thanks 

apanghal

Employee

13-04-2017

Steven,

You are absolutely right saying that almost every community component comes with default priority level 0 to support custom extensions. With livefyre integration post AEM 6.1 GA, we have a new implementation of AbstractUser via this factory - com.adobe.social.integrations.livefyre.user.impl.LivefyreUserFactoryImpl (see using system/console/components) which has priority level 100. so for any custom extension, this need to be superseded. 

I believe this need to be documented for future reference and we will surely do that. Thanks.

stevencarterhs2

13-04-2017

ashokkumar wrote...

Try to work with priority level of your extended component ( AbstractUser) as ootb components get registered first and custom component need priority level higher than ootb.

Try adding this to your extended component class 

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

/** Priority level of the component. */

@Property(name = "priority", intValue = 200)

protected int priority;

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

 

I was using a value greater than 0 when I first wrote my override component. Is there a way for us to determine what the different priority levels are for the various OOTB implementations so we know what priority we have to use? For other components, using any value greater than 0 has always been sufficient for us.

The quoted response is the correct answer for future people attempting to override a component. I was comically frustrated last night while working on this, and ended up using 999999 as my priority, which obviously made it begin working. You should also ensure that you are using the correct cq-social-badging-api and cq-social-scoring-api packages instead of the classes out of the Uber JAR on AEM 6.1, since the Uber JAR version is older.

stevencarterhs2

12-04-2017

I too am having this issue. I had already tried what both of the previous users have tried. Has anyone had any success overriding the user profile?

snbaem

02-03-2017

Hello All,

I am trying exact same thing. I am using an extended comments component that uses the profile image based on path to we.retail profile page instead of my-project profile page.

Did two things. Created

  • UserProfileComponent (extends com.adobe.cq.social.scf.core.AbstractUser and implements com.adobe.cq.social.scf.User). In this class I am looking to override the getAvatarUrl() to get desired url.
  • UserProfileComponentFactory (Implements com.adobe.cq.social.scf.SocialComponentFactory.)
    • Tried extending com.adobe.cq.social.scf.core.AbstractSocialComponentFactory, but does seem like the binding is happening.  I am supposing that when I load my custom comments component (Or any component that uses getAvatarUrl() method to get the OOTB avatar image), the debugger should get in UserProfileComponent. Also returning my component res type in getSupportedResourceType() in factory class.
    • Also tried extending com.adobe.cq.social.commons.client.api.UserSocialComponentFactory but the edependency does not resolve. I am using AEM 6.2 SP1 and FP2. Is this class deprecated/not available?

Please suggest how the dependency could be resolved or any other class I need to extend in my UserProfileComponentFactory class