continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jzurb...@apache.org
Subject svn commit: r1081766 - in /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/java/org...
Date Tue, 15 Mar 2011 13:14:52 GMT
Author: jzurbano
Date: Tue Mar 15 13:14:51 2011
New Revision: 1081766

URL: http://svn.apache.org/viewvc?rev=1081766&view=rev
Log:
[CONTINUUM-2613] Add xmlrpc service method overload for buildProject that accepts projectId,
buildDefinitionId, and buildTrigger as the parameters
* applied patch
* minor modifications made
** corrected typo "defintion"
** refactored unit test

Submitted by: Warner B. PiƱero


Modified:
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java
    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/ContinuumServiceImplStub.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=1081766&r1=1081765&r2=1081766&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
Tue Mar 15 13:14:51 2011
@@ -399,7 +399,7 @@ public interface ContinuumService
      * Update a project build definition.
      * 
      * @param projectId The project id
-     * @param buildDef The build defintion to update
+     * @param buildDef The build definition to update
      * @return the updated build definition
      * @throws Exception
      */
@@ -410,7 +410,7 @@ public interface ContinuumService
      * Same method but compatible with standard XMLRPC
      * 
      * @param projectId The project id
-     * @param buildDef The build defintion to update
+     * @param buildDef The build definition to update
      * @return the updated build definition as RPC value
      * @throws Exception
      */
@@ -421,7 +421,7 @@ public interface ContinuumService
      * Update a project group build definition.
      * 
      * @param projectGroupId The project group id
-     * @param buildDef The build defintion to update
+     * @param buildDef The build definition to update
      * @return the updated build definition
      * @throws Exception
      */
@@ -432,7 +432,7 @@ public interface ContinuumService
      * Same method but compatible with standard XMLRPC
      * 
      * @param projectGroupId The project group id
-     * @param buildDef The build defintion to update
+     * @param buildDef The build definition to update
      * @return the updated build definition as RPC value
      * @throws Exception
      */
@@ -443,7 +443,7 @@ public interface ContinuumService
      * Add a project build definition.
      * 
      * @param projectId The project id
-     * @param buildDef The build defintion to update
+     * @param buildDef The build definition to update
      * @return the added build definition
      * @throws Exception
      */
@@ -454,7 +454,7 @@ public interface ContinuumService
      * Same method but compatible with standard XMLRPC
      * 
      * @param projectId The project id
-     * @param buildDef The build defintion to update
+     * @param buildDef The build definition to update
      * @return the added build definition as RPC value
      * @throws Exception
      */
@@ -465,7 +465,7 @@ public interface ContinuumService
      * Add a project group buildDefinition.
      * 
      * @param projectGroupId The project group id
-     * @param buildDef The build defintion to update
+     * @param buildDef The build definition to update
      * @return the build definition added
      * @throws Exception
      */
@@ -476,7 +476,7 @@ public interface ContinuumService
      * Same method but compatible with standard XMLRPC
      * 
      * @param projectGroupId The project group id
-     * @param buildDef The build defintion to update
+     * @param buildDef The build definition to update
      * @return the added build definition as RPC value
      * @throws Exception
      */
@@ -553,6 +553,18 @@ public interface ContinuumService
      */
     int buildProject( int projectId, BuildTrigger buildTrigger )
         throws Exception;
+    
+    /**
+     * Forced build the project
+     * 
+     * @param projectId The project id
+     * @param buildDefinitionId The build definition id
+     * @param buildTrigger The build trigger
+     * @return
+     * @throws Exception
+     */
+    int buildProject( int projectId, int buildDefinitionId, BuildTrigger buildTrigger )
+        throws Exception;
 
     /**
      * Build the project group with the default build definition.
@@ -1070,7 +1082,7 @@ public interface ContinuumService
      * @return The installations list.
      * @throws Exception
      */
