cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieving associations over CMIS

gehriga
Champ in-the-making
Champ in-the-making
Hi there,

right now I'm trying to build an application based on Alfresco, connected over its CMIS API.
My current problem while testing the API is following:

How can I retrieve a (child-)association of a document via CMIS? I'm able to retrieve properties, child documents of folders, but no associations on custom document types.

Here's an example of my type definition:
<type name="hits:DownloadTeaser">
   <title>DownloadTeaser</title>
   <parent>hits:Content</parent>
   <associations>
      <child-association name="hits:DownloadTeaser:Headline">
         <title>DownloadTeaser:Headline</title>
         <source>
            <mandatory>false</mandatory>
            <many>false</many>
         </source>
         <target>
            <class>hits:binaryLanguageContent</class>
            <mandatory>false</mandatory>
            <many>false</many>
         </target>
      </child-association>
   </associations>
</type>
After creating the linked target content of type binaryLanguageContent I have linked it to the main document of type DownloadTeaser in the Web Client. By accessing the main document via CMIS I don't get any hint on how to retrieve the linked target document.

Here's what is returned by accessing the document:
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/" xmlns:alf="http://www.alfresco.org">
<author><name>admin</name></author>
<content type="text/plain" src="http://localhost:8080/alfresco/service/cmis/s/workspace:SpacesStore/i/845410d9-03de-4595-a71d-86854b...><id>urn:uuid:845410d9-03de-4595-a71d-86854ba09e0d</id>
<link rel="self" href="http://localhost:8080/alfresco/service/cmis/s/workspace:SpacesStore/i/845410d9-03de-4595-a71d-86854b...>
<link rel="enclosure" href="http://localhost:8080/alfresco/service/cmis/s/workspace:SpacesStore/i/845410d9-03de-4595-a71d-86854b..." type="text/plain"/>
<link rel="edit" href="http://localhost:8080/alfresco/service/cmis/s/workspace:SpacesStore/i/845410d9-03de-4595-a71d-86854b...>
<link rel="edit-media" href="http://localhost:8080/alfresco/service/cmis/s/workspace:SpacesStore/i/845410d9-03de-4595-a71d-86854b..." type="text/plain"/>
<link rel="http://docs.oasis-open.org/ns/cmis/link/200908/allowableactions" href="http://localhost:8080/alfresco/service/cmis/s/workspace:SpacesStore/i/845410d9-03de-4595-a71d-86854b...>
<link rel="http://docs.oasis-open.org/ns/cmis/link/200908/relationships" href="http://localhost:8080/alfresco/service/cmis/s/workspace:SpacesStore/i/845410d9-03de-4595-a71d-86854b...>
<link rel="up" href="http://localhost:8080/alfresco/service/cmis/s/workspace:SpacesStore/i/845410d9-03de-4595-a71d-86854b..." type="application/atom+xml;type=feed"/>
<link rel="version-history" href="http://localhost:8080/alfresco/service/cmis/s/workspace:SpacesStore/i/845410d9-03de-4595-a71d-86854b...>
<link rel="describedby" href="http://localhost:8080/alfresco/service/cmis/type/D:hits:binaryLanguageContent'/>
<link rel="service" href="http://localhost:8080/alfresco/service/cmis'/>
<published>2009-11-25T10:09:55.200+01:00</published>
<summary></summary>
<title>headline</title>
<updated>2009-11-25T10:27:02.492+01:00</updated>
<app:edited>2009-11-25T10:27:02.492+01:00</app:edited>
<alf:icon>http://localhost:8080/alfresco/images/filetypes/_default.gif</alf:icon>
<cmisra:object>
<cmis:properties>
<cmis:propertyId propertyDefinitionId="cmis:objectTypeId"><cmis:value>D:hits:binaryLanguageContent</cmis:value></cmis:propertyId>
<cmis:propertyString propertyDefinitionId="cmis:checkinComment"/>
<cmis:propertyDateTime propertyDefinitionId="cmis:lastModificationDate"><cmis:value>2009-11-25T10:27:02.492+01:00</cmis:value></cmis:propertyDateTime>
<cmis:propertyBoolean propertyDefinitionId="cmis:isImmutable"><cmis:value>false</cmis:value></cmis:propertyBoolean>
<cmis:propertyString propertyDefinitionId="cmis:versionSeriesCheckedOutBy"/>
<cmis:propertyString propertyDefinitionId="cmis:versionLabel"/>
<cmis:propertyBoolean propertyDefinitionId="cmis:isLatestVersion"><cmis:value>true</cmis:value></cmis:propertyBoolean>
<cmis:propertyString propertyDefinitionId="cmis:createdBy"><cmis:value>admin</cmis:value></cmis:propertyString>
<cmis:propertyString propertyDefinitionId="cmis:name"><cmis:value>headline</cmis:value></cmis:propertyString>
<cmis:propertyId propertyDefinitionId="cmis:baseTypeId"><cmis:value>cmis:document</cmis:value></cmis:propertyId>
<cmis:propertyString propertyDefinitionId="cmis:contentStreamFileName"><cmis:value>headline</cmis:value></cmis:propertyString>
<cmis:propertyId propertyDefinitionId="cmis:contentStreamId"><cmis:value>cm:content</cmis:value></cmis:propertyId>
<cmis:propertyString propertyDefinitionId="cmis:contentStreamMimeType"><cmis:value>text/plain</cmis:value></cmis:propertyString>
<cmis:propertyString propertyDefinitionId="cmis:changeToken"/>
<cmis:propertyInteger propertyDefinitionId="cmis:contentStreamLength"><cmis:value>0</cmis:value></cmis:propertyInteger>
<cmis:propertyId propertyDefinitionId="cmis:versionSeriesCheckedOutId"/>
<cmis:propertyId propertyDefinitionId="cmis:versionSeriesId"><cmis:value>workspace://SpacesStore/845410d9-03de-4595-a71d-86854ba09e0d</cmis:value></cmis:propertyId>
<cmis:propertyId propertyDefinitionId="cmis:objectId"><cmis:value>workspace://SpacesStore/845410d9-03de-4595-a71d-86854ba09e0d</cmis:value></cmis:propertyId>
<cmis:propertyDateTime propertyDefinitionId="cmis:creationDate"><cmis:value>2009-11-25T10:09:55.200+01:00</cmis:value></cmis:propertyDateTime>
<cmis:propertyBoolean propertyDefinitionId="cmis:isMajorVersion"><cmis:value>false</cmis:value></cmis:propertyBoolean>
<cmis:propertyString propertyDefinitionId="cmis:lastModifiedBy"><cmis:value>admin</cmis:value></cmis:propertyString>
<cmis:propertyBoolean propertyDefinitionId="cmis:isLatestMajorVersion"><cmis:value>false</cmis:value></cmis:propertyBoolean>
<cmis:propertyBoolean propertyDefinitionId="cmis:isVersionSeriesCheckedOut"><cmis:value>false</cmis:value></cmis:propertyBoolean>
</cmis:properties>
</cmisra:object>
<cmisra:pathSegment>headline</cmisra:pathSegment>
</entry>
Anyone out there who can answer this?
Thanks!
8 REPLIES 8

