Different entry points for stop vs. end
git-svn-id: https://svn.apache.org/repos/asf/manifoldcf/branches/CONNECTORS-1119@1647558 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/email/EmailConnector.java b/connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/email/EmailConnector.java
index 838fe63..847d819 100644
--- a/connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/email/EmailConnector.java
+++ b/connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/email/EmailConnector.java
@@ -216,11 +216,25 @@
//////////////////////////////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
diff --git a/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/INotificationConnector.java b/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/INotificationConnector.java
index 6aa3008..5865084 100644
--- a/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/INotificationConnector.java
+++ b/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/INotificationConnector.java
@@ -64,7 +64,13 @@
*/
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
diff --git a/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/notifications/BaseNotificationConnector.java b/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/notifications/BaseNotificationConnector.java
index 7ff3bd0..7ccd4ee 100644
--- a/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/notifications/BaseNotificationConnector.java
+++ b/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/notifications/BaseNotificationConnector.java
@@ -73,6 +73,15 @@
{
}
+ /** 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
diff --git a/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobResetThread.java b/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobResetThread.java
index 883e52d..80fefca 100644
--- a/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobResetThread.java
+++ b/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobResetThread.java
@@ -78,7 +78,7 @@
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 @@
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 @@
}
}
- protected static void doNotifications(IJobDescription jobDescription, INotificationConnectionManager notificationManager,
+ protected static void doStopNotifications(IJobDescription jobDescription, INotificationConnectionManager notificationManager,
INotificationConnectorPool notificationPool)
throws ManifoldCFException
{
@@ -217,4 +217,43 @@
}
}
+ 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);
+ }
+ }
+ }
+
}