Extend the OOB social component

Avatar

Avatar

monikaa6

Avatar

monikaa6

monikaa6

05-12-2016

Hi 

I am trying to extend the OOB social component(Activity Stream Component) following this code

https://github.com/Adobe-Marketing-Cloud/aem-scf-sample-components-extension

But my custom class is not getting called,( I wrote the Factory as well to map the extending resource Type)  

Component class I am extending from below class and interface

public class CustomSocialComponent extends  AbstractActivityStream implements SocialComponent {

}

I want to remove some of the information returned by the OOB Activity Stream JSON, but my custom class is not getting executed.

Please advice. How does extended component map to the custom class?

Thanks,

Monika

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

monikaa6

Avatar

monikaa6

monikaa6

12-01-2017

Sorry missed to reply on this, but my custom component started working

I just changed in Custom Component class 

public class CustomSocialComponent extends AbstractActivityStream implements SocialActivityStream

but I think key is do not specify  immediate=true in component annotations in factory class, just provide the component name and create it as service.

It resolved and gets in active state at runtime only.

Answers (8)

Answers (8)

Avatar

Avatar

aponnusa

Employee

Avatar

aponnusa

Employee

aponnusa
Employee

12-12-2016

This looks right to me. Did the code work after your components were in active state ?

My next question would be, when you say your component is not working ? can you say what is not working ? (As in, any exception in logs if the components are active)

In the page, where you have your custom component can you try (custom_component_path.social.json ex localhost:4503/content/community-components/en/comments/jcr:content/content/includable/slingIncluded.social.json)

My next question is there any activity (did you create comment, blog and forum posts)

Also try using your component inside the component guide (/content/community-components/en) . So I would check if the default Activity Streams component is woking, and then replacing the OOTB component with your custom component.

Avatar

Avatar

monikaa6

Avatar

monikaa6

monikaa6

12-12-2016

kautuksahni wrote...

Hi

I have asked internally to have a look at this.

~kautuk

 

Hi Kautuksahni

Did you get a chance to look into this? Let me know if you were able to find something on this

Thanks,

Monika

Avatar

Avatar

monikaa6

Avatar

monikaa6

monikaa6

12-12-2016

aponnusa wrote...

Hi Monika,

Are you using a new resourceType or using social/activitystreams/components/hbs/activitystreams. If you are using social/activitystreams/components/hbs/activitystreams, then we might have to assign priority so that your custom component gets the preference. Add this code in your Factory

  1. @Override
  2. public int getPriority() {
  3. return 10;
  4. }

Next steps, Did you check if your bundle is active in OSGI System Console (/system/console/bundles) and your factory active at (/system/console/components)

If nothing helped, can you share your code. (We can try locally and see if something else is wrong)

Thanks

 

 

Hi 

I am using the new resouceType

So I have my component class 

