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.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
39 public class DeleteGroupNotifierAction
40 extends ContinuumActionSupport
41 {
42 private int projectGroupId;
43
44 private int notifierId;
45
46 private String notifierType;
47
48 private String recipient;
49
50 private String projectGroupName = "";
51
52 public String execute()
53 throws ContinuumException
54 {
55 try
56 {
57 checkRemoveProjectGroupNotifierAuthorization( getProjectGroupName() );
58 }
59 catch ( AuthorizationRequiredException authzE )
60 {
61 addActionError( authzE.getMessage() );
62 return REQUIRES_AUTHORIZATION;
63 }
64
65 getContinuum().removeGroupNotifier( projectGroupId, notifierId );
66
67 return SUCCESS;
68 }
69
70 public String doDefault()
71 throws ContinuumException
72 {
73 try
74 {
75 checkRemoveProjectGroupNotifierAuthorization( getProjectGroupName() );
76 }
77 catch ( AuthorizationRequiredException authzE )
78 {
79 addActionError( authzE.getMessage() );
80 return REQUIRES_AUTHORIZATION;
81 }
82
83 ProjectNotifier notifier = getContinuum().getGroupNotifier( projectGroupId, notifierId );
84
85 notifierType = notifier.getType();
86
87 recipient = GenerateRecipentNotifier.generate( notifier );
88
89 return "delete";
90 }
91
92 public void setNotifierId( int notifierId )
93 {
94 this.notifierId = notifierId;
95 }
96
97 public int getNotifierId()
98 {
99 return notifierId;
100 }
101
102 public void setNotifierType( String notifierType )
103 {
104 this.notifierType = notifierType;
105 }
106
107 public String getNotifierType()
108 {
109 return notifierType;
110 }
111
112
113
114
115 public int getProjectGroupId()
116 {
117 return projectGroupId;
118 }
119
120
121
122
123 public void setProjectGroupId( int projectGroupId )
124 {
125 this.projectGroupId = projectGroupId;
126 }
127
128 public int getProjectId()
129 {
130
131 return -1;
132 }
133
134 public String getRecipient()
135 {
136 return recipient;
137 }
138
139 public void setRecipient( String recipient )
140 {
141 this.recipient = recipient;
142 }
143
144 public String getProjectGroupName()
145 throws ContinuumException
146 {
147 if ( StringUtils.isEmpty( projectGroupName ) )
148 {
149 projectGroupName = getContinuum().getProjectGroup( projectGroupId ).getName();
150 }
151
152 return projectGroupName;
153 }
154 }