continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r387188 - in /maven/continuum/branches/continuum-1.0.x: continuum-api/src/main/java/org/apache/maven/continuum/notification/ continuum-core/src/main/java/org/apache/maven/continuum/ continuum-core/src/main/java/org/apache/maven/continuum/bu...
Date Mon, 20 Mar 2006 11:21:27 GMT
Author: evenisse
Date: Mon Mar 20 03:21:20 2006
New Revision: 387188

URL: http://svn.apache.org/viewcvs?rev=387188&view=rev
Log:
o Return empty list instead of null when velocity template call DefaultContinuum method
o Remove lot of unnecessary database requests

Modified:
    maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcher.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectFromWorkingDirectoryContinuumAction.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/ContinuumRecipientSource.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/CheckOutTaskExecutor.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/resources/META-INF/plexus/components.xml
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java
    maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java
    maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-irc/src/main/java/org/apache/maven/continuum/notification/irc/IrcContinuumNotifier.java
    maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-jabber/src/main/java/org/apache/maven/continuum/notification/jabber/JabberContinuumNotifier.java
    maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-msn/src/main/java/org/apache/maven/continuum/notification/msn/MsnContinuumNotifier.java

Modified: maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcher.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcher.java?rev=387188&r1=387187&r2=387188&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcher.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcher.java
Mon Mar 20 03:21:20 2006
@@ -50,6 +50,8 @@
 
     String CONTEXT_PROJECT = "project";
 
+    String CONTEXT_PROJECT_NOTIFIER = "projectNotifier";
+
     String CONTEXT_BUILD_RESULT = "result";
 
     String CONTEXT_UPDATE_SCM_RESULT = "scmResult";

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=387188&r1=387187&r2=387188&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Mon Mar 20 03:21:20 2006
@@ -164,12 +164,26 @@
 
     public Map getLatestBuildResults()
     {
-        return store.getLatestBuildResults();
+        Map result = store.getLatestBuildResults();
+
+        if ( result == null )
+        {
+            result = new HashMap();
+        }
+
+        return result;
     }
 
     public Map getBuildResultsInSuccess()
     {
-        return store.getBuildResultsInSuccess();
+        Map result = store.getBuildResultsInSuccess();
+
+        if ( result == null )
+        {
+            result = new HashMap();
+        }
+
+        return result;
     }
 
     public BuildResult getLatestBuildResultForProject( int projectId )
@@ -354,6 +368,8 @@
 
         for ( Iterator i = projectsList.iterator(); i.hasNext(); )
         {
+            long start = System.currentTimeMillis();
+
             Project project = (Project) i.next();
 
             Integer buildDefId = (Integer) buildDefinitionsIds.get( new Integer( project.getId()
) );
@@ -364,7 +380,9 @@
                     "Project (id=" + project.getId() + " doens't have a default build definition."
);
             }
 
-            buildProject( project.getId(), buildDefId.intValue(), trigger );
+            buildProject( project, buildDefId.intValue(), trigger );
+
+            getLogger().debug( "Add " + project.getName() + " in " + ( System.currentTimeMillis()
- start ) + "ms" );
         }
     }
 
@@ -372,6 +390,7 @@
         throws ContinuumException
     {
         Collection projectsList;
+
         Map projectsMap = null;
 
         try
@@ -399,14 +418,14 @@
 
         for ( Iterator projectIterator = projectsList.iterator(); projectIterator.hasNext();
)
         {
-            Project p = (Project) projectIterator.next();
+            Project project = (Project) projectIterator.next();
 
-            Integer buildDefId = ( (Integer) projectsMap.get( new Integer( p.getId() ) )
);
+            Integer buildDefId = ( (Integer) projectsMap.get( new Integer( project.getId()
) ) );
 
-            if ( buildDefId != null && !isInBuildingQueue( p.getId(), buildDefId.intValue()
) &&
-                !isInCheckoutQueue( p.getId() ) )
+            if ( buildDefId != null && !isInBuildingQueue( project.getId(), buildDefId.intValue()
) &&
+                !isInCheckoutQueue( project.getId() ) )
             {
-                buildProject( p.getId(), buildDefId.intValue(), ContinuumProjectState.TRIGGER_SCHEDULED,
false );
+                buildProject( project, buildDefId.intValue(), ContinuumProjectState.TRIGGER_SCHEDULED,
false );
             }
         }
     }