public class CustomSocialComponent extends AbstractActivityStream implements SocialComponent { public CustomSocialComponent(Resource resource, ClientUtilities clientUtils, SocialActivityManager socialAcm) { super(resource, clientUtils, socialAcm); } public CustomSocialComponent(Resource resource,ClientUtilities clientUtils, QueryRequestInfo queryRequestInfo,SocialActivityManager socialAcm) { super(resource, clientUtils, queryRequestInfo, socialAcm); } @Override public int getTotalSize() { return 0; }

in which I am just trying to override one of the attrubte of the JSON response.

My Custom Factory class for this is 

@Component(name = "Custom Social Component Factory") @Service public class CustomSocialComponentFactory extends AbstractSocialComponentFactory implements SocialComponentFactory { @Reference private SocialActivityManager socialAcm; @Override public SocialComponent getSocialComponent(Resource resource) { return new CustomSocialComponent(resource, this.getClientUtilities(resource.getResourceResolver()),socialAcm); } @Override public SocialComponent getSocialComponent(Resource resource, SlingHttpServletRequest request) { return new CustomSocialComponent(resource, this.getClientUtilities(request),this.getQueryRequestInfo(request),socialAcm); } @Override public SocialComponent getSocialComponent(Resource resource, ClientUtilities clientUtils, QueryRequestInfo queryRequestInfo) { return new CustomSocialComponent(resource, clientUtils,queryRequestInfo,socialAcm); } @Override public int getPriority() { return 10; } @Override public String getSupportedResourceType() { return "apps/customsocial/components/social/activitystreams"; }

After deploying code I see my factory in "satisfied" state in /system/console/components

But if I add immediate=true in component annotations, it deploy as "active" state

@Component(immediate=true,metatype = true).

Somehow, I am feeling that I am not extending and implementing the correct classes for activitystreams, I tried extending the comment component, and I was able to call the Custom class.

The way "CommentSocialComponentFactory" is exposed, is there any class for ActivityStream as well?

Also in documentation, only Interfaces are specified in ActivityStream components API, but if I look into Java Editor(eclipse), I could see AbstractActivityStream class exposed.

Are there not any Abstract classes available for this components, which can be used to extend.

Let me know if If I am doing something wrong.

Avatar

Avatar

aponnusa

Employee

Avatar

aponnusa

Employee

aponnusa
Employee

07-12-2016

Hi Monika,

Are you using a new resourceType or using social/activitystreams/components/hbs/activitystreams. If you are using social/activitystreams/components/hbs/activitystreams, then we might have to assign priority so that your custom component gets the preference. Add this code in your Factory

@Override public int getPriority() { return 10; }

Next steps, Did you check if your bundle is active in OSGI System Console (/system/console/bundles) and your factory active at (/system/console/components)

If nothing helped, can you share your code. (We can try locally and see if something else is wrong)

Thanks

Avatar

Avatar

monikaa6

Avatar

monikaa6

monikaa6

07-12-2016

JK Kendall wrote...

Hi Monika,

Did you also adapt the scripts in the /apps dir?

The last three lines of this script are particularly important

https://github.com/Adobe-Marketing-Cloud/aem-scf-sample-components-extension/blob/master/content/jcr...

  1. SCF.registerComponent('acme/components/ideation/post', SCF.Post, SCF.PostView);
  2. SCF.registerComponent('acme/components/ideation/topic', SCF.Idea, SCF.IdeaView);
  3. SCF.registerComponent('acme/components/ideation/forum', SCF.Forum, SCF.ForumView);

See Extending Javascript on the Client-side Customization doc page.

- JK

 

Thanks JK!! Yes I did adapt the scripts to apps directory, but it still didnt call my custom class.

I am not sure if I am extending the correct class for extending the Activity Stream component.

I am extending 

public class CustomSocialComponent extends AbstractActivityStream implements SocialComponent {} 

and in Factory class 

public class CustomSocialComponentFactory extends AbstractSocialComponentFactory implements SocialComponentFactory { }

registered the resource type by overriding this method in factory

   

@Override public String getSupportedResourceType() { ... }

Avatar

Avatar

JK_Kendall

Avatar

JK_Kendall

JK_Kendall

06-12-2016

Hi Monika,

Did you also adapt the scripts in the /apps dir?

The last three lines of this script are particularly important

https://github.com/Adobe-Marketing-Cloud/aem-scf-sample-components-extension/blob/master/content/jcr...

SCF.registerComponent('acme/components/ideation/post', SCF.Post, SCF.PostView); SCF.registerComponent('acme/components/ideation/topic', SCF.Idea, SCF.IdeaView); SCF.registerComponent('acme/components/ideation/forum', SCF.Forum, SCF.ForumView);

See Extending Javascript on the Client-side Customization doc page.

- JK

Avatar

Avatar

monikaa6

Avatar

monikaa6

monikaa6

06-12-2016

Thanks Kautuk, much appreciated !!

Avatar

Avatar

kautuk_sahni

Community Manager

Total Posts

5.5K

Likes

955

Correct Answer

1.1K

Avatar

kautuk_sahni

Community Manager

Total Posts

5.5K

Likes

955

Correct Answer

1.1K
kautuk_sahni
Community Manager

05-12-2016

Hi

I have asked internally to have a look at this.

~kautuk