continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r584714 - in /maven/continuum/trunk: continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/ continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/ continuum-notifiers/continuum-notifier-api/src/main/jav...
Date Mon, 15 Oct 2007 09:03:01 GMT
Author: evenisse
Date: Mon Oct 15 02:02:58 2007
New Revision: 584714

URL: http://svn.apache.org/viewvc?rev=584714&view=rev
Log:
move getPreviousBuild in AbstractContinuumNotifier

Modified:
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java
    maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java
    maven/continuum/trunk/continuum-notifiers/continuum-notifier-irc/src/main/java/org/apache/maven/continuum/notification/irc/IrcContinuumNotifier.java
    maven/continuum/trunk/continuum-notifiers/continuum-notifier-jabber/src/main/java/org/apache/maven/continuum/notification/jabber/JabberContinuumNotifier.java
    maven/continuum/trunk/continuum-notifiers/continuum-notifier-msn/src/main/java/org/apache/maven/continuum/notification/msn/MsnContinuumNotifier.java
    maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/mdo/continuum-service.xml
    maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java?rev=584714&r1=584713&r2=584714&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
Mon Oct 15 02:02:58 2007
@@ -703,6 +703,8 @@
 
         build.setScmResult( context.getScmResult() );
 
+        build.setBuildDefinition( context.getBuildDefinition() );
+
         if ( error != null )
         {
             build.setError( error );

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java?rev=584714&r1=584713&r2=584714&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java
Mon Oct 15 02:02:58 2007
@@ -37,8 +37,6 @@
 import org.apache.maven.continuum.notification.ContinuumNotificationDispatcher;
 import org.apache.maven.continuum.notification.ContinuumRecipientSource;
 import org.apache.maven.continuum.project.ContinuumProjectState;
-import org.apache.maven.continuum.store.ContinuumStore;
-import org.apache.maven.continuum.store.ContinuumStoreException;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.exception.ResourceNotFoundException;
 import org.codehaus.plexus.mailsender.MailMessage;
@@ -82,11 +80,6 @@
     private ConfigurationService configurationService;
 
     /**
-     * @plexus.requirement role-hint="jdo"
-     */
-    private ContinuumStore store;
-
-    /**
      * @plexus.requirement
      */
     private Continuum continuum;
@@ -130,12 +123,12 @@
 
     /**
      * Customizable mail subject.  Use any combination of literal text, project or build
attributes.
-     * Examples: 
-     *   "[continuum] BUILD ${state}: ${project.groupId} ${project.name}" results in "[continuum]
BUILD SUCCESSFUL: foo.bar Hello World"
-     *   "[continuum] BUILD ${state}: ${project.name} ${project.scmTag}" results in "[continuum]
BUILD SUCCESSFUL: Hello World Branch001"
-     *   "[continuum] BUILD ${state}: ${project.name} ${build.durationTime}" results in "[continuum]
BUILD SUCCESSFUL: Hello World 2 sec"
-     *   "[continuum] BUILD ${state}: ${project.name}, Build Def - ${build.buildDefinition.description}"
results in "[continuum] BUILD SUCCESSFUL: Hello World, Build Def - Nightly Test Build"
-     * 
+     * Examples:
+     * "[continuum] BUILD ${state}: ${project.groupId} ${project.name}" results in "[continuum]
BUILD SUCCESSFUL: foo.bar Hello World"
+     * "[continuum] BUILD ${state}: ${project.name} ${project.scmTag}" results in "[continuum]
BUILD SUCCESSFUL: Hello World Branch001"
+     * "[continuum] BUILD ${state}: ${project.name} ${build.durationTime}" results in "[continuum]
BUILD SUCCESSFUL: Hello World 2 sec"
+     * "[continuum] BUILD ${state}: ${project.name}, Build Def - ${build.buildDefinition.description}"
results in "[continuum] BUILD SUCCESSFUL: Hello World, Build Def - Nightly Test Build"
+     *
      * @plexus.configuration
      */
     private String subjectFormat = "[continuum] BUILD ${state}: ${project.groupId} ${project.name}";
@@ -255,7 +248,7 @@
         // Check if the mail should be sent at all
         // ----------------------------------------------------------------------
 
-        BuildResult previousBuild = getPreviousBuild( project, build );
+        BuildResult previousBuild = getPreviousBuild( project, buildDefinition, build );
 
         if ( !shouldNotify( build, previousBuild, projectNotifier ) )
         {
@@ -283,7 +276,8 @@
                 context.put( "buildOutput", buildOutput );
             }
 
-            if ( includeBuildSummary ) {
+            if ( includeBuildSummary )
+            {
                 context.put( "build", build );
 
                 context.put( "project", project );
@@ -322,15 +316,14 @@
 
                 context.put( "builderVersions", getBuilderVersion( buildDefinition, project
) );
             }
-            
+
             // ----------------------------------------------------------------------
             // Data objects
             // ----------------------------------------------------------------------
 
             context.put( "reportUrl", getReportUrl( project, build, configurationService
) );
 
-
-            // TODO put other profile env var could be a security if they provide passwords
? 
+            // TODO put other profile env var could be a security if they provide passwords
?
 
             // ----------------------------------------------------------------------
             // Generate
@@ -356,9 +349,12 @@
         // ----------------------------------------------------------------------
 
         String subject;
-        try {
+        try
+        {
             subject = generateSubject( project, build );
-        } catch ( Exception e ) {
+        }
+        catch ( Exception e )
+        {
             throw new NotificationException( "Error while generating mail subject.", e );
         }
 
@@ -431,19 +427,20 @@
             .getVarValue(), executorConfigurator, profile );
     }
 
-    private String generateSubject( Project project, BuildResult build ) throws Exception
+    private String generateSubject( Project project, BuildResult build )
+        throws Exception
     {
         String state = getState( project, build );
-        
+
         VelocityContext context = new VelocityContext();
         context.put( "project", project );
         context.put( "build", build );
         context.put( "state", state );
-        
+
         StringWriter writer = new StringWriter();
 
         boolean velocityResults = velocity.getEngine().evaluate( context, writer, "subjectPattern",
subjectFormat );
-            
+
         String subject = writer.toString();
 
         return subject;
@@ -453,11 +450,11 @@
     {
         int state = project.getState();
 
-        if ( build != null ) {
+        if ( build != null )
+        {
             state = build.getState();
         }
 
-
         if ( state == ContinuumProjectState.OK )
         {
             return "SUCCESSFUL";
@@ -475,7 +472,7 @@
             getLogger().warn( "Unknown build state " + state + " for project " + project.getId()
);
 
             return "ERROR: Unknown build state " + state;
-       }
+        }
     }
 
     private void sendMessage( Project project, Set recipients, String subject, String content,
Map configuration )
@@ -564,39 +561,6 @@
         }
 
         return address;
-    }
-
-    private BuildResult getPreviousBuild( Project project, BuildResult currentBuild )
-        throws NotificationException
-    {
-        try
-        {
-            // TODO: prefer to remove this and get them up front
-            if ( project.getId() > 0 )
-            {
-                project = store.getProjectWithBuilds( project.getId() );
-            }
-        }
-        catch ( ContinuumStoreException e )
-        {
-            throw new NotificationException( "Unable to obtain project builds", e );
-        }
-        List builds = project.getBuildResults();
-
-        if ( builds.size() < 2 )
-        {
-            return null;
-        }
-
-        BuildResult build = (BuildResult) builds.get( builds.size() - 1 );
-
-        if ( currentBuild != null && build.getId() != currentBuild.getId() )
-        {
-            throw new NotificationException( "INTERNAL ERROR: The current build wasn't the
first in the build list. " +
-                "Current build: '" + currentBuild.getId() + "', " + "first build: '" + build.getId()
+ "'." );
-        }
-
-        return (BuildResult) builds.get( builds.size() - 2 );
     }
 
     /**

Modified: maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java?rev=584714&r1=584713&r2=584714&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java
(original)
+++ maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java
Mon Oct 15 02:02:58 2007
@@ -22,16 +22,27 @@
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.configuration.ConfigurationLoadingException;
 import org.apache.maven.continuum.configuration.ConfigurationService;
+import org.apache.maven.continuum.model.project.BuildDefinition;
 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.project.ContinuumProjectState;
+import org.apache.maven.continuum.store.ContinuumStore;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.codehaus.plexus.notification.NotificationException;
 import org.codehaus.plexus.notification.notifier.AbstractNotifier;
 
+import java.util.List;
+
 public abstract class AbstractContinuumNotifier
     extends AbstractNotifier
 {
     /**
+     * @plexus.requirement role-hint="jdo"
+     */
+    private ContinuumStore store;
+
+    /**
      * @plexus.configuration
      */
     private boolean alwaysSend = false;
