continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r220334 - in /maven/continuum/trunk: ./ continuum-core/ continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/ continuum-notifiers/ continuum-notifiers/continuum-notifier-api/ continuum-notifiers/continuum-notifier-api/s...
Date Fri, 22 Jul 2005 15:07:55 GMT
Author: evenisse
Date: Fri Jul 22 08:07:32 2005
New Revision: 220334

URL: http://svn.apache.org/viewcvs?rev=220334&view=rev
Log:
o [CONTINUUM-230]. Provide a useful url in notification
o clean jabber and msn notifiers

Added:
    maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/   (with props)
    maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/pom.xml   (with props)
    maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/src/
    maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/src/main/
    maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/src/main/java/
    maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/src/main/java/org/
    maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/
    maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/
    maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/
    maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/
    maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java
  (with props)
Modified:
    maven/continuum/trunk/continuum-core/pom.xml
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java
    maven/continuum/trunk/continuum-notifiers/continuum-notifier-irc/pom.xml
    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/pom.xml
    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/pom.xml
    maven/continuum/trunk/continuum-notifiers/continuum-notifier-msn/src/main/java/org/apache/maven/continuum/notification/msn/MsnContinuumNotifier.java
    maven/continuum/trunk/continuum-notifiers/pom.xml
    maven/continuum/trunk/continuum-plexus-application/src/conf/application.xml
    maven/continuum/trunk/pom.xml

Modified: maven/continuum/trunk/continuum-core/pom.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/pom.xml?rev=220334&r1=220333&r2=220334&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/pom.xml (original)
+++ maven/continuum/trunk/continuum-core/pom.xml Fri Jul 22 08:07:32 2005
@@ -23,6 +23,10 @@
       <artifactId>continuum-test</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.apache.maven.continuum</groupId>
+      <artifactId>continuum-notifier-api</artifactId>
+    </dependency>
+    <dependency>
       <groupId>jpox</groupId>
       <artifactId>jpox</artifactId>
     </dependency>

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java?rev=220334&r1=220333&r2=220334&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
Fri Jul 22 08:07:32 2005
@@ -26,6 +26,7 @@
 import java.util.Set;
 
 import org.apache.maven.continuum.ContinuumException;
+import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.notification.ContinuumNotificationDispatcher;
 import org.apache.maven.continuum.notification.ContinuumRecipientSource;
 import org.apache.maven.continuum.project.ContinuumBuild;
@@ -61,6 +62,11 @@
      * @plexus.requirement
      */
     private VelocityComponent velocity;
+
+    /**
+     * @plexus.requirement
+     */
+    private ConfigurationService configurationService;
 
     /**
      * @plexus.configuration

Propchange: maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Jul 22 08:07:32 2005
@@ -0,0 +1 @@
+target

Added: maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/pom.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/pom.xml?rev=220334&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/pom.xml (added)
+++ maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/pom.xml Fri Jul 22 08:07:32
2005
@@ -0,0 +1,11 @@
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.maven.continuum</groupId>
+    <artifactId>continuum-parent-notifiers</artifactId>
+    <version>1.0-beta-1-SNAPSHOT</version>
+  </parent>
+  <artifactId>continuum-notifier-api</artifactId>
+  <version>1.0-beta-1-SNAPSHOT</version>
+  <name>Continuum Notifier API</name>
+</project>

Propchange: maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java?rev=220334&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java
(added)
+++ maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java
Fri Jul 22 08:07:32 2005
@@ -0,0 +1,59 @@
+package org.apache.maven.continuum.notification;
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+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.project.ContinuumBuild;
+import org.apache.maven.continuum.project.ContinuumProject;
+import org.codehaus.plexus.notification.notifier.AbstractNotifier;
+
+public abstract class AbstractContinuumNotifier
+    extends AbstractNotifier
+{
+    /**
+     * Returns url of the last build
+     *
+     * @param project The project
+     * @param build The build
+     */
+    public String getReportUrl( ContinuumProject project, ContinuumBuild build, ConfigurationService
configurationService )
+        throws ContinuumException
+    {
+        try
+        {
+            //TODO it's bad to load always the conf when we want read a value
+            configurationService.load();
+
+            StringBuffer buf = new StringBuffer( configurationService.getUrl() );
+
+            if ( !buf.toString().endsWith( "/" ) )
+            {
+                buf.append( "/" );
+            }
+
+            buf.append( "target/ProjectBuild.vm/view/ProjectBuild/id/" ).append( project.getId()
).append( "/buildId/" ).append( build.getId() );
+
+            return buf.toString();
+        }
+        catch ( ConfigurationLoadingException e )
+        {
+            throw new ContinuumException( "Can't obtain the base url from configuration.",
e );
+        }
+    }
+}

