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