Author: kwright
Date: Sun Mar  3 10:02:11 2019
New Revision: 1854680

URL: http://svn.apache.org/viewvc?rev=1854680&view=rev
Log:
More work

Modified:
    
manifoldcf/branches/CONNECTORS-1566/connectors/csws/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/csws/CswsConnector.java
    
manifoldcf/branches/CONNECTORS-1566/connectors/csws/connector/src/main/java/org/apache/manifoldcf/csws/CswsSession.java

Modified: 
manifoldcf/branches/CONNECTORS-1566/connectors/csws/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/csws/CswsConnector.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1566/connectors/csws/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/csws/CswsConnector.java?rev=1854680&r1=1854679&r2=1854680&view=diff
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-1566/connectors/csws/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/csws/CswsConnector.java
 (original)
+++ 
manifoldcf/branches/CONNECTORS-1566/connectors/csws/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/csws/CswsConnector.java
 Sun Mar  3 10:02:11 2019
@@ -41,6 +41,8 @@ import com.opentext.livelink.service.doc
 import com.opentext.livelink.service.docman.DocumentManagement_Service;
 import com.opentext.livelink.service.docman.GetNodesInContainerOptions;
 import com.opentext.livelink.service.docman.Node;
+import com.opentext.livelink.service.docman.NodePermissions;
+import javax.xml.datatype.XMLGregorianCalendar;
 
 import org.apache.manifoldcf.csws.*;
 
@@ -1069,48 +1071,41 @@ public class CswsConnector extends org.a
 
       int colonPos = docID.indexOf(":",1);
 
-      int objID;
-      int vol;
+      long objID;
+      long vol;
 
-      if (colonPos == -1)
-      {
-        objID = new Integer(docID.substring(1)).intValue();
-        vol = LLENTWK_VOL;
-      }
-      else
-      {
-        objID = new Integer(docID.substring(colonPos+1)).intValue();
-        vol = new Integer(docID.substring(1,colonPos)).intValue();
-      }
+      objID = new Long(docID.substring(colonPos+1)).longValue();
+      vol = new Long(docID.substring(1,colonPos)).longValue();
 
       getSession();