@@ -448,12 +467,35 @@
         buildProject( projectId, buildDefinitionId, trigger, true );
     }
 
-    private synchronized void buildProject( int projectId, int buildDefinitionId, int trigger,
boolean checkQueues )
+    public void buildProject( Project project, int buildDefinitionId, int trigger )
+        throws ContinuumException
+    {
+        buildProject( project, buildDefinitionId, trigger, true );
+    }
+
+    private void buildProject( int projectId, int buildDefinitionId, int trigger, boolean
checkQueues )
+        throws ContinuumException
+    {
+        Project project;
+
+        try
+        {
+            project = store.getProject( projectId );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw logAndCreateException( "Error while getting project " + projectId + ".",
e );
+        }
+
+        buildProject( project, buildDefinitionId, trigger, checkQueues );
+    }
+
+    private synchronized void buildProject( Project project, int buildDefinitionId, int trigger,
boolean checkQueues )
         throws ContinuumException
     {
         if ( checkQueues )
         {
-            if ( isInBuildingQueue( projectId, buildDefinitionId ) || isInCheckoutQueue(
projectId ) )
+            if ( isInBuildingQueue( project.getId(), buildDefinitionId ) || isInCheckoutQueue(
project.getId() ) )
             {
                 return;
             }
@@ -461,18 +503,18 @@
 
         try
         {
-            Project project = store.getProject( projectId );
-
             if ( project.getState() != ContinuumProjectState.NEW &&
                 project.getState() != ContinuumProjectState.CHECKEDOUT &&
                 project.getState() != ContinuumProjectState.OK && project.getState()
!= ContinuumProjectState.FAILED &&
                 project.getState() != ContinuumProjectState.ERROR )
             {
                 ContinuumBuildExecutor executor = executorManager.getBuildExecutor( project.getExecutorId()
);
+
                 if ( executor.isBuilding( project ) )
                 {
                     // project is building
                     getLogger().info( "Project '" + project.getName() + "' always running."
);
+
                     return;
                 }
                 else
@@ -481,7 +523,7 @@
 
                     store.updateProject( project );
 
-                    project = store.getProject( projectId );
+                    project = store.getProject( project.getId() );
                 }
             }
 
@@ -494,7 +536,7 @@
             getLogger().info(
                 "Enqueuing '" + project.getName() + "' (Build definition id=" + buildDefinitionId
+ ")." );
 
-            buildQueue.put( new BuildProjectTask( projectId, buildDefinitionId, trigger )
);
+            buildQueue.put( new BuildProjectTask( project.getId(), buildDefinitionId, trigger
) );
         }
         catch ( ContinuumStoreException e )
         {
@@ -593,6 +635,11 @@
             }
 
             buildResult = (BuildResult) buildResultsIterator.next();
+        }
+
+        if ( changes == null )
+        {
+            changes = Collections.EMPTY_LIST;
         }
 
         return changes;

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java?rev=387188&r1=387187&r2=387188&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
Mon Mar 20 03:21:20 2006
@@ -95,13 +95,13 @@
 
         try
         {
-            project = store.getProject( projectId );
+            project = store.getProjectWithBuildDetails( projectId );
 
             buildDefinition = store.getBuildDefinition( buildDefinitionId );
         }
         catch ( ContinuumStoreException ex )
         {
-            getLogger().error( "Internal error while building the project.", ex );
+            getLogger().error( "Internal error while getting the project.", ex );
 
             return;
         }
@@ -136,8 +136,12 @@
 
             actionContext.put( AbstractContinuumAction.KEY_PROJECT_ID, new Integer( projectId
) );
 
+            actionContext.put( AbstractContinuumAction.KEY_PROJECT, project );
+
             actionContext.put( AbstractContinuumAction.KEY_BUILD_DEFINITION_ID, new Integer(
buildDefinitionId ) );
 
