manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mol...@apache.org
Subject svn commit: r1633282 - in /manifoldcf/trunk/connectors: filesystem/connector/src/main/java/org/apache/manifoldcf/agents/output/filesystem/ hdfs/connector/src/main/java/org/apache/manifoldcf/agents/output/hdfs/
Date Tue, 21 Oct 2014 06:32:02 GMT
Author: molgun
Date: Tue Oct 21 06:32:01 2014
New Revision: 1633282

URL: http://svn.apache.org/r1633282
Log:
CONNECTORS-1077: Using actual exception names

Modified:
    manifoldcf/trunk/connectors/filesystem/connector/src/main/java/org/apache/manifoldcf/agents/output/filesystem/FileOutputConnector.java
    manifoldcf/trunk/connectors/hdfs/connector/src/main/java/org/apache/manifoldcf/agents/output/hdfs/HDFSOutputConnector.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=1633282&r1=1633281&r2=1633282&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
Tue Oct 21 06:32:01 2014
@@ -169,6 +169,9 @@ public class FileOutputConnector extends
     FileOutputSpecs specs = new FileOutputSpecs(getSpecNode(outputDescription.getSpecification()));;
     StringBuffer path = new StringBuffer();
 
+    String errorCode = "OK";
+    String errorDesc = null;
+
     try {
       /*
         * make file path
@@ -215,8 +218,9 @@ public class FileOutputConnector extends
           }
           else
           {
-              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?");
+              errorCode = activities.CREATED_DIRECTORY;
+              errorDesc = "Could not create directory '\"+newPath+\"'.  Permission issue?";
+              throw new ManifoldCFException(errorDesc);
           }
         }
         // Directory successfully created!
@@ -247,8 +251,9 @@ public class FileOutputConnector extends
             continue;
           }
           // Probably some other error
-          activities.recordActivity(null, INGEST_ACTIVITY, new Long(document.getBinaryLength()),
documentURI, activities.EXCEPTION, "Unexpected exception while creating the file.'" + outputPath
+ "'");
-          throw new ManifoldCFException("Could not create file '"+outputPath+"': "+e.getMessage(),e);
+          errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
+          errorDesc = "Could not create file '" + outputPath + "': " +e.getMessage();
+          throw new ManifoldCFException(errorDesc,e);
         }
       }
 
@@ -259,8 +264,9 @@ public class FileOutputConnector extends
         FileChannel channel = output.getChannel();
         FileLock lock = channel.tryLock();
         if (lock == null){
-          activities.recordActivity(null,INGEST_ACTIVITY, new Long(document.getBinaryLength()),
documentURI,activities.EXCEPTION,"Could not lock file: '" + outputPath + "'");
-          throw new ServiceInterruption("Could not lock file: '"+outputPath+"'",null,1000L,-1L,10,false);
+          errorCode = ServiceInterruption.class.getSimpleName().toUpperCase(Locale.ROOT);
+          errorDesc = "Could not lock file: '"+outputPath+"'";
+          throw new ServiceInterruption(errorDesc,null,1000L,-1L,10,false);
         }
 
 
@@ -292,24 +298,29 @@ public class FileOutputConnector extends
         }
       }
     } catch (URISyntaxException e) {
-      activities.recordActivity(null,INGEST_ACTIVITY,new Long(document.getBinaryLength()),
documentURI,activities.EXCEPTION,"Failed to write document due to: " + e.getMessage());
+      errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
+      errorDesc = "Failed to write document due to: " + e.getMessage();
       handleURISyntaxException(e);
       return DOCUMENTSTATUS_REJECTED;
     } catch (FileNotFoundException e) {
-      activities.recordActivity(null,INGEST_ACTIVITY,new Long(document.getBinaryLength()),
documentURI,activities.EXCEPTION,"Failed to write document due to: " + e.getMessage());
+      errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
+      errorDesc = "Failed to write document due to: " + e.getMessage();
       handleFileNotFoundException(e);
       return DOCUMENTSTATUS_REJECTED;
     } catch (SecurityException e) {
-      activities.recordActivity(null,INGEST_ACTIVITY,new Long(document.getBinaryLength()),
documentURI,activities.EXCEPTION,"Failed to write document due to: " + e.getMessage());
+      errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
+      errorDesc = "Failed to write document due to: " + e.getMessage();
       handleSecurityException(e);
       return DOCUMENTSTATUS_REJECTED;
     } catch (IOException e) {
-      activities.recordActivity(null,INGEST_ACTIVITY,new Long(document.getBinaryLength()),
documentURI ,activities.EXCEPTION,"Failed to write document due to: " + e.getMessage());
+      errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
+      errorDesc = "Failed to write document due to: " + e.getMessage();
       handleIOException(e);
       return DOCUMENTSTATUS_REJECTED;
+    } finally {
+        activities.recordActivity(null, INGEST_ACTIVITY, new Long(document.getBinaryLength()),
documentURI, errorCode, errorDesc);
     }
 
-    activities.recordActivity(null, INGEST_ACTIVITY, new Long(document.getBinaryLength()),
documentURI, "OK", null);
     return DOCUMENTSTATUS_ACCEPTED;
   }
 
@@ -361,6 +372,9 @@ public class FileOutputConnector extends
     // Establish a session
     getSession();
 
+    String errorCode = "OK";
+    String errorDesc = null;
+
     FileOutputConfig config = getConfigParameters(null);
 
     StringBuffer path = new StringBuffer();
@@ -432,27 +446,32 @@ public class FileOutputConnector extends
         catch (FileNotFoundException e)
         {
           // Probably some other error
-          activities.recordActivity(null,REMOVE_ACTIVITY,null,documentURI,activities.EXCEPTION,"Couldn't
delete the file due to FileNotFoundException '"+outputPath+"':" + e.getMessage());
+          errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
+          errorDesc = "Couldn't delete the file due to:" + e.getMessage();
           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) {
-      activities.recordActivity(null,REMOVE_ACTIVITY,null, documentURI,activities.EXCEPTION,"Failed
to delete document due to: " + e.getMessage());
+      errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
+      errorDesc = "Failed to delete document due to: " + e.getMessage();
       handleURISyntaxException(e);
     } catch (FileNotFoundException e) {
-      activities.recordActivity(null,REMOVE_ACTIVITY,null, documentURI,activities.EXCEPTION,"Failed
to delete document due to: " + e.getMessage());
+      errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
+      errorDesc = "Failed to delete document due to: " + e.getMessage();
       handleFileNotFoundException(e);
     } catch (SecurityException e) {
-      activities.recordActivity(null,REMOVE_ACTIVITY,null, documentURI,activities.EXCEPTION,"Failed
to delete document due to: " + e.getMessage());
+      errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
+      errorDesc = "Failed to delete document due to: " + e.getMessage();
       handleSecurityException(e);
     } catch (IOException e) {
-      activities.recordActivity(null,REMOVE_ACTIVITY,null, documentURI ,activities.EXCEPTION,"Failed
to delete document due to: " + e.getMessage());
+      errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
+      errorDesc = "Failed to delete document due to: " + e.getMessage();
       handleIOException(e);
+    } finally {
+        activities.recordActivity(null, REMOVE_ACTIVITY, null, documentURI, errorCode, errorDesc);
     }
-
-    activities.recordActivity(null, REMOVE_ACTIVITY, null, documentURI, "OK", null);
   }
 
   /** Output the specification header section.

Modified: manifoldcf/trunk/connectors/hdfs/connector/src/main/java/org/apache/manifoldcf/agents/output/hdfs/HDFSOutputConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/hdfs/connector/src/main/java/org/apache/manifoldcf/agents/output/hdfs/HDFSOutputConnector.java?rev=1633282&r1=1633281&r2=1633282&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/hdfs/connector/src/main/java/org/apache/manifoldcf/agents/output/hdfs/HDFSOutputConnector.java
(original)
+++ manifoldcf/trunk/connectors/hdfs/connector/src/main/java/org/apache/manifoldcf/agents/output/hdfs/HDFSOutputConnector.java
Tue Oct 21 06:32:01 2014
@@ -290,7 +290,7 @@ public class HDFSOutputConnector extends
       activities.recordActivity(startTime, INGEST_ACTIVITY, new Long(document.getBinaryLength()),
documentURI, "OK", null);
       return DOCUMENTSTATUS_ACCEPTED;
     } catch (URISyntaxException e) {
-      activities.recordActivity(null,INGEST_ACTIVITY,new Long(document.getBinaryLength()),documentURI,activities.EXCEPTION,"Failed
to write document due to: " + e.getMessage());
+      activities.recordActivity(null,INGEST_ACTIVITY,new Long(document.getBinaryLength()),documentURI,e.getClass().getSimpleName().toUpperCase(Locale.ROOT),"Failed
to write document due to: " + e.getMessage());
       handleURISyntaxException(e);
       return DOCUMENTSTATUS_REJECTED;
     }
@@ -324,10 +324,10 @@ public class HDFSOutputConnector extends
       deleteFile(path,activities,documentURI);
       activities.recordActivity(startTime, REMOVE_ACTIVITY, null, documentURI, "OK", null);
     } catch (JSONException e) {
-      activities.recordActivity(null,REMOVE_ACTIVITY,null,documentURI,activities.EXCEPTION,"Failed
to delete document due to: " + e.getMessage());
+      activities.recordActivity(null,REMOVE_ACTIVITY,null,documentURI,e.getClass().getSimpleName().toUpperCase(Locale.ROOT),"Failed
to delete document due to: " + e.getMessage());
       handleJSONException(e);
     } catch (URISyntaxException e) {
-      activities.recordActivity(null,REMOVE_ACTIVITY,null,documentURI,activities.EXCEPTION,"Failed
to delete document due to: " + e.getMessage());
+      activities.recordActivity(null,REMOVE_ACTIVITY,null,documentURI,e.getClass().getSimpleName().toUpperCase(Locale.ROOT),"Failed
to delete document due to: " + e.getMessage());
       handleURISyntaxException(e);
     }
   }
@@ -655,23 +655,33 @@ public class HDFSOutputConnector extends
   protected void createFile(Path path, InputStream input,IOutputAddActivity activities, String
documentURI)
     throws ManifoldCFException, ServiceInterruption {
     CreateFileThread t = new CreateFileThread(getSession(), path, input);
+    String errorCode = null;
+    String errorDesc = null;
     try {
       t.start();
       t.finishUp();
     } catch (InterruptedException e) {
       t.interrupt();
-      activities.recordActivity(null,INGEST_ACTIVITY,null,documentURI,activities.EXCEPTION,"Failed
to write document due to: " + e.getMessage());
+      errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
+      errorDesc = "Failed to write document due to: " + e.getMessage();
       throw new ManifoldCFException("Interrupted: "+e.getMessage(),e,ManifoldCFException.INTERRUPTED);
     } catch (java.net.SocketTimeoutException e) {
-      activities.recordActivity(null,INGEST_ACTIVITY,null,documentURI,activities.EXCEPTION,"Failed
to write document due to: " + e.getMessage());
+      errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
+      errorDesc = "Failed to write document due to: " + e.getMessage();
       handleIOException(e);
     } catch (InterruptedIOException e) {
       t.interrupt();
-      activities.recordActivity(null,INGEST_ACTIVITY,null,documentURI,activities.EXCEPTION,"Failed
to write document due to: " + e.getMessage());
+      errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
+      errorDesc = "Failed to write document due to: " + e.getMessage();
       handleIOException(e);
     } catch (IOException e) {
-      activities.recordActivity(null,INGEST_ACTIVITY,null,documentURI,activities.EXCEPTION,"Failed
to write document due to: " + e.getMessage());
+      errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
+      errorDesc = "Failed to write document due to: " + e.getMessage();
       handleIOException(e);
+    } finally {
+      if(errorCode != null & errorDesc != null){
+        activities.recordActivity(null,INGEST_ACTIVITY,null,documentURI,errorCode,errorDesc);
+      }
     }
   }
 
@@ -714,23 +724,33 @@ public class HDFSOutputConnector extends
     throws ManifoldCFException, ServiceInterruption {
     // Establish a session
     DeleteFileThread t = new DeleteFileThread(getSession(),path);
+    String errorCode = null;
+    String errorDesc = null;
     try {
       t.start();
       t.finishUp();
     } catch (InterruptedException e) {
-      t.interrupt();
-      activities.recordActivity(null,REMOVE_ACTIVITY,null,documentURI,activities.EXCEPTION,"Failed
to delete document due to: " + e.getMessage());
-      throw new ManifoldCFException("Interrupted: "+e.getMessage(),e,ManifoldCFException.INTERRUPTED);
+        t.interrupt();
+        errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
+        errorDesc = "Failed to write document due to: " + e.getMessage();
+        throw new ManifoldCFException("Interrupted: "+e.getMessage(),e,ManifoldCFException.INTERRUPTED);
     } catch (java.net.SocketTimeoutException e) {
-      activities.recordActivity(null,REMOVE_ACTIVITY,null,documentURI,activities.EXCEPTION,"Failed
to delete document due to: " + e.getMessage());
-      handleIOException(e);
+        errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
+        errorDesc = "Failed to write document due to: " + e.getMessage();
+        handleIOException(e);
     } catch (InterruptedIOException e) {
-      t.interrupt();
-      activities.recordActivity(null,REMOVE_ACTIVITY,null,documentURI,activities.EXCEPTION,"Failed
to delete document due to: " + e.getMessage());
-      handleIOException(e);
+        t.interrupt();
+        errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
+        errorDesc = "Failed to write document due to: " + e.getMessage();
+        handleIOException(e);
     } catch (IOException e) {
-      activities.recordActivity(null,REMOVE_ACTIVITY,null,documentURI,activities.EXCEPTION,"Failed
to delete document due to: " + e.getMessage());
-      handleIOException(e);
+        errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
+        errorDesc = "Failed to write document due to: " + e.getMessage();
+        handleIOException(e);
+    } finally {
+        if(errorCode != null & errorDesc != null){
+            activities.recordActivity(null,REMOVE_ACTIVITY,null,documentURI,errorCode,errorDesc);
+        }
     }
   }
 



Mime
View raw message