You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by mo...@apache.org on 2014/10/18 23:39:35 UTC

svn commit: r1632844 - in /manifoldcf/trunk: connectors/filesystem/connector/src/main/java/org/apache/manifoldcf/agents/output/filesystem/ framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/

Author: molgun
Date: Sat Oct 18 21:39:35 2014
New Revision: 1632844

URL: http://svn.apache.org/r1632844
Log:
Added activity logging.

Modified:
    manifoldcf/trunk/connectors/filesystem/connector/src/main/java/org/apache/manifoldcf/agents/output/filesystem/FileOutputConnector.java
    manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/IOutputHistoryActivity.java

Modified: manifoldcf/trunk/connectors/filesystem/connector/src/main/java/org/apache/manifoldcf/agents/output/filesystem/FileOutputConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/filesystem/connector/src/main/java/org/apache/manifoldcf/agents/output/filesystem/FileOutputConnector.java?rev=1632844&r1=1632843&r2=1632844&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/filesystem/connector/src/main/java/org/apache/manifoldcf/agents/output/filesystem/FileOutputConnector.java (original)
+++ manifoldcf/trunk/connectors/filesystem/connector/src/main/java/org/apache/manifoldcf/agents/output/filesystem/FileOutputConnector.java Sat Oct 18 21:39:35 2014
@@ -19,7 +19,6 @@
 package org.apache.manifoldcf.agents.output.filesystem;
 
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -37,10 +36,7 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.HashMap;
 
-import org.apache.manifoldcf.agents.interfaces.IOutputAddActivity;
-import org.apache.manifoldcf.agents.interfaces.IOutputRemoveActivity;
-import org.apache.manifoldcf.agents.interfaces.RepositoryDocument;
-import org.apache.manifoldcf.agents.interfaces.ServiceInterruption;
+import org.apache.manifoldcf.agents.interfaces.*;
 import org.apache.manifoldcf.agents.output.BaseOutputConnector;
 import org.apache.manifoldcf.agents.system.Logging;
 import org.apache.manifoldcf.core.interfaces.Specification;
@@ -48,7 +44,6 @@ import org.apache.manifoldcf.core.interf
 import org.apache.manifoldcf.core.interfaces.ConfigurationNode;
 import org.apache.manifoldcf.core.interfaces.IHTTPOutput;
 import org.apache.manifoldcf.core.interfaces.IPostParameters;
-import org.apache.manifoldcf.core.interfaces.IThreadContext;
 import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
 import org.apache.manifoldcf.core.interfaces.SpecificationNode;
 import org.apache.manifoldcf.core.interfaces.VersionContext;
@@ -219,7 +214,10 @@ public class FileOutputConnector extends
             suffix++;
           }
           else
-            throw new ManifoldCFException("Could not create directory '"+newPath+"'.  Permission issue?");
+          {
+              activities.recordActivity(null,INGEST_ACTIVITY,null,documentURI,activities.CREATED_DIRECTORY,"Couldn't create directory ("+newPath+").");
+              throw new ManifoldCFException("Could not create directory '"+newPath+"'.  Permission issue?");
+          }
         }
         // Directory successfully created!
         currentPath = newPath;
@@ -249,6 +247,7 @@ public class FileOutputConnector extends
             continue;
           }
           // Probably some other error
+          activities.recordActivity(null, INGEST_ACTIVITY, new Long(document.getBinaryLength()), documentURI, activities.EXCEPTION, "Rejected due to FileNotFoundException.");
           throw new ManifoldCFException("Could not create file '"+outputPath+"': "+e.getMessage(),e);
         }
       }
@@ -259,8 +258,11 @@ public class FileOutputConnector extends
           */
         FileChannel channel = output.getChannel();
         FileLock lock = channel.tryLock();
