Author: kwright
Date: Wed Sep 10 16:50:04 2014
New Revision: 1624058
URL: http://svn.apache.org/r1624058
Log:
Update Filenet connector to handle revised IRepositoryConnector API properly.
Part of CONNECTORS-977.
Modified:
manifoldcf/trunk/connectors/filenet/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/filenet/FilenetConnector.java
manifoldcf/trunk/connectors/filenet/implementation/src/main/java/org/apache/manifoldcf/crawler/common/filenet/FilenetImpl.java
manifoldcf/trunk/connectors/filenet/interface/src/main/java/org/apache/manifoldcf/crawler/common/filenet/IFilenet.java
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=1624058&r1=1624057&r2=1624058&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
Wed Sep 10 16:50:04 2014
@@ -133,9 +133,28 @@ public class FilenetConnector extends or
}
}
- public Throwable getException()
+ public void finishUp()
+ throws java.net.MalformedURLException, NotBoundException,
RemoteException, FilenetException, InterruptedException
{
- return exception;
+ join();
+ Throwable thr = exception;
+ if (thr != null)
+ {
+ if (thr instanceof java.net.MalformedURLException)
+ throw (java.net.MalformedURLException)thr;
+ else if (thr instanceof NotBoundException)
+ throw (NotBoundException)thr;
+ else if (thr instanceof RemoteException)
+ throw (RemoteException)thr;
+ else if (thr instanceof FilenetException)
+ throw (FilenetException)thr;
+ else if (thr instanceof RuntimeException)
+ throw (RuntimeException)thr;
+ else if (thr instanceof Error)
+ throw (Error)thr;
+ else
+ throw new RuntimeException("Unexpected exception type:
"+thr.getClass().getName()+": "+thr.getMessage(),thr);
+ }
}
}
@@ -184,26 +203,10 @@ public class FilenetConnector extends or
long currentTime;
GetSessionThread t = new GetSessionThread();
+ t.start();
try
{
- t.start();
- t.join();
- Throwable thr = t.getException();
- if (thr != null)
- {
- if (thr instanceof java.net.MalformedURLException)
- throw (java.net.MalformedURLException)thr;
- else if (thr instanceof NotBoundException)
- throw (NotBoundException)thr;
- else if (thr instanceof RemoteException)
- throw (RemoteException)thr;
- else if (thr instanceof FilenetException)
- throw (FilenetException)thr;
- else if (thr instanceof RuntimeException)
- throw (RuntimeException)thr;
- else
- throw (Error)thr;
- }
+ t.finishUp();
}
catch (InterruptedException e)
{
@@ -272,9 +275,24 @@ public class FilenetConnector extends or
}
}
- public Throwable getException()
+ public void finishUp()
+ throws RemoteException, FilenetException, InterruptedException
{
- return exception;
+ join();
+ Throwable thr = exception;
+ if (thr != null)
+ {
+ if (thr instanceof RemoteException)
+ throw (RemoteException)thr;
+ else if (thr instanceof FilenetException)
+ throw (FilenetException)thr;
+ else if (thr instanceof RuntimeException)
+ throw (RuntimeException)thr;
+ else if (thr instanceof Error)
+ throw (Error)thr;
+ else
+ throw new RuntimeException("Unexpected exception type:
"+thr.getClass().getName()+": "+thr.getMessage(),thr);
+ }
}
}
@@ -291,22 +309,10 @@ public class FilenetConnector extends or
if (currentTime >= lastSessionFetch + timeToRelease)
{
DestroySessionThread t = new DestroySessionThread();
+ t.start();
try
{
- t.start();
- t.join();
- Throwable thr = t.getException();
- if (thr != null)
- {
- if (thr instanceof RemoteException)
- throw (RemoteException)thr;
- else if (thr instanceof FilenetException)
- throw (FilenetException)thr;
- else if (thr instanceof RuntimeException)
- throw (RuntimeException)thr;
- else
- throw (Error)thr;
- }
+ t.finishUp();
session = null;
lastSessionFetch = -1L;
}
@@ -492,22 +498,10 @@ public class FilenetConnector extends or
if (session != null)
{
DestroySessionThread t = new DestroySessionThread();
+ t.start();
try
{
- t.start();
- t.join();
- Throwable thr = t.getException();
- if (thr != null)
- {
- if (thr instanceof RemoteException)
- throw (RemoteException)thr;
- else if (thr instanceof FilenetException)
- throw (FilenetException)thr;
- else if (thr instanceof RuntimeException)
- throw (RuntimeException)thr;
- else
- throw (Error)thr;
- }
+ t.finishUp();
session = null;
lastSessionFetch = -1L;
}
@@ -921,90 +915,47 @@ public class FilenetConnector extends or
return value - digit * divisor;
}
- /** Get document versions given an array of document identifiers.
- * This method is called for EVERY document that is considered. It is
- * therefore important to perform as little work as possible here.
- *@param documentIdentifiers is the array of local document identifiers, as
understood by this connector.
- *@param oldVersions is the corresponding array of version strings that have
been saved for the document identifiers.
- * A null value indicates that this is a first-time fetch, while an empty
string indicates that the previous document
- * had an empty version string.
- *@param activity is the interface this method should use to perform whatever
framework actions are desired.
- *@param spec is the current document specification for the current job. If
there is a dependency on this
- * specification, then the version string should include the pertinent data,
so that reingestion will occur
- * when the specification changes. This is primarily useful for metadata.
+ /** Process a set of documents.
+ * This is the method that should cause each document to be fetched,
processed, and the results either added
+ * to the queue of documents for the current job, and/or entered into the
incremental ingestion manager.
+ * The document specification allows this class to filter what is done based
on the job.
+ * The connector will be connected before this method can be called.
+ *@param documentIdentifiers is the set of document identifiers to process.
+ *@param statuses are the currently-stored document versions for each
document in the set of document identifiers
+ * passed in above.
+ *@param activities is the interface this method should use to queue up new
document references
+ * and ingest documents.
*@param jobMode is an integer describing how the job is being run, whether
continuous or once-only.
*@param usesDefaultAuthority will be true only if the authority in use for
these documents is the default one.
- *@return the corresponding version strings, with null in the places where
the document no longer exists.
- * Empty version strings indicate that there is no versioning ability for the
corresponding document, and the document
- * will always be processed.
*/
@Override
- public String[] getDocumentVersions(String[] documentIdentifiers, String[]
oldVersions, IVersionActivity activity,
- DocumentSpecification spec, int jobMode, boolean usesDefaultAuthority)
+ public void processDocuments(String[] documentIdentifiers, IExistingVersions
statuses, Specification spec,
+ IProcessActivity activities, int jobMode, boolean usesDefaultAuthority)
throws ManifoldCFException, ServiceInterruption
{
- Logging.connectors.debug("FileNet: Inside getDocumentVersions");
-
- String[] acls = getAcls(spec);
-
- String[] rval = new String[documentIdentifiers.length];
+ Logging.connectors.debug("FileNet: Inside processDocuments");
- // Put together a set of the metadata fields, from the document
specification
- int i = 0;
- HashMap docClassSpecs = new HashMap();
- // Also calculate the fields we will need to retrieve from each document,
on a document class basis
- HashMap metadataFields = new HashMap();
- while (i < spec.getChildCount())
- {
- SpecificationNode sn = spec.getChild(i++);
- if (sn.getType().equals(SPEC_NODE_DOCUMENTCLASS))
- {
- String value = sn.getAttributeValue(SPEC_ATTRIBUTE_VALUE);
- DocClassSpec classSpec = new DocClassSpec(sn);
- docClassSpecs.put(value,classSpec);
- if (classSpec.getAllMetadata())
- metadataFields.put(value,new Boolean(true));
- else
- {
- HashMap sumMap = new HashMap();
- int j = 0;
- String[] fields = classSpec.getMetadataFields();
- while (j < fields.length)
- {
- String field = fields[j++];
- sumMap.put(field,field);
- }
- j = 0;
- while (j < classSpec.getMatchCount())
- {
- String field = classSpec.getMatchField(j++);
- sumMap.put(field,field);
- }
- // Convert to an array
- String[] fieldArray = new String[sumMap.size()];
- Iterator iter = sumMap.keySet().iterator();
- j = 0;
- while (iter.hasNext())
- {
- fieldArray[j++] = (String)iter.next();
- }
- metadataFields.put(value,fieldArray);
- }
- }
- }
+ SpecInfo dSpec = new SpecInfo(spec);
+
+ String[] acls = dSpec.getAcls();
- for (i=0; i<documentIdentifiers.length; i++)
+ for (String documentIdentifier : documentIdentifiers)
{
// For each document, be sure to confirm job still active
- activity.checkJobStillActive();
-
- String documentIdentifier = documentIdentifiers[i];
+ activities.checkJobStillActive();
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)
{
@@ -1013,12 +964,13 @@ public class FilenetConnector extends or
long currentTime;
try
{
- FileInfo fileInfo = doGetDocumentInformation(vId, metadataFields);
+ FileInfo fileInfo = doGetDocumentInformation(vId,
dSpec.getMetadataFields());
if (fileInfo == null)
{
if (Logging.connectors.isDebugEnabled())
Logging.connectors.debug("FileNet: Skipping document
'"+documentIdentifier+"' because not a current document");
- rval[i] = null;
+ activities.deleteDocument(documentIdentifier);
+ continue;
}
else
{
@@ -1032,8 +984,8 @@ public class FilenetConnector extends or
// (c) the url prefix to use
StringBuilder versionBuffer = new StringBuilder();
- String docClass = fileInfo.getDocClass();
- DocClassSpec docclassspec =
(DocClassSpec)docClassSpecs.get(docClass);
+ docClass = fileInfo.getDocClass();
+ DocClassSpec docclassspec = dSpec.getDocClassSpec(docClass);
// First, verify that this document matches the match criteria
boolean docMatches = true;
@@ -1063,7 +1015,7 @@ public class FilenetConnector extends or
if (docclassspec.checkMetadataIncluded(field))
metadataCount++;
}
- String[] metadataFieldNames = new String[metadataCount];
+ metadataFieldNames = new String[metadataCount];
int j = 0;
iter = fileInfo.getMetadataIterator();
while (iter.hasNext())
@@ -1076,7 +1028,7 @@ public class FilenetConnector extends or
// Pack field names and values
// For sanity, pack the names first and then the values!
packList(versionBuffer,metadataFieldNames,'+');
- String[] metadataFieldValues = new
String[metadataFieldNames.length];
+ metadataFieldValues = new String[metadataFieldNames.length];
j = 0;
while (j < metadataFieldValues.length)
{
@@ -1089,8 +1041,6 @@ public class FilenetConnector extends or
// Acl info
// Future work will add "forced acls", so use a single character
as a signal as to whether security is on or off.
- String[] aclValues = null;
- String[] denyAclValues = null;
if (acls != null && acls.length == 0)
{
// Security is on, so use the acls that came back from filenet
@@ -1134,13 +1084,14 @@ public class FilenetConnector extends or
// Document URI
pack(versionBuffer,docURIPrefix,'+');
- rval[i] = versionBuffer.toString();
+ versionString = versionBuffer.toString();
}
else
{
if (Logging.connectors.isDebugEnabled())
Logging.connectors.debug("FileNet: Skipping document
'"+documentIdentifier+"' because doesn't match field criteria");
- rval[i] = null;
+ activities.deleteDocument(documentIdentifier);
+ continue;
}
}
}
@@ -1154,8 +1105,8 @@ public class FilenetConnector extends or
{
if (Logging.connectors.isDebugEnabled())
Logging.connectors.debug("FileNet: Skipping file
'"+documentIdentifier+"' because: "+e.getMessage(),e);
- rval[i] = null;
-
+ activities.deleteDocument(documentIdentifier);
+ continue;
}
else
throw new ManifoldCFException(e.getMessage(),e);
@@ -1166,73 +1117,25 @@ public class FilenetConnector extends or
// This is a naked version identifier.
// On every crawl, we need to convert this identifier to the
individual identifiers for each bit of content.
// There is no versioning available for this process.
- rval[i] = "";
+ versionString = "";
}
- }
- return rval;
- }
-
- /** Emulate the query matching for filenet sql expressions. */
- protected static boolean performMatch(String matchType, String
matchDocValue, String matchValue)
- {
- if (matchType.equals("="))
- return matchDocValue.equalsIgnoreCase(matchValue);
- else if (matchType.equals("!="))
- return !matchDocValue.equalsIgnoreCase(matchValue);
-
- // Do a LIKE comparison
- return likeMatch(matchDocValue,0,matchValue,0);
- }
-
- /** Match a portion of a string with SQL wildcards (%) */
- protected static boolean likeMatch(String matchDocValue, int matchDocPos,
String matchValue, int matchPos)
- {
- if (matchPos == matchValue.length())
- {
- return matchDocPos == matchDocValue.length();
- }
- if (matchDocPos == matchDocValue.length())
- {
- return matchValue.charAt(matchPos) == '%' &&
likeMatch(matchDocValue,matchDocPos,matchValue,matchPos+1);
- }
- char x = matchDocValue.charAt(matchDocPos);
- char y = matchValue.charAt(matchPos);
- if (y != '%')
- return Character.toLowerCase(x) == Character.toLowerCase(y) &&
likeMatch(matchDocValue,matchDocPos+1,matchValue,matchPos+1);
-
- return likeMatch(matchDocValue,matchDocPos+1,matchValue,matchPos) ||
- likeMatch(matchDocValue,matchDocPos,matchValue,matchPos+1);
- }
-
- /** Process documents whose versions indicate they need processing.
- */
- public void processDocuments(String[] documentIdentifiers, String[]
documentVersions,
- IProcessActivity activities, DocumentSpecification spec, boolean[]
scanOnly)
- throws ManifoldCFException, ServiceInterruption
- {
- Logging.connectors.debug("FileNet: Inside processDocuments");
-
- int i = 0;
- while (i < documentIdentifiers.length)
- {
- // For each document, be sure to confirm job still active
- activities.checkJobStillActive();
-
- String documentIdentifier = documentIdentifiers[i];
- String documentVersion = documentVersions[i];
+
+ if (versionString.length() == 0 ||
activities.checkDocumentNeedsReindexing(documentIdentifier,versionString))
+ {
+ // For each document, be sure to confirm job still active
+ activities.checkJobStillActive();
- if (Logging.connectors.isDebugEnabled())
- Logging.connectors.debug("FileNet: Processing document identifier
'"+documentIdentifier+"'");
+ String documentVersion = versionString;
- // Calculate the version id and the element number
- int cIndex = documentIdentifier.indexOf(",");
- if (cIndex != -1)
- {
if (Logging.connectors.isDebugEnabled())
- Logging.connectors.debug("FileNet: Document identifier
'"+documentIdentifier+"' is a document attachment");
+ Logging.connectors.debug("FileNet: Processing document identifier
'"+documentIdentifier+"'");
- if (!scanOnly[i])
+ // Calculate the version id and the element number
+ if (cIndex != -1)
{
+ if (Logging.connectors.isDebugEnabled())
+ Logging.connectors.debug("FileNet: Document identifier
'"+documentIdentifier+"' is a document attachment");
+
String vId = documentIdentifier.substring(0,cIndex);
int elementNumber;
try
@@ -1244,30 +1147,6 @@ public class FilenetConnector extends or
throw new ManifoldCFException("Bad number in identifier:
"+documentIdentifier,e);
}
- // Unpack the information in the document version
- ArrayList metadataNames = new ArrayList();
- ArrayList metadataValues = new ArrayList();
- ArrayList aclValues = null;
- ArrayList denyAclValues = null;
- StringBuilder documentClass = new StringBuilder();
- StringBuilder urlBase = new StringBuilder();
- int position = 0;
- position = unpackList(metadataNames, documentVersion, position, '+');
- position = unpackList(metadataValues, documentVersion, position,
'+');
- //Logging.connectors.debug("Names length =
"+Integer.toString(metadataNames.size()));
- //Logging.connectors.debug("Values length =
"+Integer.toString(metadataValues.size()));
- if (documentVersion.length() > position &&
documentVersion.charAt(position++) == '+')
- {
- //Logging.connectors.debug("Acls found at position
"+Integer.toString(position));
- aclValues = new ArrayList();
- position = unpackList(aclValues, documentVersion, position, '+');
- denyAclValues = new ArrayList();
- position = unpackList(denyAclValues, documentVersion, position,
'+');
- //Logging.connectors.debug("ACLs length =
"+Integer.toString(aclValues.size()));
- }
- position = unpack(documentClass, documentVersion, position, '+');
- position = unpack(urlBase, documentVersion, position, '+');
-
//Logging.connectors.debug("Url base from version string =
"+urlBase.toString());
try
{
@@ -1298,7 +1177,6 @@ public class FilenetConnector extends or
if (Logging.connectors.isDebugEnabled())
Logging.connectors.debug("FileNet: Removing file
'"+documentIdentifier+"' because: "+e.getMessage(),e);
activities.noDocument(documentIdentifier,documentVersion);
- i++;
continue;
}
else
@@ -1325,42 +1203,26 @@ public class FilenetConnector extends or
rd.setBinary(is, fileLength);
// Apply metadata
- int j = 0;
- while (j < metadataNames.size())
+ for (int j = 0; j < metadataFieldNames.length; j++)
{
- String metadataName = (String)metadataNames.get(j);
- String metadataValue = (String)metadataValues.get(j);
+ String metadataName = metadataFieldNames[j];
+ String metadataValue = metadataFieldValues[j];
rd.addField(metadataName,metadataValue);
- j++;
}
// Apply acls
if (aclValues != null)
{
- String[] acls = new String[aclValues.size()];
- j = 0;
- while (j < aclValues.size())
- {
- acls[j] = (String)aclValues.get(j);
- j++;
- }
-
rd.setSecurityACL(RepositoryDocument.SECURITY_TYPE_DOCUMENT,acls);
+
rd.setSecurityACL(RepositoryDocument.SECURITY_TYPE_DOCUMENT,aclValues);
}
if (denyAclValues != null)
{
- String[] denyAcls = new String[denyAclValues.size()];
- j = 0;
- while (j < denyAclValues.size())
- {
- denyAcls[j] = (String)denyAclValues.get(j);
- j++;
- }
-
rd.setSecurityDenyACL(RepositoryDocument.SECURITY_TYPE_DOCUMENT,denyAcls);
+
rd.setSecurityDenyACL(RepositoryDocument.SECURITY_TYPE_DOCUMENT,denyAclValues);
}
// Ingest
activities.ingestDocumentWithException(documentIdentifier,documentVersion,
-
convertToURI(urlBase.toString(),vId,elementNumber,documentClass.toString()),rd);
+ convertToURI(docURIPrefix,vId,elementNumber,docClass),rd);
}
finally
@@ -1398,6 +1260,7 @@ public class FilenetConnector extends or
throw new ManifoldCFException("IO Exception ingesting document
'"+documentIdentifier+"': "+e.getMessage(),e);
}
}
+
}
else
{
@@ -1414,8 +1277,7 @@ public class FilenetConnector extends or
if (Logging.connectors.isDebugEnabled())
Logging.connectors.debug("FileNet: Removing version
'"+documentIdentifier+"' because it seems to no longer exist");
- activities.noDocument(documentIdentifier,documentVersion);
- i++;
+ activities.noDocument(documentIdentifier,versionString);
continue;
}
@@ -1444,8 +1306,7 @@ public class FilenetConnector extends or
{
if (Logging.connectors.isDebugEnabled())
Logging.connectors.debug("FileNet: Removing version
'"+documentIdentifier+"' because: "+e.getMessage(),e);
- activities.noDocument(documentIdentifier,documentVersion);
- i++;
+ activities.noDocument(documentIdentifier,versionString);
continue;
}
else
@@ -1454,23 +1315,40 @@ public class FilenetConnector extends or
}
}
}
- i++;
+
}
+ }
+
+ /** Emulate the query matching for filenet sql expressions. */
+ protected static boolean performMatch(String matchType, String
matchDocValue, String matchValue)
+ {
+ if (matchType.equals("="))
+ return matchDocValue.equalsIgnoreCase(matchValue);
+ else if (matchType.equals("!="))
+ return !matchDocValue.equalsIgnoreCase(matchValue);
+ // Do a LIKE comparison
+ return likeMatch(matchDocValue,0,matchValue,0);
}
- /** Free a set of documents. This method is called for all documents whose
versions have been fetched using
- * the getDocumentVersions() method, including those that returned null
versions. It may be used to free resources
- * committed during the getDocumentVersions() method. It is guaranteed to be
called AFTER any calls to
- * processDocuments() for the documents in question.
- *@param documentIdentifiers is the set of document identifiers.
- *@param versions is the corresponding set of version identifiers (individual
identifiers may be null).
- */
- @Override
- public void releaseDocumentVersions(String[] documentIdentifiers, String[]
versions)
- throws ManifoldCFException
+ /** Match a portion of a string with SQL wildcards (%) */
+ protected static boolean likeMatch(String matchDocValue, int matchDocPos,
String matchValue, int matchPos)
{
- // Nothing to do
+ if (matchPos == matchValue.length())
+ {
+ return matchDocPos == matchDocValue.length();
+ }
+ if (matchDocPos == matchDocValue.length())
+ {
+ return matchValue.charAt(matchPos) == '%' &&
likeMatch(matchDocValue,matchDocPos,matchValue,matchPos+1);
+ }
+ char x = matchDocValue.charAt(matchDocPos);
+ char y = matchValue.charAt(matchPos);
+ if (y != '%')
+ return Character.toLowerCase(x) == Character.toLowerCase(y) &&
likeMatch(matchDocValue,matchDocPos+1,matchValue,matchPos+1);
+
+ return likeMatch(matchDocValue,matchDocPos+1,matchValue,matchPos) ||
+ likeMatch(matchDocValue,matchDocPos,matchValue,matchPos+1);
}
@Override
@@ -3310,11 +3188,25 @@ public class FilenetConnector extends or
}
}
- public Throwable getException()
+ public void finishUp()
+ throws RemoteException, FilenetException, InterruptedException
{
- return exception;
+ join();
+ Throwable thr = exception;
+ if (thr != null)
+ {
+ if (thr instanceof RemoteException)
+ throw (RemoteException)thr;
+ else if (thr instanceof FilenetException)
+ throw (FilenetException)thr;
+ else if (thr instanceof RuntimeException)
+ throw (RuntimeException)thr;
+ else if (thr instanceof Error)
+ throw (Error)thr;
+ else
+ throw new RuntimeException("Unexpected exception type:
"+thr.getClass().getName()+": "+thr.getMessage(),thr);
+ }
}
-
}
/** Check connection, with appropriate retries */
@@ -3327,22 +3219,10 @@ public class FilenetConnector extends or
getSession();
long currentTime;
CheckConnectionThread t = new CheckConnectionThread();
+ t.start();
try
{
- t.start();
- t.join();
- Throwable thr = t.getException();
- if (thr != null)
- {
- if (thr instanceof RemoteException)
- throw (RemoteException)thr;
- else if (thr instanceof FilenetException)
- throw (FilenetException)thr;
- else if (thr instanceof RuntimeException)
- throw (RuntimeException)thr;
- else
- throw (Error)thr;
- }
+ t.finishUp();
return;
}
catch (InterruptedException e)
@@ -3390,13 +3270,24 @@ public class FilenetConnector extends or
}
}
- public Throwable getException()
- {
- return exception;
- }
-
- public DocumentClassDefinition[] getResponse()
+ public DocumentClassDefinition[] finishUp()
+ throws RemoteException, FilenetException, InterruptedException
{
+ join();
+ Throwable thr = exception;
+ if (thr != null)
+ {
+ if (thr instanceof RemoteException)
+ throw (RemoteException)thr;
+ else if (thr instanceof FilenetException)
+ throw (FilenetException)thr;
+ else if (thr instanceof RuntimeException)
+ throw (RuntimeException)thr;
+ else if (thr instanceof Error)
+ throw (Error)thr;
+ else
+ throw new RuntimeException("Unexpected exception type:
"+thr.getClass().getName()+": "+thr.getMessage(),thr);
+ }
return rval;
}
}
@@ -3411,23 +3302,10 @@ public class FilenetConnector extends or
getSession();
long currentTime;
GetDocumentClassesInfoThread t = new GetDocumentClassesInfoThread();
+ t.start();
try
{
- t.start();
- t.join();
- Throwable thr = t.getException();
- if (thr != null)
- {
- if (thr instanceof RemoteException)
- throw (RemoteException)thr;
- else if (thr instanceof FilenetException)
- throw (FilenetException)thr;
- else if (thr instanceof RuntimeException)
- throw (RuntimeException)thr;
- else
- throw (Error)thr;
- }
- return t.getResponse();
+ return t.finishUp();
}
catch (InterruptedException e)
{
@@ -3476,13 +3354,24 @@ public class FilenetConnector extends or
}
}
- public Throwable getException()
- {
- return exception;
- }
-
- public MetadataFieldDefinition[] getResponse()
+ public MetadataFieldDefinition[] finishUp()
+ throws RemoteException, FilenetException, InterruptedException
{
+ join();
+ Throwable thr = exception;
+ if (thr != null)
+ {
+ if (thr instanceof RemoteException)
+ throw (RemoteException)thr;
+ else if (thr instanceof FilenetException)
+ throw (FilenetException)thr;
+ else if (thr instanceof RuntimeException)
+ throw (RuntimeException)thr;
+ else if (thr instanceof Error)
+ throw (Error)thr;
+ else
+ throw new RuntimeException("Unexpected exception type:
"+thr.getClass().getName()+": "+thr.getMessage(),thr);
+ }
return rval;
}
}
@@ -3497,23 +3386,10 @@ public class FilenetConnector extends or
getSession();
long currentTime;
GetDocumentClassesMetadataFieldsInfoThread t = new
GetDocumentClassesMetadataFieldsInfoThread(documentClassName);
+ t.start();
try
{
- t.start();
- t.join();
- Throwable thr = t.getException();
- if (thr != null)
- {
- if (thr instanceof RemoteException)
- throw (RemoteException)thr;
- else if (thr instanceof FilenetException)
- throw (FilenetException)thr;
- else if (thr instanceof RuntimeException)
- throw (RuntimeException)thr;
- else
- throw (Error)thr;
- }
- return t.getResponse();
+ return t.finishUp();
}
catch (InterruptedException e)
{
@@ -3539,7 +3415,7 @@ public class FilenetConnector extends or
protected class GetChildFoldersThread extends Thread
{
- protected String[] folderPath;
+ protected final String[] folderPath;
protected String[] rval = null;
protected Throwable exception = null;
@@ -3562,16 +3438,27 @@ public class FilenetConnector extends or
}
}
- public String[] getResponse()
+ public String[] finishUp()
+ throws RemoteException, FilenetException, InterruptedException
{
+ join();
+ Throwable thr = exception;
+ if (thr != null)
+ {
+ if (thr instanceof RemoteException)
+ throw (RemoteException)thr;
+ else if (thr instanceof FilenetException)
+ throw (FilenetException)thr;
+ else if (thr instanceof RuntimeException)
+ throw (RuntimeException)thr;
+ else if (thr instanceof Error)
+ throw (Error)thr;
+ else
+ throw new RuntimeException("Unexpected exception type:
"+thr.getClass().getName()+": "+thr.getMessage(),thr);
+ }
return rval;
}
- public Throwable getException()
- {
- return exception;
- }
-
}
@@ -3585,23 +3472,10 @@ public class FilenetConnector extends or
getSession();
long currentTime;
GetChildFoldersThread t = new GetChildFoldersThread(folderPath);
+ t.start();
try
{
- t.start();
- t.join();
- Throwable thr = t.getException();
- if (thr != null)
- {
- if (thr instanceof RemoteException)
- throw (RemoteException)thr;
- else if (thr instanceof FilenetException)
- throw (FilenetException)thr;
- else if (thr instanceof RuntimeException)
- throw (RuntimeException)thr;
- else
- throw (Error)thr;
- }
- return t.getResponse();
+ return t.finishUp();
}
catch (InterruptedException e)
{
@@ -3650,16 +3524,26 @@ public class FilenetConnector extends or
}
}
- public String[] getResponse()
+ public String[] finishUp()
+ throws RemoteException, FilenetException, InterruptedException
{
+ join();
+ Throwable thr = exception;
+ if (thr != null)
+ {
+ if (thr instanceof RemoteException)
+ throw (RemoteException)thr;
+ else if (thr instanceof FilenetException)
+ throw (FilenetException)thr;
+ else if (thr instanceof RuntimeException)
+ throw (RuntimeException)thr;
+ else if (thr instanceof Error)
+ throw (Error)thr;
+ else
+ throw new RuntimeException("Unexpected exception type:
"+thr.getClass().getName()+": "+thr.getMessage(),thr);
+ }
return rval;
}
-
- public Throwable getException()
- {
- return exception;
- }
-
}
/** Get matching object id's for a given query */
@@ -3672,23 +3556,10 @@ public class FilenetConnector extends or
getSession();
long currentTime;
GetMatchingObjectIdsThread t = new GetMatchingObjectIdsThread(sql);
+ t.start();
try
{
- t.start();
- t.join();
- Throwable thr = t.getException();
- if (thr != null)
- {
- if (thr instanceof RemoteException)
- throw (RemoteException)thr;
- else if (thr instanceof FilenetException)
- throw (FilenetException)thr;
- else if (thr instanceof RuntimeException)
- throw (RuntimeException)thr;
- else
- throw (Error)thr;
- }
- return t.getResponse();
+ return t.finishUp();
}
catch (InterruptedException e)
{
@@ -3737,16 +3608,27 @@ public class FilenetConnector extends or
}
}
- public Integer getResponse()
+ public Integer finishUp()
+ throws RemoteException, FilenetException, InterruptedException
{
+ join();
+ Throwable thr = exception;
+ if (thr != null)
+ {
+ if (thr instanceof RemoteException)
+ throw (RemoteException)thr;
+ else if (thr instanceof FilenetException)
+ throw (FilenetException)thr;
+ else if (thr instanceof RuntimeException)
+ throw (RuntimeException)thr;
+ else if (thr instanceof Error)
+ throw (Error)thr;
+ else
+ throw new RuntimeException("Unexpected exception type:
"+thr.getClass().getName()+": "+thr.getMessage(),thr);
+ }
return rval;
}
- public Throwable getException()
- {
- return exception;
- }
-
}
protected Integer doGetDocumentContentCount(String documentIdentifier)
@@ -3758,23 +3640,10 @@ public class FilenetConnector extends or
getSession();
long currentTime;
GetDocumentContentCountThread t = new
GetDocumentContentCountThread(documentIdentifier);
+ t.start();
try
{
- t.start();
- t.join();
- Throwable thr = t.getException();
- if (thr != null)
- {
- if (thr instanceof RemoteException)
- throw (RemoteException)thr;
- else if (thr instanceof FilenetException)
- throw (FilenetException)thr;
- else if (thr instanceof RuntimeException)
- throw (RuntimeException)thr;
- else
- throw (Error)thr;
- }
- return t.getResponse();
+ return t.finishUp();
}
catch (InterruptedException e)
{
@@ -3801,12 +3670,12 @@ public class FilenetConnector extends or
protected class GetDocumentInformationThread extends Thread
{
- protected String docId;
- protected HashMap metadataFields;
+ protected final String docId;
+ protected final Map<String,Object> metadataFields;
protected FileInfo rval = null;
protected Throwable exception = null;
- public GetDocumentInformationThread(String docId, HashMap metadataFields)
+ public GetDocumentInformationThread(String docId, Map<String,Object>
metadataFields)
{
super();
setDaemon(true);
@@ -3826,20 +3695,31 @@ public class FilenetConnector extends or
}
}
- public FileInfo getResponse()
+ public FileInfo finishUp()
+ throws RemoteException, FilenetException, InterruptedException
{
+ join();
+ Throwable thr = exception;
+ if (thr != null)
+ {
+ if (thr instanceof RemoteException)
+ throw (RemoteException)thr;
+ else if (thr instanceof FilenetException)
+ throw (FilenetException)thr;
+ else if (thr instanceof RuntimeException)
+ throw (RuntimeException)thr;
+ else if (thr instanceof Error)
+ throw (Error)thr;
+ else
+ throw new RuntimeException("Unexpected exception type:
"+thr.getClass().getName()+": "+thr.getMessage(),thr);
+ }
return rval;
}
- public Throwable getException()
- {
- return exception;
- }
-
}
/** Get document info */
- protected FileInfo doGetDocumentInformation(String docId, HashMap
metadataFields)
+ protected FileInfo doGetDocumentInformation(String docId, Map<String,Object>
metadataFields)
throws FilenetException, ManifoldCFException, ServiceInterruption
{
while (true)
@@ -3848,23 +3728,10 @@ public class FilenetConnector extends or
getSession();
long currentTime;
GetDocumentInformationThread t = new
GetDocumentInformationThread(docId,metadataFields);
+ t.start();
try
{
- t.start();
- t.join();
- Throwable thr = t.getException();
- if (thr != null)
- {
- if (thr instanceof RemoteException)
- throw (RemoteException)thr;
- else if (thr instanceof FilenetException)
- throw (FilenetException)thr;
- else if (thr instanceof RuntimeException)
- throw (RuntimeException)thr;
- else
- throw (Error)thr;
- }
- return t.getResponse();
+ return t.finishUp();
}
catch (InterruptedException e)
{
@@ -3890,9 +3757,10 @@ public class FilenetConnector extends or
protected class GetDocumentContentsThread extends Thread
{
- protected String docId;
- protected int elementNumber;
- protected String tempFileName;
+ protected final String docId;
+ protected final int elementNumber;
+ protected final String tempFileName;
+
protected Throwable exception = null;
public GetDocumentContentsThread(String docId, int elementNumber, String
tempFileName)
@@ -3916,11 +3784,25 @@ public class FilenetConnector extends or
}
}
- public Throwable getException()
+ public void finishUp()
+ throws RemoteException, FilenetException, InterruptedException
{
- return exception;
+ join();
+ Throwable thr = exception;
+ if (thr != null)
+ {
+ if (thr instanceof RemoteException)
+ throw (RemoteException)thr;
+ else if (thr instanceof FilenetException)
+ throw (FilenetException)thr;
+ else if (thr instanceof RuntimeException)
+ throw (RuntimeException)thr;
+ else if (thr instanceof Error)
+ throw (Error)thr;
+ else
+ throw new RuntimeException("Unexpected exception type:
"+thr.getClass().getName()+": "+thr.getMessage(),thr);
+ }
}
-
}
/** Get document contents */
@@ -3933,22 +3815,10 @@ public class FilenetConnector extends or
getSession();
long currentTime;
GetDocumentContentsThread t = new
GetDocumentContentsThread(docId,elementNumber,tempFileName);
+ t.start();
try
{
- t.start();
- t.join();
- Throwable thr = t.getException();
- if (thr != null)
- {
- if (thr instanceof RemoteException)
- throw (RemoteException)thr;
- else if (thr instanceof FilenetException)
- throw (FilenetException)thr;
- else if (thr instanceof RuntimeException)
- throw (RuntimeException)thr;
- else
- throw (Error)thr;
- }
+ t.finishUp();
return;
}
catch (InterruptedException e)
@@ -3975,45 +3845,96 @@ public class FilenetConnector extends or
}
- // Utility methods
+ // Utility classes/methods
- /** Grab forced acl out of document specification.
- *@param spec is the document specification.
- *@return the acls.
- */
- protected static String[] getAcls(DocumentSpecification spec)
+ protected static class SpecInfo
{
- HashMap map = new HashMap();
- int i = 0;
- boolean securityOn = true;
- while (i < spec.getChildCount())
+ protected final Set<String> aclMap = new HashSet<String>();
+ protected final boolean securityOn;
+ protected final Map<String,DocClassSpec> docClassSpecs = new
HashMap<String,DocClassSpec>();
+ protected final Map<String,Object> metadataFields = new
HashMap<String,Object>();
+
+ public SpecInfo(Specification spec)
{
- SpecificationNode sn = spec.getChild(i++);
- if (sn.getType().equals("access"))
+ boolean securityOn = true;
+ for (int i = 0; i < spec.getChildCount(); i++)
{
- String token = sn.getAttributeValue("token");
- map.put(token,token);
+ SpecificationNode sn = spec.getChild(i);
+ if (sn.getType().equals("access"))
+ {
+ String token = sn.getAttributeValue("token");
+ aclMap.add(token);
+ }
+ else if (sn.getType().equals("security"))
+ {
+ String value = sn.getAttributeValue("value");
+ if (value.equals("on"))
+ securityOn = true;
+ else if (value.equals("off"))
+ securityOn = false;
+ }
+ else if (sn.getType().equals(SPEC_NODE_DOCUMENTCLASS))
+ {
+ String value = sn.getAttributeValue(SPEC_ATTRIBUTE_VALUE);
+ DocClassSpec classSpec = new DocClassSpec(sn);
+ docClassSpecs.put(value,classSpec);
+ if (classSpec.getAllMetadata())
+ metadataFields.put(value,new Boolean(true));
+ else
+ {
+ Set<String> sumMap = new HashSet<String>();
+ int j = 0;
+ String[] fields = classSpec.getMetadataFields();
+ for (String field : fields)
+ {
+ sumMap.add(field);
+ }
+ for (j = 0; j < classSpec.getMatchCount(); j++)
+ {
+ sumMap.add(classSpec.getMatchField(j));
+ }
+ // Convert to an array
+ String[] fieldArray = new String[sumMap.size()];
+ j = 0;
+ for (String field : sumMap)
+ {
+ fieldArray[j++] = field;
+ }
+ metadataFields.put(value,fieldArray);
+ }
+ }
+
}
- else if (sn.getType().equals("security"))
+
+ this.securityOn = securityOn;
+
+ }
+
+ public String[] getAcls()
+ {
+ if (!securityOn)
+ return null;
+
+ String[] rval = new String[aclMap.size()];
+ int i = 0;
+ for (String acl : aclMap)
{
- String value = sn.getAttributeValue("value");
- if (value.equals("on"))
- securityOn = true;
- else if (value.equals("off"))
- securityOn = false;
+ rval[i++] = acl;
}
+ return rval;
+ }
+
+ public DocClassSpec getDocClassSpec(String docClass)
+ {
+ return docClassSpecs.get(docClass);
}
- if (!securityOn)
- return null;
- String[] rval = new String[map.size()];
- Iterator iter = map.keySet().iterator();
- i = 0;
- while (iter.hasNext())
+ public Map<String,Object> getMetadataFields()
{
- rval[i++] = (String)iter.next();
+ return metadataFields;
}
- return rval;
- }
+
+ }
+
}
Modified:
manifoldcf/trunk/connectors/filenet/implementation/src/main/java/org/apache/manifoldcf/crawler/common/filenet/FilenetImpl.java
URL:
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/filenet/implementation/src/main/java/org/apache/manifoldcf/crawler/common/filenet/FilenetImpl.java?rev=1624058&r1=1624057&r2=1624058&view=diff
==============================================================================
---
manifoldcf/trunk/connectors/filenet/implementation/src/main/java/org/apache/manifoldcf/crawler/common/filenet/FilenetImpl.java
(original)
+++
manifoldcf/trunk/connectors/filenet/implementation/src/main/java/org/apache/manifoldcf/crawler/common/filenet/FilenetImpl.java
Wed Sep 10 16:50:04 2014
@@ -349,7 +349,7 @@ public class FilenetImpl extends Unicast
/** Get document information for a given filenet document. Will return null
if the version id is not a current document version id.
* The metadataFields hashmap is keyed by document class, and contains as a
value either Boolean(true) (meaning "all"), or a String[] that has the
* list of fields desired. */
- public FileInfo getDocumentInformation(String docId, HashMap metadataFields)
+ public FileInfo getDocumentInformation(String docId, Map<String,Object>
metadataFields)
throws FilenetException, RemoteException
{
//System.out.println("Looking for document information on "+docId);
Modified:
manifoldcf/trunk/connectors/filenet/interface/src/main/java/org/apache/manifoldcf/crawler/common/filenet/IFilenet.java
URL:
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/filenet/interface/src/main/java/org/apache/manifoldcf/crawler/common/filenet/IFilenet.java?rev=1624058&r1=1624057&r2=1624058&view=diff
==============================================================================
---
manifoldcf/trunk/connectors/filenet/interface/src/main/java/org/apache/manifoldcf/crawler/common/filenet/IFilenet.java
(original)
+++
manifoldcf/trunk/connectors/filenet/interface/src/main/java/org/apache/manifoldcf/crawler/common/filenet/IFilenet.java
Wed Sep 10 16:50:04 2014
@@ -79,7 +79,7 @@ public interface IFilenet extends Remote
/** Get document information for a given filenet document. Will return null
if the version id is not a current document version id.
* The metadataFields hashmap is keyed by document class, and contains as a
value either null (meaning "all"), or a String[] that has the
* list of fields desired. */
- public FileInfo getDocumentInformation(String docId, HashMap metadataFields)
+ public FileInfo getDocumentInformation(String docId, Map<String,Object>
metadataFields)
throws FilenetException, RemoteException;
/** Get document contents */