-    List<Installation> getBuildAgentInstallations(String url)
+    List<Installation> getBuildAgentInstallations( String url )
         throws Exception;
 
     /**

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=1081766&r1=1081765&r2=1081766&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
Tue Mar 15 13:14:51 2011
@@ -332,6 +332,12 @@ public class ContinuumXmlRpcClient
     {
         return continuum.buildProject( projectId, buildTrigger );
     }
+    
+    public int buildProject( int projectId, int buildDefinitionId, BuildTrigger buildTrigger
)
+        throws Exception
+    {
+        return continuum.buildProject( projectId, buildDefinitionId, buildTrigger );
+    }
 
     public int buildGroup( int projectGroupId )
         throws Exception

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=1081766&r1=1081765&r2=1081766&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
Tue Mar 15 13:14:51 2011
@@ -653,29 +653,38 @@ public class ContinuumServiceImpl
         return 0;
     }
 
-    public int buildProject( int projectId, int buildDefintionId )
+    public int buildProject( int projectId, int buildDefinitionId )
         throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException
     {
         ProjectSummary ps = getProjectSummary( projectId );
         checkBuildProjectInGroupAuthorization( ps.getProjectGroup().getName() );
-
-        continuum.buildProjectWithBuildDefinition( projectId,
-                                                   buildDefintionId,
-                                                   new org.apache.continuum.utils.build.BuildTrigger(
-                                                                                        
             ContinuumProjectState.TRIGGER_SCHEDULED,
-                                                                                        
             "" ) );
+        
+        buildProjectWithBuildDefinition( projectId, buildDefinitionId,
+                                         new org.apache.continuum.utils.build.BuildTrigger(
ContinuumProjectState.TRIGGER_SCHEDULED, "" ) );
         return 0;
     }
 
-    public int buildProject( int projectId, BuildTrigger buildTrigger )
+    public int buildProject( int projectId, BuildTrigger xmlrpcBuildTrigger )
         throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException
     {
         ProjectSummary ps = getProjectSummary( projectId );
         checkBuildProjectInGroupAuthorization( ps.getProjectGroup().getName() );
 
-        org.apache.continuum.utils.build.BuildTrigger bd = populateBuildTrigger( buildTrigger
);
+        org.apache.continuum.utils.build.BuildTrigger buildTrigger = populateBuildTrigger(
xmlrpcBuildTrigger );
 
-        continuum.buildProject( projectId, bd );
+        continuum.buildProject( projectId, buildTrigger );
+        return 0;
+    }
+    
+    public int buildProject( int projectId, int buildDefinitionId, BuildTrigger xmlrpcBuildTrigger
)
+        throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException
+    {
+        ProjectSummary projectSummary = getProjectSummary( projectId );
+        checkBuildProjectInGroupAuthorization( projectSummary.getProjectGroup().getName()
);
+
+        org.apache.continuum.utils.build.BuildTrigger buildTrigger = populateBuildTrigger(
xmlrpcBuildTrigger );
+        buildProjectWithBuildDefinition( projectId, buildDefinitionId, buildTrigger );
+        
         return 0;
     }
 
@@ -693,14 +702,14 @@ public class ContinuumServiceImpl
         return 0;
     }
 
-    public int buildGroup( int projectGroupId, int buildDefintionId )
+    public int buildGroup( int projectGroupId, int buildDefinitionId )
         throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException
     {
         ProjectGroupSummary pg = getProjectGroupSummary( projectGroupId );
         checkBuildProjectInGroupAuthorization( pg.getName() );
 
         continuum.buildProjectGroupWithBuildDefinition( projectGroupId,
-                                                        buildDefintionId,
+                                                        buildDefinitionId,
                                                         new org.apache.continuum.utils.build.BuildTrigger(
                                                                                         
                  ContinuumProjectState.TRIGGER_SCHEDULED,
                                                                                         
                  "" ) );
@@ -1261,7 +1270,7 @@ public class ContinuumServiceImpl
         {
             Map<String, List<org.apache.continuum.taskqueue.BuildProjectTask>>
buildTasks;
             
-            if( continuum.getConfiguration().isDistributedBuildEnabled() )
+            if ( continuum.getConfiguration().isDistributedBuildEnabled() )
             {
                 buildTasks = distributedBuildManager.getProjectsInBuildQueue();
             }
@@ -1719,8 +1728,7 @@ public class ContinuumServiceImpl
         ConfigurationService configurationService = continuum.getConfiguration();
         org.apache.continuum.configuration.BuildAgentConfiguration buildAgent =
             configurationService.getBuildAgent( buildAgentConfiguration.getUrl() );
-        BuildAgentConfiguration buildAgentConfigurationToUpdate =
-            buildAgent != null ? populateBuildAgent( buildAgent ) : null;
+        BuildAgentConfiguration buildAgentConfigurationToUpdate = buildAgent != null ? populateBuildAgent(
buildAgent ) : null;
 
         if ( buildAgentConfigurationToUpdate != null )
         {
@@ -1952,7 +1960,7 @@ public class ContinuumServiceImpl
     }
 
     protected org.apache.maven.continuum.model.project.BuildDefinition populateBuildDefinition(
BuildDefinition buildDef,
-                                                                                        
     org.apache.maven.continuum.model.project.BuildDefinition bd )
+                                                                                        
       org.apache.maven.continuum.model.project.BuildDefinition bd )
         throws ProfileException, ContinuumException
     {
         if ( buildDef == null )
@@ -1987,13 +1995,19 @@ public class ContinuumServiceImpl
             bd.setSchedule( null );
         }
         
-        if( StringUtils.isNotEmpty( buildDef.getDescription() ) )
+        if ( StringUtils.isNotEmpty( buildDef.getDescription() ) )
         {
             bd.setDescription( buildDef.getDescription() );
         }
 
         return bd;
     }
+    
+    protected void buildProjectWithBuildDefinition( int projectId, int buildDefinitionId,
org.apache.continuum.utils.build.BuildTrigger buildTrigger )
+        throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException
+    {
+        continuum.buildProjectWithBuildDefinition( projectId, buildDefinitionId, buildTrigger
);
+    }
 
     private BuildDefinitionTemplate populateBuildDefinitionTemplate( org.apache.maven.continuum.model.project.BuildDefinitionTemplate
bdt )
     {
@@ -2262,7 +2276,7 @@ public class ContinuumServiceImpl
         }
         catch ( ContinuumException e )
         {
-            logger.warn( "Unable to connect to build agent " + buildAgentConfiguration.getUrl()
+ "." , e );
+            logger.warn( "Unable to connect to build agent " + buildAgentConfiguration.getUrl()
+ ".", e );
             buildAgentConfiguration.setPlatform( "" );
             return buildAgentConfiguration;
         }
@@ -3331,7 +3345,7 @@ public class ContinuumServiceImpl
         }
     }
 
-    public List<Map<String, String>> getProjectReleaseAndDevelopmentVersions(
int projectId, String pomFilename, 
+    public List<Map<String, String>> getProjectReleaseAndDevelopmentVersions(
int projectId, String pomFilename,
                                                                               boolean autoVersionSubmodules
)
         throws Exception
     {

Modified: continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplStub.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplStub.java?rev=1081766&r1=1081765&r2=1081766&view=diff
==============================================================================
--- continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplStub.java
(original)
+++ continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplStub.java
Tue Mar 15 13:14:51 2011
@@ -1,5 +1,6 @@
 package org.apache.continuum.xmlrpc.server;
 
+import org.apache.continuum.utils.build.BuildTrigger;
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.profile.ProfileException;
 import org.apache.maven.continuum.xmlrpc.project.BuildDefinition;
@@ -14,6 +15,17 @@ public class ContinuumServiceImplStub
         // do nothing
     }
     
+    protected void checkViewProjectGroupAuthorization( String resource )
+        throws ContinuumException
+    {
+        // do nothing
+    }
+    
+    protected void buildProjectWithBuildDefinition( int projectId, int buildDefinitionId,
BuildTrigger buildTrigger )
+    {
+        // do nothing
+    }
+    
     public org.apache.maven.continuum.model.project.BuildDefinition getBuildDefinition( BuildDefinition
buildDef,
                                                                                         org.apache.maven.continuum.model.project.BuildDefinition
buildDefinition )
         throws ProfileException, ContinuumException

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=1081766&r1=1081765&r2=1081766&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
Tue Mar 15 13:14:51 2011
@@ -5,12 +5,14 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.continuum.release.distributed.manager.DistributedReleaseManager;
+import org.apache.continuum.xmlrpc.utils.BuildTrigger;
 import org.apache.maven.continuum.Continuum;
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.release.ContinuumReleaseManager;
 import org.apache.maven.continuum.xmlrpc.project.BuildDefinition;
+import org.apache.maven.continuum.xmlrpc.project.ContinuumProjectState;
 import org.apache.maven.continuum.xmlrpc.project.ReleaseListenerSummary;
 import org.apache.maven.continuum.xmlrpc.server.ContinuumServiceImpl;
 import org.codehaus.plexus.spring.PlexusInSpringTestCase;
@@ -71,7 +73,7 @@ public class ContinuumServiceImplTest
     {
         params = new HashMap<String, Object>();
         params.put( "scm-tag", "" );
-        params.put( "scm-tagbase", "" );    
+        params.put( "scm-tagbase", "" );
 
         context.checking( new Expectations()
         {
@@ -157,6 +159,35 @@ public class ContinuumServiceImplTest
         assertEquals( buildDef.isDefaultForProject(), buildDefinition.isDefaultForProject()
);
     }
     
+    public void testBuildProjectWithBuildTrigger()
+        throws Exception
+    {
+        final ProjectGroup projectGroup = new ProjectGroup();
+        projectGroup.setName( "test-group" );
+        
+        BuildTrigger buildTrigger = new BuildTrigger();
+        buildTrigger.setTrigger( ContinuumProjectState.TRIGGER_FORCED );
+        buildTrigger.setTriggeredBy( "username" );
+
+        BuildDefinition buildDef = createBuildDefinition();
+        buildDef.setId( 1 );
+    
+        context.checking( new Expectations()
+        {
+            {
+                atLeast( 1 ).of( continuum ).getProject( project.getId() );
+                will( returnValue( project ) );
+                
+                atLeast( 1 ).of( continuum ).getProjectGroupByProjectId( project.getId()
);
+                will( returnValue( projectGroup ) );
+            }
+        });
+    
+        int result = continuumService.buildProject( project.getId(), buildDef.getId(), buildTrigger
);
+        assertEquals( 0, result );
+    
+    }
+    
     private BuildDefinition createBuildDefinition()
     {
         BuildDefinition buildDef = new BuildDefinition();
@@ -175,7 +206,7 @@ public class ContinuumServiceImplTest
     private Map<String, Object> getListenerMap()
     {
         Map<String, Object> map = new HashMap<String, Object>();
- 
+        
         map.put( "release-phases", Arrays.asList( "incomplete-phase" ) );
         map.put( "completed-release-phases", Arrays.asList( "completed-phase" ) );
         return map;



Mime
View raw message