+            actionContext.put( AbstractContinuumAction.KEY_BUILD_DEFINITION, buildDefinition
);
+
             actionContext.put( AbstractContinuumAction.KEY_TRIGGER, new Integer( trigger
) );
 
             ScmResult scmResult = null;
@@ -194,8 +198,6 @@
 
                 actionContext.put( AbstractContinuumAction.KEY_UPDATE_SCM_RESULT, scmResult
);
 
-                scmResult = (ScmResult) actionContext.get( AbstractContinuumAction.KEY_UPDATE_SCM_RESULT
);
-
                 List changes = scmResult.getChanges();
 
                 Iterator iterChanges = changes.iterator();
@@ -347,15 +349,6 @@
         }
         finally
         {
-            try
-            {
-                project = store.getProject( projectId );
-            }
-            catch ( ContinuumStoreException ex )
-            {
-                getLogger().error( "Internal error while building the project.", ex );
-            }
-
             if ( project.getState() != ContinuumProjectState.NEW &&
                 project.getState() != ContinuumProjectState.CHECKEDOUT &&
                 project.getState() != ContinuumProjectState.OK && project.getState()
!= ContinuumProjectState.FAILED &&

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java?rev=387188&r1=387187&r2=387188&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
Mon Mar 20 03:21:20 2006
@@ -16,6 +16,7 @@
  * limitations under the License.
  */
 
+import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.model.scm.ScmResult;
@@ -38,8 +39,12 @@
 
     public static final String KEY_PROJECT_ID = "project-id";
 
+    public static final String KEY_PROJECT = "project";
+
     public static final String KEY_BUILD_DEFINITION_ID = "build-definition-id";
 
+    public static final String KEY_BUILD_DEFINITION = "build-definition";
+
     public static final String KEY_UNVALIDATED_PROJECT = "unvalidated-project";
 
     public static final String KEY_PROJECT_GROUP_ID = "project-group-id";
@@ -81,6 +86,11 @@
         return getInteger( context, KEY_PROJECT_ID );
     }
 
+    public static Project getProject( Map context )
+    {
+        return (Project) getObject( context, KEY_PROJECT );
+    }
+
     public static int getProjectGroupId( Map context )
     {
         return Integer.valueOf( getString( context, KEY_PROJECT_GROUP_ID ) ).intValue();
@@ -89,6 +99,11 @@
     public static int getBuildDefinitionId( Map context )
     {
         return getInteger( context, KEY_BUILD_DEFINITION_ID );
+    }
+
+    public static BuildDefinition getBuildDefinition( Map context )
+    {
+        return (BuildDefinition) getObject( context, KEY_BUILD_DEFINITION );
     }
 
     public static String getBuildId( Map context )

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java?rev=387188&r1=387187&r2=387188&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java
Mon Mar 20 03:21:20 2006
@@ -42,7 +42,7 @@
     public void execute( Map context )
         throws Exception
     {
-        Project project = store.getProject( getProjectId( context ) );
+        Project project = getProject( context );
 
         project.setState( ContinuumProjectState.CHECKING_OUT );
 
@@ -55,6 +55,7 @@
         // ----------------------------------------------------------------------
 
         ScmResult result;
+
         try
         {
             result = scm.checkOut( project, workingDirectory );
@@ -67,7 +68,9 @@
             if ( cause instanceof NoSuchScmProviderException )
             {
                 result = new ScmResult();
+
                 result.setSuccess( false );
+
                 result.setProviderMessage( cause.getMessage() );
             }
             else if ( e.getResult() != null )
@@ -77,7 +80,9 @@
             else
             {
                 result = new ScmResult();
+
                 result.setSuccess( false );
+
                 result.setException( ContinuumUtils.throwableMessagesToString( e ) );
             }
         }
@@ -85,7 +90,9 @@
         {
             // TODO: do we want this here, or should it be to the logs?
             result = new ScmResult();
+
             result.setSuccess( false );
+
             result.setException( ContinuumUtils.throwableMessagesToString( t ) );
         }
         finally
@@ -94,6 +101,7 @@
 
             store.updateProject( project );
         }
+
         context.put( KEY_CHECKOUT_SCM_RESULT, result );
     }
 }

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java?rev=387188&r1=387187&r2=387188&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java
Mon Mar 20 03:21:20 2006
@@ -29,7 +29,6 @@
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.project.ContinuumProjectState;
-import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.utils.WorkingDirectoryService;
 
 import java.io.File;