@@ -39,8 +50,11 @@
     /**
      * Returns url of the last build
      *
-     * @param project The project
-     * @param build   The build
+     * @param project              The project
+     * @param build                The build
+     * @param configurationService The configuration Service
+     * @return The report URL
+     * @throws ContinuumException whne the configuration can't be loaded
      */
     public String getReportUrl( Project project, BuildResult build, ConfigurationService
configurationService )
         throws ContinuumException
@@ -76,19 +90,6 @@
     /**
      * Determine if message must be sent
      *
-     * @param build         The current build result
-     * @param previousBuild The previous build result
-     * @return True if a message must be sent
-     * @deprecated
-     */
-    public boolean shouldNotify( BuildResult build, BuildResult previousBuild )
-    {
-        return shouldNotify( build, previousBuild, null );
-    }
-
-    /**
-     * Determine if message must be sent
-     *
      * @param build           The current build result
      * @param previousBuild   The previous build result
      * @param projectNotifier The project notifier
@@ -180,4 +181,38 @@
 
         return false;
     }
+
+    protected BuildResult getPreviousBuild( Project project, BuildDefinition buildDef, BuildResult
currentBuild )
+        throws NotificationException
+    {
+        try
+        {
+            // TODO: prefer to remove this and get them up front
+            if ( project.getId() > 0 )
+            {
+                project = store.getProjectWithBuilds( project.getId() );
+            }
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new NotificationException( "Unable to obtain project builds", e );
+        }
+        List builds = project.getBuildResults();
+
+        if ( builds.size() < 2 )
+        {
+            return null;
+        }
+
+        BuildResult build = (BuildResult) builds.get( builds.size() - 1 );
+
+        if ( currentBuild != null && build.getId() != currentBuild.getId() )
+        {
+            throw new NotificationException( "INTERNAL ERROR: The current build wasn't the
first in the build list. " +
+                "Current build: '" + currentBuild.getId() + "', " + "first build: '" + build.getId()
+ "'." );
+        }
+
+        return (BuildResult) builds.get( builds.size() - 2 );
+    }
+
 }

Modified: maven/continuum/trunk/continuum-notifiers/continuum-notifier-irc/src/main/java/org/apache/maven/continuum/notification/irc/IrcContinuumNotifier.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-notifiers/continuum-notifier-irc/src/main/java/org/apache/maven/continuum/notification/irc/IrcContinuumNotifier.java?rev=584714&r1=584713&r2=584714&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-notifiers/continuum-notifier-irc/src/main/java/org/apache/maven/continuum/notification/irc/IrcContinuumNotifier.java
(original)
+++ maven/continuum/trunk/continuum-notifiers/continuum-notifier-irc/src/main/java/org/apache/maven/continuum/notification/irc/IrcContinuumNotifier.java
Mon Oct 15 02:02:58 2007
@@ -21,14 +21,13 @@
 
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.configuration.ConfigurationService;
+import org.apache.maven.continuum.model.project.BuildDefinition;
 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;
-import org.apache.maven.continuum.store.ContinuumStore;
-import org.apache.maven.continuum.store.ContinuumStoreException;
 import org.codehaus.plexus.notification.NotificationException;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Disposable;
 import org.codehaus.plexus.util.StringUtils;
@@ -65,11 +64,6 @@
     // ----------------------------------------------------------------------
 
     /**
-     * @plexus.requirement role-hint="jdo"
-     */
-    private ContinuumStore store;
-
-    /**
      * @plexus.requirement
      */
     private ConfigurationService configurationService;
