cancel
Showing results for 
Search instead for 
Did you mean: 

UpdateProperties

pavo83
Champ in-the-making
Champ in-the-making
Hello,

I'm working with some rest api to update the properties of an alfresco element, but I'm having some problem to understand how to use the Api I've found.

I'm using:

<b>PUT /alfresco/service/cmis/i/{id}</b>

My body is:

{"title" : "Try me"}

(I also tested with "cm:title")

But the response is 500  Internal Server Error, with this exception:

<b>Exception:</b>freemarker.core.InvalidReferenceException - Expression node is undefined on line 10, column 6 in org/alfresco/cmis/item.patch.atomentry.ftl.


I think that my error is in the body content-type and/or the way I write it, but I'm not sure.

Can anyone help me?
4 REPLIES 4

jpotts
World-Class Innovator
World-Class Innovator
First, I have to ask if there is a reason you are using the raw HTTP binding instead of using a CMIS library such as OpenCMIS (Java), cmislib (Python), or one of the other client libraries? It will save you a LOT of work.

The problem is most likely that you are trying to set a title which is defined in an aspect called cm:titled. Aspects aren't natively supported in CMIS 1.0 but they are supported in CMIS 1.1. This requires you to use the CMIS 1.1 service URL. For the browser (JSON) binding, that URL is:

http://localhost:8080/alfresco/api/-default-/cmis/versions/1.1/browser

Note that not all CMIS client libraries support the browser binding. OpenCMIS does.

You'll also need to add the cm:titled aspect to the object. In CMIS 1.1 aspects are called secondary types. See this Gist for a snippet that uses OpenCMIS to set properties defined as part of the cm:geographic aspect as an example:

https://gist.github.com/jpotts/7242070

Jeff

pavo83
Champ in-the-making
Champ in-the-making
I'm working on a connector between Alfresco and Salesforce (the original application "Alfresco for Salesforce" doesn't have any way to update the properties on Salesforce side).
I don't know of any CMIS library on Apex (Java-like programming language for the Force.com platform), so I use a lot of http request to make operation on Alfresco from Salesforce side and now I'm looking for the one to upload document properties.

On Salesforce side I don't need to add aspects so, probably, my example with the "cm:title" property is a bad example, but I'm looking for a way to modify the properties of a document using the raw http and my problem is with the body of my http request.

kaynezhang
World-Class Innovator
World-Class Innovator
write your  http request body like following(cm:title and cm:description are properties of cm:titled aspect ,if you don't need this aspect ,please remove alf:setAspects element)

<entry xmlns="http://www.w3.org/2005/Atom" 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">
   <summary>test modify cm:description property</summary>
   <title>test modify cm_name property</title>
   <cmisra:object>
      <cmis:properties>
         <cmis:propertyInteger propertyDefinitionId="cmis:contentStreamLength" displayName="Content Stream Length" queryName="cmis:contentStreamLength">
            <cmis:value>98495335</cmis:value>
         </cmis:propertyInteger>
         <alf:setAspects>
            <alf:aspectsToAdd>P:cm:titled</alf:aspectsToAdd>
            <alf:properties>
               <cmis:propertyString propertyDefinitionId="cm:description" queryName="cm:description">
                  <cmis:value>New Description</cmis:value>
               </cmis:propertyString>
               <cmis:propertyString propertyDefinitionId="cm:title" queryName="cm:title">
                  <cmis:value>New Title</cmis:value>
               </cmis:propertyString>
            </alf:properties>
         </alf:setAspects>
      </cmis:properties>
   </cmisra:object>

   <cmisra:content>
      <cmisra:mediatype>text/plain</cmisra:mediatype>
      <cmisra:base64>VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZy4=</cmisra:base64>
   </cmisra:content>
</entry>

pavo83
Champ in-the-making
Champ in-the-making
Thank you, kaynezhang, it works correctly!