AnsweredAssumed Answered

CMIS inmemory server does not seem to support versioning

Question asked by kartech11 on Sep 4, 2018

I have started an inmemory alfresco CMIS instance locally. I am able to launch the CMIS Workbench and query against the instance. 

 

I am trying to create a document in the inmemory instance and I get the below error. Do I need to setup any confirm parameters for versioning to be enabled in the inmemory instance?

 

Error when createDocument is called, (I am passing as VersioningState as MAJOR)?

org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException: The versioning state flag is imcompatible to the type definition.

at org.apache.chemistry.opencmis.client.bindings.spi.browser.AbstractBrowserBindingService.convertStatusCode(AbstractBrowserBindingService.java:284)
at org.apache.chemistry.opencmis.client.bindings.spi.browser.AbstractBrowserBindingService.post(AbstractBrowserBindingService.java:426)
at org.apache.chemistry.opencmis.client.bindings.spi.browser.ObjectServiceImpl.createDocument(ObjectServiceImpl.java:89)
at org.apache.chemistry.opencmis.client.runtime.SessionImpl.createDocument(SessionImpl.java:1197)

 

private static Document createDocument(UserSession userSession, Folder parentFolder, String documentName, byte[] data, String mimeType, Map<String, Object> metadata ) throws ActionNotEntitledException {
    Document document;
    if(isActionEntitled(Action.CAN_CREATE_DOCUMENT, parentFolder.getAllowableActions().getAllowableActions())){
        ByteArrayInputStream stream = new ByteArrayInputStream(data);
        ContentStream contentStream = userSession.getSession().getObjectFactory().createContentStream(documentName, data.length, mimeType, stream);

        // prepare properties
        Map<String, Object> documentProperties = new HashMap<>();
        documentProperties.put(PropertyIds.NAME, documentName);
        documentProperties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");

        document = parentFolder.createDocument(documentProperties, contentStream, VersioningState.MAJOR);
        //Add secondary properties such as aspect properties
        if(metadata != null && !metadata.isEmpty()){
            document.updateProperties(metadata);
        }
    }
    else{
        throw new ActionNotEntitledException("User " + userSession.getUserName() + " not entitled to create Document");
    }
    return document;
}

Outcomes