@@ -57,11 +56,6 @@
     /**
      * @plexus.requirement
      */
-    private ContinuumStore store;
-
-    /**
-     * @plexus.requirement
-     */
     private WorkingDirectoryService workingDirectoryService;
 
     /**
@@ -90,7 +84,7 @@
 
         if ( deploymentRepositoryDirectory != null )
         {
-            Project project = store.getProjectWithBuildDetails( getProjectId( context ) );
+            Project project = getProject( context );
 
             ContinuumBuildExecutor buildExecutor = buildExecutorManager.getBuildExecutor(
project.getExecutorId() );
 
@@ -100,7 +94,7 @@
 
             if ( project.getState() == ContinuumProjectState.OK )
             {
-                BuildDefinition buildDefinition = store.getBuildDefinition( getBuildDefinitionId(
context ) );
+                BuildDefinition buildDefinition = getBuildDefinition( context );
 
                 List artifacts = buildExecutor.getDeployableArtifacts(
                     workingDirectoryService.getWorkingDirectory( project ), buildDefinition
);
@@ -119,6 +113,7 @@
                     }
 
                     String location = deploymentRepositoryDirectory.toURL().toExternalForm();
+
                     ArtifactRepository deploymentRepository =
                         artifactRepositoryFactory.createDeploymentArtifactRepository( "deployment-repository",
location,
                                                                                       repositoryLayout,
true );

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java?rev=387188&r1=387187&r2=387188&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
Mon Mar 20 03:21:20 2006
@@ -67,7 +67,7 @@
         // Get parameters from the context
         // ----------------------------------------------------------------------
 
-        Project project = store.getProjectWithBuildDetails( getProjectId( context ) );
+        Project project = getProject( context );
 
         int trigger = getTrigger( context );
 
@@ -156,6 +156,8 @@
             {
                 build.setState( ContinuumProjectState.ERROR );
             }
+
+            project.setState( build.getState() );
 
             // ----------------------------------------------------------------------
             // Copy over the build result

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectFromWorkingDirectoryContinuumAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectFromWorkingDirectoryContinuumAction.java?rev=387188&r1=387187&r2=387188&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectFromWorkingDirectoryContinuumAction.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectFromWorkingDirectoryContinuumAction.java
Mon Mar 20 03:21:20 2006
@@ -47,7 +47,7 @@
     public void execute( Map context )
         throws ContinuumStoreException, ContinuumException, ContinuumBuildExecutorException
     {
-        Project project = store.getProjectWithBuildDetails( getProjectId( context ) );
+        Project project = getProject( context );
 
         getLogger().info( "Updating project '" + project.getName() + "' from checkout." );
 
@@ -59,7 +59,8 @@
 
         ContinuumBuildExecutor builder = buildExecutorManager.getBuildExecutor( project.getExecutorId()
);
 
-        builder.updateProjectFromCheckOut( workingDirectoryService.getWorkingDirectory( project
), project, buildDefinition );
+        builder.updateProjectFromCheckOut( workingDirectoryService.getWorkingDirectory( project
), project,
+                                           buildDefinition );
 
         // ----------------------------------------------------------------------
         // Store the new descriptor

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java?rev=387188&r1=387187&r2=387188&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
Mon Mar 20 03:21:20 2006
@@ -41,7 +41,7 @@
     public void execute( Map context )
         throws Exception
     {
-        Project project = store.getProject( getProjectId( context ) );
+        Project project = getProject( context );
 
         int state = project.getState();
 

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/ContinuumRecipientSource.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/ContinuumRecipientSource.java?rev=387188&r1=387187&r2=387188&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/ContinuumRecipientSource.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/ContinuumRecipientSource.java
Mon Mar 20 03:21:20 2006
@@ -74,6 +74,9 @@
     {
         Project project = (Project) context.get( ContinuumNotificationDispatcher.CONTEXT_PROJECT
);
 
+        ProjectNotifier projectNotifier =
+            (ProjectNotifier) context.get( ContinuumNotificationDispatcher.CONTEXT_PROJECT_NOTIFIER
);
+
         if ( project == null )
         {
             throw new NotificationException( "Missing project from the notification context."
);
@@ -85,6 +88,10 @@
         {
             recipients.add( toOverride );
         }
+        else if ( projectNotifier != null )
+        {
+            addNotifierAdresses( projectNotifier, recipients );
+        }
         else if ( project.getNotifiers() != null && !project.getNotifiers().isEmpty()
)
         {
             for ( Iterator notifierIterator = project.getNotifiers().iterator(); notifierIterator.hasNext();
)
@@ -94,14 +101,7 @@
                 if ( notifier.getId() == new Integer( notifierId ).intValue() &&
                     notifier.getConfiguration().containsKey( ADDRESS_FIELD ) )
                 {
-                    String addressField = (String) notifier.getConfiguration().get( ADDRESS_FIELD
);
-
-                    String[] addresses = StringUtils.split( addressField, "," );
-
-                    for ( int i = 0; i < addresses.length; i++ )
-                    {
-                        recipients.add( addresses[i].trim() );
-                    }
+                    addNotifierAdresses( notifier, recipients );
                 }
             }
         }
@@ -113,6 +113,24 @@
         else
         {
             return recipients;
+        }
+    }
+
+    private void addNotifierAdresses( ProjectNotifier notifier, Set recipients )
+    {
+        if ( notifier.getConfiguration() != null )
+        {
+            String addressField = (String) notifier.getConfiguration().get( ADDRESS_FIELD
);
+
+            if ( StringUtils.isNotEmpty( addressField ) )
+            {
+                String[] addresses = StringUtils.split( addressField, "," );
+
+                for ( int i = 0; i < addresses.length; i++ )
+                {
+                    recipients.add( addresses[i].trim() );
+                }
+            }
         }
     }
 }

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java?rev=387188&r1=387187&r2=387188&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java
Mon Mar 20 03:21:20 2006
@@ -112,12 +112,6 @@
 
         try
         {
-            // TODO: remove re-reading?
-            // Here we need to get all the project details
-            //  - builds are used to detect if the state has changed (TODO: maybe previousState
field is better)
-            //  - notifiers are used to send the notification
-            project = store.getProjectWithAllDetails( project.getId() );
-
             context.put( CONTEXT_PROJECT, project );
 
             if ( build != null )
@@ -133,12 +127,6 @@
                 context.put( CONTEXT_UPDATE_SCM_RESULT, build.getScmResult() );
             }
         }
-        catch ( ContinuumStoreException e )
-        {
-            getLogger().error( "Error while population the notification context.", e );
-
-            return;
-        }
         catch ( ConfigurationException e )
         {
             getLogger().error( "Error while population the notification context.", e );
@@ -163,7 +151,7 @@
 
             try
             {
-                configuration.put( AbstractContinuumNotifier.PROJECT_NOTIFIER_KEY, projectNotifier
);
+                context.put( CONTEXT_PROJECT_NOTIFIER, projectNotifier );
 
                 Notifier notifier = notifierManager.getNotifier( notifierType );
 

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java?rev=387188&r1=387187&r2=387188&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java
Mon Mar 20 03:21:20 2006
@@ -19,6 +19,7 @@
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectNotifier;
 import org.apache.maven.continuum.notification.AbstractContinuumNotifier;
 import org.apache.maven.continuum.notification.ContinuumNotificationDispatcher;
 import org.apache.maven.continuum.notification.ContinuumRecipientSource;
@@ -176,6 +177,9 @@
     {
         Project project = (Project) context.get( ContinuumNotificationDispatcher.CONTEXT_PROJECT
);
 
+        ProjectNotifier projectNotifier =
+            (ProjectNotifier) context.get( ContinuumNotificationDispatcher.CONTEXT_PROJECT_NOTIFIER
);
+
         BuildResult build = (BuildResult) context.get( ContinuumNotificationDispatcher.CONTEXT_BUILD
);
 
         String buildOutput = (String) context.get( ContinuumNotificationDispatcher.CONTEXT_BUILD_OUTPUT
);
@@ -195,12 +199,12 @@
 
         if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_BUILD_COMPLETE ) )
         {
-            buildComplete( project, build, buildOutput, source, recipients, configuration
);
+            buildComplete( project, projectNotifier, build, buildOutput, source, recipients,
configuration );
         }
     }
 
-    private void buildComplete( Project project, BuildResult build, String buildOutput, String
source, Set recipients,
-                                Map configuration )
+    private void buildComplete( Project project, ProjectNotifier projectNotifier, BuildResult
build, String buildOutput,
+                                String source, Set recipients, Map configuration )
         throws NotificationException
     {
         // ----------------------------------------------------------------------
@@ -209,7 +213,7 @@
 
         BuildResult previousBuild = getPreviousBuild( project, build );
 
-        if ( !shouldNotify( build, previousBuild, configuration ) )
+        if ( !shouldNotify( build, previousBuild, projectNotifier ) )
         {
             return;
         }

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/CheckOutTaskExecutor.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/CheckOutTaskExecutor.java?rev=387188&r1=387187&r2=387188&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/CheckOutTaskExecutor.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/CheckOutTaskExecutor.java
Mon Mar 20 03:21:20 2006
@@ -16,7 +16,11 @@
  * limitations under the License.
  */
 