@@ -232,6 +226,9 @@
         ProjectNotifier projectNotifier =
             (ProjectNotifier) context.get( ContinuumNotificationDispatcher.CONTEXT_PROJECT_NOTIFIER
);
 
+        BuildDefinition buildDefinition = (BuildDefinition) context
+            .get( ContinuumNotificationDispatcher.CONTEXT_BUILD_DEFINITION );
+
         BuildResult build = (BuildResult) context.get( ContinuumNotificationDispatcher.CONTEXT_BUILD
);
 
         // ----------------------------------------------------------------------
@@ -251,7 +248,7 @@
         {
             if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_BUILD_COMPLETE
) )
             {
-                buildComplete( project, projectNotifier, build, configuration );
+                buildComplete( project, projectNotifier, build, buildDefinition, configuration
);
             }
         }
         catch ( ContinuumException e )
@@ -260,14 +257,15 @@
         }
     }
 
-    private void buildComplete( Project project, ProjectNotifier projectNotifier, BuildResult
build, Map configuration )
-        throws ContinuumException
+    private void buildComplete( Project project, ProjectNotifier projectNotifier, BuildResult
build,
+                                BuildDefinition buildDef, Map configuration )
+        throws ContinuumException, NotificationException
     {
         // ----------------------------------------------------------------------
         // Check if the message should be sent at all
         // ----------------------------------------------------------------------
 
-        BuildResult previousBuild = getPreviousBuild( project, build );
+        BuildResult previousBuild = getPreviousBuild( project, buildDef, build );
 
         if ( !shouldNotify( build, previousBuild, projectNotifier ) )
         {
@@ -328,7 +326,7 @@
         }
         catch ( IOException e )
         {
-            throw new ContinuumException( "Exception while checkConnection to irc ." + host,
e );
+            throw new NotificationException( "Exception while checkConnection to irc ." +
host, e );
         }
     }
 
