Author: piergiorgio
Date: Thu Jun 29 15:35:03 2017
New Revision: 1800294
URL: http://svn.apache.org/viewvc?rev=1800294&view=rev
Log:
- added exception management for cmis:name conflicts (CONNECTORS-1356)
- improved integration tests: need more investigation due to infinite loop
Modified:
manifoldcf/branches/CONNECTORS-1356-2.7.1/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/agents/output/cmisoutput/CmisOutputConnector.java
manifoldcf/branches/CONNECTORS-1356-2.7.1/connectors/cmis/connector/src/test/java/org/apache/manifoldcf/agents/output/cmisoutput/tests/APISanityHSQLDBIT.java
manifoldcf/branches/CONNECTORS-1356-2.7.1/connectors/cmis/connector/src/test/java/org/apache/manifoldcf/agents/output/cmisoutput/tests/BaseITHSQLDB.java
Modified:
manifoldcf/branches/CONNECTORS-1356-2.7.1/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/agents/output/cmisoutput/CmisOutputConnector.java
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1356-2.7.1/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/agents/output/cmisoutput/CmisOutputConnector.java?rev=1800294&r1=1800293&r2=1800294&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-1356-2.7.1/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/agents/output/cmisoutput/CmisOutputConnector.java
(original)
+++
manifoldcf/branches/CONNECTORS-1356-2.7.1/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/agents/output/cmisoutput/CmisOutputConnector.java
Thu Jun 29 15:35:03 2017
@@ -49,6 +49,7 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
import
org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException;
import
org.apache.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException;
+import
org.apache.chemistry.opencmis.commons.exceptions.CmisNameConstraintViolationException;
import
org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import
org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import
org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl;
@@ -921,7 +922,7 @@ public class CmisOutputConnector extends
// create a major version
leafParent =
getOrCreateLeafParent(parentDropZoneFolder, creationDate,
Boolean.valueOf(createTimestampTree));
- injectedDocument =
leafParent.createDocument(properties, contentStream, VersioningState.MAJOR);
+ injectedDocument =
leafParent.createDocument(properties, contentStream, VersioningState.NONE);
resultDescription =
DOCUMENT_STATUS_ACCEPTED_DESC;
return DOCUMENT_STATUS_ACCEPTED;
@@ -930,7 +931,7 @@ public class CmisOutputConnector extends
return DOCUMENT_STATUS_REJECTED;
}
- } catch (CmisContentAlreadyExistsException e) {
+ } catch (CmisContentAlreadyExistsException |
CmisNameConstraintViolationException e) {
String documentFullPath = leafParent.getPath() +
CmisOutputConnectorUtils.SLASH + fileName;
injectedDocument = (Document)
session.getObjectByPath(documentFullPath);
@@ -940,7 +941,7 @@ public class CmisOutputConnector extends
}
Logging.connectors.warn(
- "CMIS: Document already exists: " +
documentFullPath+ CmisOutputConnectorUtils.SEP + e.getMessage(), e);
+ "CMIS: Document already exists: " +
documentFullPath + CmisOutputConnectorUtils.SEP + e.getMessage(), e);
resultDescription = DOCUMENT_STATUS_ACCEPTED_DESC;
return DOCUMENT_STATUS_ACCEPTED;
@@ -1037,4 +1038,6 @@ public class CmisOutputConnector extends
}
}
+
+
}
\ No newline at end of file
Modified:
manifoldcf/branches/CONNECTORS-1356-2.7.1/connectors/cmis/connector/src/test/java/org/apache/manifoldcf/agents/output/cmisoutput/tests/APISanityHSQLDBIT.java
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1356-2.7.1/connectors/cmis/connector/src/test/java/org/apache/manifoldcf/agents/output/cmisoutput/tests/APISanityHSQLDBIT.java?rev=1800294&r1=1800293&r2=1800294&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-1356-2.7.1/connectors/cmis/connector/src/test/java/org/apache/manifoldcf/agents/output/cmisoutput/tests/APISanityHSQLDBIT.java
(original)
+++
manifoldcf/branches/CONNECTORS-1356-2.7.1/connectors/cmis/connector/src/test/java/org/apache/manifoldcf/agents/output/cmisoutput/tests/APISanityHSQLDBIT.java
Thu Jun 29 15:35:03 2017
@@ -57,7 +57,8 @@ public class APISanityHSQLDBIT extends B
private static final String REPLACER = "?";
private static final String CMIS_TEST_QUERY_CHANGE_DOC = "SELECT * FROM
cmis:document WHERE cmis:name='"+REPLACER+"'";
-
+ private static final String CMIS_TEST_QUERY_TARGET_REPO_ALL = "SELECT *
FROM cmis:document WHERE CONTAINS('testdata')";
+
private Session cmisSourceClientSession = null;
private Session cmisTargetClientSession = null;
@@ -107,7 +108,7 @@ public class APISanityHSQLDBIT extends B
return factory.getRepositories(parameters).get(0).createSession();
}
- public Folder getTestFolder(Session session){
+ private Folder getTestFolder(Session session) {
Folder testFolder = null;
ItemIterable<QueryResult> results =
session.query(CmisOutputConfig.CMIS_QUERY_DEFAULT_VALUE, false);
for (QueryResult result : results) {
@@ -117,7 +118,13 @@ public class APISanityHSQLDBIT extends B
return testFolder;
}
- public void createNewDocument(Folder folder, String name) throws IOException{
+ private long queryTestContents(Session session) {
+ ItemIterable<QueryResult> results =
session.query(CMIS_TEST_QUERY_TARGET_REPO_ALL, false);
+ return results.getTotalNumItems();
+ }
+
+
+ private void createNewDocument(Folder folder, String name) throws
IOException{
// properties
// (minimal set: name and object type id)
Map<String, Object> contentProperties = new HashMap<String, Object>();
@@ -439,15 +446,22 @@ public class APISanityHSQLDBIT extends B
// Now, start the job, and wait until it completes.
startJob(jobIDString);
- waitJobInactive(jobIDString, 120000L);
+ waitJobInactive(jobIDString, 240000L);
// Check to be sure we actually processed the right number of documents.
// The test data area has 3 documents and one directory, and we have to
count the root directory too.
long count;
count = getJobDocumentsProcessed(jobIDString);
+
if (count != 3)
throw new ManifoldCFException("Wrong number of documents processed -
expected 3, saw "+new Long(count).toString());
+ //Tests if these two contents are stored in the target repo
+ long targetRepoNumberOfContents =
queryTestContents(cmisTargetClientSession);
+ if(targetRepoNumberOfContents != 2)
+ throw new ManifoldCFException("Wrong number of documents stored in the
CMIS Target repo - expected 2, saw "+new
Long(targetRepoNumberOfContents).toString());
+
+
// Add a file and recrawl
Folder testFolder = getTestFolder(cmisSourceClientSession);
createNewDocument(testFolder, "testdata3.txt");
@@ -455,25 +469,36 @@ public class APISanityHSQLDBIT extends B
// Now, start the job, and wait until it completes.
startJob(jobIDString);
- waitJobInactive(jobIDString, 120000L);
+ waitJobInactive(jobIDString, 240000L);
// The test data area has 4 documents and one directory, and we have to
count the root directory too.
count = getJobDocumentsProcessed(jobIDString);
if (count != 5)
throw new ManifoldCFException("Wrong number of documents processed
after add - expected 5, saw "+new Long(count).toString());
+ //Tests if there are 4 documents in the target repo
+ targetRepoNumberOfContents = queryTestContents(cmisTargetClientSession);
+ if(targetRepoNumberOfContents != 4)
+ throw new ManifoldCFException("Wrong number of documents stored in the
CMIS Target repo - expected 4, saw "+new
Long(targetRepoNumberOfContents).toString());
+
+
// Change a document, and recrawl
changeDocument(cmisSourceClientSession,"testdata1.txt","MODIFIED - CMIS
Testdata - MODIFIED");
// Now, start the job, and wait until it completes.
startJob(jobIDString);
- waitJobInactive(jobIDString, 120000L);
+ waitJobInactive(jobIDString, 240000L);
// The test data area has 4 documents and one directory, and we have to
count the root directory too.
count = getJobDocumentsProcessed(jobIDString);
if (count != 5)
throw new ManifoldCFException("Wrong number of documents processed
after change - expected 5, saw "+new Long(count).toString());
+ //Tests if there are 4 documents in the target repo
+ targetRepoNumberOfContents = queryTestContents(cmisTargetClientSession);
+ if(targetRepoNumberOfContents != 4)
+ throw new ManifoldCFException("Wrong number of documents stored in the
CMIS Target repo - expected 4, saw "+new
Long(targetRepoNumberOfContents).toString());
+
// We also need to make sure the new document was indexed. Have to
think about how to do this though.
// MHL
//System.out.println("Starting delete...");
@@ -482,18 +507,23 @@ public class APISanityHSQLDBIT extends B
// Now, start the job, and wait until it completes.
startJob(jobIDString);
- waitJobInactive(jobIDString, 120000L);
+ waitJobInactive(jobIDString, 240000L);
// Check to be sure we actually processed the right number of documents.
// The test data area has 3 documents and one directory, and we have to
count the root directory too.
count = getJobDocumentsProcessed(jobIDString);
if (count != 4)
- throw new ManifoldCFException("Wrong number of documents processed
after delete - expected 5, saw "+new Long(count).toString());
-
+ throw new ManifoldCFException("Wrong number of documents processed
after delete - expected 4, saw "+new Long(count).toString());
+
+ //Tests if there are 3 documents in the target repo
+ targetRepoNumberOfContents = queryTestContents(cmisTargetClientSession);
+ if(targetRepoNumberOfContents != 3)
+ throw new ManifoldCFException("Wrong number of documents stored in the
CMIS Target repo - expected 3, saw "+new
Long(targetRepoNumberOfContents).toString());
+
// Now, delete the job.
deleteJob(jobIDString);
- waitJobDeleted(jobIDString, 120000L);
+ waitJobDeleted(jobIDString, 240000L);
// Cleanup is automatic by the base class, so we can feel free to leave
jobs and connections lying around.
}
Modified:
manifoldcf/branches/CONNECTORS-1356-2.7.1/connectors/cmis/connector/src/test/java/org/apache/manifoldcf/agents/output/cmisoutput/tests/BaseITHSQLDB.java
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1356-2.7.1/connectors/cmis/connector/src/test/java/org/apache/manifoldcf/agents/output/cmisoutput/tests/BaseITHSQLDB.java?rev=1800294&r1=1800293&r2=1800294&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-1356-2.7.1/connectors/cmis/connector/src/test/java/org/apache/manifoldcf/agents/output/cmisoutput/tests/BaseITHSQLDB.java
(original)
+++
manifoldcf/branches/CONNECTORS-1356-2.7.1/connectors/cmis/connector/src/test/java/org/apache/manifoldcf/agents/output/cmisoutput/tests/BaseITHSQLDB.java
Thu Jun 29 15:35:03 2017
@@ -46,12 +46,12 @@ public class BaseITHSQLDB extends org.ap
protected String[] getOutputNames()
{
- return new
String[]{"org.apache.manifoldcf.agents.output.cmisoutput.CmisOutputConnector"};
+ return new String[]{"CMIS"};
}
protected String[] getOutputClasses()
{
- return new
String[]{"org.apache.manifoldcf.agents.tests.TestingOutputConnector"};
+ return new
String[]{"org.apache.manifoldcf.agents.output.cmisoutput.CmisOutputConnector"};
}
// Setup/teardown