cmisdotcmisopencmis

How to tell whether a CmisObject represents a file or a folder?


In OpenCMIS (or DotCMIS), how to tell whether a CmisObject represents a file or a folder?

Specification: http://chemistry.apache.org/java/0.5.0/maven/apidocs/org/apache/chemistry/opencmis/client/api/CmisObject.html


Solution

  • This works:

    if (cmisObject instanceof Folder) { ... }
    if (cmisObject instanceof Document) { ... }
    

    And this works:

    if (cmisObject.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) { ... }
    if (cmisObject.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT) { ... }