1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugins.ear;
20
21 import org.codehaus.plexus.util.xml.XMLWriter;
22
23
24
25
26
27
28 class SecurityRole {
29
30 protected static final String SECURITY_ROLE = "security-role";
31
32 protected static final String ID_ATTRIBUTE = "id";
33
34 protected static final String DESCRIPTION = "description";
35
36 protected static final String ROLE_NAME = "role-name";
37
38 private final String roleName;
39
40 private final String roleNameId;
41
42 private final String roleId;
43
44 private final String description;
45
46 private final String descriptionId;
47
48 SecurityRole(String roleName, String roleNameId, String roleId, String description, String descriptionId) {
49 if (roleName == null) {
50 throw new NullPointerException("role-name in security-role element could not be null.");
51 }
52 this.roleName = roleName;
53 this.roleNameId = roleNameId;
54 this.roleId = roleId;
55 this.description = description;
56 this.descriptionId = descriptionId;
57 }
58
59 public String getRoleName() {
60 return roleName;
61 }
62
63 public String getRoleNameId() {
64 return roleNameId;
65 }
66
67 public String getRoleId() {
68 return roleId;
69 }
70
71 public String getDescription() {
72 return description;
73 }
74
75 public String getDescriptionId() {
76 return descriptionId;
77 }
78
79
80
81
82
83
84 public void appendSecurityRole(XMLWriter writer) {
85 writer.startElement(SECURITY_ROLE);
86
87
88 if (getRoleId() != null) {
89 writer.addAttribute(ID_ATTRIBUTE, getRoleId());
90 }
91
92
93 if (getDescription() != null) {
94 writer.startElement(DESCRIPTION);
95 if (getDescriptionId() != null) {
96 writer.addAttribute(ID_ATTRIBUTE, getDescriptionId());
97 }
98 writer.writeText(getDescription());
99 writer.endElement();
100 }
101
102
103 writer.startElement(ROLE_NAME);
104 if (getRoleNameId() != null) {
105 writer.addAttribute(ID_ATTRIBUTE, getRoleNameId());
106 }
107 writer.writeText(getRoleName());
108 writer.endElement();
109
110
111 writer.endElement();
112 }
113
114 public String toString() {
115 return "Security role " + getRoleName();
116 }
117 }