+import org.apache.maven.continuum.core.action.AbstractContinuumAction;
 import org.apache.maven.continuum.core.action.CheckoutProjectContinuumAction;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.store.ContinuumStore;
+import org.apache.maven.continuum.store.ContinuumStoreException;
 import org.codehaus.plexus.action.ActionManager;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.taskqueue.Task;
@@ -39,6 +43,11 @@
      */
     private ActionManager actionManager;
 
+    /**
+     * @plexus.requirement
+     */
+    private ContinuumStore store;
+
     // ----------------------------------------------------------------------
     // TaskExecutor Implementation
     // ----------------------------------------------------------------------
@@ -50,11 +59,26 @@
 
         int projectId = task.getProjectId();
 
+        Project project;
+
+        try
+        {
+            project = store.getProjectWithBuildDetails( projectId );
+        }
+        catch ( ContinuumStoreException ex )
+        {
+            getLogger().error( "Internal error while getting the project.", ex );
+
+            return;
+        }
+
         String workingDirectory = task.getWorkingDirectory().getAbsolutePath();
 
         Map context = new HashMap();
 
         context.put( CheckoutProjectContinuumAction.KEY_PROJECT_ID, new Integer( projectId
) );
+
+        context.put( CheckoutProjectContinuumAction.KEY_PROJECT, project );
 
         context.put( CheckoutProjectContinuumAction.KEY_WORKING_DIRECTORY, workingDirectory
);
 

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/resources/META-INF/plexus/components.xml?rev=387188&r1=387187&r2=387188&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/resources/META-INF/plexus/components.xml
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/resources/META-INF/plexus/components.xml
Mon Mar 20 03:21:20 2006
@@ -462,6 +462,9 @@
         <requirement>
           <role>org.codehaus.plexus.action.ActionManager</role>
         </requirement>
