1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.impl.jaxb;
17
18 import java.io.Serializable;
19 import java.util.HashMap;
20 import java.util.Map;
21
22 import javax.xml.bind.annotation.XmlAccessType;
23 import javax.xml.bind.annotation.XmlAccessorType;
24 import javax.xml.bind.annotation.XmlElement;
25 import javax.xml.bind.annotation.XmlTransient;
26 import javax.xml.bind.annotation.XmlType;
27 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
28
29 import org.kuali.rice.core.util.jaxb.NameAndNamespacePair;
30 import org.kuali.rice.core.util.jaxb.NameAndNamespacePairValidatingAdapter;
31 import org.kuali.rice.core.util.jaxb.StringTrimmingAdapter;
32 import org.kuali.rice.kim.api.jaxb.NameAndNamespacePairToPermTemplateIdAdapter;
33 import org.kuali.rice.kim.api.jaxb.PermissionDetailListAdapter;
34 import org.kuali.rice.kim.api.permission.PermissionContract;
35
36
37
38
39
40
41 @XmlAccessorType(XmlAccessType.FIELD)
42 @XmlType(name="PermissionType", propOrder={
43 "permissionNameAndNamespace", "permissionTemplateId", "permissionDescription", "active", "permissionDetails"
44 })
45 public class PermissionXmlDTO implements Serializable {
46
47 private static final long serialVersionUID = 1L;
48
49 @XmlTransient
50 private String permissionId;
51
52 @XmlElement(name="permissionName")
53 @XmlJavaTypeAdapter(NameAndNamespacePairValidatingAdapter.class)
54 private NameAndNamespacePair permissionNameAndNamespace;
55
56 @XmlElement(name="templateName")
57 @XmlJavaTypeAdapter(NameAndNamespacePairToPermTemplateIdAdapter.class)
58 private String permissionTemplateId;
59
60 @XmlElement(name="description")
61 @XmlJavaTypeAdapter(StringTrimmingAdapter.class)
62 private String permissionDescription;
63
64 @XmlElement(name="active")
65 private Boolean active;
66
67 @XmlElement(name="permissionDetails")
68 @XmlJavaTypeAdapter(PermissionDetailListAdapter.class)
69 private Map<String, String> permissionDetails;
70
71 public PermissionXmlDTO() {
72 this.active = Boolean.TRUE;
73 }
74
75 public PermissionXmlDTO(PermissionContract permission) {
76 this.permissionNameAndNamespace = new NameAndNamespacePair(permission.getNamespaceCode(), permission.getName());
77 this.permissionTemplateId = permission.getTemplate().getId();
78 this.permissionDescription = permission.getDescription();
79 this.active = Boolean.valueOf(permission.isActive());
80 this.permissionDetails = (permission.getAttributes() != null) ?
81 new HashMap<String, String>(permission.getAttributes()) : new HashMap<String, String>();
82 }
83
84
85
86
87 public String getPermissionId() {
88 return this.permissionId;
89 }
90
91
92
93
94 public void setPermissionId(String permissionId) {
95 this.permissionId = permissionId;
96 }
97
98
99
100
101 public NameAndNamespacePair getPermissionNameAndNamespace() {
102 return this.permissionNameAndNamespace;
103 }
104
105
106
107
108 public void setPermissionNameAndNamespace(NameAndNamespacePair permissionNameAndNamespace) {
109 this.permissionNameAndNamespace = permissionNameAndNamespace;
110 }
111
112
113
114
115 public String getPermissionTemplateId() {
116 return this.permissionTemplateId;
117 }
118
119
120
121
122 public void setPermissionTemplateId(String permissionTemplateId) {
123 this.permissionTemplateId = permissionTemplateId;
124 }
125
126
127
128
129 public String getPermissionDescription() {
130 return this.permissionDescription;
131 }
132
133
134
135
136 public void setPermissionDescription(String permissionDescription) {
137 this.permissionDescription = permissionDescription;
138 }
139
140
141
142
143 public Boolean getActive() {
144 return this.active;
145 }
146
147
148
149
150 public void setActive(Boolean active) {
151 this.active = active;
152 }
153
154
155
156
157 public Map<String, String> getPermissionDetails() {
158 return this.permissionDetails;
159 }
160
161
162
163
164 public void setPermissionDetails(Map<String, String> permissionDetails) {
165 this.permissionDetails = permissionDetails;
166 }
167
168
169
170
171
172
173 public String getPermissionName() {
174 return (permissionNameAndNamespace != null) ? permissionNameAndNamespace.getName() : null;
175 }
176
177
178
179
180
181
182 public String getNamespaceCode() {
183 return (permissionNameAndNamespace != null) ? permissionNameAndNamespace.getNamespaceCode() : null;
184 }
185 }