Propchange: maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/continuum/trunk/continuum-notifiers/continuum-notifier-irc/pom.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-notifiers/continuum-notifier-irc/pom.xml?rev=220334&r1=220333&r2=220334&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-notifiers/continuum-notifier-irc/pom.xml (original)
+++ maven/continuum/trunk/continuum-notifiers/continuum-notifier-irc/pom.xml Fri Jul 22 08:07:32
2005
@@ -10,6 +10,11 @@
   <version>1.0-beta-1-SNAPSHOT</version>
   <dependencies>
     <dependency>
+      <groupId>org.apache.maven.continuum</groupId>
+      <artifactId>continuum-notifier-api</artifactId>
+      <version>1.0-beta-1-SNAPSHOT</version>
+    </dependency>
+    <dependency>
       <groupId>plexus</groupId>
       <artifactId>plexus-ircbot</artifactId>
       <version>1.1-alpha-4</version>

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/viewcvs/maven/continuum/trunk/continuum-notifiers/continuum-notifier-irc/src/main/java/org/apache/maven/continuum/notification/irc/IrcContinuumNotifier.java?rev=220334&r1=220333&r2=220334&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
Fri Jul 22 08:07:32 2005
@@ -17,14 +17,16 @@
  */
 
 import org.apache.maven.continuum.ContinuumException;
+import org.apache.maven.continuum.configuration.ConfigurationService;
+import org.apache.maven.continuum.notification.AbstractContinuumNotifier;
 import org.apache.maven.continuum.notification.ContinuumNotificationDispatcher;
 import org.apache.maven.continuum.project.ContinuumBuild;
 import org.apache.maven.continuum.project.ContinuumProject;
 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 org.codehaus.plexus.ircbot.IrcBot;
 
 import java.util.Collection;
@@ -38,7 +40,7 @@
  * @version $Id$
  */
 public class IrcContinuumNotifier
-    extends AbstractNotifier
+    extends AbstractContinuumNotifier
 {
     // ----------------------------------------------------------------------
     // Requirements
@@ -54,6 +56,11 @@
      */
     private IrcBot ircClient;
 
+    /**
+     * @plexus.requirement
+     */
+    private ConfigurationService configurationService;
+
     // ----------------------------------------------------------------------
     // Notifier Implementation
     // ----------------------------------------------------------------------
@@ -136,27 +143,32 @@
     }
 
     private String generateMessage( ContinuumProject project, ContinuumBuild build )
+        throws ContinuumException
     {
         int state = build.getState();
 
+        String message;
+
         if ( state == ContinuumProjectState.OK )
         {
-            return "BUILD SUCCESSFUL: " + project.getName();
+            message = "BUILD SUCCESSFUL: " + project.getName();
         }
         else if ( state == ContinuumProjectState.FAILED )
         {
-            return "BUILD FAILURE: " + project.getName();
+            message = "BUILD FAILURE: " + project.getName();
         }
         else if ( state == ContinuumProjectState.ERROR )
         {
-            return "BUILD ERROR: " + project.getName();
+            message = "BUILD ERROR: " + project.getName();
         }
         else
         {
-            getLogger().warn( "Unknown build state " + build.getState() );
+            getLogger().warn( "Unknown build state " + build.getState() + " for project "
+ project.getId() );
 
-            return "ERROR: Unknown build state " + build.getState();
+            message = "ERROR: Unknown build state " + build.getState();
         }
+
+        return message + " " + getReportUrl( project, build, configurationService );
     }
 
     private boolean shouldNotify( ContinuumBuild build, ContinuumBuild previousBuild )