+        <requirement>
+          <role>org.apache.maven.continuum.store.ContinuumStore</role>
+        </requirement>
       </requirements>
     </component>
 
@@ -659,9 +662,6 @@
         </requirement>
         <requirement>
           <role>org.apache.maven.continuum.execution.manager.BuildExecutorManager</role>
-        </requirement>
-        <requirement>
-          <role>org.apache.maven.continuum.store.ContinuumStore</role>
         </requirement>
         <requirement>
           <role>org.apache.maven.continuum.utils.WorkingDirectoryService</role>

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java?rev=387188&r1=387187&r2=387188&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java
Mon Mar 20 03:21:20 2006
@@ -39,6 +39,8 @@
 
         Project project = addProject( store, "Notification Dispatcher Test Project" );
 
+        project = store.getProjectWithBuildDetails( project.getId() );
+
         BuildResult build = new BuildResult();
 
         build.setStartTime( System.currentTimeMillis() );

Modified: maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java?rev=387188&r1=387187&r2=387188&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java
Mon Mar 20 03:21:20 2006
@@ -30,8 +30,6 @@
 public abstract class AbstractContinuumNotifier
     extends AbstractNotifier
 {
-    public static final String PROJECT_NOTIFIER_KEY = "projectNotifier";
-
     /**
      * @plexus.configuration
      */
@@ -92,16 +90,14 @@
      *
      * @param build         The current build result
      * @param previousBuild The previous build result
-     * @param configuration The project notifier configuration
+     * @param projectNotifier The project notifier
      * @return True if a message must be sent
      */
-    public boolean shouldNotify( BuildResult build, BuildResult previousBuild, Map configuration
)
+    public boolean shouldNotify( BuildResult build, BuildResult previousBuild, ProjectNotifier
projectNotifier )
     {
-        ProjectNotifier projectNotifier = new ProjectNotifier();
-
-        if ( configuration != null && configuration.get( PROJECT_NOTIFIER_KEY ) !=
null )
+        if ( projectNotifier == null )
         {
-            projectNotifier = (ProjectNotifier) configuration.get( PROJECT_NOTIFIER_KEY );
+            projectNotifier = new ProjectNotifier();
         }
 
         if ( build == null )

Modified: maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-irc/src/main/java/org/apache/maven/continuum/notification/irc/IrcContinuumNotifier.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-irc/src/main/java/org/apache/maven/continuum/notification/irc/IrcContinuumNotifier.java?rev=387188&r1=387187&r2=387188&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-irc/src/main/java/org/apache/maven/continuum/notification/irc/IrcContinuumNotifier.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-irc/src/main/java/org/apache/maven/continuum/notification/irc/IrcContinuumNotifier.java
Mon Mar 20 03:21:20 2006
@@ -20,6 +20,7 @@
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectNotifier;
 import org.apache.maven.continuum.notification.AbstractContinuumNotifier;
 import org.apache.maven.continuum.notification.ContinuumNotificationDispatcher;
 import org.apache.maven.continuum.project.ContinuumProjectState;
@@ -69,6 +70,9 @@
     {
         Project project = (Project) context.get( ContinuumNotificationDispatcher.CONTEXT_PROJECT
);
 
+        ProjectNotifier projectNotifier =
+            (ProjectNotifier) context.get( ContinuumNotificationDispatcher.CONTEXT_PROJECT_NOTIFIER
);
+
         BuildResult build = (BuildResult) context.get( ContinuumNotificationDispatcher.CONTEXT_BUILD
);
 
         // ----------------------------------------------------------------------
@@ -88,7 +92,7 @@
         {
             if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_BUILD_COMPLETE
) )
             {
-                buildComplete( project, build, configuration );
+                buildComplete( project, projectNotifier, build, configuration );
             }
         }
         catch ( ContinuumException e )
@@ -97,7 +101,7 @@
         }
     }
 
