Show Menu
TOPICS×

SRP and UGC Essentials

Introduction

If unfamiliar with the storage resource provider (SRP) and its relationship to user-generated content (UGC), visit Community Content Storage and Storage Resource Provider Overview .
This section of the documentation provides some essential information about SRP and UGC.

StorageResourceProvider API

The SocialResourceProvider API (SRP API) is an extension of various Sling Resource Provider APIs. It includes support for pagination and atomic increment (useful for tally and scoring).
Queries are necessary for SCF components as there is the need to sort by date, helpfulness, number of votes, and so on. All SRP options have flexible query mechanisms which do not rely on bucketing.
The SRP storage location incorporates the component path. The SRP API should always be used to access UGC as the root path depends on the SRP option selected, such as ASRP, MSRP, or JSRP.
The SRP API is not an abstract class, it is an interface. A custom implementation should not be undertaken lightly, as the benefits of future improvements to internal implementations would be missed when upgrading to a new release.
The means for using the SRP API are through provided utilities, such as those found in the SocialResourceUtilities package.
When upgrading from AEM 6.0 or earlier, it will be necessary to migrate UGC for all SRPs, for which an Open Source tool is available. See Upgrading to AEM Communities 6.3 .
Historically, utilities for accessing UGC were found in the SocialUtils package, which no longer exists.
For replacement utilities, see SocialUtils Refactoring .

Utility Method to Access UGC

To access UGC, use a method from the SocialResourceUtilities package that returns a path suitable for accessing UGC from SRP and replaces the deprecated method found in the SocialUtils package.
Following is a minimal example of using the resourceToUGCStoragePath() method in a servlet:
import com.adobe.cq.social.srp.utilities.api.SocialResourceUtilities;

@Reference
private SocialResourceUtilities socialResourceUtilities;

@Override
protected void doGet(final SlingHttpServletRequest request, final SlingHttpServletResponse response) throws ServletException, IOException {
  String ugcPath = socialResourceUtilities.resourceToUGCStoragePath(request.getResource());
  // rest of servlet
}

For other SocialUtils replacements, see SocialUtils Refactoring .
For coding guidelines, visit Accessing UGC with SRP .
The path resourceToUGCStoragePath() returns is *not *suitable for ACL checking .

Utility Method to Access ACLs

Some SRP implementations, such as ASRP and MSRP, store community content in databases which provide no ACL verification. Shadow nodes provide a location in the local repository to which ACLs can be applied.
Using the SRP API, all SRP options perform the same check of the shadow location prior to all CRUD operations.
To check ACLs, use a method that returns a path suitable for checking the permissions applied to the resource's UGC.
Following is a simple example of using the resourceToACLPath() method in a servlet:
import com.adobe.cq.social.srp.utilities.api.SocialResourceUtilities;

@Reference
private SocialResourceUtilities socialResourceUtilities;

@Override
protected void doGet(final SlingHttpServletRequest request, final SlingHttpServletResponse response) throws ServletException, IOException {
  String aclPath = socialResourceUtilities.resourceToACLPath(request.getResource());
  // rest of servlet
}

The path returned by resourceToACLPath() is *not *suitable for accessing the UGC itself.