Search in sources :

Example 1 with ContentStream

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);
}
Also used : ContentStream(org.apache.chemistry.opencmis.commons.data.ContentStream) InputStream(java.io.InputStream) CmisObject(org.apache.chemistry.opencmis.client.api.CmisObject) Document(org.apache.chemistry.opencmis.client.api.Document)

Example 2 with ContentStream

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);
    }
}
Also used : ContentStream(org.apache.chemistry.opencmis.commons.data.ContentStream) Message(org.apache.camel.Message) CmisObject(org.apache.chemistry.opencmis.client.api.CmisObject) Folder(org.apache.chemistry.opencmis.client.api.Folder)

Example 3 with ContentStream

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);
}
Also used : ContentStream(org.apache.chemistry.opencmis.commons.data.ContentStream) ByteArrayInputStream(java.io.ByteArrayInputStream) HashMap(java.util.HashMap) CmisObject(org.apache.chemistry.opencmis.client.api.CmisObject) UnfileObject(org.apache.chemistry.opencmis.commons.enums.UnfileObject)

Aggregations

CmisObject (org.apache.chemistry.opencmis.client.api.CmisObject)3 ContentStream (org.apache.chemistry.opencmis.commons.data.ContentStream)3 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1 Message (org.apache.camel.Message)1 Document (org.apache.chemistry.opencmis.client.api.Document)1 Folder (org.apache.chemistry.opencmis.client.api.Folder)1 UnfileObject (org.apache.chemistry.opencmis.commons.enums.UnfileObject)1