구성원이 커뮤니티 기능과 상호 작용할 때 알림 또는 게임화(점수 및 배지)와 같은 비동기 리스너를 트리거할 수 있는 OSGi 이벤트가 전송됩니다.
구성 요소의 SocialEvent 인스턴스는 actions
그것은 topic
. SocialEvent에는 verb
관련 작업을 수행한 후, 다음 항목이 있습니다 n-1 관계 간 actions
및 verbs
.
릴리스에서 제공되는 Communities 구성 요소의 경우 다음 표에서는 verbs
각 topic
사용할 수 있습니다.
달력 구성 요소
SocialEvent topic
= com/adobe/cq/social/calendar
동사 | 설명 |
---|---|
POST | 구성원이 달력 이벤트를 만듭니다. |
추가 | 달력 이벤트에 대한 구성원 댓글 |
업데이트 | 구성원의 달력 이벤트 또는 댓글이 편집됨 |
삭제 | 구성원의 달력 이벤트 또는 주석이 삭제됩니다. |
댓글 구성 요소
SocialEvent topic
= com/adobe/cq/social/comment
동사 | 설명 |
---|---|
POST | 멤버가 주석 만들기 |
추가 | 댓글 달기 |
업데이트 | 구성원의 댓글이 편집되었습니다. |
삭제 | 구성원 주석이 삭제되었습니다. |
파일 라이브러리 구성 요소
SocialEvent topic
= com/adobe/cq/social/fileLibrary
동사 | 설명 |
---|---|
POST | 구성원이 폴더를 만듭니다. |
첨부 | 구성원이 파일을 업로드합니다. |
업데이트 | 구성원이 폴더 또는 파일을 업데이트합니다 |
삭제 | 구성원이 폴더 또는 파일을 삭제합니다. |
포럼 구성 요소
SocialEvent topic
= com/adobe/cq/social/forum
동사 | 설명 |
---|---|
POST | 구성원이 포럼 주제 작성 |
추가 | 포럼 주제에 대한 회신 |
업데이트 | 구성원의 포럼 주제 또는 응답이 편집됨 |
삭제 | 구성원의 포럼 주제 또는 응답이 삭제됨 |
분개 구성 요소
SocialEvent topic
= com/adobe/cq/social/journal
동사 | 설명 |
---|---|
POST | 구성원이 블로그 문서를 만듭니다. |
추가 | 블로그 문서에 대한 구성원 댓글 |
업데이트 | 구성원의 블로그 기사 또는 댓글이 편집됨 |
삭제 | 구성원의 블로그 문서 또는 댓글이 삭제됨 |
QnA 구성 요소
SocialEvent topic
= com/adobe/cq/social/qna
동사 | 설명 |
---|---|
POST | 구성원이 QnA 질문을 만듭니다. |
추가 | 멤버가 QnA 응답을 생성합니다. |
업데이트 | 구성원의 QnA 질문 또는 답변이 편집됨 |
선택 | 멤버 답변 선택 |
선택 취소 | 멤버 응답 선택 취소 |
삭제 | 구성원의 QnA 질문 또는 답변이 삭제됩니다. |
구성 요소 검토
SocialEvent topic
= com/adobe/cq/social/review
동사 | 설명 |
---|---|
POST | 멤버 검토 만들기 |
업데이트 | 구성원 검토 편집 |
삭제 | 구성원 검토 삭제 |
등급 구성 요소
SocialEvent topic
= com/adobe/cq/social/tally
동사 | 설명 |
---|---|
등급 추가 | 구성원의 콘텐츠가 평가되었습니다. |
등급 제거 | 구성원의 콘텐츠가 다운되었습니다. |
투표 구성 요소
SocialEvent topic
= com/adobe/cq/social/tally
동사 | 설명 |
---|---|
투표 추가 | 회원의 컨텐츠가 투표되었다 |
투표 제거 | 회원의 컨텐츠가 부결되었다 |
중재 사용 구성 요소
SocialEvent topic
= com/adobe/cq/social/moderation
동사 | 설명 |
---|---|
거부 | 구성원의 콘텐츠가 거부됨 |
기가 부적절한 | 구성원의 컨텐츠에 플래그가 지정됩니다. |
부적절한 플래그 지정 | 구성원의 컨텐츠가 플래그가 지정되지 않았습니다. |
수락 | 조정자가 회원 콘텐츠를 승인함 |
닫기 | 구성원이 편집 및 회신에 대한 댓글 닫기 |
열기 | 구성원 주석 다시 열기 |
사용자 지정 구성 요소의 경우 SocialEvent 추상 클래스 구성 요소의 이벤트를 actions
그것은 topic
.
사용자 지정 이벤트는 메서드를 재정의합니다 getVerb()
그래서 적절한 verb
에 대해 반환됨 action
. 다음 verb
작업에 대해 반환되는 것은 일반적으로 사용되는 것(예: POST
) 또는 각 구성 요소의 전문( 예: ADD RATING
). 다음 항목이 있습니다 n-1 관계 간 actions
및 verbs
.
사용자 지정 확장이 제품의 기존 구현보다 낮은 등급을 사용하여 등록되었는지 확인합니다.
org.osgi.service.event.Event;
com.adobe.cq.social.scf.core.SocialEvent;
com.adobe.granite.activitystreams.ObjectTypes;
com.adobe.granite.activitystreams.Verbs;
package com.mycompany.recipe;
import org.osgi.service.event.Event;
import com.adobe.cq.social.scf.core.SocialEvent;
import com.adobe.granite.activitystreams.ObjectTypes;
import com.adobe.granite.activitystreams.Verbs;
/*
* The Recipe type, passed to RecipeEvent(), would be a custom Recipe class
* that extends either
* com.adobe.cq.social.scf.SocialComponent
* or
* com.adobe.cq.social.scf.SocialCollectionComponent
* See https://docs.adobe.com/docs/en/aem/6-2/develop/communities/scf/server-customize.html
*/
/**
* Defines events that are triggered on a custom component, "Recipe".
*/
public class RecipeEvent extends SocialEvent<RecipeEvent.RecipeActions> {
private static final long serialVersionUID = 1L;
protected static final String PARENT_PATH = "PARENT_PATH";
/**
* The event topic suffix for Recipe events
*/
public static final String RECIPE_TOPIC = "recipe";
/**
* @param recipe - the recipe resource on which the event was triggered
* @param userId - the user id of the user who triggered the action
* @param action - the recipe action that triggered this event
*/
public RecipeEvent(final Recipe recipe, final String userId, final RecipeEvent.RecipeActions action) {
String recipePath = recipe.getResource().getPath();
String parentPath = (recipe.getParentComponent() != null) ?
recipe.getParentComponent().getResource().getPath() :
recipe.getSourceComponentId();
this(recipePath, userId, parentPath, action);
}
/**
* @param recipePath - the path to the recipe resource (jcr node) on which the event was triggered
* @param userId - the user id of the user who triggered the action
* @param parentPath - the path to the parent node of the recipe resource
* @param action - the recipe action that triggered this event
*/
public RecipeEvent(final String recipePath, final String userId, final String parentPath) {
super(RECIPE_TOPIC, recipePath, userId, action,
new BaseEventObject(recipePath, ObjectTypes.ARTICLE),
new BaseEventObject(parentPath, ObjectTypes.COLLECTION),
new HashMap<String, Object>(1) {
private static final long serialVersionUID = 1L;
{
if (parentPath != null) {
this.put(PARENT_PATH, parentPath);
}
}
});
}
private RecipeEvent (final Event event) {
super(event);
}
/**
* List of available recipe actions that can trigger a recipe event.
*/
public static enum RecipeActions implements SocialEvent.SocialActions {
RecipeAdded,
RecipeModified,
RecipeDeleted;
@Override
public String getVerb() {
switch (this) {
case RecipeAdded:
return Verbs.POST;
case RecipeModified:
return Verbs.UPDATE;
case RecipeDeleted:
return Verbs.DELETE;
default:
throw new IllegalArgumentException("Unsupported action");
}
}
}
}
활동 스트림에 표시되는 내용을 수정하기 위해 이벤트를 수신할 수 있습니다.
다음 의사 코드 샘플은 활동 스트림에서 댓글 구성 요소에 대한 DELETE 이벤트를 제거합니다.
필요한 경우 최신 기능 팩.
package my.company.comments;
import java.util.Collections;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Modified;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.commons.osgi.PropertiesUtil;
import org.osgi.service.component.ComponentContext;
import com.adobe.cq.social.activitystreams.listener.api.ActivityStreamProviderExtension;
import com.adobe.cq.social.commons.events.CommentEvent.CommentActions;
import com.adobe.cq.social.scf.core.SocialEvent;
@Service
@Component(metatype = true, label = "My Comment Delete Event Filter",
description = "Prevents comment DELETE events from showing up in activity streams")
public class CommentDeleteEventActivityFilter implements ActivityStreamProviderExtension {
@Property(name = "ranking", intValue = 10)
protected int ranking;
@Activate
public void activate(final ComponentContext ctx) {
ranking = PropertiesUtil.toInteger(ctx.getProperties().get("ranking"), 10);
}
@Modified
public void update(final Map<String, Object> props) {
ranking = PropertiesUtil.toInteger(props.get("ranking"), 10);
}
@Override
public boolean evaluate(final SocialEvent<?> evt, final Resource resource) {
if (evt.getAction() != null && evt.getAction() instanceof SocialEvent.SocialActions) {
final SocialEvent.SocialActions action = evt.getAction();
if (StringUtils.equals(action.getVerb(), CommentActions.DELETED.getVerb())) {
return false;
}
}
return true;
}
@Override
public Map<String, ? extends Object> getActivityProperties(final SocialEvent<?> arg0, final Resource arg1) {
return Collections.<String, Object>emptyMap();
}
@Override
public Map<String, ? extends Object> getActorProperties(final SocialEvent<?> arg0, final Resource arg1) {
return Collections.<String, Object>emptyMap();
}
@Override
public String getName() {
return "My Comment Delete Event Filter";
}
@Override
public Map<String, ? extends Object> getObjectProperties(final SocialEvent<?> arg0, final Resource arg1) {
return Collections.<String, Object>emptyMap();
}
/* Ensure a custom extension is registered with a ranking lower than any existing implementation in the product. */
@Override
public int getRanking() {
return this.ranking;
}
@Override
public Map<String, ? extends Object> getTargetProperties(final SocialEvent<?> arg0, final Resource arg1) {
return Collections.<String, Object>emptyMap();
}
@Override
public String[] getStreamProviderPid() {
return new String[]{"*"};
}
}