Modified: maven/continuum/trunk/continuum-notifiers/continuum-notifier-jabber/pom.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-notifiers/continuum-notifier-jabber/pom.xml?rev=220334&r1=220333&r2=220334&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-notifiers/continuum-notifier-jabber/pom.xml (original)
+++ maven/continuum/trunk/continuum-notifiers/continuum-notifier-jabber/pom.xml Fri Jul 22
08:07:32 2005
@@ -10,6 +10,11 @@
   <version>1.0-beta-1-SNAPSHOT</version>
   <dependencies>
     <dependency>
+      <groupId>org.apache.maven.continuum</groupId>
+      <artifactId>continuum-notifier-api</artifactId>
+      <version>1.0-beta-1-SNAPSHOT</version>
+    </dependency>
+    <dependency>
       <groupId>plexus</groupId>
       <artifactId>plexus-jabber</artifactId>
       <version>1.0-alpha-1</version>

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/viewcvs/maven/continuum/trunk/continuum-notifiers/continuum-notifier-jabber/src/main/java/org/apache/maven/continuum/notification/jabber/JabberContinuumNotifier.java?rev=220334&r1=220333&r2=220334&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
Fri Jul 22 08:07:32 2005
@@ -21,14 +21,17 @@
 import java.util.Properties;
 import java.util.Set;
 
+import org.apache.maven.continuum.ContinuumException;
+import org.apache.maven.continuum.configuration.ConfigurationService;
+import org.apache.maven.continuum.notification.AbstractContinuumNotifier;
 import org.apache.maven.continuum.notification.ContinuumNotificationDispatcher;
 import org.apache.maven.continuum.project.ContinuumBuild;
 import org.apache.maven.continuum.project.ContinuumProject;
+import org.apache.maven.continuum.project.ContinuumProjectState;
 
 import org.codehaus.plexus.jabber.JabberClient;
 import org.codehaus.plexus.jabber.JabberClientException;
 import org.codehaus.plexus.notification.NotificationException;
-import org.codehaus.plexus.notification.notifier.AbstractNotifier;
 import org.codehaus.plexus.util.StringUtils;
 
 /**
@@ -36,7 +39,7 @@
  * @version $Id$
  */
 public class JabberContinuumNotifier
-    extends AbstractNotifier
+    extends AbstractContinuumNotifier
 {
     // ----------------------------------------------------------------------
     // Requirements
@@ -47,6 +50,11 @@
      */
     private JabberClient jabberClient;
 
+    /**
+     * @plexus.requirement
+     */
+    private ConfigurationService configurationService;
+
     // ----------------------------------------------------------------------
     // Configuration
     // ----------------------------------------------------------------------
@@ -100,39 +108,9 @@
         //
         // ----------------------------------------------------------------------
 
-/*
-        if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_BUILD_STARTED ) )
-        {
-            buildStarted( project, recipients, configuration );
-        }
-        else if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_CHECKOUT_STARTED
) )
-        {
-            checkoutStarted( project, recipients, configuration );
-        }
-        else if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_CHECKOUT_COMPLETE
) )
-        {
-            checkoutComplete( project, recipients, configuration );
-        }
-        else if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_RUNNING_GOALS
) )
-        {
-            runningGoals( project, build, recipients, configuration );
-        }
-        else if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_GOALS_COMPLETED
) )
-        {
-            goalsCompleted( project, build, recipients, configuration );
-        }
-        else if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_BUILD_COMPLETE
) )
-        {
-            buildComplete( project, build, recipients, configuration );
-        }
-        else
-        {
-            getLogger().warn( "Unknown source: '" + source + "'." );
-        }
-*/
         if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_BUILD_COMPLETE ) )
         {
-            buildComplete( project, build, recipients, configuration );
+            sendMessage( project, build, recipients, configuration );
         }
     }
 
@@ -140,64 +118,51 @@
     //
     // ----------------------------------------------------------------------
 
