1 package org.apache.maven.plugins.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 class SecurityRole
30 {
31
32 protected static final String SECURITY_ROLE = "security-role";
33
34 protected static final String ID_ATTRIBUTE = "id";
35
36 protected static final String DESCRIPTION = "description";
37
38 protected static final String ROLE_NAME = "role-name";
39
40 private final String roleName;
41
42 private final String roleNameId;
43
44 private final String roleId;
45
46 private final String description;
47
48 private final String descriptionId;
49
50 SecurityRole( String roleName, String roleNameId, String roleId, String description, String descriptionId )
51 {
52 if ( roleName == null )
53 {
54 throw new NullPointerException( "role-name in security-role element could not be null." );
55 }
56 this.roleName = roleName;
57 this.roleNameId = roleNameId;
58 this.roleId = roleId;
59 this.description = description;
60 this.descriptionId = descriptionId;
61 }
62
63 public String getRoleName()
64 {
65 return roleName;
66 }
67
68 public String getRoleNameId()
69 {
70 return roleNameId;
71 }
72
73 public String getRoleId()
74 {
75 return roleId;
76 }
77
78 public String getDescription()
79 {
80 return description;
81 }
82
83 public String getDescriptionId()
84 {
85 return descriptionId;
86 }
87
88
89
90
91
92
93 public void appendSecurityRole( XMLWriter writer )
94 {
95 writer.startElement( SECURITY_ROLE );
96
97
98 if ( getRoleId() != null )
99 {
100 writer.addAttribute( ID_ATTRIBUTE, getRoleId() );
101 }
102
103
104 if ( getDescription() != null )
105 {
106 writer.startElement( DESCRIPTION );
107 if ( getDescriptionId() != null )
108 {
109 writer.addAttribute( ID_ATTRIBUTE, getDescriptionId() );
110 }
111 writer.writeText( getDescription() );
112 writer.endElement();
113
114 }
115
116
117 writer.startElement( ROLE_NAME );
118 if ( getRoleNameId() != null )
119 {
120 writer.addAttribute( ID_ATTRIBUTE, getRoleNameId() );
121 }
122 writer.writeText( getRoleName() );
123 writer.endElement();
124
125
126 writer.endElement();
127 }
128
129 public String toString()
130 {
131 return "Security role " + getRoleName();
132 }
133
134 }