use of org.apache.chemistry.opencmis.client.api.CmisObject in project camel by apache.
the class CMISTestSupport method deleteAllContent.
protected void deleteAllContent() {
Session session = createSession();
Folder rootFolder = session.getRootFolder();
ItemIterable<CmisObject> children = rootFolder.getChildren();
for (CmisObject cmisObject : children) {
if ("cmis:folder".equals(cmisObject.getPropertyValue(PropertyIds.OBJECT_TYPE_ID))) {
List<String> notDeltedIdList = ((Folder) cmisObject).deleteTree(true, UnfileObject.DELETE, true);
if (notDeltedIdList != null && notDeltedIdList.size() > 0) {
throw new RuntimeException("Cannot empty repo");
}
} else {
cmisObject.delete(true);
}
}
session.getBinding().close();
}
use of org.apache.chemistry.opencmis.client.api.CmisObject in project camel by apache.
the class CMISProducer method createNode.
private CmisObject createNode(Exchange exchange) throws Exception {
validateRequiredHeader(exchange, PropertyIds.NAME);
Message message = exchange.getIn();
String parentFolderPath = parentFolderPathFor(message);
Folder parentFolder = getFolderOnPath(exchange, parentFolderPath);
Map<String, Object> cmisProperties = filterTypeProperties(message.getHeaders());
if (isDocument(exchange)) {
String fileName = message.getHeader(PropertyIds.NAME, String.class);
String mimeType = getMimeType(message);
byte[] buf = getBodyData(message);
ContentStream contentStream = getSessionFacade().createContentStream(fileName, buf, mimeType);
return storeDocument(parentFolder, cmisProperties, contentStream);
} else if (isFolder(message)) {
return storeFolder(parentFolder, cmisProperties);
} else {
// other types
return storeDocument(parentFolder, cmisProperties, null);
}
}
use of org.apache.chemistry.opencmis.client.api.CmisObject in project camel by apache.
the class CMISProducer method process.
public void process(Exchange exchange) throws Exception {
CmisObject cmisObject = createNode(exchange);
LOG.debug("Created node with id: {}", cmisObject.getId());
// copy the header of in message to the out message
exchange.getOut().copyFrom(exchange.getIn());
exchange.getOut().setBody(cmisObject.getId());
}
use of org.apache.chemistry.opencmis.client.api.CmisObject in project camel by apache.
the class CMISProducerTest method createDocumentWithoutContentByExplicitlySpecifyingObjectTypeHeader.
@Test
public void createDocumentWithoutContentByExplicitlySpecifyingObjectTypeHeader() throws Exception {
Exchange exchange = createExchangeWithInBody(null);
exchange.getIn().getHeaders().put(PropertyIds.CONTENT_STREAM_MIME_TYPE, "text/plain; charset=UTF-8");
exchange.getIn().getHeaders().put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
exchange.getIn().getHeaders().put(PropertyIds.NAME, "test.file");
template.send(exchange);
String newNodeId = exchange.getOut().getBody(String.class);
assertNotNull(newNodeId);
CmisObject cmisObject = retrieveCMISObjectByIdFromServer(newNodeId);
Document doc = (Document) cmisObject;
assertEquals("cmis:document", doc.getPropertyValue(PropertyIds.OBJECT_TYPE_ID));
}
use of org.apache.chemistry.opencmis.client.api.CmisObject in project camel by apache.
the class CMISProducerTest method cmisSecondaryTypePropertiesAreStored.
@Test
public void cmisSecondaryTypePropertiesAreStored() throws Exception {
List<String> secondaryTypes = Arrays.asList("MySecondaryType");
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");
exchange.getIn().getHeaders().put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypes);
exchange.getIn().getHeaders().put("SecondaryStringProp", "secondaryTypePropValue");
template.send(exchange);
String newNodeId = exchange.getOut().getBody(String.class);
CmisObject newNode = retrieveCMISObjectByIdFromServer(newNodeId);
assertEquals(1, newNode.getSecondaryTypes().size());
assertEquals("secondaryTypePropValue", newNode.getPropertyValue("SecondaryStringProp"));
}
Aggregations