You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2014/12/23 12:48:55 UTC

svn commit: r1647558 - in /manifoldcf/branches/CONNECTORS-1119: connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/email/ framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/ framework/pull-agen...

Author: kwright
Date: Tue Dec 23 11:48:54 2014
New Revision: 1647558

URL: http://svn.apache.org/r1647558
Log:
Different entry points for stop vs. end

Modified:
    manifoldcf/branches/CONNECTORS-1119/connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/email/EmailConnector.java
    manifoldcf/branches/CONNECTORS-1119/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/INotificationConnector.java
    manifoldcf/branches/CONNECTORS-1119/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/notifications/BaseNotificationConnector.java
    manifoldcf/branches/CONNECTORS-1119/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobResetThread.java

Modified: manifoldcf/branches/CONNECTORS-1119/connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/email/EmailConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1119/connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/email/EmailConnector.java?rev=1647558&r1=1647557&r2=1647558&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1119/connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/email/EmailConnector.java (original)
+++ manifoldcf/branches/CONNECTORS-1119/connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/email/EmailConnector.java Tue Dec 23 11:48:54 2014
@@ -216,11 +216,25 @@ public class EmailConnector extends org.
 
   //////////////////////////////Start of Notification Connector Method///////////////////////////////////
 
-  /** Notify of job end.
+  /** Notify of job stop.
   *@param spec is the notification specification.
   */
   @Override
   public void notifyOfJobStop(Specification spec)
+    throws ManifoldCFException, ServiceInterruption {
+    sendMail(spec);
+  }
+  
+  /** Notify of job end.
+  *@param spec is the notification specification.
+  */
+  @Override
+  public void notifyOfJobEnd(Specification spec)
+    throws ManifoldCFException, ServiceInterruption {
+    sendMail(spec);
+  }
+
+  protected void sendMail(Specification spec)
     throws ManifoldCFException, ServiceInterruption
   {
     // Grab the necessary info from the spec

Modified: manifoldcf/branches/CONNECTORS-1119/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/INotificationConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1119/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/INotificationConnector.java?rev=1647558&r1=1647557&r2=1647558&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1119/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/INotificationConnector.java (original)
+++ manifoldcf/branches/CONNECTORS-1119/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/INotificationConnector.java Tue Dec 23 11:48:54 2014
@@ -64,7 +64,13 @@ public interface INotificationConnector
   */
   public void notifyOfJobStop(Specification spec)
     throws ManifoldCFException, ServiceInterruption;
-  
+
+  /** Notify of job end
+  *@param spec is the notification specification.
+  */
+  public void notifyOfJobEnd(Specification spec)
+    throws ManifoldCFException, ServiceInterruption;
+	
   // UI support methods.
   //
   // The UI support methods come in two varieties.  The first group (inherited from IConnector) is involved

Modified: manifoldcf/branches/CONNECTORS-1119/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/notifications/BaseNotificationConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1119/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/notifications/BaseNotificationConnector.java?rev=1647558&r1=1647557&r2=1647558&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1119/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/notifications/BaseNotificationConnector.java (original)
+++ manifoldcf/branches/CONNECTORS-1119/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/notifications/BaseNotificationConnector.java Tue Dec 23 11:48:54 2014
@@ -73,6 +73,15 @@ public abstract class BaseNotificationCo
   {
   }
 
+  /** Notify of job end.
+  *@param spec is the notification specification.
+  */
+  @Override
+  public void notifyOfJobEnd(Specification spec)
+    throws ManifoldCFException, ServiceInterruption
+  {
+  }
+
   // UI support methods.
   //
   // These support methods come in two varieties.  The first bunch is involved in setting up connection configuration information.  The second bunch

Modified: manifoldcf/branches/CONNECTORS-1119/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobResetThread.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1119/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobResetThread.java?rev=1647558&r1=1647557&r2=1647558&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1119/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobResetThread.java (original)
+++ manifoldcf/branches/CONNECTORS-1119/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobResetThread.java Tue Dec 23 11:48:54 2014
@@ -78,7 +78,7 @@ public class JobResetThread extends Thre
               null,connectionManager.ACTIVITY_JOBSTOP,null,
               desc.getID().toString()+"("+desc.getDescription()+")",null,null,null);
             // As a courtesy, call all the notification connections (if any)
-            doNotifications(desc,notificationManager,notificationPool);
+            doStopNotifications(desc,notificationManager,notificationPool);
           }
 
           ArrayList jobResumes = new ArrayList();
@@ -102,7 +102,7 @@ public class JobResetThread extends Thre
               null,connectionManager.ACTIVITY_JOBEND,null,
               desc.getID().toString()+"("+desc.getDescription()+")",null,null,null);
             // As a courtesy, call all the notification connections (if any)
-            doNotifications(desc,notificationManager,notificationPool);
+            doEndNotifications(desc,notificationManager,notificationPool);
           }
           
           // If there were any job aborts, we must reprioritize all active documents, since we've done something
@@ -178,7 +178,7 @@ public class JobResetThread extends Thre
     }
   }
 
-  protected static void doNotifications(IJobDescription jobDescription, INotificationConnectionManager notificationManager,
+  protected static void doStopNotifications(IJobDescription jobDescription, INotificationConnectionManager notificationManager,
     INotificationConnectorPool notificationPool)
     throws ManifoldCFException
   {
@@ -217,4 +217,43 @@ public class JobResetThread extends Thre
     }
   }
   
+  protected static void doEndNotifications(IJobDescription jobDescription, INotificationConnectionManager notificationManager,
+    INotificationConnectorPool notificationPool)
+    throws ManifoldCFException
+  {
+    for (int j = 0; j < jobDescription.countNotifications(); j++)
+    {
+      String notificationConnectionName = jobDescription.getNotificationConnectionName(j);
+      try
+      {
+        INotificationConnection c = notificationManager.load(notificationConnectionName);
+        if (c != null)
+        {
+          INotificationConnector connector = notificationPool.grab(c);
+          if (connector != null)
+          {
+            try
+            {
+              connector.notifyOfJobEnd(jobDescription.getNotificationSpecification(j));
+            }
+            finally
+            {
+              notificationPool.release(c,connector);
+            }
+          }
+        }
+      }
+      catch (ServiceInterruption e)
+      {
+        Logging.connectors.warn("Can't notify right now: "+e.getMessage(),e);
+      }
+      catch (ManifoldCFException e)
+      {
+        if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
+          throw e;
+        Logging.connectors.warn("Error notifying: "+ e.getMessage(),e);
+      }
+    }
+  }
+
 }