Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

User generated content access (community)

Juan_Camacho_I_
Level 2
Level 2

Hi, I want to develop a custom search component in my page to seek for keywords in communitiy pages, I have tried to do using the ootb forum component (/libs/social/forum/components/hbs/forumthat uses the default storage method(I think it is JSRP).

I have seen that topics and answers are created in: "/content/usergenerated/asi/jcr/content/projectname/page/jcr:content/par/forum/", that contains all the info that i need, but I don't know how to access this folder within my Java classes, I have tried to use :

Resource r = request.getResourceResolver().getResource("/content/usergenerated/asi/jcr"); Node rootNode = r.adaptTo(Node.class);

But if i try to use rootNode.getNodes() in that folder or any folder inside that one I get an error. Is there another way to get to get the posts and their content to use it in my Java classes?.

Thank you in advance

Juan

8 Replies
Gdubz-57m2mu
Level 5
Level 5

If you're just reading information from the JCR and not writing to it, no need to adapt away from Resource. Per the AEM - Quick Reference, it's best practice to use Resource and ValueMap to retrieve information.

Also, you could continue to traverse the resource tree as you're trying to do now, or you could use QueryBuilder to search for what you want. There's a good usage example in the documentation I linked.

Opkar_Gill
Employee
Employee

Hi Juan,

you should be using the SocialResourceProvider API as it will hide the underlying persistance model being used .i.e MSRP, ASRP or JSRP. You should not be setting the path yourself.

The example in the docs[0] is slightly incorrect:

import com.adobe.cq.social.srp.utilities.api.SocialResourceUtilities;
String ugcPath = SocialResourceUtilities.resourceToUGCStoragePath(final Resource resource);

As you need to get the OSGI service and you can get the path by passing in your resource.

   @Reference
    private SocialResourceUtilities socialResourceUtilities;

Then you can use this in your code.

There was a Communities session yesterday, that I'd recommend you check out.

Regards,

Opkar

[0]https://docs.adobe.com/docs/en/aem/6-1/develop/communities/scf/srp.html

Juan_Camacho_I_
Level 2
Level 2

Hi, thank for the help.

 

I have tried to use: "import com.adobe.cq.social.srp.utilities.api.SocialResourceUtilities;" but eclipse cannot resolve the incluse, is there a jar or something to be done before using that class?

 

Regards,

 

Juan C

Gdubz-57m2mu
Level 5
Level 5

Juan Camacho I. wrote...

Hi, thank for the help.

 

I have tried to use: "import com.adobe.cq.social.srp.utilities.api.SocialResourceUtilities;" but eclipse cannot resolve the incluse, is there a jar or something to be done before using that class?

 

Regards,

 

Juan C

 

I believe you may need to include the social API as it appears to have been separated from the Uber JAR. (Documentation: https://docs.adobe.com/docs/en/aem/6-1/develop/communities/code-guide/maven.html#Communities API Jar Artifact)

<dependency> <groupId>com.adobe.cq.social</groupId> <artifactId>cq-socialcommunities-api</artifactId> <version>1.7.197</version> <scope>provided</scope> </dependency>
Opkar_Gill
Employee
Employee

In addition to dependency above you would need to deploy the communities package. This available to customers with the appropriate license.

Regards,

Opkar

JK_Kendall
Level 8
Level 8

Please upgrade to the latest version of Communities : FP4.

After upgrade you'll need to change the version for maven to 1.8.386

- JK

JK_Kendall
Level 8
Level 8

Thanks to Opkar, the documentation has been corrected.

- JK

Opkar_Gill
Employee
Employee

Hi,

if you are using the forum component[0] that is listed in the communities components[0], then you would need a license[1]. I don't see a forum component in the page authoring components list[2].

Regards,

Opkar

 

[0] https://docs.adobe.com/docs/en/aem/6-1/author/communities/forum.html

[1]https://docs.adobe.com/docs/en/aem/6-1/author/communities.html

[2]https://docs.adobe.com/docs/en/aem/6-1/author/page-authoring/default-components/editmode.html