@@ -364,39 +362,6 @@
         }
 
         return message + " " + getReportUrl( project, build, configurationService );
-    }
-
-    private BuildResult getPreviousBuild( Project project, BuildResult currentBuild )
-        throws ContinuumException
-    {
-        try
-        {
-            // TODO: prefer to remove this and get them up front
-            if ( project.getId() > 0 )
-            {
-                project = store.getProjectWithBuilds( project.getId() );
-            }
-        }
-        catch ( ContinuumStoreException e )
-        {
-            throw new ContinuumException( "Unable to obtain project builds", e );
-        }
-        List builds = project.getBuildResults();
-
-        if ( builds.size() < 2 )
-        {
-            return null;
-        }
-
-        BuildResult build = (BuildResult) builds.get( builds.size() - 1 );
-
-        if ( currentBuild != null && build.getId() != currentBuild.getId() )
-        {
-            throw new ContinuumException( "INTERNAL ERROR: The current build wasn't the first
in the build list. " +
-                "Current build: '" + currentBuild.getId() + "', " + "first build: '" + build.getId()
+ "'." );
-        }
-
-        return (BuildResult) builds.get( builds.size() - 2 );
     }
 
     /**

Modified: maven/continuum/trunk/continuum-notifiers/continuum-notifier-jabber/src/main/java/org/apache/maven/continuum/notification/jabber/JabberContinuumNotifier.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-notifiers/continuum-notifier-jabber/src/main/java/org/apache/maven/continuum/notification/jabber/JabberContinuumNotifier.java?rev=584714&r1=584713&r2=584714&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-notifiers/continuum-notifier-jabber/src/main/java/org/apache/maven/continuum/notification/jabber/JabberContinuumNotifier.java
(original)
+++ maven/continuum/trunk/continuum-notifiers/continuum-notifier-jabber/src/main/java/org/apache/maven/continuum/notification/jabber/JabberContinuumNotifier.java
Mon Oct 15 02:02:58 2007
@@ -21,20 +21,18 @@
 
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.configuration.ConfigurationService;
+import org.apache.maven.continuum.model.project.BuildDefinition;
 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;
-import org.apache.maven.continuum.store.ContinuumStore;
-import org.apache.maven.continuum.store.ContinuumStoreException;
 import org.codehaus.plexus.jabber.JabberClient;
 import org.codehaus.plexus.jabber.JabberClientException;
 import org.codehaus.plexus.notification.NotificationException;
 
 import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
@@ -60,11 +58,6 @@
      */
     private ConfigurationService configurationService;
 
