views:

413

answers:

2

I'm writing an OpenCMIS based application, which extracts some data from Alfresco 3.3.

It works fine with standard CMIS properties such as cmis:name or cmis:contentStreamMimeType; however, I can't access Alfresco especific properties, which are present on the CMIS AtomPub feed as "Alfresco extensions":

<cmisra:object>
  <cmis:properties>
    <cmis:propertyString propertyDefinitionId="cmis:name" displayName="Name" queryName="cmis:name">
      <cmis:value>test document</cmis:value>
    </cmis:propertyString>
    <cmis:propertyString propertyDefinitionId="cmis:contentStreamMimeType" displayName="Content Stream MIME Type" queryName="cmis:contentStreamMimeType">
      <cmis:value>text/html</cmis:value>
    </cmis:propertyString>
    ...
    <alf:aspects>
      ...
      <alf:properties>
        <cmis:propertyString propertyDefinitionId="cm:description" displayName="Description" queryName="cm:description">
          <cmis:value>This is just a test document</cmis:value>
        </cmis:propertyString>
      </alf:properties>
    </alf:aspects>
  </cmis:properties>
</cmisra:object>

Is there any way in which I can get the value of cm:descripcion, with OpenCMIS?

My guess is that I need to use the DocumentType interface instead of Document, and then call its getExtensions() method. But I don't know how to get an instance of DocumentType.

Any help would be really appreciated.

Regards


Edit: altough Florian's answer already worked out for me, I've just realized that I can get these properties' values with CMIS SQL, too:

select d.*, t.*, a.*
from   cmis:document d
join   cm:titled t on d.cmis:objectid = t.cmis:objectid
join   cm:author a on d.cmis:objectid = a.cmis:objectid
where  t.cm:description like ...
+2  A: 

I'm afraid the OpenCMIS high-level API cannot access all extensions yet. It's on our to-do list. For now, you have to use the low-level API. Something like this should work:

ObjectData doc = session.getBinding().getObjectService().getObject(...);
org.w3c.dom.Node domNode = (org.w3c.dom.Node) doc.getProperties().getExtensions().get(0); // <alf:aspects>
domNode.getFirstChild() ... 
Florian Müller
Thanks a lot for your answer, Florian. Yes, it works. Thats almost what I did in my last attempt yesterday: session.getBinding().getObjectService().getProperties().getExtensions()... I was just trying the response (List<Object>) as Strings instead of as Nodes.----- Glad to know that the high-level API may probably access extensions in a future release.----- Thanks again and regards
AJPerez
A: 

org.w3c.dom.Node domNode = (org.w3c.dom.Node) doc.getProperties().getExtensions().get(0); // I always return [[alf:aspects: null]] What may be happening to me?

Are you using Alfresco 3.3, or an older version?
AJPerez
Alfresco 3.3. I have another alleged. How to update these custom properties? I made a mess :(