Search code examples
javaalfrescoopencmis

How to find if a Document is versionable?


How can I find if a Document is versionable in alfresco using OpenCMIS code?


Solution

  • The way that skuro points out works. An alternative is to use the fact that all objects know what their allowable actions are. So you can just ask, like this (run this in the OpenCMIS Workbench Groovy Console):

    doc = session.getObjectByPath("/cmis-demo/temp.txt")
    allowableActions = doc.getAllowableActions().getAllowableActions()
    if (allowableActions.contains(Action.CAN_CHECK_OUT)) {
        print "Versionable!"
    }
    

    If a document is not versionable, for whatever reason, it will not have the CAN_CHECK_OUT allowable action.