-    /**
-     * @plexus.requirement role-hint="jdo"
-     */
-    private ContinuumStore store;
-
     // ----------------------------------------------------------------------
     // Configuration
     // ----------------------------------------------------------------------
@@ -111,6 +104,9 @@
         ProjectNotifier projectNotifier =
             (ProjectNotifier) context.get( ContinuumNotificationDispatcher.CONTEXT_PROJECT_NOTIFIER
);
 
+        BuildDefinition buildDefinition = (BuildDefinition) context
+            .get( ContinuumNotificationDispatcher.CONTEXT_BUILD_DEFINITION );
+
         BuildResult build = (BuildResult) context.get( ContinuumNotificationDispatcher.CONTEXT_BUILD
);
 
         // ----------------------------------------------------------------------
@@ -139,7 +135,7 @@
 
         if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_BUILD_COMPLETE ) )
         {
-            sendMessage( project, projectNotifier, build, recipients, configuration );
+            sendMessage( project, projectNotifier, build, recipients, buildDefinition, configuration
);
         }
     }
 
@@ -182,7 +178,7 @@
     }
 
     private void sendMessage( Project project, ProjectNotifier projectNotifier, BuildResult
build, Set recipients,
-                              Map configuration )
+                              BuildDefinition buildDef, Map configuration )
         throws NotificationException
     {
         String message;
@@ -191,7 +187,7 @@
         // Check if the mail should be sent at all
         // ----------------------------------------------------------------------
 
-        BuildResult previousBuild = getPreviousBuild( project, build );
+        BuildResult previousBuild = getPreviousBuild( project, buildDef, build );
 
         if ( !shouldNotify( build, previousBuild, projectNotifier ) )
         {
@@ -254,39 +250,6 @@
 
             }
         }
-    }
-
-    private BuildResult getPreviousBuild( Project project, BuildResult currentBuild )
-        throws NotificationException
-    {
-        try
-        {
-            // TODO: prefer to remove this and get them up front
-            if ( project.getId() > 0 )
-            {
-                project = store.getProjectWithBuilds( project.getId() );
-            }
-        }
-        catch ( ContinuumStoreException e )
-        {
-            throw new NotificationException( "Unable to obtain project builds", e );
-        }
-        List builds = project.getBuildResults();
-
-        if ( builds.size() < 2 )
-        {
-            return null;
-        }
-
-        BuildResult build = (BuildResult) builds.get( builds.size() - 1 );
-
-        if ( currentBuild != null && build.getId() != currentBuild.getId() )
-        {
-            throw new NotificationException( "INTERNAL ERROR: The current build wasn't the
first in the build list. " +
-                "Current build: '" + currentBuild.getId() + "', " + "first build: '" + build.getId()
+ "'." );
-        }
-
-        return (BuildResult) builds.get( builds.size() - 2 );
     }
 
     public void sendNotification( String arg0, Set arg1, Properties arg2 )

Modified: maven/continuum/trunk/continuum-notifiers/continuum-notifier-msn/src/main/java/org/apache/maven/continuum/notification/msn/MsnContinuumNotifier.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-notifiers/continuum-notifier-msn/src/main/java/org/apache/maven/continuum/notification/msn/MsnContinuumNotifier.java?rev=584714&r1=584713&r2=584714&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-notifiers/continuum-notifier-msn/src/main/java/org/apache/maven/continuum/notification/msn/MsnContinuumNotifier.java
(original)
+++ maven/continuum/trunk/continuum-notifiers/continuum-notifier-msn/src/main/java/org/apache/maven/continuum/notification/msn/MsnContinuumNotifier.java
Mon Oct 15 02:02:58 2007
@@ -21,20 +21,18 @@
 
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.configuration.ConfigurationService;
+import org.apache.maven.continuum.model.project.BuildDefinition;
 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;
-import org.apache.maven.continuum.store.ContinuumStore;
-import org.apache.maven.continuum.store.ContinuumStoreException;
 import org.codehaus.plexus.msn.MsnClient;
 import org.codehaus.plexus.msn.MsnException;
 import org.codehaus.plexus.notification.NotificationException;
 
 import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
