Expand my Community achievements bar.

SOLVED

Extend the User Profile Information in Communities Components

Avatar

Level 3

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

1 Accepted Solution

Avatar

Correct answer by
Level 3

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

View solution in original post

11 Replies

Avatar

Level 3

Any one has any thought on this?

Appreciate any help on this.

Avatar

Level 3

Anyone has any idea on this? Its becoming important to complete from our project tasks prespective..

Avatar

Community Advisor

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

Avatar

Level 1

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?

Avatar

Employee

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;

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

Avatar

Level 3

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

Avatar

Level 1

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.

Avatar

Employee

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.

Avatar

Level 4

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 

Avatar

Correct answer by
Level 3

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

Avatar

Level 4

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.