continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From car...@apache.org
Subject svn commit: r1097782 - in /continuum/trunk/continuum-xmlrpc: continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ continuum-xmlrpc-api/src/main/mdo/ continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ contin...
Date Fri, 29 Apr 2011 12:02:23 GMT
Author: carlos
Date: Fri Apr 29 12:02:22 2011
New Revision: 1097782

URL: http://svn.apache.org/viewvc?rev=1097782&view=rev
Log:
[CONTINUUM-2625] Expose ProjectScmRoot methods in the xml-rpc interface

Modified:
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/mdo/continuum-service.xml
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplTest.java

Modified: continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java?rev=1097782&r1=1097781&r2=1097782&view=diff
==============================================================================
--- continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java
(original)
+++ continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java
Fri Apr 29 12:02:22 2011
@@ -39,6 +39,7 @@ import org.apache.maven.continuum.xmlrpc
 import org.apache.maven.continuum.xmlrpc.project.ProjectGroup;
 import org.apache.maven.continuum.xmlrpc.project.ProjectGroupSummary;
 import org.apache.maven.continuum.xmlrpc.project.ProjectNotifier;
+import org.apache.maven.continuum.xmlrpc.project.ProjectScmRoot;
 import org.apache.maven.continuum.xmlrpc.project.ProjectSummary;
 import org.apache.maven.continuum.xmlrpc.project.ReleaseListenerSummary;
 import org.apache.maven.continuum.xmlrpc.project.Schedule;
@@ -586,6 +587,30 @@ public interface ContinuumService
         throws Exception;
 
     // ----------------------------------------------------------------------
+    // SCM roots
+    // ----------------------------------------------------------------------
+
+    /**
+     * Get the SCM roots for all projects in a project group
+     * 
+     * @param projectGroupId the project group id
+     * @return
+     * @throws Exception
+     */
+    List<ProjectScmRoot> getProjectScmRootByProjectGroup( int projectGroupId )
+        throws Exception;
+
+    /**
+     * Get the SCM root for a specific project
+     * 
+     * @param projectId the project id
+     * @return
+     * @throws Exception
+     */
+    ProjectScmRoot getProjectScmRootByProject( int projectId )
+        throws Exception;
+
+    // ----------------------------------------------------------------------
     // Build Results
     // ----------------------------------------------------------------------
 

Modified: continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/mdo/continuum-service.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/mdo/continuum-service.xml?rev=1097782&r1=1097781&r2=1097782&view=diff
==============================================================================
--- continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/mdo/continuum-service.xml
(original)
+++ continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/mdo/continuum-service.xml
Fri Apr 29 12:02:22 2011
@@ -1497,6 +1497,49 @@
           <type>String</type>
         </field>
       </fields>
+    </class>
+
+    <class>
+      <name>ProjectScmRoot</name>
+      <version>1.4.1+</version>
+      <packageName>org.apache.maven.continuum.xmlrpc.project</packageName>
+      <fields>
+        <field>
+          <name>id</name>
+          <version>1.4.1+</version>
+          <identifier>true</identifier>
+          <type>int</type>
+        </field>
+        <field>
+          <name>scmRootAddress</name>
+          <version>1.4.1+</version>
+          <type>String</type>
+          <required>true</required>
+        </field>
+        <field>
+          <name>oldState</name>
+          <version>1.4.1+</version>
+          <type>int</type>
+        </field>
+        <field jpox.column="scmRootState">
+          <name>state</name>
+          <version>1.4.1+</version>
+          <type>int</type>
+        </field>
+        <field stash.maxSize="8192">
+          <name>error</name>
+          <version>1.4.1+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>projectGroup</name>
+          <version>1.4.1+</version>
+          <association xml.reference="true" stash.part="true" jpox.dependent="false">
+            <type>ProjectGroup</type>
+          </association>
+          <required>true</required>
+        </field>
+      </fields>
     </class>    
   </classes>
 </model>

Modified: continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java?rev=1097782&r1=1097781&r2=1097782&view=diff
==============================================================================
--- continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java
(original)
+++ continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java
Fri Apr 29 12:02:22 2011
@@ -43,6 +43,7 @@ import org.apache.maven.continuum.xmlrpc
 import org.apache.maven.continuum.xmlrpc.project.ProjectGroup;
 import org.apache.maven.continuum.xmlrpc.project.ProjectGroupSummary;
 import org.apache.maven.continuum.xmlrpc.project.ProjectNotifier;
+import org.apache.maven.continuum.xmlrpc.project.ProjectScmRoot;
 import org.apache.maven.continuum.xmlrpc.project.ProjectSummary;
 import org.apache.maven.continuum.xmlrpc.project.ReleaseListenerSummary;
 import org.apache.maven.continuum.xmlrpc.project.Schedule;
