use of org.apache.chemistry.opencmis.commons.data.ContentStream 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.commons.data.ContentStream 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.commons.data.ContentStream in project camel by apache.
the class CMISTestSupport method createTextDocument.
protected void createTextDocument(Folder newFolder, String content, String fileName) throws UnsupportedEncodingException {
byte[] buf = content.getBytes("UTF-8");
ByteArrayInputStream input = new ByteArrayInputStream(buf);
ContentStream contentStream = createSession().getObjectFactory().createContentStream(fileName, buf.length, "text/plain; charset=UTF-8", input);
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
properties.put(PropertyIds.NAME, fileName);
newFolder.createDocument(properties, contentStream, VersioningState.NONE);
}
Aggregations