jpotts
World-Class Innovator
World-Class Innovator
I had the same problem until David Caruana pointed me in the right direction.

Try this:

http://localhost:8080/alfresco/service/cmis/s/workspaceSmiley FrustratedpacesStore/i/845410d9-03de-4595-a71d-86854ba0...

The problem is that CMIS is only giving you back relationships of type "cmis:relationship". All custom relationships are sub-types of cmis:relationship, but the default for includeSubRelationshipTypes is false.

Jeff

gehriga
Champ in-the-making
Champ in-the-making
Thanks for your quick reply Jeff,
but unfortunately an empty list is returned, no matter whether I add includeSubRelationshipTypes=true or not.
Is the association defined correctly?
The linked document is both child of a folder and now child(-association) of my main document. Could that be decisive?
Therefore, the source-part of the association-definition has changed, as the linked document has two parents, not one:

<child-association name="hits:DownloadTeaser:Headline">
<title>Headline</title>
<source>
  <mandatory>false</mandatory>
  <many>true</many>
</source>
<target>
  <class>hits:binaryLanguageContent</class>
  <mandatory>false</mandatory>
  <many>false</many>
</target>
</child-association>
For completeness, here's what is returned:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/" xmlns:alf="http://www.alfresco.org" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
<author><name>admin</name></author>
<generator version="3.2.0 (r2 2440)">Alfresco (Community)</generator>
<icon>http://localhost:8080/alfresco/images/logo/AlfrescoLogo16.ico</icon>
<id>urn:uuid:c609a1bc-5b80-41fa-841f-43c7c0928dce-relationships</id>
<link rel="service" href="http://localhost:8080/alfresco/service/cmis'/>
<link rel="self" href="http://localhost:8080/alfresco/service/cmis/s/workspace:SpacesStore/i/c609a1bc-5b80-41fa-841f-43c7c0...>
<link rel="via" href="http://localhost:8080/alfresco/service/cmis/s/workspace:SpacesStore/i/c609a1bc-5b80-41fa-841f-43c7c0...>
<title>DownloadTeaser Relationships</title>

