Problems when updating metadata properties via cmislib

cancel
Showing results for 
Search instead for 
Did you mean: 
cesarista
Customer

Problems when updating metadata properties via cmislib

Jump to solution

Hi:

Have you tried to update properties via CMIS after a repo.query with python cmislib ? 
I created a little script that searchs for two documents (kk.txt and kk3.txt) and tries to set / update a property on it.

It seems that someDoc.updateProperties(props) should work, where props are the proper dictionary for the properties. But I don't see what's wrong in the second case.

# This part works
docu = repo.getObjectByPath('/Test/kk.txt')
print docu
props = {'cmis:name': 'kk2.txt'}
docu.updateProperties(props)

# This results in error
results = repo.query("SELECT * FROM cmis:document where cmis:name = 'kk3.txt' ")
someDoc = results[0]
print someDoc
props = {'cmis:name': 'kk4.txt'}
someDoc.updateProperties(props)

File "simple.py", line 35, in <module>
someDoc.updateProperties(props)
File "/usr/lib/python2.6/site-packages/cmislib_alfresco_extension-0.3.2-py2.6.egg/cmislibalf/extension.py", line 185, in updateProperties
selfUrl = self._getSelfLink()
File "/usr/lib/python2.6/site-packages/cmislib-0.5.1-py2.6.egg/cmislib/model.py", line 2169, in _getSelfLink
assert len(url) > 0, "Could not determine the self link."
TypeError: object of type 'NoneType' has no len()


I see no problems on permissions or allowable actions. Did I miss something ?


I use cmis 0.5.1 library with Alfresco 4.2.6 EE and CMIS 1.1 endpoint

Regards.


--C.

1 Solution

Accepted Solutions
mehe
Senior Member II

Re: Problems when updating metadata properties via cmislib

Jump to solution

Hi Cesar,

then it MUST be the version problem, even if the document is not versioned. Try

someDoc=results[0].getLatestVersion()

Hope it works...

View solution in original post

4 Replies
mehe
Senior Member II

Re: Problems when updating metadata properties via cmislib

Jump to solution

Wasn't there a bug in 0.5.1 with Alfresco cmis, returning less elements than expected on repo.query?

Tried iterating over result and accessing name as property of the element ( for result in results: print result.name )?

Maybe that helps...

cesarista
Customer

Re: Problems when updating metadata properties via cmislib

Jump to solution

Thanks Martin, it is quite strange. I didn't lose elements. Iterating over the result does not help... it seems that the objects resulting from repo.query is somehow different.

I walkarounded doing an extra repo.getObject query with the results of the repo.query

results = repo.query("SELECT * FROM cmis:document where cmis:name = 'kk3.txt' ")
#someDoc = results[0]

someDoc = repo.getObject('workspace://SpacesStore/'+results[0].id)
print someDoc
pprint(someDoc)
props = {'cmis:name': 'kk4.txt'}
someDoc.updateProperties(props)

It is for 2M documents so I'll lose some time in the extra query Smiley Sad

Regards.

--C.

mehe
Senior Member II

Re: Problems when updating metadata properties via cmislib

Jump to solution

Hi Cesar,

then it MUST be the version problem, even if the document is not versioned. Try

someDoc=results[0].getLatestVersion()

Hope it works...

cesarista
Customer

Re: Problems when updating metadata properties via cmislib

Jump to solution

It works like a charm Martin, thank you very much.

Best regards.

--C.