Skip to content

Commit

Permalink
Fix updateProjectGroup method and some typo
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/maven/continuum/trunk@554753 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Emmanuel Venisse committed Jul 9, 2007
1 parent ea5766b commit 9ac8b8f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
4 changes: 4 additions & 0 deletions continuum-xmlrpc/continuum-xmlrpc-server/pom.xml
Expand Up @@ -36,6 +36,10 @@
<groupId>org.apache.maven.continuum</groupId>
<artifactId>continuum-security</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.plexus.redback</groupId>
<artifactId>redback-rbac-role-manager</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.plexus.redback</groupId>
<artifactId>redback-system</artifactId>
Expand Down
Expand Up @@ -42,6 +42,9 @@
import org.apache.maven.continuum.xmlrpc.test.TestCaseFailure;
import org.apache.maven.continuum.xmlrpc.test.TestResult;
import org.codehaus.plexus.redback.authorization.AuthorizationException;
import org.codehaus.plexus.redback.role.RoleManager;
import org.codehaus.plexus.redback.role.RoleManagerException;
import org.codehaus.plexus.util.StringUtils;

import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -63,6 +66,11 @@ public class ContinuumServiceImpl
*/
private Continuum continuum;

/**
* @plexus.requirement role-hint="default"
*/
private RoleManager roleManager;

public boolean ping()
throws ContinuumException
{
Expand Down Expand Up @@ -138,11 +146,11 @@ public ProjectSummary updateProject( ProjectSummary project )

p.setName( project.getName() );
p.setVersion( project.getVersion() );
p.setScmUrl( p.getScmUrl() );
p.setScmUrl( project.getScmUrl() );
p.setScmUseCache( project.isScmUseCache() );
p.setScmUsername( project.getScmUsername() );
p.setScmPassword( project.getScmPassword() );
p.setScmTag( p.getScmTag() );
p.setScmTag( project.getScmTag() );

continuum.updateProject( p );

Expand Down Expand Up @@ -248,9 +256,46 @@ public int removeProjectGroup( int projectGroupId )
public ProjectGroupSummary updateProjectGroup( ProjectGroupSummary projectGroup )
throws ContinuumException
{
if ( projectGroup == null )
{
return null;
}

checkModifyProjectGroupAuthorization( getProjectGroupName( projectGroup.getId() ) );

continuum.updateProjectGroup( populateProjectGroupSummary( projectGroup ) );
if ( StringUtils.isEmpty( projectGroup.getName() ) )
{
throw new ContinuumException( "project group name is required" );
}
else if ( StringUtils.isEmpty( projectGroup.getName().trim() ) )
{
throw new ContinuumException( "project group name can't be spaces" );
}

org.apache.maven.continuum.model.project.ProjectGroup pg =
continuum.getProjectGroupWithProjects( projectGroup.getId() );

// need to administer roles since they are based off of this
// todo convert everything like to work off of string keys
if ( !projectGroup.getName().equals( pg.getName() ) )
{
try
{
roleManager.updateRole( "project-administrator", pg.getName(), projectGroup.getName() );
roleManager.updateRole( "project-developer", pg.getName(), projectGroup.getName() );
roleManager.updateRole( "project-user", pg.getName(), projectGroup.getName() );

pg.setName( projectGroup.getName() );
}
catch ( RoleManagerException e )
{
throw new ContinuumException( "unable to rename the project group", e );
}
}

pg.setDescription( projectGroup.getDescription() );

continuum.updateProjectGroup( pg );
return getProjectGroupSummary( projectGroup.getId() );
}

Expand Down

0 comments on commit 9ac8b8f

Please sign in to comment.