<updated>2009-11-26T09:15:09.846+01:00</updated>
<opensearch:totalResults>0</opensearch:totalResults>
<opensearch:startIndex>0</opensearch:startIndex>
<opensearch:itemsPerPage>-1</opensearch:itemsPerPage>
<cmisra:numItems>0</cmisra:numItems>
</feed>

In the Alfresco Node Browser the child-relationship is shown correctly.
Any idea?

gehriga
Champ in-the-making
Champ in-the-making
ok, new situation.
Obviously your hint belongs to a "normal" association. Here the additional parameter gives me the correct list of linked documents.
But what about child-associations? They are not in the list of relationships, and there is no working url for getting children of a non-folder document.

Thanks in advance!

gehriga
Champ in-the-making
Champ in-the-making
Hi there,

meanwhile I refrained from using child associations for my project.
In my structure of document types I'm using "normal" relations betweens documents. Now I'm trying to discover possible relations on the startup of my application. I'm able to find all possible properties for a certain type by using the script at /alfresco/service/cmis/{typeid}. But there are no associations listed.
Is there any possibilty to discover possible relationships for a certain type?

Thanks for your answers!

shivam
Champ in-the-making
Champ in-the-making
Hi Guys,
Sorry to pull in a different topic, I just started with CMIS web services call. I am getting security header error when I try to call CMIS web service. It will be great if you can share a code sample where you make a call to web services.

Anything basic like getRepositories OR getRepositoryInfo would be great.

Awaiting response.

Regards,
Shivam

fupduck
Champ in-the-making
Champ in-the-making
Hey folks,

thanks to jpotts i can see that there are relations. But how can i access them?
calling .getRelationships() on the item just returns an empty list.

Thank you 😃

Edit: Ok, now I saw it. So is there really no possibilty at all to get associations via CMIS? 
I would really love to know this.
cheers

Edit2: now I found session.getRelationships(). But I just don't get it. Does anybody have an example to share? I'd apreciate that.

fmui
Champ in-the-making
Champ in-the-making
Child association are not exposed through CMIS.
You can get all relationships by calling getObject() with the parameter includeRelationships=both.

You should also download the CMIS Workbench [1] and discover what is visible through CMIS.


- Florian


[1] http://chemistry.apache.org/java/developing/tools/dev-tools-workbench.html

fupduck
Champ in-the-making
Champ in-the-making
Thank you for this information 😃

Finally got it to work.