OpenCMIS/DotCMIS: I have CmisFolder and filename, how to get CmisDocument?

376 views Asked by At

I want to get the CmisDocument of this CMIS remote file: server1/dir1/file1.

I already have the CmisFolder for server1/dir1.
I also have the filename "file1" as a string.

Any elegant way to get the CmisDocument?

Below is my very inelegant attempt:

IDocument document = null;
foreach(ICmisObject obj in remoteFolder.GetChildren())
{
    if (obj is IDocument)
    {
        document = (IDocument)obj;
        if (document.Name.Equals(fileName))
        {
            break;
        }
    }
}
1

There are 1 answers

0
Nic On

You could try using a query:

string statement = "select * from cmis:document where cmis:contentStreamFileName = 'filename' and in_folder('myfolderid')"; 

IItemEnumerable<IQueryResult> qr = session.Query(statement, true);

You can also change cmis:document to the specific table/class that contains your document to make your query a little faster.