@@ -352,6 +353,22 @@ public class ContinuumXmlRpcClient
     }
 
     // ----------------------------------------------------------------------
+    // SCM roots
+    // ----------------------------------------------------------------------
+
+    public List<ProjectScmRoot> getProjectScmRootByProjectGroup( int projectGroupId
)
+        throws Exception
+    {
+        return continuum.getProjectScmRootByProjectGroup( projectGroupId );
+    }
+
+    public ProjectScmRoot getProjectScmRootByProject( int projectId )
+        throws Exception
+    {
+        return getProjectScmRootByProject( projectId );
+    }
+
+    // ----------------------------------------------------------------------
     // Build Results
     // ----------------------------------------------------------------------
 

Modified: continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java?rev=1097782&r1=1097781&r2=1097782&view=diff
==============================================================================
--- continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
(original)
+++ continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
Fri Apr 29 12:02:22 2011
@@ -40,7 +40,6 @@ import org.apache.continuum.configuratio
 import org.apache.continuum.configuration.BuildAgentGroupConfiguration;
 import org.apache.continuum.configuration.ContinuumConfigurationException;
 import org.apache.continuum.dao.SystemConfigurationDao;
-import org.apache.continuum.model.project.ProjectScmRoot;
 import org.apache.continuum.purge.ContinuumPurgeManagerException;
 import org.apache.continuum.purge.PurgeConfigurationServiceException;
 import org.apache.continuum.repository.RepositoryServiceException;
@@ -75,6 +74,7 @@ import org.apache.maven.continuum.xmlrpc
 import org.apache.maven.continuum.xmlrpc.project.ProjectGroup;
 import org.apache.maven.continuum.xmlrpc.project.ProjectGroupSummary;
 import org.apache.maven.continuum.xmlrpc.project.ProjectNotifier;
+import org.apache.maven.continuum.xmlrpc.project.ProjectScmRoot;
 import org.apache.maven.continuum.xmlrpc.project.ProjectSummary;
 import org.apache.maven.continuum.xmlrpc.project.ReleaseListenerSummary;
 import org.apache.maven.continuum.xmlrpc.project.Schedule;
@@ -719,6 +719,41 @@ public class ContinuumServiceImpl
     }
 
     // ----------------------------------------------------------------------
+    // SCM roots
+    // ----------------------------------------------------------------------
+
+    public List<ProjectScmRoot> getProjectScmRootByProjectGroup( int projectGroupId
)
+        throws ContinuumException
+    {
+        checkViewProjectGroupAuthorization( getProjectGroupName( projectGroupId ) );
+
+        List<org.apache.continuum.model.project.ProjectScmRoot> projectScmRoots =
+            continuum.getProjectScmRootByProjectGroup( projectGroupId );
+
+        List<ProjectScmRoot> result = new ArrayList<ProjectScmRoot>( projectScmRoots.size()
);
+        if ( projectScmRoots != null )
+        {
+            for ( org.apache.continuum.model.project.ProjectScmRoot projectScmRoot : projectScmRoots
)
+            {
+                result.add( populateProjectScmRoot( projectScmRoot ) );
+            }
+        }
+
+        return result;
+    }
+
+    public ProjectScmRoot getProjectScmRootByProject( int projectId )
+        throws ContinuumException
+    {
+        org.apache.continuum.model.project.ProjectScmRoot projectScmRoot =
+            continuum.getProjectScmRootByProject( projectId );
+
+        checkViewProjectGroupAuthorization( projectScmRoot.getProjectGroup().getName() );
+
+        return populateProjectScmRoot( projectScmRoot );
+    }
+
+    // ----------------------------------------------------------------------
     // Build Results
     // ----------------------------------------------------------------------
 
@@ -1357,7 +1392,8 @@ public class ContinuumServiceImpl
                 {
                     if ( buildAgentUrl != null )
                     {
-                        ProjectScmRoot scmRoot = continuum.getProjectScmRootByProject( projectId
);
+                        org.apache.continuum.model.project.ProjectScmRoot scmRoot =
+                            continuum.getProjectScmRootByProject( projectId );
                         dbm.removeFromPrepareBuildQueue( buildAgentUrl, scmRoot.getProjectGroup().getId(),
                                                          scmRoot.getId() );
                     }
@@ -1398,7 +1434,8 @@ public class ContinuumServiceImpl
 
                 if ( parallelBuildsManager.isInPrepareBuildQueue( projectId ) )
                 {
-                    ProjectScmRoot scmRoot = continuum.getProjectScmRootByProject( projectId
);
+                    org.apache.continuum.model.project.ProjectScmRoot scmRoot =
+                        continuum.getProjectScmRootByProject( projectId );
                     parallelBuildsManager.removeProjectFromPrepareBuildQueue( scmRoot.getProjectGroup().getId(),
                                                                               scmRoot.getId()
);
                 }
@@ -1938,6 +1975,11 @@ public class ContinuumServiceImpl
         return (Project) mapper.map( project, Project.class );
     }
 