-      ObjectInformation value = llc.getObjectInformation(vol,objID);
+      
+      final ObjectInformation value = llc.getObjectInformation(vol, objID);
       if (!value.exists())
       {
         if (Logging.connectors.isDebugEnabled())
-          Logging.connectors.debug("Csws: Object 
"+Integer.toString(vol)+":"+Integer.toString(objID)+" has no information - 
deleting");
+          Logging.connectors.debug("Csws: Object "+vol+":"+objID+" has no 
information - deleting");
         activities.deleteDocument(documentIdentifier);
         continue;
       }
         
       // Make sure we have permission to see the object's contents
-      int permissions = value.getPermissions().intValue();
-      if ((permissions & LAPI_DOCUMENTS.PERM_SEECONTENTS) == 0)
+      final NodePermissions permissions = value.getPermissions();
+      if (!permissions.seeContentsPermission())
       {
         if (Logging.connectors.isDebugEnabled())
-          Logging.connectors.debug("Csws: Crawl user cannot see contents of 
object "+Integer.toString(vol)+":"+Integer.toString(objID)+" - deleting");
+          Logging.connectors.debug("Csws: Crawl user cannot see contents of 
object "+vol+":"+objID+" - deleting");
         activities.deleteDocument(documentIdentifier);
         continue;
       }
-        
-        
-      Date dt = value.getModifyDate();
+
+      final Date dt = new 
Date(value.getModifyDate().toGregorianCalendar().getTimeInMillis());
+
       // The rights don't change when the object changes, so we have to 
include those too.
-      int[] rights = getObjectRights(vol,objID);
+      int[] rights = getObjectRights(vol, objID);
       if (rights == null)
       {
         if (Logging.connectors.isDebugEnabled())
-          Logging.connectors.debug("Csws: Could not get rights for object 
"+Integer.toString(vol)+":"+Integer.toString(objID)+" - deleting");
+          Logging.connectors.debug("Csws: Could not get rights for object 
"+vol+":"+objID+" - deleting");
         activities.deleteDocument(documentIdentifier);
         continue;
       }
@@ -1131,7 +1126,7 @@ public class CswsConnector extends org.a
         final List<? extends Node> childrenDocs = t.finishUp();
         for (final Node childDoc : childrenDocs)
         {
-          final int childID = childDoc.getId();
+          final long childID = childDoc.getID();
 
           if (Logging.connectors.isDebugEnabled())
           {
@@ -1281,35 +1276,35 @@ public class CswsConnector extends org.a
         // processDocuments.
         sb.append("=").append(pathNameAttributeVersion);
           
-        // Tack on ingestCgiPath, to insulate us against changes to the 
repository connection setup.  Added 9/7/07.
+        // Tack on ingestCgiPath, to insulate us against changes to the 
repository connection setup. 
         sb.append("_").append(viewBasePath);
 
         String versionString = sb.toString();
         if (Logging.connectors.isDebugEnabled())
-          Logging.connectors.debug("Csws: Successfully calculated version 
string for document "+Integer.toString(vol)+":"+Integer.toString(objID)+" : 
'"+versionString+"'");
+          Logging.connectors.debug("Csws: Successfully calculated version 
string for document "+vol+":"+objID+" : '"+versionString+"'");
               
-        if 
(!activities.checkDocumentNeedsReindexing(documentIdentifier,versionString))
+        if (!activities.checkDocumentNeedsReindexing(documentIdentifier, 
versionString))
           continue;
         
         // Index the document
         if (Logging.connectors.isDebugEnabled())
-          Logging.connectors.debug("Csws: Processing document 
"+Integer.toString(vol)+":"+Integer.toString(objID));
+          Logging.connectors.debug("Csws: Processing document "+vol+":"+objID);
         if (!checkIngest(llc,objID,spec))
         {
           if (Logging.connectors.isDebugEnabled())
-            Logging.connectors.debug("Csws: Decided not to ingest document 
"+Integer.toString(vol)+":"+Integer.toString(objID)+" - Did not match ingestion 
criteria");
+            Logging.connectors.debug("Csws: Decided not to ingest document 
"+vol+":"+objID+" - Did not match ingestion criteria");
           activities.noDocument(documentIdentifier,versionString);
           continue;
         }
 
         if (Logging.connectors.isDebugEnabled())
-          Logging.connectors.debug("Csws: Decided to ingest document 
"+Integer.toString(vol)+":"+Integer.toString(objID));
+          Logging.connectors.debug("Csws: Decided to ingest document 
"+vol+":"+objID);
 
         // Grab the access tokens for this file from the version string, 
inside ingest method.
-        
ingestFromCsws(llc,documentIdentifier,versionString,actualAcls,denyAcls,categoryPaths,activities,desc,sDesc);
+        ingestFromCsws(llc, documentIdentifier, versionString, actualAcls, 
denyAcls, categoryPaths, activities, desc, sDesc);
           
         if (Logging.connectors.isDebugEnabled())
-          Logging.connectors.debug("Csws: Done processing document 
"+Integer.toString(vol)+":"+Integer.toString(objID));
+          Logging.connectors.debug("Csws: Done processing document 
"+vol+":"+objID);
       }
     }
   }
@@ -1319,13 +1314,13 @@ public class CswsConnector extends org.a
    */
   protected class ListObjectsThread extends Thread
   {
-    protected final int vol;
-    protected final int objID;
+    protected final long vol;
+    protected final long objID;
     protected final String filterString;
     protected Throwable exception = null;
     protected List<? extends Node> rval = null;
 
-    public ListObjectsThread(int vol, int objID, String filterString)
+    public ListObjectsThread(long vol, long objID, String filterString)
     {
       super();
       setDaemon(true);
@@ -1339,6 +1334,7 @@ public class CswsConnector extends org.a
       try
       {
         //         int status = LLDocs.ListObjects(vol, objID, null, 
filterString, LAPI_DOCUMENTS.PERM_SEECONTENTS, childrenDocs);
+        // No filter support!!! TBD
         rval = cswsSession.getChildren(objID);
       }
       catch (Throwable e)
@@ -3934,13 +3930,13 @@ public class CswsConnector extends org.a
   */
   protected class ObjectInformation
   {
-    protected final int volumeID;
-    protected final int objectID;
+    protected final long volumeID;
+    protected final long objectID;
     protected final String workspaceName;
     
     protected Node objectValue = null;
     
-    public ObjectInformation(final int volumeID, final int objectID)
+    public ObjectInformation(final long volumeID, final long objectID)
     {
       this.volumeID = volumeID;
       this.objectID = objectID;
@@ -3949,8 +3945,8 @@ public class CswsConnector extends org.a
 
     public ObjectInformation(final String workspaceName) {
       this.workspaceName = workspaceName;
-      this.volumeID = -1;
-      this.objectID = -1;
+      this.volumeID = -1L;
+      this.objectID = -1L;
     }
     
     /**
@@ -3988,7 +3984,7 @@ public class CswsConnector extends org.a
         return null;
 
       // Grab the volume ID and starting object
-      int obj = objInfo.getId();
+      int obj = objInfo.getID();
       int vol = objInfo.getVolumeId();
 
       // Pick apart the start path.  This is a string separated by slashes.
@@ -4016,58 +4012,40 @@ public class CswsConnector extends org.a
         String filterString = "(SubType="+ LAPI_DOCUMENTS.FOLDERSUBTYPE + " or 
SubType=" + LAPI_DOCUMENTS.PROJECTSUBTYPE +
           " or SubType=" + LAPI_DOCUMENTS.COMPOUNDDOCUMENTSUBTYPE + ") and 
Name='" + subFolder + "'";
 
-        int sanityRetryCount = FAILURE_RETRY_COUNT;
-        while (true)
+        final ListObjectsThread t = new 
ListObjectsThread(vol,obj,filterString);
+        try
         {
-          ListObjectsThread t = new ListObjectsThread(vol,obj,filterString);
-          try
-          {
-            t.start();
-           LLValue children;
-           try
-           {
-             children = t.finishUp();
-           }
-           catch (ManifoldCFException e)
-           {
-             sanityRetryCount = assessRetry(sanityRetryCount,e);
-             continue;
-            }
+          t.start();
+          final List<? extends Node> children = t.finishUp();
 
-            if (children == null)
-              return null;
+          if (children == null) {
+            return null;
+          }
 
-            // If there is one child, then we are okay.
-            if (children.size() == 1)
-            {
-              // New starting point is the one we found.
-              obj = children.toInteger(0, "ID");
-              int subtype = children.toInteger(0, "SubType");
-              if (subtype == LAPI_DOCUMENTS.PROJECTSUBTYPE)
-              {
-                vol = obj;
-                obj = -obj;
-              }
-            }
-            else
+          // If there is one child, then we are okay.
+          if (children.size() == 1)
+          {
+            // New starting point is the one we found.
+            final Node child = children.get(0);
+            obj = child.getID();
+            final int subtype = child.getSubtype();
+            if (subtype == LAPI_DOCUMENTS.PROJECTSUBTYPE)
             {
-              // Couldn't find the path.  Instead of throwing up, return null 
to indicate
-              // illegal node.
-              return null;
+              vol = obj;
+              obj = -obj;
             }
-            break;
+          }
+          else
+          {
+            // Couldn't find the path.  Instead of throwing up, return null to 
indicate
+            // illegal node.
+            return null;
           }
           catch (InterruptedException e)
           {
             t.interrupt();
             throw new ManifoldCFException("Interrupted: 
"+e.getMessage(),e,ManifoldCFException.INTERRUPTED);
           }
-          catch (RuntimeException e)
-          {
-            sanityRetryCount = 
handleCswsRuntimeException(e,sanityRetryCount,true);
-            continue;
-
-          }
         }
 
       }
@@ -4078,7 +4056,7 @@ public class CswsConnector extends org.a
     * Returns the category ID specified by the path name.
     * @param startPath is the folder name, ending in a category name (a string 
with slashes as separators)
     */
-    public int getCategoryId(String startPath)
+    public long getCategoryId(String startPath)
       throws ManifoldCFException, ServiceInterruption
     {
       final Node objInfo = getObjectValue();
@@ -4086,8 +4064,8 @@ public class CswsConnector extends org.a
         return -1;
 
       // Grab the volume ID and starting object
-      int obj = objInfo.getId();
-      int vol = objInfo.getVolumeId();
+      long obj = objInfo.getID();
+      long vol = objInfo.getVolumeID();
 
       // Pick apart the start path.  This is a string separated by slashes.
       if (startPath.length() == 0)
@@ -4137,7 +4115,7 @@ public class CswsConnector extends org.a
           {
             // New starting point is the one we found.
             final Node child = children.get(0);
-            obj = child.getId();
+            obj = child.getID();
             final int subtype = child.getSubtype();
             if (subtype == LAPI_DOCUMENTS.PROJECTSUBTYPE)
             {
@@ -4149,7 +4127,7 @@ public class CswsConnector extends org.a
           {
             // Couldn't find the path.  Instead of throwing up, return null to 
indicate
             // illegal node.
-            return -1;
+            return -1L;
           }
         }
         catch (InterruptedException e)
@@ -4163,13 +4141,13 @@ public class CswsConnector extends org.a
 
     /** Get permissions.
     */
-    public Integer getPermissions()
+    public NodePermissions getPermissions()
       throws ServiceInterruption, ManifoldCFException
     {
       Node elem = getObjectValue();
       if (elem == null)
         return null;
-      return new Integer(objectValue.toInteger("Permissions"));
+      return new elem.getPermissions();
     }
     
     /** Get OpenText document name.
@@ -4180,7 +4158,7 @@ public class CswsConnector extends org.a
       Node elem = getObjectValue();
       if (elem == null)
         return null;
-      return elem.toString("NAME"); 
+      return elem.getName(); 
     }
 
     /** Get OpenText comments/description.
@@ -4191,73 +4169,73 @@ public class CswsConnector extends org.a
       Node elem = getObjectValue();
       if (elem == null)
         return null;
-      return elem.toString("COMMENT"); 
+      return elem.getComment(); 
     }
 
     /** Get parent ID.
     */
-    public Integer getParentId()
+    public Long getParentId()
       throws ServiceInterruption, ManifoldCFException
     {
       Node elem = getObjectValue();
       if (elem == null)
         return null;
-      return new Integer(elem.toInteger("ParentId")); 
+      return elem.getParentID(); 
     }
 
     /** Get owner ID.
     */
-    public Integer getOwnerId()
+    public Long getOwnerId()
       throws ServiceInterruption, ManifoldCFException
     {
       Node elem = getObjectValue();
       if (elem == null)
         return null;
-      return new Integer(elem.toInteger("UserId")); 
+      return elem.getUserID();
     }
 
     /** Get group ID.
     */
-    public Integer getGroupId()
+    public Long getGroupId()
       throws ServiceInterruption, ManifoldCFException
     {
       Node elem = getObjectValue();
       if (elem == null)
         return null;
-      return new Integer(elem.toInteger("GroupId")); 
+      return elem.getGroupID(); 
     }
     
     /** Get creation date.
     */
-    public Date getCreationDate()
+    public XMLGregorianCalendar getCreationDate()
       throws ServiceInterruption, ManifoldCFException
     {
       Node elem = getObjectValue();
       if (elem == null)
         return null;
-      return elem.toDate("CREATEDATE"); 
+      return elem.getCreateDate(); 
     }
     
     /** Get creator ID.
     */
-    public Integer getCreatorId()
+    public Long getCreatorId()
       throws ServiceInterruption, ManifoldCFException
     {
       Node elem = getObjectValue();
       if (elem == null)
         return null;
-      return new Integer(elem.toInteger("CREATEDBY")); 
+      return new elem.getCreatedBy(); 
     }
 
     /* Get modify date.
     */
-    public Date getModifyDate()
+    public XMLGregorianCalendar getModifyDate()
       throws ServiceInterruption, ManifoldCFException
     {
       Node elem = getObjectValue();
       if (elem == null)
         return null;
-      return elem.toDate("ModifyDate"); 
+      return elem.getModifyDate(); 
     }
 
     /** Get the objInfo object.
@@ -4278,10 +4256,6 @@ public class CswsConnector extends org.a
           t.interrupt();
           throw new ManifoldCFException("Interrupted: 
"+e.getMessage(),e,ManifoldCFException.INTERRUPTED);
         }
-        catch (RuntimeException e)
-        {
-          handleCswsRuntimeException(e,sanityRetryCount,true);
-        }
       }
       return objectValue;
     }

Modified: 
manifoldcf/branches/CONNECTORS-1566/connectors/csws/connector/src/main/java/org/apache/manifoldcf/csws/CswsSession.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1566/connectors/csws/connector/src/main/java/org/apache/manifoldcf/csws/CswsSession.java?rev=1854680&r1=1854679&r2=1854680&view=diff
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-1566/connectors/csws/connector/src/main/java/org/apache/manifoldcf/csws/CswsSession.java
 (original)
+++ 
manifoldcf/branches/CONNECTORS-1566/connectors/csws/connector/src/main/java/org/apache/manifoldcf/csws/CswsSession.java
 Sun Mar  3 10:02:11 2019
@@ -50,6 +50,8 @@ import com.opentext.livelink.service.doc
 import com.opentext.livelink.service.docman.GetNodesInContainerOptions;
 import com.opentext.livelink.service.docman.Node;
 
+import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
+import org.apache.manifoldcf.agents.interfaces.ServiceInterruption;
 
 /** This class describes a livelink csws session.  It manages OAuth 
authentication
 * and provides logged-in access to csws services via methods provided within.
@@ -146,10 +148,15 @@ public class CswsSession
   /**
    * Fetch root node types.   These will be cached so we only need to do it 
once.
    */
-  public List<? extends String> getRootNodeTypes() {
+  public List<? extends String> getRootNodeTypes()
+    throws ManifoldCFException, ServiceInterruption {
     if (rootNodeTypes == null) {
       // Fetch them
-      this.rootNodeTypes = 
getDocumentManagementHandle().getRootNodeTypes(getOTAuthentication());
+      try {
+        this.rootNodeTypes = 
getDocumentManagementHandle().getRootNodeTypes(getOTAuthentication());
+      } catch (SOAPFaultException e) {
+        processSOAPFault(e);
+      }
     }
     return this.rootNodeTypes;
   }
@@ -157,10 +164,15 @@ public class CswsSession
   /**
    * Fetch root node given type.
    */
-  public Node getRootNode(final String nodeType) {
+  public Node getRootNode(final String nodeType) 
+  throws ManifoldCFException, ServiceInterruption {
     Node thisWorkspaceNode = workspaceTypeNodes.get(nodeType);
     if (thisWorkspaceNode == null) {
-      thisWorkspaceNode = getDocumentManagementHandle().getRootNode(nodeType, 
getOTAuthentication());
+      try {
+        thisWorkspaceNode = 
getDocumentManagementHandle().getRootNode(nodeType, getOTAuthentication());
+      } catch (SOAPFaultException e) {
+        processSOAPFault(e);
+      }
       workspaceTypeNodes.put(nodeType, thisWorkspaceNode);
     }
     return thisWorkspaceNode;
@@ -168,21 +180,36 @@ public class CswsSession
   
   // Helper methods -- helpful simplifications of API
   
-  public List<? extends Node> getChildren(final String nodeId) {
+  public List<? extends Node> getChildren(final String nodeId)
+    throws ManifoldCFException, ServiceInterruption {
     final GetNodesInContainerOptions gnico = new GetNodesInContainerOptions();
     // Depth 0 - default listing and Depth 1 - One level down
     gnico.setMaxDepth(0);
     // We're listing folder by folder so hopefully this is nowhere near what 
we'll ever get back
     gnico.setMaxResults(1000000);
-    return getDocumentManagementHandle().getNodesInContainer(nodeId, gnico);
+    try {
+      return getDocumentManagementHandle().getNodesInContainer(nodeId, gnico);
+    } catch (SOAPFaultException e) {
+      processSOAPFault(e);
+    }
   }
   
-  public List<? extends CategoryInheritance> getCategoryInheritance(final 
String parentId) {
-    return getDocumentManagementHandle().getCategoryInheritance(parentId, 
getOTAuthentication());
+  public List<? extends CategoryInheritance> getCategoryInheritance(final 
String parentId)
+    throws ManifoldCFException, ServiceInterruption {
+    try {
+      return getDocumentManagementHandle().getCategoryInheritance(parentId, 
getOTAuthentication());
+    } catch (SOAPFaultException e) {
+      processSOAPFault(e);
+    }
   }
 
-  public Node getNode(final String parentId) {
-    return getDocumentManagementHandle().getNode(parentId, 
getOTAuthentication());
+  public Node getNode(final String parentId) 
+    throws ManifoldCFException, ServiceInterruption {
+    try {
+      return getDocumentManagementHandle().getNode(parentId, 
getOTAuthentication());
+      } catch (SOAPFaultException e) {
+        processSOAPFault(e);
+      }
   }
   
   // Construct authentication token argument, which must be passed as last 
argument for every method
@@ -190,7 +217,8 @@ public class CswsSession
   /**
    * Construct OTAuthentication structure (to be passed as an argument)
    */
-  public OTAuthentication getOTAuthentication() {
+  public OTAuthentication getOTAuthentication() 
+    throws ManifoldCFException, ServiceInterruption {
     final String authToken = getAuthToken();
     // Create the OTAuthentication object and set the authentication token
     final OTAuthentication otAuth = new OTAuthentication();
@@ -200,17 +228,26 @@ public class CswsSession
 
   // Private methods
   
-  private String getAuthToken() {
+  private String getAuthToken()
+    throws ManifoldCFException, ServiceInterruption {
     final long currentTime = System.currentTimeMillis();
     if (currentSessionExpiration == -1L || currentTime > 
currentSessionExpiraton) {
       // Kill current auth token etc
       currentSessionExpiration = -1L;
       currentAuthToken = null;
       // Refetch the auth token (this may fail)
-      currentAuthToken = authClient.authenticateUser(userName, password);
+      try {
+        currentAuthToken = authClient.authenticateUser(userName, password);
+      } catch (SOAPFaultException e) {
+        processSOAPFault(e);
+      }
       currentSessionExpiration = currentTime + expirationInterval;
     }
     return currentAuthToken;
   }
   
+  private void processSOAPFault(SOAPFaultException e)
+    throws ManifoldCFException, ServiceInterruption {
+    // MHL
+  }
 }


Reply via email to