1 package org.apache.maven.continuum.web.action.notifier;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.continuum.ContinuumException;
23 import org.apache.maven.continuum.model.project.Project;
24 import org.apache.maven.continuum.model.project.ProjectGroup;
25 import org.apache.maven.continuum.model.project.ProjectNotifier;
26 import org.apache.maven.continuum.web.action.ContinuumActionSupport;
27 import org.apache.maven.continuum.web.exception.AuthorizationRequiredException;
28 import org.codehaus.plexus.util.StringUtils;
29
30
31
32
33
34
35
36
37
38 public class AddProjectNotifierAction
39 extends ContinuumActionSupport
40 {
41
42
43
44 private int projectId;
45
46
47
48
49 private int projectGroupId;
50
51
52
53
54 private String notifierType;
55
56
57
58
59
60 private boolean fromGroupPage = false;
61
62 private String projectGroupName = "";
63
64
65
66
67
68
69
70 public String execute()
71 throws ContinuumException
72 {
73 try
74 {
75 checkAddProjectNotifierAuthorization( getProjectGroupName() );
76 }
77 catch ( AuthorizationRequiredException authzE )
78 {
79 addActionError( authzE.getMessage() );
80 return REQUIRES_AUTHORIZATION;
81 }
82
83 return notifierType + "_" + INPUT;
84 }
85
86
87 public String doDefault()
88 throws ContinuumException
89 {
90 return input();
91 }
92
93 public String input()
94 throws ContinuumException
95 {
96 try
97 {
98 checkAddProjectNotifierAuthorization( getProjectGroupName() );
99 }
100 catch ( AuthorizationRequiredException authzE )
101 {
102 addActionError( authzE.getMessage() );
103 return REQUIRES_AUTHORIZATION;
104 }
105
106 return INPUT;
107 }
108
109
110
111
112
113
114 public String getNotifierType()
115 {
116 return notifierType;
117 }
118
119
120
121
122
123
124 public void setNotifierType( String notifierType )
125 {
126 this.notifierType = notifierType;
127 }
128
129
130
131
132
133
134 public int getProjectId()
135 {
136 return projectId;
137 }
138
139
140
141
142
143
144
145 public void setProjectId( int projectId )
146 {
147 this.projectId = projectId;
148 }
149
150
151
152
153
154
155
156 public int getProjectGroupId()
157 {
158 return projectGroupId;
159 }
160
161
162
163
164
165
166
167 public void setProjectGroupId( int projectGroupId )
168 {
169 this.projectGroupId = projectGroupId;
170 }
171
172
173
174
175 public boolean isFromGroupPage()
176 {
177 return fromGroupPage;
178 }
179
180
181
182
183 public void setFromGroupPage( boolean fromGroupPage )
184 {
185 this.fromGroupPage = fromGroupPage;
186 }
187
188 public String getProjectGroupName()
189 throws ContinuumException
190 {
191 if ( StringUtils.isEmpty( projectGroupName ) )
192 {
193 if ( projectGroupId != 0 )
194 {
195 projectGroupName = getContinuum().getProjectGroup( projectGroupId ).getName();
196 }
197 else
198 {
199 projectGroupName = getContinuum().getProjectGroupByProjectId( projectId ).getName();
200 }
201 }
202
203 return projectGroupName;
204 }
205 }