0

I was trying to retrieve a list of document names linked to a given index id (in my example "index-80") with the code below:

Note: The code below uses .Net but I can use java too.

IObjectId id = session.CreateObjectId("index-80");
IFolder indexFolder = session.GetObject(id) as IFolder;
foreach (ICmisObject cmisObject in indexFolder.GetChildren())
{
   Console.WriteLine(cmisObject.Name);
}

The issue is, the code will return only children indexes ("index-80" is parent of a couple of nested indexes in our CMIS repository) but it won't return documents linked to it.

After a bit of reading, it seems that documents are children of the ROOTFOLDER, but not of an indexentry. That will explain why the code above won't work.

How can I retrieve all document names linked to a given index in apache chemistry opencmis?

  • Can you explain what "linked" means in this context? Are CMIS relationships? Are there special properties with object IDs? – Florian Müller Apr 04 '17 at 09:59
  • I should have used the word "related" instead of "linked", but yes, those objects have relationships between them. You may think, well, why not use the relationship between index a document to get a document given the index. The reason is, AFAIK, relationships point to the parent object, so documents are related to indexes but indexes are only related to other indexes (parent indexes). My issue is that I need to get documents (unknown variable) related with a given index (the variable I know). – John Casablanca Apr 05 '17 at 05:58
  • You can traverse relationships in both directions. Call `getObject()` on the index object with an Operation Context that includes relationships (see https://chemistry.apache.org/docs/cmis-samples/samples/operation-context/index.html#relationships). Get the relationships from the from the object with `getRelationships()`. On each relationship object call `getSource()` to get the related document. – Florian Müller Apr 05 '17 at 07:27
  • Yes, relationships are retrieved in both directions. The issue is, the "from" direction points to "itself" (the index itself) and the "to" direction points to the parent, which is another index. See image [here](https://www.screencast.com/t/Ef195PQpj3k). In that image, the base object (the index I am exploring) is "indexentry-55-141-x-x-x-x-80". Check the SourceId of the relationship. It is the same "indexentry-55-141-x-x-x-x-80". The targetId is "index-80", which is the parent index. – John Casablanca Apr 05 '17 at 23:57
  • You probably have to traverse all the relationships. This data model does not provide direct access to the documents. – Florian Müller Apr 06 '17 at 11:50
  • Florian, when you said "This data model does not provide direct access to the documents", did you find evidence of that somewhere? I think you are right, actually that's what I told our tool vendor support, as they insist that it can be done and that I should be doing something wrong at my end. – John Casablanca Apr 06 '17 at 22:26

0 Answers0