manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1654651 - in /manifoldcf/trunk: CHANGES.txt connectors/filenet/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/filenet/FilenetConnector.java
Date Sun, 25 Jan 2015 12:09:57 GMT
Author: kwright
Date: Sun Jan 25 12:09:57 2015
New Revision: 1654651

URL: http://svn.apache.org/r1654651
Log:
Tentative fix for CONNECTORS-1151.

Modified:
    manifoldcf/trunk/CHANGES.txt
    manifoldcf/trunk/connectors/filenet/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/filenet/FilenetConnector.java

Modified: manifoldcf/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/CHANGES.txt?rev=1654651&r1=1654650&r2=1654651&view=diff
==============================================================================
--- manifoldcf/trunk/CHANGES.txt (original)
+++ manifoldcf/trunk/CHANGES.txt Sun Jan 25 12:09:57 2015
@@ -3,6 +3,10 @@ $Id$
 
 ======================= 2.1-dev =====================
 
+CONNECTORS-1151: FileNet connector completely broken, due to
+MCF 1.8 reorganization.
+(Guy Sperry, Karl Wright)
+
 CONNECTORS-1150: Go to Tika 1.7
 (Karl Wright)
 

Modified: manifoldcf/trunk/connectors/filenet/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/filenet/FilenetConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/filenet/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/filenet/FilenetConnector.java?rev=1654651&r1=1654650&r2=1654651&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/filenet/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/filenet/FilenetConnector.java
(original)
+++ manifoldcf/trunk/connectors/filenet/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/filenet/FilenetConnector.java
Sun Jan 25 12:09:57 2015
@@ -949,21 +949,30 @@ public class FilenetConnector extends or
       if (Logging.connectors.isDebugEnabled())
         Logging.connectors.debug("Filenet: Getting version for identifier '"+documentIdentifier+"'");
 