@@ -60,11 +58,6 @@
      */
     private ConfigurationService configurationService;
 
-    /**
-     * @plexus.requirement="jdo"
-     */
-    private ContinuumStore store;
-
     // ----------------------------------------------------------------------
     // Configuration
     // ----------------------------------------------------------------------
@@ -95,6 +88,9 @@
         ProjectNotifier projectNotifier =
             (ProjectNotifier) context.get( ContinuumNotificationDispatcher.CONTEXT_PROJECT_NOTIFIER
);
 
+        BuildDefinition buildDefinition = (BuildDefinition) context
+            .get( ContinuumNotificationDispatcher.CONTEXT_BUILD_DEFINITION );
+
         BuildResult build = (BuildResult) context.get( ContinuumNotificationDispatcher.CONTEXT_BUILD
);
 
         // ----------------------------------------------------------------------
@@ -123,7 +119,7 @@
 
         if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_BUILD_COMPLETE ) )
         {
-            buildComplete( project, projectNotifier, build, recipients, configuration );
+            buildComplete( project, projectNotifier, build, recipients, buildDefinition,
configuration );
         }
     }
 
@@ -166,7 +162,7 @@
     }
 
     private void buildComplete( Project project, ProjectNotifier projectNotifier, BuildResult
build, Set recipients,
-                                Map configuration )
+                                BuildDefinition buildDef, Map configuration )
         throws NotificationException
     {
         String message;
@@ -175,7 +171,7 @@
         // Check if the message should be sent at all
         // ----------------------------------------------------------------------
 
-        BuildResult previousBuild = getPreviousBuild( project, build );
+        BuildResult previousBuild = getPreviousBuild( project, buildDef, build );
 
         if ( !shouldNotify( build, previousBuild, projectNotifier ) )
         {
@@ -221,39 +217,6 @@
 
             }
         }
-    }
-
-    private BuildResult getPreviousBuild( Project project, BuildResult currentBuild )
-        throws NotificationException
-    {
-        try
-        {
-            // TODO: prefer to remove this and get them up front
-            if ( project.getId() > 0 )
-            {
-                project = store.getProjectWithBuilds( project.getId() );
-            }
-        }
-        catch ( ContinuumStoreException e )
-        {
-            throw new NotificationException( "Unable to obtain project builds", e );
-        }
-        List builds = project.getBuildResults();
-
-        if ( builds.size() < 2 )
-        {
-            return null;
-        }
-
-        BuildResult build = (BuildResult) builds.get( builds.size() - 1 );
-
-        if ( currentBuild != null && build.getId() != currentBuild.getId() )
-        {
-            throw new NotificationException( "INTERNAL ERROR: The current build wasn't the
first in the build list. " +
-                "Current build: '" + currentBuild.getId() + "', " + "first build: '" + build.getId()
+ "'." );
-        }
-
-        return (BuildResult) builds.get( builds.size() - 2 );
     }
 
     /**

Modified: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/mdo/continuum-service.xml
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/mdo/continuum-service.xml?rev=584714&r1=584713&r2=584714&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/mdo/continuum-service.xml
(original)
+++ maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/mdo/continuum-service.xml
Mon Oct 15 02:02:58 2007
@@ -454,6 +454,13 @@
             <type>ProjectSummary</type>
           </association>
         </field>
+        <field>
+          <name>buildDefinition</name>
+          <version>1.1.0+</version>
+          <association xml.reference="true">
+            <type>BuildDefinition</type>
+          </association>
+        </field>
       </fields>
     </class>
 

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?rev=584714&r1=584713&r2=584714&view=diff
==============================================================================
--- 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 Oct 15 02:02:58 2007
@@ -929,6 +929,7 @@
         br.setSuccess( buildResult.isSuccess() );
         br.setTrigger( buildResult.getTrigger() );
         br.setProject( populateProjectSummary( buildResult.getProject() ) );
+        br.setBuildDefinition( populateBuildDefinition( buildResult.getBuildDefinition()
) );
         return br;
     }
 



Mime
View raw message