-    private void buildComplete( Project project, BuildResult build, Map configuration )
+    private void buildComplete( Project project, ProjectNotifier projectNotifier, BuildResult
build, Map configuration )
         throws ContinuumException
     {
         // ----------------------------------------------------------------------
@@ -106,7 +110,7 @@
 
         BuildResult previousBuild = getPreviousBuild( project, build );
 
-        if ( !shouldNotify( build, previousBuild, configuration ) )
+        if ( !shouldNotify( build, previousBuild, projectNotifier ) )
         {
             return;
         }

Modified: maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-jabber/src/main/java/org/apache/maven/continuum/notification/jabber/JabberContinuumNotifier.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-jabber/src/main/java/org/apache/maven/continuum/notification/jabber/JabberContinuumNotifier.java?rev=387188&r1=387187&r2=387188&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-jabber/src/main/java/org/apache/maven/continuum/notification/jabber/JabberContinuumNotifier.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-jabber/src/main/java/org/apache/maven/continuum/notification/jabber/JabberContinuumNotifier.java
Mon Mar 20 03:21:20 2006
@@ -20,6 +20,7 @@
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectNotifier;
 import org.apache.maven.continuum.notification.AbstractContinuumNotifier;
 import org.apache.maven.continuum.notification.ContinuumNotificationDispatcher;
 import org.apache.maven.continuum.project.ContinuumProjectState;
@@ -104,6 +105,9 @@
     {
         Project project = (Project) context.get( ContinuumNotificationDispatcher.CONTEXT_PROJECT
);
 
+        ProjectNotifier projectNotifier =
+            (ProjectNotifier) context.get( ContinuumNotificationDispatcher.CONTEXT_PROJECT_NOTIFIER
);
+
         BuildResult build = (BuildResult) context.get( ContinuumNotificationDispatcher.CONTEXT_BUILD
);
 
         // ----------------------------------------------------------------------
@@ -132,7 +136,7 @@
 
         if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_BUILD_COMPLETE ) )
         {
-            sendMessage( project, build, recipients, configuration );
+            sendMessage( project, projectNotifier, build, recipients, configuration );
         }
     }
 