-    private void buildStarted( ContinuumProject project, Set recipients, Map configuration
)
-        throws NotificationException
-    {
-        sendMessage( project, null, "Build started.", recipients, configuration );
-    }
-
-    private void checkoutStarted( ContinuumProject project, Set recipients, Map configuration
)
-        throws NotificationException
-    {
-        sendMessage( project, null, "Checkout started.", recipients, configuration );
-    }
-
-    private void checkoutComplete( ContinuumProject project, Set recipients, Map configuration
)
-        throws NotificationException
+    private String generateMessage( ContinuumProject project, ContinuumBuild build )
+        throws ContinuumException
     {
-        sendMessage( project, null, "Checkout complete.", recipients, configuration );
-    }
+        int state = build.getState();
 
-    private void runningGoals( ContinuumProject project, ContinuumBuild build, Set recipients,
Map configuration )
-        throws NotificationException
-    {
-        sendMessage( project, build, "Running goals.", recipients, configuration );
-    }
+        String message;
 
-    private void goalsCompleted( ContinuumProject project, ContinuumBuild build, Set recipients,
Map configuration )
-        throws NotificationException
-    {
-        if ( build.getError() == null )
+        if ( state == ContinuumProjectState.OK )
         {
-            sendMessage( project, build, "Goals completed. state: " + build.getState(), recipients,
configuration );
+            message = "BUILD SUCCESSFUL: " + project.getName();
         }
-        else
+        else if ( state == ContinuumProjectState.FAILED )
         {
-            sendMessage( project, build, "Goals completed.", recipients, configuration );
+            message = "BUILD FAILURE: " + project.getName();
         }
-    }
-
-    private void buildComplete( ContinuumProject project, ContinuumBuild build, Set recipients,
Map configuration )
-        throws NotificationException
-    {
-        if ( build.getError() == null )
+        else if ( state == ContinuumProjectState.ERROR )
         {
-            sendMessage( project, build, "Build complete. state: " + build.getState(), recipients,
configuration );
+            message = "BUILD ERROR: " + project.getName();
         }
         else
         {
-            sendMessage( project, build, "Build complete.", recipients, configuration );
+            getLogger().warn( "Unknown build state " + build.getState() + " for project "
+ project.getId() );
+
+            message = "ERROR: Unknown build state " + build.getState();
         }
+
+        return message + " " + getReportUrl( project, build, configurationService );
     }
 
     private void sendMessage( ContinuumProject project,
                               ContinuumBuild build,
-                              String msg,
                               Set recipients,
                               Map configuration )
         throws NotificationException
     {
-        String message = "Build event for project '" + project.getName() + "':" + msg;
+        String message = "";
+
+        try
+        {
+            message = generateMessage( project, build );
+        }
+        catch ( ContinuumException e )
+        {
+            throw new NotificationException( "Can't generate the message.", e );
+        }
 
         jabberClient.setHost( getHost( configuration ) );
 

Modified: maven/continuum/trunk/continuum-notifiers/continuum-notifier-msn/pom.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-notifiers/continuum-notifier-msn/pom.xml?rev=220334&r1=220333&r2=220334&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-notifiers/continuum-notifier-msn/pom.xml (original)
+++ maven/continuum/trunk/continuum-notifiers/continuum-notifier-msn/pom.xml Fri Jul 22 08:07:32
2005
@@ -10,6 +10,11 @@
   <version>1.0-beta-1-SNAPSHOT</version>
   <dependencies>
     <dependency>
+      <groupId>org.apache.maven.continuum</groupId>
+      <artifactId>continuum-notifier-api</artifactId>
+      <version>1.0-beta-1-SNAPSHOT</version>
+    </dependency>
+    <dependency>
       <groupId>plexus</groupId>
       <artifactId>plexus-msn</artifactId>
       <version>1.0-alpha-1</version>

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/viewcvs/maven/continuum/trunk/continuum-notifiers/continuum-notifier-msn/src/main/java/org/apache/maven/continuum/notification/msn/MsnContinuumNotifier.java?rev=220334&r1=220333&r2=220334&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
Fri Jul 22 08:07:32 2005
@@ -21,14 +21,17 @@
 import java.util.Properties;
 import java.util.Set;
 
+import org.apache.maven.continuum.ContinuumException;
+import org.apache.maven.continuum.configuration.ConfigurationService;
+import org.apache.maven.continuum.notification.AbstractContinuumNotifier;
 import org.apache.maven.continuum.notification.ContinuumNotificationDispatcher;
 import org.apache.maven.continuum.project.ContinuumBuild;
 import org.apache.maven.continuum.project.ContinuumProject;
+import org.apache.maven.continuum.project.ContinuumProjectState;
 
 import org.codehaus.plexus.msn.MsnClient;
 import org.codehaus.plexus.msn.MsnException;
 import org.codehaus.plexus.notification.NotificationException;
-import org.codehaus.plexus.notification.notifier.AbstractNotifier;
 import org.codehaus.plexus.util.StringUtils;
 
 /**
@@ -36,7 +39,7 @@
  * @version $Id$
  */
 public class MsnContinuumNotifier
-    extends AbstractNotifier
+    extends AbstractContinuumNotifier
 {
     // ----------------------------------------------------------------------
     // Requirements
@@ -47,6 +50,11 @@
      */
     private MsnClient msnClient;
 
+    /**
+     * @plexus.requirement
+     */
+    private ConfigurationService configurationService;
+
     // ----------------------------------------------------------------------
     // Configuration
     // ----------------------------------------------------------------------
@@ -94,39 +102,9 @@
         //
         // ----------------------------------------------------------------------
 
-/*
-        if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_BUILD_STARTED ) )
-        {
-            buildStarted( project, recipients, configuration );
-        }
-        else if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_CHECKOUT_STARTED
) )
-        {
-            checkoutStarted( project, recipients, configuration );
-        }
-        else if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_CHECKOUT_COMPLETE
) )
-        {
-            checkoutComplete( project, recipients, configuration );
-        }
-        else if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_RUNNING_GOALS
) )
-        {
-            runningGoals( project, build, recipients, configuration );
-        }
-        else if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_GOALS_COMPLETED
) )
-        {
-            goalsCompleted( project, build, recipients, configuration );
-        }
-        else if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_BUILD_COMPLETE
) )
-        {
-            buildComplete( project, build, recipients, configuration );
-        }
-        else
-        {
-            getLogger().warn( "Unknown source: '" + source + "'." );
-        }
-*/
         if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_BUILD_COMPLETE ) )
         {
-            buildComplete( project, build, recipients, configuration );
+            sendMessage( project, build, recipients, configuration );
         }
     }
 
