AnsweredAssumed Answered

CMISLIB reports missing <content> tag in getContentStream call

Question asked by hughdbrown on Apr 11, 2013
Latest reply on Apr 17, 2013 by jpotts
I am using cmislib to query Alfresco programmatically. I have a custom content type named bulletin in the namespace wg. I try to query it like this:

<python>
from cmislib import CmisClient

url = "http://myservert:8080/alfresco/cmisatom"
client = CmisClient(url, 'admin', 'admin')
repo = client.defaultRepository
results = repo.query("select * from wg:bulletin")
print results[0].getContentStream().read()
</python>

And I get this error:


Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/hbrown/.virtualenvs/access_manager_master/local/lib/python2.7/site-packages/cmislib/model.py", line 2467, in getContentStream
    assert(len(contentElements) == 1), 'Expected to find exactly one atom:content element.'
AssertionError: Expected to find exactly one atom:content element.


When I modify cmislib's <a href="https://svn.apache.org/repos/asf/chemistry/cmislib/trunk/src/cmislib/atompub_binding.py">model.py</a> to dump its XMl, I get this:


<atom:entry>
    <atom:author>
        <atom:name/>
    </atom:author>
    <atom:id>http://chemistry.apache.org/aWQtMQ==</atom:id>
    <atom:published>2013-04-10T20:44:00Z</atom:published>
    <atom:title>Query Result id-1</atom:title>
    <app:edited>2013-04-10T20:44:00Z</app:edited>
    <atom:updated>2013-04-10T20:44:00Z</atom:updated>
    <cmisra:object xmlns:ns3="http://docs.oasis-open.org/ns/cmis/messaging/200908/">
        <cmis:properties>
            <cmis:propertyInteger displayName="Content Stream Length" localName="contentStreamLength" propertyDefinitionId="cmis:contentStreamLength" queryName="b.cmis:contentStreamLength">
                <cmis:value>249</cmis:value>
            </cmis:propertyInteger>
            <cmis:propertyId displayName="Object Type Id" localName="objectTypeId" propertyDefinitionId="cmis:objectTypeId" queryName="b.cmis:objectTypeId">
                <cmis:value>D:wg:bulletin</cmis:value>
            </cmis:propertyId>
            <cmis:propertyString displayName="Version Series Checked Out By" localName="versionSeriesCheckedOutBy" propertyDefinitionId="cmis:versionSeriesCheckedOutBy" queryName="b.cmis:versionSeriesCheckedOutBy"/>
            <cmis:propertyId displayName="Version Series Checked Out Id" localName="versionSeriesCheckedOutId" propertyDefinitionId="cmis:versionSeriesCheckedOutId" queryName="b.cmis:versionSeriesCheckedOutId"/>
            <cmis:propertyId displayName="Version series id" localName="versionSeriesId" propertyDefinitionId="cmis:versionSeriesId" queryName="b.cmis:versionSeriesId">
                <cmis:value>workspace://SpacesStore/1cd2053d-1fc4-4e85-b780-ba80284f0841</cmis:value>
            </cmis:propertyId>
            <cmis:propertyString displayName="wg:account" localName="account" propertyDefinitionId="wg:account" queryName="b.wg:account"/>
            <cmis:propertyString displayName="Version Label" localName="versionLabel" propertyDefinitionId="cmis:versionLabel" queryName="b.cmis:versionLabel">
                <cmis:value>1.0</cmis:value>
            </cmis:propertyString>
            <cmis:propertyBoolean displayName="Is Latest Version" localName="isLatestVersion" propertyDefinitionId="cmis:isLatestVersion" queryName="b.cmis:isLatestVersion">
                <cmis:value>true</cmis:value>
            </cmis:propertyBoolean>
            <cmis:propertyBoolean displayName="Is Version Series Checked Out" localName="isVersionSeriesCheckedOut" propertyDefinitionId="cmis:isVersionSeriesCheckedOut" queryName="b.cmis:isVersionSeriesCheckedOut">
                <cmis:value>false</cmis:value>
            </cmis:propertyBoolean>
            <cmis:propertyString displayName="Last Modified By" localName="lastModifiedBy" propertyDefinitionId="cmis:lastModifiedBy" queryName="b.cmis:lastModifiedBy">
                <cmis:value>admin</cmis:value>
            </cmis:propertyString>
            <cmis:propertyString displayName="Created by" localName="createdBy" propertyDefinitionId="cmis:createdBy" queryName="b.cmis:createdBy">
                <cmis:value>admin</cmis:value>
            </cmis:propertyString>
            <cmis:propertyDateTime displayName="wg:displayUntil" localName="displayUntil" propertyDefinitionId="wg:displayUntil" queryName="b.wg:displayUntil"/>
            <cmis:propertyId displayName="Alfresco Node Ref" localName="nodeRef" propertyDefinitionId="alfcmis:nodeRef" queryName="b.alfcmis:nodeRef">
                <cmis:value>workspace://SpacesStore/1cd2053d-1fc4-4e85-b780-ba80284f0841</cmis:value>
            </cmis:propertyId>
            <cmis:propertyString displayName="wg:email" localName="email" propertyDefinitionId="wg:email" queryName="b.wg:email"/>
            <cmis:propertyBoolean displayName="wg:isActive" localName="isActive" propertyDefinitionId="wg:isActive" queryName="b.wg:isActive">
                <cmis:value>false</cmis:value>
            </cmis:propertyBoolean>
            <cmis:propertyString displayName="wg:username" localName="username" propertyDefinitionId="wg:username" queryName="b.wg:username"/>
            <cmis:propertyBoolean displayName="Is Latest Major Version" localName="isLatestMajorVersion" propertyDefinitionId="cmis:isLatestMajorVersion" queryName="b.cmis:isLatestMajorVersion">
                <cmis:value>true</cmis:value>
            </cmis:propertyBoolean>
            <cmis:propertyId displayName="Content Stream Id" localName="contentStreamId" propertyDefinitionId="cmis:contentStreamId" queryName="b.cmis:contentStreamId">
                <cmis:value>store://2013/4/10/15/29/20b185d0-afae-4a7f-a06e-58eab399bdc9.bin</cmis:value>
            </cmis:propertyId>ATOM_NS
            <cmis:propertyString displayName="Name" localName="name" propertyDefinitionId="cmis:name" queryName="b.cmis:name">
                <cmis:value>.pythonrc</cmis:value>
            </cmis:propertyString>
            <cmis:propertyString displayName="Content Stream MIME Type" localName="contentStreamMimeType" propertyDefinitionId="cmis:contentStreamMimeType" queryName="b.cmis:contentStreamMimeType">
                <cmis:value>text/plain</cmis:value>
            </cmis:propertyString>
            <cmis:propertyDateTime displayName="Creation Date" localName="creationDate" propertyDefinitionId="cmis:creationDate" queryName="b.cmis:creationDate">
                <cmis:value>2013-04-10T15:29:18.146-04:00</cmis:value>
            </cmis:propertyDateTime>
            <cmis:propertyString displayName="Change token" localName="changeToken" propertyDefinitionId="cmis:changeToken" queryName="b.cmis:changeToken"/>
            <cmis:propertyString displayName="wg:state" localName="state" propertyDefinitionId="wg:state" queryName="b.wg:state"/>
            <cmis:propertyDateTime displayName="wg:displayFrom" localName="displayFrom" propertyDefinitionId="wg:displayFrom" queryName="b.wg:displayFrom"/>
            <cmis:propertyString displayName="Checkin Comment" localName="checkinComment" propertyDefinitionId="cmis:checkinComment" queryName="b.cmis:checkinComment"/>
            <cmis:propertyString displayName="wg:application" localName="application" propertyDefinitionId="wg:application" queryName="b.wg:application"/>
            <cmis:propertyId displayName="Object Id" localName="objectId" propertyDefinitionId="cmis:objectId" queryName="b.cmis:objectId">
                <cmis:value>workspace://SpacesStore/1cd2053d-1fc4-4e85-b780-ba80284f0841;1.0</cmis:value>
            </cmis:propertyId>
            <cmis:propertyBoolean displayName="Is Immutable" localName="isImmutable" propertyDefinitionId="cmis:isImmutable" queryName="b.cmis:isImmutable">
                <cmis:value>false</cmis:value>
            </cmis:propertyBoolean>
            <cmis:propertyBoolean displayName="Is Major Version" localName="isMajorVersion" propertyDefinitionId="cmis:isMajorVersion" queryName="b.cmis:isMajorVersion">
                <cmis:value>true</cmis:value>
            </cmis:propertyBoolean>
            <cmis:propertyString displayName="wg:institution" localName="institution" propertyDefinitionId="wg:institution" queryName="b.wg:institution"/>
            <cmis:propertyId displayName="Base Type Id" localName="baseTypeId" propertyDefinitionId="cmis:baseTypeId" queryName="b.cmis:baseTypeId">
                <cmis:value>cmis:document</cmis:value>
            </cmis:propertyId>
            <cmis:propertyString displayName="Content Stream Filename" localName="contentStreamFileName" propertyDefinitionId="cmis:contentStreamFileName" queryName="b.cmis:contentStreamFileName">
                <cmis:value>.pythonrc</cmis:value>
            </cmis:propertyString>
            <cmis:propertyDateTime displayName="Last Modified Date" localName="lastModificationDate" propertyDefinitionId="cmis:lastModificationDate" queryName="b.cmis:lastModificationDate">
                <cmis:value>2013-04-10T15:29:23.384-04:00</cmis:value>
            </cmis:propertyDateTime>
        </cmis:properties>
    </cmisra:object>
</atom:entry>


How can my document be missing the content tag? Or is the problem in cmislib? I can see content in Alfresco share and explorer, so there must be an alternative way to get this data.

Outcomes