1 package org.apache.maven.continuum.core.action;
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.dao.ProjectGroupDao;
23 import org.apache.maven.continuum.ContinuumException;
24 import org.apache.maven.continuum.model.project.ProjectGroup;
25 import org.apache.maven.continuum.store.ContinuumStoreException;
26 import org.codehaus.plexus.redback.role.RoleManager;
27 import org.codehaus.plexus.redback.role.RoleManagerException;
28
29 import java.util.Map;
30
31
32
33
34
35
36
37
38 public class RemoveAssignableRolesAction
39 extends AbstractContinuumAction
40 {
41
42
43
44 private ProjectGroupDao projectGroupDao;
45
46
47
48
49 private RoleManager roleManager;
50
51 public void execute( Map context )
52 throws ContinuumException, ContinuumStoreException
53 {
54 int projectGroupId = getProjectGroupId( context );
55
56 ProjectGroup projectGroup = projectGroupDao.getProjectGroup( projectGroupId );
57
58 try
59 {
60 if ( !roleManager.templatedRoleExists( "project-administrator", projectGroup.getName() ) )
61 {
62 roleManager.removeTemplatedRole( "project-administrator", projectGroup.getName() );
63 }
64 if ( !roleManager.templatedRoleExists( "project-developer", projectGroup.getName() ) )
65 {
66 roleManager.removeTemplatedRole( "project-developer", projectGroup.getName() );
67 }
68
69 if ( !roleManager.templatedRoleExists( "project-user", projectGroup.getName() ) )
70 {
71 roleManager.removeTemplatedRole( "project-user", projectGroup.getName() );
72 }
73 }
74 catch ( RoleManagerException e )
75 {
76 e.printStackTrace();
77 throw new ContinuumException( "error removing templated role for project " + projectGroup.getName(), e );
78 }
79 }
80 }