+    private ProjectScmRoot populateProjectScmRoot( org.apache.continuum.model.project.ProjectScmRoot
projectScmRoot )
+    {
+        return (ProjectScmRoot) mapper.map( projectScmRoot, ProjectScmRoot.class );
+    }
+
     private org.apache.maven.continuum.model.project.Project populateProject( ProjectSummary
projectSummary,
                                                                               org.apache.maven.continuum.model.project.Project
project )
         throws ContinuumException
@@ -3544,5 +3586,4 @@ public class ContinuumServiceImpl
     {
         this.continuum = continuum;
     }
-
 }

Modified: continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplTest.java?rev=1097782&r1=1097781&r2=1097782&view=diff
==============================================================================
--- continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplTest.java
(original)
+++ continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplTest.java
Fri Apr 29 12:02:22 2011
@@ -1,9 +1,12 @@
 package org.apache.continuum.xmlrpc.server;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
+import org.apache.continuum.model.project.ProjectScmRoot;
 import org.apache.continuum.release.distributed.manager.DistributedReleaseManager;
 import org.apache.continuum.xmlrpc.utils.BuildTrigger;
 import org.apache.maven.continuum.Continuum;
@@ -187,7 +190,81 @@ public class ContinuumServiceImplTest
         assertEquals( 0, result );
     
     }
-    
+
+    public void testGetProjectScmRootByProjectGroup()
+        throws Exception
+    {
+        final ProjectGroup projectGroup = new ProjectGroup();
+        projectGroup.setName( "test-group" );
+        projectGroup.setId( 1 );
+
+        final List<ProjectScmRoot> scmRoots = new ArrayList<ProjectScmRoot>();
+
+        ProjectScmRoot scmRoot = new ProjectScmRoot();
+        scmRoot.setState( 1 );
+        scmRoot.setOldState( 3 );
+        scmRoot.setScmRootAddress( "address1" );
+        scmRoot.setProjectGroup( projectGroup );
+        scmRoots.add( scmRoot );
+
+        scmRoot = new ProjectScmRoot();
+        scmRoot.setState( 2 );
+        scmRoot.setOldState( 4 );
+        scmRoot.setScmRootAddress( "address2" );
+        scmRoot.setProjectGroup( projectGroup );
+        scmRoots.add( scmRoot );
+
+        context.checking( new Expectations()
+        {
+            {
+                atLeast( 1 ).of( continuum ).getProjectScmRootByProjectGroup( projectGroup.getId()
);
+                will( returnValue( scmRoots ) );
+
+                atLeast( 1 ).of( continuum ).getProjectGroup( projectGroup.getId() );
+                will( returnValue( projectGroup ) );
+            }
+        } );
+
+        List<org.apache.maven.continuum.xmlrpc.project.ProjectScmRoot> projectScmRoots
=
+            continuumService.getProjectScmRootByProjectGroup( projectGroup.getId() );
+        assertEquals( 2, projectScmRoots.size() );
+        assertEquals( 1, projectScmRoots.get( 0 ).getState() );
+        assertEquals( 2, projectScmRoots.get( 1 ).getState() );
+    }
+
+    public void testGetProjectScmRootByProject()
+        throws Exception
+    {
+        final ProjectGroup projectGroup = new ProjectGroup();
+        projectGroup.setName( "test-group" );
+        projectGroup.setId( 1 );
+
+        final int projectId = 1;
+
+        final ProjectScmRoot scmRoot = new ProjectScmRoot();
+        scmRoot.setState( 1 );
+        scmRoot.setOldState( 3 );
+        scmRoot.setScmRootAddress( "address1" );
+        scmRoot.setProjectGroup( projectGroup );
+
+        context.checking( new Expectations()
+        {
+            {
+                atLeast( 1 ).of( continuum ).getProjectScmRootByProject( projectId );
+                will( returnValue( scmRoot ) );
+            }
+        } );
+
+        org.apache.maven.continuum.xmlrpc.project.ProjectScmRoot projectScmRoot =
+            continuumService.getProjectScmRootByProject( projectId );
+        assertNotNull( projectScmRoot );
+        assertEquals( 1, projectScmRoot.getState() );
+        assertEquals( 3, projectScmRoot.getOldState() );
+        assertEquals( "address1", projectScmRoot.getScmRootAddress() );
+        assertEquals( projectGroup.getName(), projectScmRoot.getProjectGroup().getName()
);
+        assertEquals( projectGroup.getId(), projectScmRoot.getProjectGroup().getId() );
+    }
+
     private BuildDefinition createBuildDefinition()
     {
         BuildDefinition buildDef = new BuildDefinition();



Mime
View raw message