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.continuum.web.util.GenerateRecipentNotifier;
23 import org.apache.maven.continuum.ContinuumException;
24 import org.apache.maven.continuum.model.project.Project;
25 import org.apache.maven.continuum.model.project.ProjectGroup;
26 import org.apache.maven.continuum.model.project.ProjectNotifier;
27 import org.apache.maven.continuum.web.action.ContinuumActionSupport;
28 import org.apache.maven.continuum.web.exception.AuthorizationRequiredException;
29 import org.codehaus.plexus.util.StringUtils;
30
31
32
33
34
35
36
37
38 public class DeleteProjectNotifierAction
39 extends ContinuumActionSupport
40 {
41 private int projectId;
42
43
44
45
46 private int projectGroupId;
47
48 private int notifierId;
49
50 private String notifierType;
51
52 private String recipient;
53
54 private boolean fromGroupPage = false;
55
56 private String projectGroupName = "";
57
58 public String execute()
59 throws ContinuumException
60 {
61 try
62 {
63 checkRemoveProjectNotifierAuthorization( getProjectGroupName() );
64 }
65 catch ( AuthorizationRequiredException authzE )
66 {
67 addActionError( authzE.getMessage() );
68 return REQUIRES_AUTHORIZATION;
69 }
70
71 getContinuum().removeNotifier( projectId, notifierId );
72
73 if ( fromGroupPage )
74 {
75 return "to_group_page";
76 }
77
78 return SUCCESS;
79 }
80
81 public String doDefault()
82 throws ContinuumException
83 {
84 try
85 {
86 checkRemoveProjectNotifierAuthorization( getProjectGroupName() );
87 }
88 catch ( AuthorizationRequiredException authzE )
89 {
90 addActionError( authzE.getMessage() );
91 return REQUIRES_AUTHORIZATION;
92 }
93
94 ProjectNotifier notifier = getContinuum().getNotifier( projectId, notifierId );
95
96 notifierType = notifier.getType();
97
98 recipient = GenerateRecipentNotifier.generate( notifier );
99
100 return "delete";
101 }
102
103 public void setProjectId( int projectId )
104 {
105 this.projectId = projectId;
106 }
107
108 public int getProjectId()
109 {
110 return projectId;
111 }
112
113 public void setNotifierId( int notifierId )
114 {
115 this.notifierId = notifierId;
116 }
117
118 public int getNotifierId()
119 {
120 return notifierId;
121 }
122
123 public void setNotifierType( String notifierType )
124 {
125 this.notifierType = notifierType;
126 }
127
128 public String getNotifierType()
129 {
130 return notifierType;
131 }
132
133 public int getProjectGroupId()
134 {
135 return projectGroupId;
136 }
137
138 public void setProjectGroupId( int projectGroupId )
139 {
140 this.projectGroupId = projectGroupId;
141 }
142
143 public String getRecipient()
144 {
145 return recipient;
146 }
147
148 public void setRecipient( String recipient )
149 {
150 this.recipient = recipient;
151 }
152
153 public boolean isFromGroupPage()
154 {
155 return fromGroupPage;
156 }
157
158 public void setFromGroupPage( boolean fromGroupPage )
159 {
160 this.fromGroupPage = fromGroupPage;
161 }
162
163 public String getProjectGroupName()
164 throws ContinuumException
165 {
166 if ( StringUtils.isEmpty( projectGroupName ) )
167 {
168 if ( projectGroupId != 0 )
169 {
170 projectGroupName = getContinuum().getProjectGroup( projectGroupId ).getName();
171 }
172 else
173 {
174 projectGroupName = getContinuum().getProjectGroupByProjectId( projectId ).getName();
175 }
176 }
177
178 return projectGroupName;
179 }
180 }