continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r554617 - in /maven/continuum/trunk/continuum-xmlrpc: continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ continuum-xmlrpc-server/src/main/jav...
Date Mon, 09 Jul 2007 12:29:53 GMT
Author: evenisse
Date: Mon Jul  9 05:29:52 2007
New Revision: 554617

URL: http://svn.apache.org/viewvc?view=rev&rev=554617
Log:
Add methods to retrieve all project groups and to update build definitions

Modified:
    maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java
    maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java
    maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/AbstractContinuumSecureService.java
    maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java

Modified: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java?view=diff&rev=554617&r1=554616&r2=554617
==============================================================================
--- maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java
(original)
+++ maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java
Mon Jul  9 05:29:52 2007
@@ -21,6 +21,7 @@
 
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.xmlrpc.project.AddingResult;
+import org.apache.maven.continuum.xmlrpc.project.BuildDefinition;
 import org.apache.maven.continuum.xmlrpc.project.BuildResult;
 import org.apache.maven.continuum.xmlrpc.project.Project;
 import org.apache.maven.continuum.xmlrpc.project.ProjectGroup;
@@ -98,6 +99,26 @@
     // ----------------------------------------------------------------------
 
     /**
+     * Get all project groups.
+     *
+     * @return All project groups
+     * @throws ContinuumException
+     * @throws XmlRpcException
+     */
+    List getAllProjectGroups()
+        throws ContinuumException, XmlRpcException;
+
+    /**
+     * Get all project groups with all details.
+     *
+     * @return All project groups
+     * @throws ContinuumException
+     * @throws XmlRpcException
+     */
+    List getAllProjectGroupsWithProjects()
+        throws ContinuumException, XmlRpcException;
+
+    /**
      * Get a project group.
      *
      * @param projectGroupId The project group id
@@ -163,6 +184,28 @@
      * @throws XmlRpcException
      */
     List getBuildDefinitionsForProjectGroup( int projectGroupId )
+        throws ContinuumException, XmlRpcException;
+
+    /**
+     * Update a project buildDefinition.
+     *
+     * @param projectId The project id
+     * @param buildDef  The build defintion to update
+     * @throws ContinuumException
+     * @throws XmlRpcException
+     */
+    BuildDefinition updateBuildDefinitionForProject( int projectId, BuildDefinition buildDef
)
+        throws ContinuumException, XmlRpcException;
+
+    /**
+     * Update a project group buildDefinition.
+     *
+     * @param projectGroupId The project group id
+     * @param buildDef       The build defintion to update
+     * @throws ContinuumException
+     * @throws XmlRpcException
+     */
+    BuildDefinition updateBuildDefinitionForProjectGroup( int projectGroupId, BuildDefinition
buildDef )
         throws ContinuumException, XmlRpcException;
 
     // ----------------------------------------------------------------------

Modified: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java?view=diff&rev=554617&r1=554616&r2=554617
==============================================================================
--- maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java
(original)
+++ maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java
Mon Jul  9 05:29:52 2007
@@ -22,6 +22,7 @@
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.xmlrpc.ContinuumService;
 import org.apache.maven.continuum.xmlrpc.project.AddingResult;
+import org.apache.maven.continuum.xmlrpc.project.BuildDefinition;
 import org.apache.maven.continuum.xmlrpc.project.BuildResult;
 import org.apache.maven.continuum.xmlrpc.project.ContinuumProjectState;
 import org.apache.maven.continuum.xmlrpc.project.Project;
@@ -196,6 +197,32 @@
     // Projects Groups
     // ----------------------------------------------------------------------
 
