Author: kwright
Date: Sat Mar 2 19:18:18 2019
New Revision: 1854664
URL: http://svn.apache.org/viewvc?rev=1854664&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=1854664&r1=1854663&r2=1854664&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
Sat Mar 2 19:18:18 2019
@@ -163,14 +163,18 @@ public class CswsConnector extends org.a
private final static long expirationInterval = 300000L;
// Data required for maintaining csws connection
- // MHL
+ private CswsSession cswsSession = null;
+ // Workspace Nodes (computed once and cached); should contain both
enterprise and category workspaces
+ private Map<String, Node> workspaceNodes = new HashMap<>();
+ /*
// Various IDs we need
private int LLENTWK_VOL;
private int LLENTWK_ID;
private int LLCATWK_VOL;
private int LLCATWK_ID;
-
+ */
+
// Parameter values we need
private String serverProtocol = null;
private String serverName = null;
@@ -268,14 +272,14 @@ public class CswsConnector extends org.a
{
try
{
- // Create the session
- // MHL
-
- if (Logging.connectors.isDebugEnabled())
- {
- String passwordExists =
(serverPassword!=null&&serverPassword.length()>0)?"password exists":"";
- Logging.connectors.debug("Csws: Csws Session:
Server='"+serverName+"'; port='"+serverPort+"'; user name='"+serverUsername+"';
"+passwordExists);
+ // Get all the root workspaces
+ final List<? extends String> workspaceNames =
cswsSession.getRootNodeTypes();
+ // Loop over these and get the nodes (which we'll save for later)
+ workspaceNodes.clear();
+ for (final String workspaceName : workspaceNames) {
+ workspaceNodes.put(workspaceName,
cswsSession.getRootNode(workspaceName));
}
+
/* Here we need to obtain IDs for LLENTWK and LLCATWK
LLValue entinfo = new LLValue().setAssoc();
@@ -507,29 +511,38 @@ public class CswsConnector extends org.a
httpClient = builder.build();
- // System.out.println("Connection server object = "+llServer.toString());
+ // Construct the various URLs we need
+ final String baseURL = serverProtocol + "://" + serverName + ":" +
serverPortString;
+ final String authenticationServiceURL = baseURL +
authenticationServicePath;
+ final String documentManagementServiceURL = baseURL +
documentManagementServicePath;
+ final String contentServiceServiceURL = baseURL +
contentServiceServicePath;
+ final String memberServiceServiceURL = baseURL +
memberServiceServicePath;
- // Establish the actual connection
- int sanityRetryCount = FAILURE_RETRY_COUNT;
- while (true)
+ // Build web services connection management object
+ if (Logging.connectors.isDebugEnabled())
{
- GetSessionThread t = new GetSessionThread();
- try
- {
- t.start();
- t.finishUp();
- hasConnected = true;
- break;
- }
- catch (InterruptedException e)
- {
- t.interrupt();
- throw new ManifoldCFException("Interrupted:
"+e.getMessage(),e,ManifoldCFException.INTERRUPTED);
- }
- catch (RuntimeException e2)
- {
- sanityRetryCount =
handleCswsRuntimeException(e2,sanityRetryCount,true);
- }
+ String passwordExists =
(serverPassword!=null&&serverPassword.length()>0)?"password exists":"";
+ Logging.connectors.debug("Csws: Csws Session: Server='"+serverName+"';
port='"+serverPort+"'; user name='"+serverUsername+"'; "+passwordExists);
+ }
+
+ // Construct a new csws session object for setting up this session
+ cswsSession = new CswsSession(userName, password, 1000L * 60L * 15L,
authenticationServiceURL, documentManagementServiceURL,
contentServiceServiceURL, memberServiceServiceURL);
+
+ final GetSessionThread t = new GetSessionThread();
+ try
+ {
+ t.start();
+ t.finishUp();
+ hasConnected = true;
+ }
+ catch (InterruptedException e)
+ {
+ t.interrupt();
+ throw new ManifoldCFException("Interrupted:
"+e.getMessage(),e,ManifoldCFException.INTERRUPTED);
+ }
+ catch (RuntimeException e2)
+ {
+ handleCswsRuntimeException(e2);
}
}
expirationTime = System.currentTimeMillis() + expirationInterval;
@@ -880,10 +893,7 @@ public class CswsConnector extends org.a
CswsContext llc = new CswsContext();
// First, grab the root LLValue
- // MHL - TBD
- ObjectInformation rootValue = null;
- /*
- ObjectInformation rootValue =
llc.getObjectInformation(LLENTWK_VOL,LLENTWK_ID);
+ ObjectInformation rootValue = llc.getObjectInformation(LLENTWK_VOL,
LLENTWK_ID);
if (!rootValue.exists())
{
// If we get here, it HAS to be a bad network/transient problem.
@@ -891,7 +901,6 @@ public class CswsConnector extends org.a
throw new ServiceInterruption("Service interruption during seeding",new
ManifoldCFException("Could not looking root workspace object during
seeding"),System.currentTimeMillis()+60000L,
System.currentTimeMillis()+600000L,-1,true);
}
- */
// Walk the specification for the "startpoint" types. Amalgamate these
into a list of strings.
// Presume that all roots are startpoint nodes
@@ -910,7 +919,7 @@ public class CswsConnector extends org.a
activities.recordActivity(new Long(beginTime),ACTIVITY_SEED,null,
path,"OK",null,null);
- String newID = "F" + new Integer(vaf.getVolumeID()).toString()+":"+
new Integer(vaf.getPathId()).toString();
+ String newID = "F" + vaf.getVolumeID()+":"+ vaf.getPathId();
activities.addSeedDocument(newID);
if (Logging.connectors.isDebugEnabled())
Logging.connectors.debug("Csws: Seed = '"+newID+"'");
@@ -1113,96 +1122,67 @@ public class CswsConnector extends org.a
// === Csws folder ===
// I'm still not sure if Csws folder modified dates are one-level or
hierarchical.
// The code below assumes one-level only, so we always scan folders
and there's no versioning
- if (Logging.connectors.isDebugEnabled())
- Logging.connectors.debug("Csws: Processing folder
"+Integer.toString(vol)+":"+Integer.toString(objID));
-
- // TBD
+ if (Logging.connectors.isDebugEnabled()) {
+ Logging.connectors.debug("Csws: Processing folder "+vol+":"+objID);
+ }
- /*
- int sanityRetryCount = FAILURE_RETRY_COUNT;
- while (true)
+ final ListObjectsThread t = new ListObjectsThread(vol, objID,
filterString);
+ t.start();
+ final List<? extends Node> childrenDocs = t.finishUp();
+ for (final Node childDoc : childrenDocs)
{
- ListObjectsThread t = new ListObjectsThread(vol,objID,filterString);
- try
+ final int childID = childDoc.getId();
+
+ if (Logging.connectors.isDebugEnabled())
{
- t.start();
- LLValue childrenDocs;
- try
- {
- childrenDocs = t.finishUp();
+ Logging.connectors.debug("Csws: Found a child of folder
"+vol+":"+objID+" : ID="+childID);
+ }
+
+ // All we need to know is whether the child is a container or not,
and there is a way to do that directly from the node
+ /*
+ int subtype = childDoc.getSubtype();
+ boolean childIsFolder = (subtype == LAPI_DOCUMENTS.FOLDERSUBTYPE ||
subtype == LAPI_DOCUMENTS.PROJECTSUBTYPE ||
+ subtype == LAPI_DOCUMENTS.COMPOUNDDOCUMENTSUBTYPE);
+ */
+ final boolean childIsFolder = childDoc.isContainer();
+
+ // If it's a folder, we just let it through for now
+ if (!childIsFolder && checkInclude(childDoc.getName() + "." +
childDoc.getFileType(), spec) == false)
+ {
+ if (Logging.connectors.isDebugEnabled()) {
+ Logging.connectors.debug("Csws: Child identifier "+childID+" was
excluded by inclusion criteria");
}
- catch (ManifoldCFException e)
+ continue;
+ }
+
+ if (childIsFolder)
+ {
+ if (Logging.connectors.isDebugEnabled()) {
+ Logging.connectors.debug("Csws: Child identifier "+childID+" is
a folder, project, or compound document; adding a reference");
+ }
+ if (subtype == LAPI_DOCUMENTS.PROJECTSUBTYPE)
{
- sanityRetryCount = assessRetry(sanityRetryCount,e);
- continue;
+ // If we pick up a project object, we need to describe the
volume object (which
+ // will be the root of all documents beneath)
+ activities.addDocumentReference("F"+childID+":"+(-childID));
}
-
- int size = 0;
-
- if (childrenDocs.isRecord())
- size = 1;
- if (childrenDocs.isTable())
- size = childrenDocs.size();
-
- // System.out.println("Total child count =
"+Integer.toString(size));
- // Do the scan
- for (int j = 0; j < size; j++)
+ else
{
- int childID = childrenDocs.toInteger(j, "ID");
-
- if (Logging.connectors.isDebugEnabled())
- Logging.connectors.debug("Csws: Found a child of folder
"+Integer.toString(vol)+":"+Integer.toString(objID)+" :
ID="+Integer.toString(childID));
-
- int subtype = childrenDocs.toInteger(j, "SubType");
- boolean childIsFolder = (subtype == LAPI_DOCUMENTS.FOLDERSUBTYPE
|| subtype == LAPI_DOCUMENTS.PROJECTSUBTYPE ||
- subtype == LAPI_DOCUMENTS.COMPOUNDDOCUMENTSUBTYPE);
-
- // If it's a folder, we just let it through for now
- if (!childIsFolder &&
checkInclude(childrenDocs.toString(j,"Name") + "." +
childrenDocs.toString(j,"FileType"), spec) == false)
- {
- if (Logging.connectors.isDebugEnabled())
- Logging.connectors.debug("Csws: Child identifier
"+Integer.toString(childID)+" was excluded by inclusion criteria");
- continue;
- }
-
- if (childIsFolder)
- {
- if (Logging.connectors.isDebugEnabled())
- Logging.connectors.debug("Csws: Child identifier
"+Integer.toString(childID)+" is a folder, project, or compound document;
adding a reference");
- if (subtype == LAPI_DOCUMENTS.PROJECTSUBTYPE)
- {
- // If we pick up a project object, we need to describe the
volume object (which
- // will be the root of all documents beneath)
- activities.addDocumentReference("F"+new
Integer(childID).toString()+":"+new Integer(-childID).toString());
- }
- else
- activities.addDocumentReference("F"+new
Integer(vol).toString()+":"+new Integer(childID).toString());
- }
- else
- {
- if (Logging.connectors.isDebugEnabled())
- Logging.connectors.debug("Csws: Child identifier
"+Integer.toString(childID)+" is a simple document; adding a reference");
-
- activities.addDocumentReference("D"+new
Integer(vol).toString()+":"+new Integer(childID).toString());
- }
-
+ activities.addDocumentReference("F"+vol+":"+childID);
}
- break;
}
- catch (InterruptedException e)
- {
- t.interrupt();
- throw new ManifoldCFException("Interrupted:
"+e.getMessage(),e,ManifoldCFException.INTERRUPTED);
- }
- catch (RuntimeException e)
+ else
{
- sanityRetryCount =
handleCswsRuntimeException(e,sanityRetryCount,true);
- continue;
+ if (Logging.connectors.isDebugEnabled()) {
+ Logging.connectors.debug("Csws: Child identifier "+childID+" is
a simple document; adding a reference");
+ }
+ activities.addDocumentReference("D"+vol+":"+childID);
}
+
+ }
+ if (Logging.connectors.isDebugEnabled()) {
+ Logging.connectors.debug("Csws: Done processing folder
"+vol+":"+objID);
}
- */
- if (Logging.connectors.isDebugEnabled())
- Logging.connectors.debug("Csws: Done processing folder
"+Integer.toString(vol)+":"+Integer.toString(objID));
}
else
{
@@ -1334,13 +1314,16 @@ public class CswsConnector extends org.a
}
}
+ /**
+ * Thread that reads child objects that have a specified filter criteria,
given a volume ID and object ID.
+ */
protected class ListObjectsThread extends Thread
{
protected final int vol;
protected final int objID;
protected final String filterString;
protected Throwable exception = null;
- //protected LLValue rval = null;
+ protected List<? extends Node> rval = null;
public ListObjectsThread(int vol, int objID, String filterString)
{
@@ -1355,16 +1338,8 @@ public class CswsConnector extends org.a
{
try
{
- // MHL - TBD
- /*
- LLValue childrenDocs = new LLValue();
- int status = LLDocs.ListObjects(vol, objID, null, filterString,
LAPI_DOCUMENTS.PERM_SEECONTENTS, childrenDocs);
- if (status != 0)
- {
- throw new ManifoldCFException("Error retrieving contents of folder
"+Integer.toString(vol)+":"+Integer.toString(objID)+" :
Status="+Integer.toString(status)+" ("+llServer.getErrors()+")");
- }
- rval = childrenDocs;
- */
+ // int status = LLDocs.ListObjects(vol, objID, null,
filterString, LAPI_DOCUMENTS.PERM_SEECONTENTS, childrenDocs);
+ rval = cswsSession.getChildren(objID);
}
catch (Throwable e)
{
@@ -1372,7 +1347,7 @@ public class CswsConnector extends org.a
}
}
- public LLValue finishUp()
+ public List<? extends Node> finishUp()
throws ManifoldCFException, InterruptedException
{
join();
@@ -1388,7 +1363,7 @@ public class CswsConnector extends org.a
else
throw new RuntimeException("Unrecognized exception type:
"+thr.getClass().getName()+": "+thr.getMessage(),thr);
}
- return null;//rval;
+ return rval;
}
}
@@ -2635,7 +2610,15 @@ public class CswsConnector extends org.a
public String[] getWorkspaceNames()
throws ManifoldCFException, ServiceInterruption
{
- return new String[]{CATEGORY_NAME,ENTWKSPACE_NAME};
+ getSession();
+ final Set<String> workspaceNames = workspaceNodes.keySet();
+ final String[] rval = new String[workspaceNames.size()];
+ int i = 0;
+ for (final String name : workspaceNames) {
+ rval[i++] = name;
+ }
+ java.util.Arrays.sort(rval);
+ return rval;
}
/** Given a path string, get a list of folders and projects under that node.
@@ -3659,23 +3642,35 @@ public class CswsConnector extends org.a
protected class CswsContext
{
/** Cache of ObjectInformation objects. */
- protected final Map<ObjectInformation,ObjectInformation> objectInfoMap =
new HashMap<ObjectInformation,ObjectInformation>();
+ protected final Map<ObjectInformation,ObjectInformation> objectInfoMap =
new HashMap<>();
/** Cache of VersionInformation objects. */
- protected final Map<VersionInformation,VersionInformation> versionInfoMap
= new HashMap<VersionInformation,VersionInformation>();
+ protected final Map<VersionInformation,VersionInformation> versionInfoMap
= new HashMap<>();
/** Cache of UserInformation objects */
- protected final Map<UserInformation,UserInformation> userInfoMap = new
HashMap<UserInformation,UserInformation>();
+ protected final Map<UserInformation,UserInformation> userInfoMap = new
HashMap<>();
public CswsContext()
{
}
+ public ObjectInformation getObjectInformation(final String workspaceName)
+ {
+ ObjectInformation oi = new ObjectInformation(workspaceName);
+ ObjectInformation lookupValue = objectInfoMap.get(oi);
+ if (lookupValue == null)
+ {
+ objectInfoMap.put(oi, oi);
+ return oi;
+ }
+ return lookupValue;
+ }
+
public ObjectInformation getObjectInformation(int volumeID, int objectID)
{
- ObjectInformation oi = new ObjectInformation(volumeID,objectID);
+ ObjectInformation oi = new ObjectInformation(volumeID, objectID);
ObjectInformation lookupValue = objectInfoMap.get(oi);
if (lookupValue == null)
{
- objectInfoMap.put(oi,oi);
+ objectInfoMap.put(oi, oi);
return oi;
}
return lookupValue;
@@ -3941,15 +3936,30 @@ public class CswsConnector extends org.a
{
protected final int volumeID;
protected final int objectID;
+ protected final String workspaceName;
- protected LLValue objectValue = null;
+ protected Node objectValue = null;
- public ObjectInformation(int volumeID, int objectID)
+ public ObjectInformation(final int volumeID, final int objectID)
{
this.volumeID = volumeID;
this.objectID = objectID;
+ this.workspaceName = null;
}
+ public ObjectInformation(final String workspaceName) {
+ this.workspaceName = workspaceName;
+ this.volumeID = -1;
+ this.objectID = -1;
+ }
+
+ /**
+ * Get workspace name
+ */
+ public String getWorkspaceName() {
+ return workspaceName;
+ }
+
/**
* Check whether object seems to exist or not.
*/
@@ -3959,20 +3969,6 @@ public class CswsConnector extends org.a
return getObjectValue() != null;
}
- /** Check if this object is the category workspace.
- */
- public boolean isCategoryWorkspace()
- {
- return objectID == LLCATWK_ID;
- }
-
- /** Check if this object is the entity workspace.
- */
- public boolean isEntityWorkspace()
- {
- return objectID == LLENTWK_ID;
- }
-
/** toString override */
@Override
public String toString()
@@ -3987,13 +3983,13 @@ public class CswsConnector extends org.a
public VolumeAndId getPathId(String startPath)
throws ServiceInterruption, ManifoldCFException
{
- LLValue objInfo = getObjectValue();
+ Node objInfo = getObjectValue();
if (objInfo == null)
return null;
// Grab the volume ID and starting object
- int obj = objInfo.toInteger("ID");
- int vol = objInfo.toInteger("VolumeID");
+ int obj = objInfo.getId();
+ int vol = objInfo.getVolumeId();
// Pick apart the start path. This is a string separated by slashes.
int charindex = 0;
@@ -4015,7 +4011,7 @@ public class CswsConnector extends org.a
currentTokenBuffer.append(x);
}
- String subFolder = currentTokenBuffer.toString();
+ final String subFolder = currentTokenBuffer.toString();
// We want only folders that are children of the current object and
which match the specified subfolder
String filterString = "(SubType="+ LAPI_DOCUMENTS.FOLDERSUBTYPE + " or
SubType=" + LAPI_DOCUMENTS.PROJECTSUBTYPE +
" or SubType=" + LAPI_DOCUMENTS.COMPOUNDDOCUMENTSUBTYPE + ") and
Name='" + subFolder + "'";
@@ -4085,13 +4081,13 @@ public class CswsConnector extends org.a
public int getCategoryId(String startPath)
throws ManifoldCFException, ServiceInterruption
{
- LLValue objInfo = getObjectValue();
+ final Node objInfo = getObjectValue();
if (objInfo == null)
return -1;
// Grab the volume ID and starting object
- int obj = objInfo.toInteger("ID");
- int vol = objInfo.toInteger("VolumeID");
+ int obj = objInfo.getId();
+ int vol = objInfo.getVolumeId();
// Pick apart the start path. This is a string separated by slashes.
if (startPath.length() == 0)
@@ -4127,58 +4123,40 @@ public class CswsConnector extends org.a
filterString += " 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;
- }
-
- if (children == null)
- return -1;
+ t.start();
+ final List<? extends Node> children = t.finishUp();
+ if (children == null) {
+ return -1;
+ }
- // If there is one child, then we are okay.
- if (children.size() == 1)
+ // 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)
{
- // 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
- {
- // Couldn't find the path. Instead of throwing up, return null
to indicate
- // illegal node.
- return -1;
+ vol = obj;
+ obj = -obj;
}
- break;
- }
- catch (InterruptedException e)
- {
- t.interrupt();
- throw new ManifoldCFException("Interrupted:
"+e.getMessage(),e,ManifoldCFException.INTERRUPTED);
}
- catch (RuntimeException e)
+ else
{
- sanityRetryCount =
handleCswsRuntimeException(e,sanityRetryCount,true);
- continue;
+ // Couldn't find the path. Instead of throwing up, return null to
indicate
+ // illegal node.
+ return -1;
}
}
+ catch (InterruptedException e)
+ {
+ t.interrupt();
+ throw new ManifoldCFException("Interrupted:
"+e.getMessage(),e,ManifoldCFException.INTERRUPTED);
+ }
}
return obj;
}
@@ -4188,7 +4166,7 @@ public class CswsConnector extends org.a
public Integer getPermissions()
throws ServiceInterruption, ManifoldCFException
{
- LLValue elem = getObjectValue();
+ Node elem = getObjectValue();
if (elem == null)
return null;
return new Integer(objectValue.toInteger("Permissions"));
@@ -4199,7 +4177,7 @@ public class CswsConnector extends org.a
public String getName()
throws ServiceInterruption, ManifoldCFException
{
- LLValue elem = getObjectValue();
+ Node elem = getObjectValue();
if (elem == null)
return null;
return elem.toString("NAME");
@@ -4210,7 +4188,7 @@ public class CswsConnector extends org.a
public String getComments()
throws ServiceInterruption, ManifoldCFException
{
- LLValue elem = getObjectValue();
+ Node elem = getObjectValue();
if (elem == null)
return null;
return elem.toString("COMMENT");
@@ -4221,7 +4199,7 @@ public class CswsConnector extends org.a
public Integer getParentId()
throws ServiceInterruption, ManifoldCFException
{
- LLValue elem = getObjectValue();
+ Node elem = getObjectValue();
if (elem == null)
return null;
return new Integer(elem.toInteger("ParentId"));
@@ -4232,7 +4210,7 @@ public class CswsConnector extends org.a
public Integer getOwnerId()
throws ServiceInterruption, ManifoldCFException
{
- LLValue elem = getObjectValue();
+ Node elem = getObjectValue();
if (elem == null)
return null;
return new Integer(elem.toInteger("UserId"));
@@ -4243,7 +4221,7 @@ public class CswsConnector extends org.a
public Integer getGroupId()
throws ServiceInterruption, ManifoldCFException
{
- LLValue elem = getObjectValue();
+ Node elem = getObjectValue();
if (elem == null)
return null;
return new Integer(elem.toInteger("GroupId"));
@@ -4254,7 +4232,7 @@ public class CswsConnector extends org.a
public Date getCreationDate()
throws ServiceInterruption, ManifoldCFException
{
- LLValue elem = getObjectValue();
+ Node elem = getObjectValue();
if (elem == null)
return null;
return elem.toDate("CREATEDATE");
@@ -4265,7 +4243,7 @@ public class CswsConnector extends org.a
public Integer getCreatorId()
throws ServiceInterruption, ManifoldCFException
{
- LLValue elem = getObjectValue();
+ Node elem = getObjectValue();
if (elem == null)
return null;
return new Integer(elem.toInteger("CREATEDBY"));
@@ -4276,7 +4254,7 @@ public class CswsConnector extends org.a
public Date getModifyDate()
throws ServiceInterruption, ManifoldCFException
{
- LLValue elem = getObjectValue();
+ Node elem = getObjectValue();
if (elem == null)
return null;
return elem.toDate("ModifyDate");
@@ -4284,39 +4262,25 @@ public class CswsConnector extends org.a
/** Get the objInfo object.
*/
- protected LLValue getObjectValue()
+ protected Node getObjectValue()
throws ServiceInterruption, ManifoldCFException
{
if (objectValue == null)
{
- int sanityRetryCount = FAILURE_RETRY_COUNT;
- while (true)
+ final GetObjectInfoThread t = new GetObjectInfoThread(volumeID,
objectID);
+ try
{
- GetObjectInfoThread t = new GetObjectInfoThread(volumeID,objectID);
- try
- {
- t.start();
- try
- {
- objectValue = t.finishUp();
- }
- catch (ManifoldCFException e)
- {
- sanityRetryCount = assessRetry(sanityRetryCount,e);
- continue;
- }
- break;
- }
- catch (InterruptedException e)
- {
- t.interrupt();
- throw new ManifoldCFException("Interrupted:
"+e.getMessage(),e,ManifoldCFException.INTERRUPTED);
- }
- catch (RuntimeException e)
- {
- sanityRetryCount =
handleCswsRuntimeException(e,sanityRetryCount,true);
- continue;
- }
+ t.start();
+ objectValue = t.finishUp();
+ }
+ catch (InterruptedException e)
+ {
+ t.interrupt();
+ throw new ManifoldCFException("Interrupted:
"+e.getMessage(),e,ManifoldCFException.INTERRUPTED);
+ }
+ catch (RuntimeException e)
+ {
+ handleCswsRuntimeException(e,sanityRetryCount,true);
}
}
return objectValue;
@@ -4325,6 +4289,9 @@ public class CswsConnector extends org.a
@Override
public int hashCode()
{
+ if (workspaceName != null) {
+ return workspaceName.hashCode();
+ }
return (volumeID << 5) ^ (volumeID >> 3) ^ (objectID << 5) ^ (objectID
>> 3);
}
@@ -4333,7 +4300,13 @@ public class CswsConnector extends org.a
{
if (!(o instanceof ObjectInformation))
return false;
- ObjectInformation other = (ObjectInformation)o;
+ final ObjectInformation other = (ObjectInformation)o;
+ if (workspaceName != null || other.workspaceName != null) {
+ if (workspaceName == null || other.workspaceName == null) {
+ return false;
+ }
+ return workspaceName.equals(other.workspaceName);
+ }
return volumeID == other.volumeID && objectID == other.objectID;
}
}
@@ -5374,7 +5347,7 @@ public class CswsConnector extends org.a
path = name;
else
{
- String parentIdentifier =
"F"+Integer.toString(volumeID)+":"+Integer.toString(parentID);
+ String parentIdentifier = "F"+volumeID+":"+parentID;
String parentPath = getNodePathString(parentIdentifier);
if (parentPath == null)
return null;
@@ -5539,7 +5512,7 @@ public class CswsConnector extends org.a
protected String findPath(int catID)
throws ManifoldCFException, ServiceInterruption
{
- return getObjectPath(llc.getObjectInformation(0,catID));
+ return getObjectPath(llc.getObjectInformation(0, catID));
}
/** Get the complete path for an object.
@@ -5550,10 +5523,9 @@ public class CswsConnector extends org.a
String path = null;
while (true)
{
- if (currentObject.isCategoryWorkspace())
- return CATEGORY_NAME + ((path==null)?"":":" + path);
- else if (currentObject.isEntityWorkspace())
- return ENTWKSPACE_NAME + ((path==null)?"":":" + path);
+ if (currentObject.getWorkspaceName() != null) {
+ return currentObject.getWorkspaceName() + ((path==null)?"":":" +
path);
+ }
if (!currentObject.exists())
{
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=1854664&r1=1854663&r2=1854664&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
Sat Mar 2 19:18:18 2019
@@ -18,6 +18,10 @@
*/
package org.apache.manifoldcf.csws;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+
import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPElement;
@@ -29,17 +33,20 @@ import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
import javax.xml.ws.soap.MTOMFeature;
import javax.xml.ws.soap.SOAPFaultException;
+import javax.xml.ws.BindingProvider;
import com.opentext.ecm.api.OTAuthentication;
import com.opentext.livelink.service.core.Authentication;
import com.opentext.livelink.service.core.Authentication_Service;
import com.opentext.livelink.service.core.ContentService;
import com.opentext.livelink.service.core.ContentService_Service;
-import com.opentext.livelink.service.core.FileAtts;
-import com.opentext.livelink.service.docman.AttributeGroup;
-import com.opentext.livelink.service.docman.CategoryInheritance;
+import com.opentext.livelink.service.memberservice.MemberService;
+import com.opentext.livelink.service.memberservice.MemberService_Service;
import com.opentext.livelink.service.docman.DocumentManagement;
import com.opentext.livelink.service.docman.DocumentManagement_Service;
+
+import com.opentext.livelink.service.docman.AttributeGroup;
+import com.opentext.livelink.service.docman.CategoryInheritance;
import com.opentext.livelink.service.docman.GetNodesInContainerOptions;
import com.opentext.livelink.service.docman.Node;
@@ -60,11 +67,21 @@ public class CswsSession
private final Authentication_Service authService;
private final ContentService_Service contentServiceService;
private final DocumentManagement_Service documentManagementService;
+ private final MemberService_Service memberServiceService;
// Authentication support
private final Authentication authClientHandle;
private final DocumentManagement documentManagementHandle;
private final ContentService contentServiceHandle;
+ private final MemberService memberServiceHandle;
+
+ // Transient data
+
+ // Cached root node types
+ private List<? extends String> rootNodeTypes = null;
+
+ // Cached workspace root nodes
+ private Map<String, Node> workspaceTypeNodes = new HashMap<>();
// Transient data that will need to be periodically rebuilt
private long currentSessionExpiration = -1L;
@@ -73,66 +90,115 @@ public class CswsSession
public CswsSession(final String userName,
final String password,
final long sessionExpirationInterval,
- final Authentication_Service authenticationService,
- final ContentService_Service contentServiceService,
- final DocumentManagement_Service documentManagementService) {
+ final String authenticationServiceURL,
+ final String documentManagementServiceURL,
+ final String contentServiceServiceURL,
+ final String memberServiceServiceURL) {
+
+ // Save username/password
this.userName = userName;
this.password = password;
+ // Save expiration interval
this.sessionExpirationInterval = sessionExpirationInterval;
- this.authService = authService;
- this.contentServiceService = contentServiceService;
- this.documentManagementService = documentManagementService;
-
+ // Construct service references from the URLs
+ this.authService = new Authentication_Service();
+ this.documentManagementService = new DocumentManagement_Service();
+ this.contentServiceService = new ContentService_Service();
+ this.memberServiceService = new MemberService_Service();
// Initialize authclient etc.
this.authClientHandle = authService.getBasicHttpBindingAuthentication();
this.documentManagementHandle =
documentManagementService.getBasicHttpBindingDocumentManagement();
this.contentServiceHandle =
contentServiceService.getBasicHttpBindingContentService();
+ this.memberServiceHandle =
memberServiceService.getBasicHttpBindingMemberService();
+ // Set up endpoints
+
((BindingProvider)authClientHandle).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
authenticationServiceURL);
+
((BindingProvider)documentManagementHandle).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
documentManagementServiceURL);
+
((BindingProvider)contentServiceHandle).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
contentServiceServiceURL);
+
((BindingProvider)memberServiceHandle).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
memberServiceServiceURL);
}
-
+
+ /**
+ * Fetch initialized DocumentManagement handle.
+ */
+ public DocumentManagement getDocumentManagementHandle() {
+ // MHL to set up transport etc.
+ return documentManagementHandle;
+ }
+
+ /**
+ * Fetch initialized ContentService handle.
+ */
public ContentService getContentServiceHandle() {
+ // MHL to set up transport etc.
+ return contentServiceHandle;
+ }
+
+ /**
+ * Fetch initialized MemberService handle.
+ */
+ public MemberService getMemberServiceHandle() {
// MHL
- return null;
+ return memberServiceHandle;
}
- public DocumentManagement getDocumentManagementHandle() {
- // Set the outgoing headers; all we need is the auth token
- // Create a SOAP header
- final SOAPHeader header =
MessageFactory.newInstance().createMessage().getSOAPPart().getEnvelope().getHeader();
-
//((WSBindingProvider)documentManagementHandle).setOutboundHeaders(createAuthHeader(header));
-
- List<String> rootNodeTypes = documentManagementHandle.getRootNodeTypes();
+ // Accessors for information that only needs to be accessed once per
session, which we will cache
+
+ /**
+ * Fetch root node types. These will be cached so we only need to do it
once.
+ */
+ public List<? extends String> getRootNodeTypes() {
+ if (rootNodeTypes == null) {
+ // Fetch them
+ this.rootNodeTypes =
getDocumentManagementHandle().getRootNodeTypes(getOTAuthentication());
+ }
+ return this.rootNodeTypes;
+ }
+
+ /**
+ * Fetch root node given type.
+ */
+ public Node getRootNode(final String nodeType) {
+ Node thisWorkspaceNode = workspaceTypeNodes.get(nodeType);
+ if (thisWorkspaceNode == null) {
+ thisWorkspaceNode = getDocumentManagementHandle().getRootNode(nodeType,
getOTAuthentication());
+ workspaceTypeNodes.put(nodeType, thisWorkspaceNode);
+ }
+ return thisWorkspaceNode;
+ }
+
+ // Helper methods -- helpful simplifications of API
+
+ public List<? extends Node> getChildren(final String nodeId) {
+ 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);
+ }
+
+ public List<? extends CategoryInheritance> getCategoryInheritance(final
String parentId) {
+ return getDocumentManagementHandle().getCategoryInheritance(parentId,
getOTAuthentication());
+ }
- return documentManagementHandle;
+ public Node getNode(final String parentId) {
+ return getDocumentManagementHandle().getNode(parentId,
getOTAuthentication());
}
- // Private methods
+ // Construct authentication token argument, which must be passed as last
argument for every method
- /*
- private Header createAuthHeader(final SOAPHeader header) {
+ /**
+ * Construct OTAuthentication structure (to be passed as an argument)
+ */
+ public OTAuthentication getOTAuthentication() {
final String authToken = getAuthToken();
// Create the OTAuthentication object and set the authentication token
final OTAuthentication otAuth = new OTAuthentication();
otAuth.setAuthenticationToken(authToken);
-
- // We need to manually set the SOAP header to include the authentication
token
-
- // Add the OTAuthentication SOAP header element
- final SOAPHeaderElement otAuthElement = header.addHeaderElement(new
QName(ECM_API_NAMESPACE, "OTAuthentication"));
-
- // Add the AuthenticationToken SOAP element
- final SOAPElement authTokenElement = otAuthElement.addChildElement(new
QName(ECM_API_NAMESPACE, "AuthenticationToken"));
- authTokenElement.addTextNode(otAuth.getAuthenticationToken());
- return Headers.create(otAuthElement);
+ return otAuth;
}
- */
-
- /*
- private static Header getContentIDHeader(final SOAPHeader header, String
contentID) {
- final SOAPHeaderElement contentIDElement = header.addHeaderElement(new
QName(CORE_NAMESPACE, "contextID"));
- contentIDElement.addTextNode(contentID);
- return Headers.create(contentIDElement);
- }
- */
+
+ // Private methods
private String getAuthToken() {
final long currentTime = System.currentTimeMillis();
@@ -140,8 +206,6 @@ public class CswsSession
// Kill current auth token etc
currentSessionExpiration = -1L;
currentAuthToken = null;
- documentManagementHandle = null;
- contentServiceHandle = null;
// Refetch the auth token (this may fail)
currentAuthToken = authClient.authenticateUser(userName, password);
currentSessionExpiration = currentTime + expirationInterval;