-        if (lock == null)
+        if (lock == null){
+          activities.recordActivity(null,INGEST_ACTIVITY, new Long(document.getBinaryLength()), documentURI,activities.EXCEPTION,"Rejected due to ServiceInterruptionException.");
           throw new ServiceInterruption("Could not lock file: '"+outputPath+"'",null,1000L,-1L,10,false);
+        }
+
 
         try {
 
@@ -290,16 +292,16 @@ public class FileOutputConnector extends
         }
       }
     } catch (URISyntaxException e) {
-      handleURISyntaxException(e);
+      handleURISyntaxException(e,activities);
       return DOCUMENTSTATUS_REJECTED;
     } catch (FileNotFoundException e) {
-      handleFileNotFoundException(e);
+      handleFileNotFoundException(e,activities);
       return DOCUMENTSTATUS_REJECTED;
     } catch (SecurityException e) {
-      handleSecurityException(e);
+      handleSecurityException(e,activities);
       return DOCUMENTSTATUS_REJECTED;
     } catch (IOException e) {
-      handleIOException(e);
+      handleIOException(e,activities);
       return DOCUMENTSTATUS_REJECTED;
     }
 
@@ -313,26 +315,26 @@ public class FileOutputConnector extends
     throw new ManifoldCFException(e.getMessage(),e);
   }
 
-  protected static void handleURISyntaxException(URISyntaxException e)
+  protected static void handleURISyntaxException(URISyntaxException e, IOutputHistoryActivity activities)
     throws ManifoldCFException, ServiceInterruption {
     Logging.agents.error("FileSystem: URISyntaxException: "+e.getMessage(),e);
     throw new ManifoldCFException(e.getMessage(),e);
   }
 
-  protected static void handleSecurityException(SecurityException e)
+  protected static void handleSecurityException(SecurityException e, IOutputHistoryActivity activities)
     throws ManifoldCFException, ServiceInterruption {
     Logging.agents.error("FileSystem: SecurityException: "+e.getMessage(),e);
     throw new ManifoldCFException(e.getMessage(),e);
   }
 
-  protected static void handleFileNotFoundException(FileNotFoundException e)
+  protected static void handleFileNotFoundException(FileNotFoundException e, IOutputHistoryActivity activities)
     throws ManifoldCFException, ServiceInterruption {
     Logging.agents.error("FileSystem: Path is illegal: "+e.getMessage(),e);
     throw new ManifoldCFException(e.getMessage(),e);
   }
 
   /** Handle IOException */
-  protected static void handleIOException(IOException e)
+  protected static void handleIOException(IOException e, IOutputHistoryActivity activities)
     throws ManifoldCFException, ServiceInterruption
   {
     if (!(e instanceof java.net.SocketTimeoutException) && (e instanceof InterruptedIOException)) {
@@ -426,19 +428,20 @@ public class FileOutputConnector extends
         catch (FileNotFoundException e)
         {
           // Probably some other error
+          activities.recordActivity(null,REMOVE_ACTIVITY,null,documentURI,activities.EXCEPTION,"Couldn't deleted due to FileNotFoundException");
           throw new ManifoldCFException("Could not zero out file '"+outputPath+"': "+e.getMessage(),e);
         }
       }
       // Just close it, to make a zero-length grave marker.
       output.close();
     } catch (URISyntaxException e) {
-      handleURISyntaxException(e);
+      handleURISyntaxException(e,activities);
     } catch (FileNotFoundException e) {
-      handleFileNotFoundException(e);
+      handleFileNotFoundException(e,activities);
     } catch (SecurityException e) {
-      handleSecurityException(e);
+      handleSecurityException(e,activities);
     } catch (IOException e) {
-      handleIOException(e);
+      handleIOException(e,activities);
     }
 
     activities.recordActivity(null, REMOVE_ACTIVITY, null, documentURI, "OK", null);

Modified: manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/IOutputHistoryActivity.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/IOutputHistoryActivity.java?rev=1632844&r1=1632843&r2=1632844&view=diff
==============================================================================
--- manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/IOutputHistoryActivity.java (original)
+++ manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/IOutputHistoryActivity.java Sat Oct 18 21:39:35 2014
@@ -27,6 +27,9 @@ public interface IOutputHistoryActivity
 {
   public static final String _rcsid = "@(#)$Id: IOutputHistoryActivity.java 988245 2010-08-23 18:39:35Z kwright $";
 
+  public static final String EXCEPTION = "EXCEPTION";
+  public static final String CREATED_DIRECTORY = "CREATEDDIRECTORY";
+
   /** Record time-stamped information about the activity of the output connector.
   *@param startTime is either null or the time since the start of epoch in milliseconds (Jan 1, 1970).  Every
   *       activity has an associated time; the startTime field records when the activity began.  A null value