+    public List getAllProjectGroups()
+        throws ContinuumException, XmlRpcException
+    {
+        try
+        {
+            return continuum.getAllProjectGroups();
+        }
+        catch ( Exception e )
+        {
+            throw new ContinuumException( "The remote method failed.", e );
+        }
+    }
+
+    public List getAllProjectGroupsWithProjects()
+        throws ContinuumException, XmlRpcException
+    {
+        try
+        {
+            return continuum.getAllProjectGroupsWithProjects();
+        }
+        catch ( Exception e )
+        {
+            throw new ContinuumException( "The remote method failed.", e );
+        }
+    }
+
     public ProjectGroupSummary getProjectGroupSummary( int projectGroupId )
         throws ContinuumException
     {
@@ -291,6 +318,32 @@
         try
         {
             return continuum.getBuildDefinitionsForProjectGroup( projectGroupId );
+        }
+        catch ( Exception e )
+        {
+            throw new ContinuumException( "The remote method failed.", e );
+        }
+    }
+
+    public BuildDefinition updateBuildDefinitionForProject( int projectId, BuildDefinition
buildDef )
+        throws ContinuumException, XmlRpcException
+    {
+        try
+        {
+            return continuum.updateBuildDefinitionForProject( projectId, buildDef );
+        }
+        catch ( Exception e )
+        {
+            throw new ContinuumException( "The remote method failed.", e );
+        }
+    }
+
+    public BuildDefinition updateBuildDefinitionForProjectGroup( int projectGroupId, BuildDefinition
buildDef )
+        throws ContinuumException, XmlRpcException
+    {
+        try
+        {
+            return continuum.updateBuildDefinitionForProjectGroup( projectGroupId, buildDef
);
         }
         catch ( Exception e )
         {

Modified: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/AbstractContinuumSecureService.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/AbstractContinuumSecureService.java?view=diff&rev=554617&r1=554616&r2=554617
==============================================================================
--- maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/AbstractContinuumSecureService.java
(original)
+++ maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/AbstractContinuumSecureService.java
Mon Jul  9 05:29:52 2007
@@ -97,6 +97,49 @@
     }
 
     /**
+     * Verify if the current user is authorized to do the action
+     *
+     * @param role     the role
+     * @param resource the operation resource
+     * @return true if the user is authorized
+     * @throws AuthorizationException if the authorizing request generate an error
+     */
+    protected boolean isAuthorized( String role, String resource )
+        throws AuthorizationException
+    {
+        return isAuthorized( role, resource, true );
+    }
+
+    /**
+     * Verify if the current user is authorized to do the action
+     *
+     * @param role             the role
+     * @param resource         the operation resource
+     * @param requiredResource true if resource can't be null
+     * @return true if the user is authorized
+     * @throws AuthorizationException if the authorizing request generate an error
+     */
+    protected boolean isAuthorized( String role, String resource, boolean requiredResource
)
+        throws AuthorizationException
+    {
+        if ( resource != null && StringUtils.isNotEmpty( resource.trim() ) )
+        {
+            if ( !getSecuritySystem().isAuthorized( config.getSecuritySession(), role, resource
) )
+            {
+                return false;
+            }
+        }
+        else
+        {
+            if ( requiredResource || !getSecuritySystem().isAuthorized( config.getSecuritySession(),
role ) )
+            {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
      * Check if the current user is authorized to do the action
      *
      * @param role             the role
@@ -109,19 +152,9 @@
     {
         try
         {
-            if ( resource != null && StringUtils.isNotEmpty( resource.trim() ) )
-            {
-                if ( !getSecuritySystem().isAuthorized( config.getSecuritySession(), role,
resource ) )
-                {
-                    throw new ContinuumException( "You're not authorized to execute this
action." );
-                }
-            }
-            else
+            if ( !isAuthorized( role, resource, requiredResource ) )
             {
-                if ( requiredResource || !getSecuritySystem().isAuthorized( config.getSecuritySession(),
role ) )
-                {
-                    throw new ContinuumException( "You're not authorized to execute this
action." );
-                }
+                throw new ContinuumException( "You're not authorized to execute this action."
);
             }
         }
         catch ( AuthorizationException ae )

Modified: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java?view=diff&rev=554617&r1=554616&r2=554617
==============================================================================
--- maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
(original)
+++ maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
Mon Jul  9 05:29:52 2007
@@ -23,6 +23,7 @@
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.project.ContinuumProjectState;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
+import org.apache.maven.continuum.security.ContinuumRoleConstants;
 import org.apache.maven.continuum.xmlrpc.project.AddingResult;
 import org.apache.maven.continuum.xmlrpc.project.BuildDefinition;
 import org.apache.maven.continuum.xmlrpc.project.BuildResult;
@@ -40,6 +41,7 @@
 import org.apache.maven.continuum.xmlrpc.test.SuiteResult;
 import org.apache.maven.continuum.xmlrpc.test.TestCaseFailure;
 import org.apache.maven.continuum.xmlrpc.test.TestResult;
+import org.codehaus.plexus.redback.authorization.AuthorizationException;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -140,6 +142,54 @@
     // Projects Groups
     // ----------------------------------------------------------------------
 
+    public List getAllProjectGroups()
+        throws ContinuumException
+    {
+        Collection pgList = continuum.getAllProjectGroups();
+        List result = new ArrayList();
+        for ( Iterator i = pgList.iterator(); i.hasNext(); )
+        {
+            org.apache.maven.continuum.model.project.ProjectGroup projectGroup =
+                (org.apache.maven.continuum.model.project.ProjectGroup) i.next();
+            try
+            {
+                if ( isAuthorized( ContinuumRoleConstants.CONTINUUM_VIEW_GROUP_OPERATION,
projectGroup.getName() ) )
+                {
+                    result.add( populateProjectGroupWithProjects( projectGroup ) );
+                }
+            }
+            catch ( AuthorizationException e )
+            {
+                throw new ContinuumException( "error authorizing request." );
+            }
+        }
+        return result;
+    }
+
+    public List getAllProjectGroupsWithProjects()
+        throws ContinuumException
+    {
+        Collection pgList = continuum.getAllProjectGroupsWithProjects();
+        List result = new ArrayList();
+        for ( Iterator i = pgList.iterator(); i.hasNext(); )
+        {
+            org.apache.maven.continuum.model.project.ProjectGroup projectGroup =
+                (org.apache.maven.continuum.model.project.ProjectGroup) i.next();
+            try
+            {
+                if ( isAuthorized( ContinuumRoleConstants.CONTINUUM_VIEW_GROUP_OPERATION,
projectGroup.getName() ) )
+                {
+                    result.add( populateProjectGroupWithProjects( projectGroup ) );
+                }
+            }
+            catch ( AuthorizationException e )
+            {
+                throw new ContinuumException( "error authorizing request." );
+            }
+        }
+        return result;
+    }
+
     protected String getProjectGroupName( int projectGroupId )
         throws ContinuumException
     {
@@ -218,9 +268,7 @@
     public List getBuildDefinitionsForProjectGroup( int projectGroupId )
         throws ContinuumException
     {
-        ProjectGroupSummary pgs = getProjectGroupSummary( projectGroupId );
-
-        checkViewProjectGroupAuthorization( pgs.getName() );
+        checkViewProjectGroupAuthorization( getProjectGroupName( projectGroupId ) );
 
         List bds = continuum.getBuildDefinitionsForProjectGroup( projectGroupId );
 
@@ -231,6 +279,28 @@
                 populateBuildDefinition( (org.apache.maven.continuum.model.project.BuildDefinition)
i.next() ) );
         }
         return result;
+    }
+
+    public BuildDefinition updateBuildDefinitionForProject( int projectId, BuildDefinition
buildDef )
+        throws ContinuumException
+    {
+        ProjectSummary ps = getProjectSummary( projectId );
+
+        checkModifyProjectBuildDefinitionAuthorization( ps.getProjectGroup().getName() );
+
+        org.apache.maven.continuum.model.project.BuildDefinition bd = populateBuildDefinition(
buildDef );
+        bd = continuum.updateBuildDefinitionForProject( projectId, bd );
+        return populateBuildDefinition( bd );
+    }
+
+    public BuildDefinition updateBuildDefinitionForProjectGroup( int projectGroupId, BuildDefinition
buildDef )
+        throws ContinuumException
+    {
+        checkModifyGroupBuildDefinitionAuthorization( getProjectGroupName( projectGroupId
) );
+
+        org.apache.maven.continuum.model.project.BuildDefinition bd = populateBuildDefinition(
buildDef );
+        bd = continuum.updateBuildDefinitionForProjectGroup( projectGroupId, bd );
+        return populateBuildDefinition( bd );
     }
 
     // ----------------------------------------------------------------------



Mime
View raw message