How to tell whether a CmisObject represents a file or a folder?
Question
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) { ... }
OTHER TIPS
Here is the way I have found (C# syntax):
cmisObject is DotCMIS.Client.Impl.Folder
Any better idea is welcome!
Florian Müller's answer adapted and tested for DotCMIS:
if (cmisObject is IFolder) { ... }
if (cmisObject is IDocument) { ... }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow