1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kew.api.action; |
17 | |
|
18 | |
import java.io.Serializable; |
19 | |
import java.util.Collection; |
20 | |
import java.util.Collections; |
21 | |
import java.util.Set; |
22 | |
|
23 | |
import javax.xml.bind.annotation.XmlAccessType; |
24 | |
import javax.xml.bind.annotation.XmlAccessorType; |
25 | |
import javax.xml.bind.annotation.XmlAnyElement; |
26 | |
import javax.xml.bind.annotation.XmlElement; |
27 | |
import javax.xml.bind.annotation.XmlElementWrapper; |
28 | |
import javax.xml.bind.annotation.XmlRootElement; |
29 | |
import javax.xml.bind.annotation.XmlType; |
30 | |
|
31 | |
import org.apache.commons.lang.StringUtils; |
32 | |
import org.apache.commons.lang.builder.EqualsBuilder; |
33 | |
import org.apache.commons.lang.builder.HashCodeBuilder; |
34 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
35 | |
import org.kuali.rice.core.api.CoreConstants; |
36 | |
import org.w3c.dom.Element; |
37 | |
|
38 | |
@XmlRootElement(name = AdHocRevoke.Constants.ROOT_ELEMENT_NAME) |
39 | |
@XmlAccessorType(XmlAccessType.NONE) |
40 | |
@XmlType(name = AdHocRevoke.Constants.TYPE_NAME, propOrder = { |
41 | |
AdHocRevoke.Elements.NODE_NAMES, |
42 | |
AdHocRevoke.Elements.PRINCIPAL_IDS, |
43 | |
AdHocRevoke.Elements.GROUP_IDS, |
44 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
45 | |
}) |
46 | |
public final class AdHocRevoke implements Serializable { |
47 | |
|
48 | |
private static final long serialVersionUID = 5848714514445793355L; |
49 | |
|
50 | |
@XmlElementWrapper(name = Elements.NODE_NAMES, required = false) |
51 | |
@XmlElement(name = Elements.NODE_NAME, required = false) |
52 | |
private final Set<String> nodeNames; |
53 | |
|
54 | |
@XmlElementWrapper(name = Elements.PRINCIPAL_IDS, required = false) |
55 | |
@XmlElement(name = Elements.PRINCIPAL_ID, required = false) |
56 | |
private final Set<String> principalIds; |
57 | |
|
58 | |
@XmlElementWrapper(name = Elements.GROUP_IDS, required = false) |
59 | |
@XmlElement(name = Elements.GROUP_ID, required = false) |
60 | |
private final Set<String> groupIds; |
61 | |
|
62 | 0 | @SuppressWarnings("unused") |
63 | |
@XmlAnyElement |
64 | |
private final Collection<Element> _futureElements = null; |
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | 0 | private AdHocRevoke() { |
70 | 0 | this.nodeNames = null; |
71 | 0 | this.principalIds = null; |
72 | 0 | this.groupIds = null; |
73 | 0 | } |
74 | |
|
75 | |
|
76 | 0 | private AdHocRevoke(Set<String> nodeNames, Set<String> principalIds, Set<String> groupIds) { |
77 | 0 | this.nodeNames = nodeNames; |
78 | 0 | this.principalIds = principalIds; |
79 | 0 | this.groupIds = groupIds; |
80 | 0 | } |
81 | |
|
82 | |
public static AdHocRevoke create(Set<String> nodeNames, Set<String> principalIds, Set<String> groupIds) { |
83 | 0 | return new AdHocRevoke(nodeNames, principalIds, groupIds); |
84 | |
} |
85 | |
|
86 | |
public static AdHocRevoke createRevokeFromPrincipal(String principalId) { |
87 | 0 | if (StringUtils.isBlank(principalId)) { |
88 | 0 | throw new IllegalArgumentException("principalId was null or blank"); |
89 | |
} |
90 | 0 | return create(null, Collections.singleton(principalId), null); |
91 | |
} |
92 | |
|
93 | |
public static AdHocRevoke createRevokeFromGroup(String groupId) { |
94 | 0 | if (StringUtils.isBlank(groupId)) { |
95 | 0 | throw new IllegalArgumentException("groupId was null or blank"); |
96 | |
} |
97 | 0 | return create(null, null, Collections.singleton(groupId)); |
98 | |
} |
99 | |
|
100 | |
public static AdHocRevoke createRevokeAtNode(String nodeName) { |
101 | 0 | if (StringUtils.isBlank(nodeName)) { |
102 | 0 | throw new IllegalArgumentException("nodeName was null or blank"); |
103 | |
} |
104 | 0 | return create(Collections.singleton(nodeName), null, null); |
105 | |
} |
106 | |
|
107 | |
public Set<String> getNodeNames() { |
108 | 0 | if (nodeNames == null) { |
109 | 0 | return Collections.emptySet(); |
110 | |
} |
111 | 0 | return Collections.unmodifiableSet(nodeNames); |
112 | |
} |
113 | |
|
114 | |
public Set<String> getPrincipalIds() { |
115 | 0 | if (principalIds == null) { |
116 | 0 | return Collections.emptySet(); |
117 | |
} |
118 | 0 | return Collections.unmodifiableSet(principalIds); |
119 | |
} |
120 | |
|
121 | |
public Set<String> getGroupIds() { |
122 | 0 | if (groupIds == null) { |
123 | 0 | return Collections.emptySet(); |
124 | |
} |
125 | 0 | return Collections.unmodifiableSet(groupIds); |
126 | |
} |
127 | |
|
128 | |
@Override |
129 | |
public int hashCode() { |
130 | 0 | return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
131 | |
} |
132 | |
|
133 | |
@Override |
134 | |
public boolean equals(Object object) { |
135 | 0 | return EqualsBuilder.reflectionEquals(object, this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
136 | |
} |
137 | |
|
138 | |
@Override |
139 | |
public String toString() { |
140 | 0 | return ToStringBuilder.reflectionToString(this); |
141 | |
} |
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | 0 | static class Constants { |
147 | |
final static String ROOT_ELEMENT_NAME = "adHocRevoke"; |
148 | |
final static String TYPE_NAME = "AdHocRevokeType"; |
149 | 0 | final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[] { CoreConstants.CommonElements.FUTURE_ELEMENTS }; |
150 | |
} |
151 | |
|
152 | |
|
153 | |
|
154 | |
|
155 | 0 | static class Elements { |
156 | |
final static String NODE_NAMES = "nodeNames"; |
157 | |
final static String NODE_NAME = "nodeName"; |
158 | |
final static String PRINCIPAL_IDS = "principalIds"; |
159 | |
final static String PRINCIPAL_ID = "principalId"; |
160 | |
final static String GROUP_IDS = "groupIds"; |
161 | |
final static String GROUP_ID = "groupId"; |
162 | |
} |
163 | |
|
164 | |
} |