use of org.apache.chemistry.opencmis.client.api.CmisObject in project camel by apache.
the class RecursiveTreeWalker method processFolderRecursively.
int processFolderRecursively(Folder folder) throws Exception {
processFolderNode(folder);
OperationContext operationContext = cmisConsumer.createOperationContext();
operationContext.setMaxItemsPerPage(pageSize);
int count = 0;
int pageNumber = 0;
boolean finished = false;
ItemIterable<CmisObject> itemIterable = folder.getChildren(operationContext);
while (!finished) {
ItemIterable<CmisObject> currentPage = itemIterable.skipTo(count).getPage();
LOG.debug("Processing page {}", pageNumber);
for (CmisObject child : currentPage) {
if (CMISHelper.isFolder(child)) {
Folder childFolder = (Folder) child;
processFolderRecursively(childFolder);
} else {
processNonFolderNode(child, folder);
}
count++;
if (totalPolled == readCount) {
finished = true;
break;
}
}
pageNumber++;
if (!currentPage.getHasMoreItems()) {
finished = true;
}
}
return totalPolled;
}
use of org.apache.chemistry.opencmis.client.api.CmisObject in project camel by apache.
the class RecursiveTreeWalker method processNonFolderNode.
private void processNonFolderNode(CmisObject cmisObject, Folder parentFolder) throws Exception {
InputStream inputStream = null;
Map<String, Object> properties = CMISHelper.objectProperties(cmisObject);
properties.put(CamelCMISConstants.CMIS_FOLDER_PATH, parentFolder.getPath());
if (CMISHelper.isDocument(cmisObject) && readContent) {
ContentStream contentStream = ((Document) cmisObject).getContentStream();
if (contentStream != null) {
inputStream = contentStream.getStream();
}
}
sendNode(properties, inputStream);
}
use of org.apache.chemistry.opencmis.client.api.CmisObject in project camel by apache.
the class CMISProducerTest method emptyBodyAndMissingObjectTypeHeaderCreatesFolderNode.
@Test
public void emptyBodyAndMissingObjectTypeHeaderCreatesFolderNode() throws Exception {
Exchange exchange = createExchangeWithInBody(null);
exchange.getIn().getHeaders().put(PropertyIds.NAME, "testFolder");
template.send(exchange);
String newNodeId = exchange.getOut().getBody(String.class);
assertNotNull(newNodeId);
CmisObject newNode = retrieveCMISObjectByIdFromServer(newNodeId);
assertEquals("cmis:folder", newNode.getType().getId());
assertTrue(newNode instanceof Folder);
}
use of org.apache.chemistry.opencmis.client.api.CmisObject in project camel by apache.
the class CMISProducerTest method cmisPropertiesAreStored.
@Test
public void cmisPropertiesAreStored() throws Exception {
Exchange exchange = createExchangeWithInBody("Some content to be store");
exchange.getIn().getHeaders().put(PropertyIds.CONTENT_STREAM_MIME_TYPE, "text/plain; charset=UTF-8");
exchange.getIn().getHeaders().put(PropertyIds.NAME, "test.txt");
template.send(exchange);
String newNodeId = exchange.getOut().getBody(String.class);
CmisObject newNode = retrieveCMISObjectByIdFromServer(newNodeId);
assertEquals("test.txt", newNode.getPropertyValue(PropertyIds.NAME));
assertEquals("text/plain; charset=UTF-8", newNode.getPropertyValue(PropertyIds.CONTENT_STREAM_MIME_TYPE));
}
use of org.apache.chemistry.opencmis.client.api.CmisObject in project camel by apache.
the class CMISProducerTest method getDocumentMimeTypeFromMessageContentType.
@Test
public void getDocumentMimeTypeFromMessageContentType() throws Exception {
Exchange exchange = createExchangeWithInBody("Some content to be store");
exchange.getIn().getHeaders().put(Exchange.CONTENT_TYPE, "text/plain");
exchange.getIn().getHeaders().put(PropertyIds.NAME, "test.file");
template.send(exchange);
String newNodeId = exchange.getOut().getBody(String.class);
CmisObject cmisObject = retrieveCMISObjectByIdFromServer(newNodeId);
Document doc = (Document) cmisObject;
assertEquals("text/plain", doc.getPropertyValue(PropertyIds.CONTENT_STREAM_MIME_TYPE));
}
Aggregations