-      // Calculate the version id and the element number
-      String versionString;
-      String[] aclValues = null;
-      String[] denyAclValues = null;
-      String docClass = null;
-      String[] metadataFieldNames = null;
-      String[] metadataFieldValues = null;
       
       int cIndex = documentIdentifier.indexOf(",");
       if (cIndex != -1)
       {
         String vId = documentIdentifier.substring(0,cIndex);
+        int elementNumber;
+        try
+        {
+          elementNumber = Integer.parseInt(documentIdentifier.substring(cIndex+1));
+        }
+        catch (NumberFormatException e)
+        {
+          throw new ManifoldCFException("Bad number in identifier: "+documentIdentifier,e);
+        }
+
+        // Calculate the version id and the element number
+        String versionString;
+        String[] aclValues = null;
+        String[] denyAclValues = null;
+        String docClass = null;
+        String[] metadataFieldNames = null;
+        String[] metadataFieldValues = null;
 
         FileInfo fileInfo;
-        Integer count;
         try
         {
           fileInfo = doGetDocumentInformation(vId, dSpec.getMetadataFields());
@@ -974,15 +983,6 @@ public class FilenetConnector extends or
             activities.deleteDocument(documentIdentifier);
             continue;
           }
-          
-          count = doGetDocumentContentCount(documentIdentifier);
-          if (count == null)
-          {
-            if (Logging.connectors.isDebugEnabled())
-              Logging.connectors.debug("FileNet: Removing version '"+documentIdentifier+"'
because it seems to no longer exist");
-            activities.deleteDocument(documentIdentifier);
-            continue;
-          }
         }
         catch (FilenetException e)
         {
@@ -1114,192 +1114,210 @@ public class FilenetConnector extends or
         pack(versionBuffer,docURIPrefix,'+');
 
         versionString = versionBuffer.toString();
-            
+        
         if (Logging.connectors.isDebugEnabled())
-          Logging.connectors.debug("FileNet: There are "+count.toString()+" content values
for '"+documentIdentifier+"'");
+          Logging.connectors.debug("FileNet: Document identifier '"+documentIdentifier+"'
is a document attachment");
 
-        // Loop through all document content identifiers and add a child identifier for each
-        for (int q = 0; q < count.intValue(); q++)
-        {
-          if (Logging.connectors.isDebugEnabled())
-            Logging.connectors.debug("Filenet: Adding document identifier '"+documentIdentifier+","+Integer.toString(q)+"'");
-
-          activities.addDocumentReference(documentIdentifier + "," + Integer.toString(q));
-        }
+        String errorCode = null;
+        String errorDesc = null;
+        long startTime = System.currentTimeMillis();
+        Long fileLengthLong = null;
         
-        // No more processing is necessary for document identifiers.
-        activities.noDocument(documentIdentifier,versionString);
-        continue;
-      }
-      
-      // It's a version identifier.
-      String vId = documentIdentifier.substring(0,cIndex);
-      int elementNumber;
-      try
-      {
-        elementNumber = Integer.parseInt(documentIdentifier.substring(cIndex+1));
-      }
-      catch (NumberFormatException e)
-      {
-        throw new ManifoldCFException("Bad number in identifier: "+documentIdentifier,e);
-      }
-
-      versionString = "";
-      
-      if (Logging.connectors.isDebugEnabled())
-        Logging.connectors.debug("FileNet: Document identifier '"+documentIdentifier+"' is
a document attachment");
-
-      String errorCode = null;
-      String errorDesc = null;
-      long startTime = System.currentTimeMillis();
-      Long fileLengthLong = null;
-      
-      try
-      {
-        String uri = convertToURI(docURIPrefix,vId,elementNumber,docClass);
-        if (!activities.checkURLIndexable(uri))
-        {
-          errorCode = activities.EXCLUDED_URL;
-          errorDesc = "Excluded because of url ('"+uri+"')";
-          activities.noDocument(documentIdentifier,versionString);
-          continue;
-        }
-      
-        File objFileTemp = null;
-        try
-        {
-          objFileTemp = File.createTempFile("_mc_fln_", null);
-        }
-        catch (IOException e)
-        {
-          errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
-          errorDesc = e.getMessage();
-          handleIOException(e,documentIdentifier,"creating temporary file");
-        }
         try
         {
+          String uri = convertToURI(docURIPrefix,vId,elementNumber,docClass);
+          if (!activities.checkURLIndexable(uri))
+          {
+            errorCode = activities.EXCLUDED_URL;
+            errorDesc = "Excluded because of url ('"+uri+"')";
+            activities.noDocument(documentIdentifier,versionString);
+            continue;
+          }
+        
+          File objFileTemp = null;
           try
           {
-            doGetDocumentContents(vId,elementNumber,objFileTemp.getCanonicalPath());
+            objFileTemp = File.createTempFile("_mc_fln_", null);
           }
           catch (IOException e)
           {
             errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
             errorDesc = e.getMessage();
-            handleIOException(e,documentIdentifier,"reading document");
+            handleIOException(e,documentIdentifier,"creating temporary file");
           }
-          catch (FilenetException e)
+          try
           {
-            errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
-            errorDesc = e.getMessage();
-            // Base our treatment on the kind of error it is.
-            long currentTime = System.currentTimeMillis();
-            if (e.getType() == FilenetException.TYPE_SERVICEINTERRUPTION)
+            try
             {
-              throw new ServiceInterruption(e.getMessage(),e,currentTime+300000L,currentTime+12*60*60000L,-1,true);
+              doGetDocumentContents(vId,elementNumber,objFileTemp.getCanonicalPath());
             }
-            else if (e.getType() == FilenetException.TYPE_NOTALLOWED)
+            catch (IOException e)
             {
-              if (Logging.connectors.isDebugEnabled())
-                Logging.connectors.debug("FileNet: Removing file '"+documentIdentifier+"'
because: "+e.getMessage(),e);
-              activities.noDocument(documentIdentifier,versionString);
-              continue;
+              errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
+              errorDesc = e.getMessage();
+              handleIOException(e,documentIdentifier,"reading document");
             }
-            else
+            catch (FilenetException e)
             {
-              throw new ManifoldCFException(e.getMessage(),e);
+              errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
+              errorDesc = e.getMessage();
+              // Base our treatment on the kind of error it is.
+              long currentTime = System.currentTimeMillis();
+              if (e.getType() == FilenetException.TYPE_SERVICEINTERRUPTION)
+              {
+                throw new ServiceInterruption(e.getMessage(),e,currentTime+300000L,currentTime+12*60*60000L,-1,true);
+              }
+              else if (e.getType() == FilenetException.TYPE_NOTALLOWED)
+              {
+                if (Logging.connectors.isDebugEnabled())
+                  Logging.connectors.debug("FileNet: Removing file '"+documentIdentifier+"'
because: "+e.getMessage(),e);
+                activities.noDocument(documentIdentifier,versionString);
+                continue;
+              }
+              else
+              {
+                throw new ManifoldCFException(e.getMessage(),e);
+              }
             }
-          }
 
-          // Document fetch completed
-          long fileLength = objFileTemp.length();
-          if (!activities.checkLengthIndexable(fileLength))
-          {
-            errorCode = activities.EXCLUDED_LENGTH;
-            errorDesc = "Excluded document because of length ("+fileLength+")";
-            activities.noDocument(documentIdentifier,versionString);
-            continue;
-          }
-
-          RepositoryDocument rd = new RepositoryDocument();
-          // Apply metadata
-          for (int j = 0; j < metadataFieldNames.length; j++)
-          {
-            String metadataName = metadataFieldNames[j];
-            String metadataValue = metadataFieldValues[j];
-            rd.addField(metadataName,metadataValue);
-          }
+            // Document fetch completed
+            long fileLength = objFileTemp.length();
+            if (!activities.checkLengthIndexable(fileLength))
+            {
+              errorCode = activities.EXCLUDED_LENGTH;
+              errorDesc = "Excluded document because of length ("+fileLength+")";
+              activities.noDocument(documentIdentifier,versionString);
+              continue;
+            }
 
-          // Apply acls
-          if (aclValues != null)
-          {
-            rd.setSecurityACL(RepositoryDocument.SECURITY_TYPE_DOCUMENT,aclValues);
-          }
-          if (denyAclValues != null)
-          {
-            rd.setSecurityDenyACL(RepositoryDocument.SECURITY_TYPE_DOCUMENT,denyAclValues);
-          }
+            RepositoryDocument rd = new RepositoryDocument();
+            // Apply metadata
+            for (int k = 0; k < metadataFieldNames.length; k++)
+            {
+              String metadataName = metadataFieldNames[k];
+              String metadataValue = metadataFieldValues[k];
+              rd.addField(metadataName,metadataValue);
+            }
 
-          InputStream is = null;
-          try
-          {
-            is = new FileInputStream(objFileTemp);
-          }
-          catch (IOException e)
-          {
-            errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
-            errorDesc = e.getMessage();
-            handleIOException(e,documentIdentifier,"Opening temporary file");
-          }
-          try
-          {
-            rd.setBinary(is, fileLength);
+            // Apply acls
+            if (aclValues != null)
+            {
+              rd.setSecurityACL(RepositoryDocument.SECURITY_TYPE_DOCUMENT,aclValues);
+            }
+            if (denyAclValues != null)
+            {
+              rd.setSecurityDenyACL(RepositoryDocument.SECURITY_TYPE_DOCUMENT,denyAclValues);
+            }
 
+            InputStream is = null;
             try
             {
-              // Ingest
-              activities.ingestDocumentWithException(documentIdentifier,versionString,uri,rd);
-              errorCode = "OK";
-              fileLengthLong = new Long(fileLength);
+              is = new FileInputStream(objFileTemp);
             }
             catch (IOException e)
             {
               errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
               errorDesc = e.getMessage();
-              handleIOException(e,documentIdentifier,"ingesting document");
+              handleIOException(e,documentIdentifier,"Opening temporary file");
             }
-          }
-          finally
-          {
             try
             {
-              is.close();
+              rd.setBinary(is, fileLength);
+
+              try
+              {
+                // Ingest
+                activities.ingestDocumentWithException(documentIdentifier,versionString,uri,rd);
+                errorCode = "OK";
+                fileLengthLong = new Long(fileLength);
+              }
+              catch (IOException e)
+              {
+                errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
+                errorDesc = e.getMessage();
+                handleIOException(e,documentIdentifier,"ingesting document");
+              }
             }
-            catch (IOException e)
+            finally
             {
-              errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
-              errorDesc = e.getMessage();
-              handleIOException(e,documentIdentifier,"closing input stream");
+              try
+              {
+                is.close();
+              }
+              catch (IOException e)
+              {
+                errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
+                errorDesc = e.getMessage();
+                handleIOException(e,documentIdentifier,"closing input stream");
+              }
             }
           }
+          finally
+          {
+            // Delete temp file
+            objFileTemp.delete();
+          }
+        }
+        catch (ManifoldCFException e)
+        {
+          if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
+            errorCode = null;
+          throw e;
         }
         finally
         {
-          // Delete temp file
-          objFileTemp.delete();
+          if (errorCode != null)
+            activities.recordActivity(new Long(startTime),ACTIVITY_FETCH,
+              fileLengthLong,documentIdentifier,errorCode,errorDesc,null);
         }
       }
-      catch (ManifoldCFException e)
-      {
-        if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
-          errorCode = null;
-        throw e;
-      }
-      finally
+      else
       {
-        if (errorCode != null)
-          activities.recordActivity(new Long(startTime),ACTIVITY_FETCH,
-            fileLengthLong,documentIdentifier,errorCode,errorDesc,null);
+        Integer count;
+        try
+        {
+          count = doGetDocumentContentCount(documentIdentifier);
+          if (count == null)
+          {
+            if (Logging.connectors.isDebugEnabled())
+              Logging.connectors.debug("FileNet: Removing version '"+documentIdentifier+"'
because it seems to no longer exist");
+            activities.deleteDocument(documentIdentifier);
+            continue;
+          }
+        }
+        catch (FilenetException e)
+        {
+          // Base our treatment on the kind of error it is.
+          long currentTime = System.currentTimeMillis();
+          if (e.getType() == FilenetException.TYPE_SERVICEINTERRUPTION)
+            throw new ServiceInterruption(e.getMessage(),e,currentTime+300000L,currentTime+12*60*60000L,-1,true);
+          else if (e.getType() == FilenetException.TYPE_NOTALLOWED)
+          {
+            if (Logging.connectors.isDebugEnabled())
+              Logging.connectors.debug("FileNet: Skipping file '"+documentIdentifier+"' because:
"+e.getMessage(),e);
+            activities.deleteDocument(documentIdentifier);
+            continue;
+          }
+          else
+            throw new ManifoldCFException(e.getMessage(),e);
+        }
+
+        if (Logging.connectors.isDebugEnabled())
+          Logging.connectors.debug("FileNet: There are "+count.toString()+" content values
for '"+documentIdentifier+"'");
+
+        // Loop through all document content identifiers and add a child identifier for each
+        for (int q = 0; q < count.intValue(); q++)
+        {
+          if (Logging.connectors.isDebugEnabled())
+            Logging.connectors.debug("Filenet: Adding document identifier '"+documentIdentifier+","+Integer.toString(q)+"'");
+
+          activities.addDocumentReference(documentIdentifier + "," + Integer.toString(q));
+        }
+        
+        // No more processing is necessary for document identifiers.
+        activities.noDocument(documentIdentifier,"");
+        continue;
+
       }
     }
   }



Mime
View raw message