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

1.6k Views Asked by At

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

3

There are 3 best solutions below

0
On BEST ANSWER

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) { ... }
1
On

Here is the way I have found (C# syntax):

cmisObject is DotCMIS.Client.Impl.Folder

Any better idea is welcome!

0
On

Florian Müller's answer adapted and tested for DotCMIS:

if (cmisObject is IFolder) { ... }
if (cmisObject is IDocument) { ... }