NotificationUtil.java
2.75 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.day.cq.security.Authorizable
* javax.jcr.Item
* javax.jcr.Node
* javax.jcr.RepositoryException
* javax.jcr.Session
*/
package com.day.cq.wcm.notification;
import com.day.cq.security.Authorizable;
import java.util.Map;
import javax.jcr.Item;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
public abstract class NotificationUtil {
public static final String PROPERTY_CHANNEL_TYPE = "type";
public static final String PROPERTY_CHANNEL_NAME = "channel";
public static final String PROPERTY_SUBSCRIPTION_TYPE = "type";
public static String getChannelType(Map channelConfig) {
return null != channelConfig ? (String)channelConfig.get("type") : null;
}
public static String getChannelName(Map subscriptionConfig) {
return null != subscriptionConfig ? (String)subscriptionConfig.get("channel") : null;
}
public static String getSubscriptionType(Map subscriptionConfig) {
return null != subscriptionConfig ? (String)subscriptionConfig.get("type") : null;
}
public static Node getNotificationNode(Authorizable authorizable) throws RepositoryException {
Node n = (Node)authorizable.adaptTo(Node.class);
if (n != null) {
return NotificationUtil.getNotificationNode(authorizable, n.getSession());
}
return null;
}
public static Node getNotificationNode(Authorizable authorizable, Session s) throws RepositoryException {
Node productNode;
Node authorizableHome = (Node)s.getItem(authorizable.getHomePath());
boolean save = false;
if (!authorizableHome.hasNode("wcm")) {
authorizableHome.addNode("wcm", "sling:Folder");
save = true;
}
if (!(productNode = authorizableHome.getNode("wcm")).hasNode("notification")) {
productNode.addNode("notification", "sling:Folder");
save = true;
}
if (save) {
s.save();
}
return productNode.getNode("notification");
}
public static Node getNotificationNode(String authorizablePath, Session s) throws RepositoryException {
Node productNode;
Node authorizableHome = (Node)s.getItem(authorizablePath);
boolean save = false;
if (!authorizableHome.hasNode("wcm")) {
authorizableHome.addNode("wcm", "sling:Folder");
save = true;
}
if (!(productNode = authorizableHome.getNode("wcm")).hasNode("notification")) {
productNode.addNode("notification", "sling:Folder");
save = true;
}
if (save) {
s.save();
}
return productNode.getNode("notification");
}
}