@@ -134,64 +112,51 @@
     //
     // ----------------------------------------------------------------------
 
-    private void buildStarted( ContinuumProject project, Set recipients, Map configuration
)
-        throws NotificationException
-    {
-        sendMessage( project, null, "Build started.", recipients, configuration );
-    }
-
-    private void checkoutStarted( ContinuumProject project, Set recipients, Map configuration
)
-        throws NotificationException
-    {
-        sendMessage( project, null, "Checkout started.", recipients, configuration );
-    }
-
-    private void checkoutComplete( ContinuumProject project, Set recipients, Map configuration
)
-        throws NotificationException
+    private String generateMessage( ContinuumProject project, ContinuumBuild build )
+        throws ContinuumException
     {
-        sendMessage( project, null, "Checkout complete.", recipients, configuration );
-    }
+        int state = build.getState();
 
-    private void runningGoals( ContinuumProject project, ContinuumBuild build, Set recipients,
Map configuration )
-        throws NotificationException
-    {
-        sendMessage( project, build, "Running goals.", recipients, configuration );
-    }
+        String message;
 
-    private void goalsCompleted( ContinuumProject project, ContinuumBuild build, Set recipients,
Map configuration )
-        throws NotificationException
-    {
-        if ( build.getError() == null )
+        if ( state == ContinuumProjectState.OK )
         {
-            sendMessage( project, build, "Goals completed. state: " + build.getState(), recipients,
configuration );
+            message = "BUILD SUCCESSFUL: " + project.getName();
         }
-        else
+        else if ( state == ContinuumProjectState.FAILED )
         {
-            sendMessage( project, build, "Goals completed.", recipients, configuration );
+            message = "BUILD FAILURE: " + project.getName();
         }
-    }
-
-    private void buildComplete( ContinuumProject project, ContinuumBuild build, Set recipients,
Map configuration )
-        throws NotificationException
-    {
-        if ( build.getError() == null )
+        else if ( state == ContinuumProjectState.ERROR )
         {
-            sendMessage( project, build, "Build complete. state: " + build.getState(), recipients,
configuration );
+            message = "BUILD ERROR: " + project.getName();
         }
         else
         {
-            sendMessage( project, build, "Build complete.", recipients, configuration );
+            getLogger().warn( "Unknown build state " + build.getState() + " for project "
+ project.getId() );
+
+            message = "ERROR: Unknown build state " + build.getState();
         }
+
+        return message + " " + getReportUrl( project, build, configurationService );
     }
 
     private void sendMessage( ContinuumProject project,
                               ContinuumBuild build,
-                              String msg,
                               Set recipients,
                               Map configuration )
         throws NotificationException
     {
-        String message = "Build event for project '" + project.getName() + "':" + msg;
+        String message = "";
+
+        try
+        {
+            message = generateMessage( project, build );
+        }
+        catch ( ContinuumException e )
+        {
+            throw new NotificationException( "Can't generate the message.", e );
+        }
 
         msnClient.setLogin( getUsername( configuration ) );
 

Modified: maven/continuum/trunk/continuum-notifiers/pom.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-notifiers/pom.xml?rev=220334&r1=220333&r2=220334&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-notifiers/pom.xml (original)
+++ maven/continuum/trunk/continuum-notifiers/pom.xml Fri Jul 22 08:07:32 2005
@@ -23,6 +23,7 @@
     </dependency>
   </dependencies>
   <modules>
+    <module>continuum-notifier-api</module>
     <module>continuum-notifier-irc</module>
     <module>continuum-notifier-jabber</module>
     <module>continuum-notifier-msn</module>

Modified: maven/continuum/trunk/continuum-plexus-application/src/conf/application.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-plexus-application/src/conf/application.xml?rev=220334&r1=220333&r2=220334&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-plexus-application/src/conf/application.xml (original)
+++ maven/continuum/trunk/continuum-plexus-application/src/conf/application.xml Fri Jul 22
08:07:32 2005
@@ -85,6 +85,9 @@
         <requirement>
           <role>org.codehaus.plexus.mailsender.MailSender</role>
         </requirement>
+        <requirement>
+          <role>org.apache.maven.continuum.configuration.ConfigurationService</role>
+        </requirement>
       </requirements>
       <configuration>
         <from-mailbox>@mail.override.from.mailbox@</from-mailbox>
@@ -134,6 +137,9 @@
         <requirement>
           <role>org.apache.maven.continuum.store.ContinuumStore</role>      
 
         </requirement>        
+        <requirement>
+          <role>org.apache.maven.continuum.configuration.ConfigurationService</role>
+        </requirement>
       </requirements>
     </component>
 
@@ -153,6 +159,9 @@
         <requirement>
           <role>org.codehaus.plexus.jabber.JabberClient</role>
         </requirement>
+        <requirement>
+          <role>org.apache.maven.continuum.configuration.ConfigurationService</role>
+        </requirement>
         <!--
         <requirement>
           <role>org.apache.maven.continuum.store.ContinuumStore</role>      
 
@@ -182,6 +191,9 @@
       <requirements>
         <requirement>
           <role>org.codehaus.plexus.msn.MsnClient</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.continuum.configuration.ConfigurationService</role>
         </requirement>
         <!--
         <requirement>

Modified: maven/continuum/trunk/pom.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/pom.xml?rev=220334&r1=220333&r2=220334&view=diff
==============================================================================
--- maven/continuum/trunk/pom.xml (original)
+++ maven/continuum/trunk/pom.xml Fri Jul 22 08:07:32 2005
@@ -110,6 +110,11 @@
       </dependency>
       <dependency>
         <groupId>org.apache.maven.continuum</groupId>
+        <artifactId>continuum-notifier-api</artifactId>
+        <version>1.0-beta-1-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.maven.continuum</groupId>
         <artifactId>continuum-notifier-irc</artifactId>
         <version>1.0-beta-1-SNAPSHOT</version>
       </dependency>



Mime
View raw message