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 {
54 if ( roleName == null )
55 {
56 throw new NullPointerException( "role-name in security-role element could not be null." );
57 }
58 this.roleName = roleName;
59 this.roleNameId = roleNameId;
60 this.roleId = roleId;
61 this.description = description;
62 this.descriptionId = descriptionId;
63 }
64
65 public String getRoleName()
66 {
67 return roleName;
68 }
69
70 public String getRoleNameId()
71 {
72 return roleNameId;
73 }
74
75 public String getRoleId()
76 {
77 return roleId;
78 }
79
80 public String getDescription()
81 {
82 return description;
83 }
84
85 public String getDescriptionId()
86 {
87 return descriptionId;
88 }
89
90
91
92
93
94
95 public void appendSecurityRole( XMLWriter writer )
96 {
97 writer.startElement( SECURITY_ROLE );
98
99
100 if ( getRoleId() != null )
101 {
102 writer.addAttribute( ID_ATTRIBUTE, getRoleId() );
103 }
104
105
106 if ( getDescription() != null )
107 {
108 writer.startElement( DESCRIPTION );
109 if ( getDescriptionId() != null )
110 {
111 writer.addAttribute( ID_ATTRIBUTE, getDescriptionId() );
112 }
113 writer.writeText( getDescription() );
114 writer.endElement();
115
116 }
117
118
119 writer.startElement( ROLE_NAME );
120 if ( getRoleNameId() != null )
121 {
122 writer.addAttribute( ID_ATTRIBUTE, getRoleNameId() );
123 }
124 writer.writeText( getRoleName() );
125 writer.endElement();
126
127
128 writer.endElement();
129 }
130
131 public String toString()
132 {
133 return "Security role " + getRoleName();
134 }
135
136
137 }