SRP and UGC Essentials

簡介

如果不熟悉儲存資源提供商(SRP)及其與用戶生成內容(UGC)的關係,請訪問 社區內容儲存 和儲存資源提供商概述

This section of the documentation provides some essential information about SRP and UGC.

StorageResourceProvider API

SocialResourceProvider API(SRP API)是各種Sling Resource Provider API的擴充功能。 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. SRP API應一律用於存取UGC,因為根路徑取決於所選SRP選項,例如ASRP、MSRP或JSRP。

SRP API不是抽象類,它是介面。 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
}

如需其他SocialUtils替代項目,請參 閱SocialUtils重構

如需編碼准則,請造 訪使用SRP存取UGC

注意

傳回的路徑resourceToUGCStoragePath()是*not *不適合 ACL檢查

訪問ACL的實用方法

某些SRP實施(如ASRP和MSRP)將社區內容儲存在不提供ACL驗證的資料庫中。 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.

The following descriptions of storage location may be of help when developing with JSRP or perhaps MSRP. There is currently no UI to access UGC stored in ASRP, as there is for JSRP (CRXDE Lite) and MSRP (MongoDB tools).

component location

When a member enters UGC in the publish environment, they are interacting with a component as part of an AEM site.

An example of such a component is the comments component that exists in the Community Components Guide site. The path to the comment node in the local repository is:

  • 元件路徑= /content/community-components/en/comments/jcr:content/content/include/comments

陰影節點位置

建立UGC還會建立 一個影子節點 ,以便應用必要的ACL。 到本地儲存庫中相應卷影節點的路徑是在元件路徑中預先放置卷影節點根路徑的結果:

  • 根路徑= /content/usergenerated
  • 注釋陰影節點= /content/usergenerated/content/community-components/en/comments/jcr:content/content/include/comments

UGC位置

UGC不是在這兩個位置中建立的,且僅應使用叫用SRP API的 公用程式方法 來存取。

  • 根路徑= /content/usergenerated/asi/srp-choice
  • JSRP的UGC節點= /content/usergenerated/asi/jcr/content/community-components/en/comments/jcr:content/content/includable/comments/srzd-let_it_be_

請注意,對於JSRP,UGC節點將只 會出現 (作者或發佈)在輸入AEM例項上。 如果在發佈例項上輸入,則無法從作者的協調控制台進行協調。

本頁內容