SocialGraphFactoryImpl.java
4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.granite.security.user.UserPropertiesService
* javax.jcr.RepositoryException
* org.apache.felix.scr.annotations.Activate
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Property
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.Service
* org.apache.sling.api.resource.ResourceResolver
* org.apache.sling.commons.osgi.OsgiUtil
*/
package com.adobe.granite.socialgraph.impl;
import com.adobe.granite.security.user.UserPropertiesService;
import com.adobe.granite.socialgraph.SocialGraph;
import com.adobe.granite.socialgraph.SocialGraphException;
import com.adobe.granite.socialgraph.impl.JcrSocialGraph;
import com.adobe.granite.socialgraph.impl.SocialGraphConfig;
import com.adobe.granite.socialgraph.impl.SocialGraphFactory;
import java.util.Map;
import javax.jcr.RepositoryException;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.commons.osgi.OsgiUtil;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
@Component(metatype=1, label="Adobe Granite Social Graph Factory", description="Factory service that configures and creates the social graph bindings.")
@Service(value={SocialGraphFactory.class})
public class SocialGraphFactoryImpl
implements SocialGraphFactory {
@Property(value={"following"}, label="GroupToMember RT", description="Defines the relationship type between a group and his group member.")
static final String GROUP_2_MEMBER_RS_OUTGOING = "group2member.relationship.outgoing";
@Property(value={}, label="Excluded GroupToMember", cardinality=Integer.MAX_VALUE, description="Defines the groups that do not create relationships to their group members.")
static final String GROUP_2_MEMBER_EX_OUTGOING = "group2member.excluded.outgoing";
@Property(value={"member"}, label="GroupFromMember RT", description="Defines the relationship type between a group member and his group.")
static final String GROUP_2_MEMBER_RS_INCOMING = "group2member.relationship.incoming";
@Property(value={"contributor", "content-authors"}, label="Excluded MemberToGroup", cardinality=Integer.MAX_VALUE, description="Defines the groups that do not create relationships from their group members.")
static final String GROUP_2_MEMBER_EX_INCOMING = "group2member.excluded.incoming";
@Reference
private UserPropertiesService upService = null;
private SocialGraphConfig config;
@Activate
private void activate(Map<String, Object> props) {
this.config = new SocialGraphConfig();
this.config.setGroupOutgoingRelationship(OsgiUtil.toString((Object)props.get("group2member.relationship.outgoing"), (String)"following"));
this.config.setOutgoingExcludedGroups(OsgiUtil.toStringArray((Object)props.get("group2member.excluded.outgoing")));
this.config.setGroupIncomingRelationship(OsgiUtil.toString((Object)props.get("group2member.relationship.incoming"), (String)"member"));
this.config.setIncomingExcludedGroups(OsgiUtil.toStringArray((Object)props.get("group2member.excluded.incoming")));
}
@Override
public SocialGraph createSocialGraph(ResourceResolver resolver) {
try {
return new JcrSocialGraph(this.upService, resolver, this.config);
}
catch (RepositoryException e) {
throw new SocialGraphException("Unable to create social graph", (Throwable)e);
}
}
protected void bindUpService(UserPropertiesService userPropertiesService) {
this.upService = userPropertiesService;
}
protected void unbindUpService(UserPropertiesService userPropertiesService) {
if (this.upService == userPropertiesService) {
this.upService = null;
}
}
}