@@ -174,7 +178,8 @@
         return message + " " + getReportUrl( project, build, configurationService );
     }
 
-    private void sendMessage( Project project, BuildResult build, Set recipients, Map configuration
)
+    private void sendMessage( Project project, ProjectNotifier projectNotifier, BuildResult
build, Set recipients,
+                              Map configuration )
         throws NotificationException
     {
         String message;
@@ -185,7 +190,7 @@
 
         BuildResult previousBuild = getPreviousBuild( project, build );
 
-        if ( !shouldNotify( build, previousBuild, configuration ) )
+        if ( !shouldNotify( build, previousBuild, projectNotifier ) )
         {
             return;
         }
@@ -327,7 +332,7 @@
         {
             return port;
         }
-        else if ( isSslConnection ( configuration ) )
+        else if ( isSslConnection( configuration ) )
         {
             return 5223;
         }
@@ -368,7 +373,7 @@
     {
         if ( configuration.containsKey( "sslConnection" ) )
         {
-            return convertBoolean( (String ) configuration.get( "sslConnection" ) );
+            return convertBoolean( (String) configuration.get( "sslConnection" ) );
         }
 
         return sslConnection;

Modified: maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-msn/src/main/java/org/apache/maven/continuum/notification/msn/MsnContinuumNotifier.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-msn/src/main/java/org/apache/maven/continuum/notification/msn/MsnContinuumNotifier.java?rev=387188&r1=387187&r2=387188&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-msn/src/main/java/org/apache/maven/continuum/notification/msn/MsnContinuumNotifier.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-msn/src/main/java/org/apache/maven/continuum/notification/msn/MsnContinuumNotifier.java
Mon Mar 20 03:21:20 2006
@@ -20,6 +20,7 @@
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectNotifier;
 import org.apache.maven.continuum.notification.AbstractContinuumNotifier;
 import org.apache.maven.continuum.notification.ContinuumNotificationDispatcher;
 import org.apache.maven.continuum.project.ContinuumProjectState;
@@ -88,6 +89,9 @@
     {
         Project project = (Project) context.get( ContinuumNotificationDispatcher.CONTEXT_PROJECT
);
 
+        ProjectNotifier projectNotifier =
+            (ProjectNotifier) context.get( ContinuumNotificationDispatcher.CONTEXT_PROJECT_NOTIFIER
);
+
         BuildResult build = (BuildResult) context.get( ContinuumNotificationDispatcher.CONTEXT_BUILD
);
 
         // ----------------------------------------------------------------------
@@ -116,7 +120,7 @@
 
         if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_BUILD_COMPLETE ) )
         {
-            buildComplete( project, build, recipients, configuration );
+            buildComplete( project, projectNotifier, build, recipients, configuration );
         }
     }
 
@@ -158,7 +162,8 @@
         return message + " " + getReportUrl( project, build, configurationService );
     }
 
-    private void buildComplete( Project project, BuildResult build, Set recipients, Map configuration
)
+    private void buildComplete( Project project, ProjectNotifier projectNotifier, BuildResult
build, Set recipients,
+                                Map configuration )
         throws NotificationException
     {
         String message;
@@ -169,7 +174,7 @@
 
         BuildResult previousBuild = getPreviousBuild( project, build );
 
-        if ( !shouldNotify( build, previousBuild, configuration ) )
+        if ( !shouldNotify( build, previousBuild, projectNotifier ) )
         {
             return;
         }



Mime
View raw message