cancel
Showing results for 
Search instead for 
Did you mean: 

Change/set metadata attribute on a file

marcus_svensson
Champ in-the-making
Champ in-the-making
The scenario is that I need to change a metadata attribute on a file. A GET request to the object can be seen in the attachment alfresco_get_request.xml. To change the metadata I want I send in a PUT request as specified by alfresco_put_request.xml.

The expected outcome of this would be that the attribute peas:authorisedBy is set to "nisse.jpg".

However Alfresco responds back with an error as seen in alfresco_response.html.


Am I doing something wrong here or is Alfresco just playing me?



I also opened a JIRA issue on this as I suspect that it may be a bug:
https://issues.alfresco.com/jira/browse/ALF-7445
3 REPLIES 3

marcus_svensson
Champ in-the-making
Champ in-the-making
alfresco_put_request.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<atom:entry xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/" xmlns:cmism="http://docs.oasis-open.org/ns/cmis/messaging/200908/" xmlns:atom="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/">
   <atom:title>IMAG0020.jpg</atom:title>
   <atom:summary>IMAG0020.jpg</atom:summary>
   <cmisraSmiley Surprisedbject>
      <cmisSmiley Tongueroperties>
         <cmisSmiley TongueropertyString propertyDefinitionId="peas:authorisedBy">
            <cmis:value>nisse.jpg</cmis:value>
         </cmisSmiley TongueropertyString>
      </cmisSmiley Tongueroperties>
   </cmisraSmiley Surprisedbject>
</atom:entry>

alfresco_get_request.xml:
<?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="image/jpeg" src="http://bettan:28080/alfresco/service/cmis/s/workspaceSmiley FrustratedpacesStore/i/e72eac0c-5440-4eea-b823-a9b570f332...>
   <id>urn:uuid:e72eac0c-5440-4eea-b823-a9b570f33270</id>
   <link rel="self" href="http://bettan:28080/alfresco/service/cmis/s/workspaceSmiley FrustratedpacesStore/i/e72eac0c-5440-4eea-b823-a9b570f332...>
   <link rel="enclosure" href="http://bettan:28080/alfresco/service/cmis/s/workspaceSmiley FrustratedpacesStore/i/e72eac0c-5440-4eea-b823-a9b570f332..." type="image/jpeg"/>
   <link rel="edit" href="http://bettan:28080/alfresco/service/cmis/s/workspaceSmiley FrustratedpacesStore/i/e72eac0c-5440-4eea-b823-a9b570f332...>
   <link rel="edit-media" href="http://bettan:28080/alfresco/service/cmis/s/workspaceSmiley FrustratedpacesStore/i/e72eac0c-5440-4eea-b823-a9b570f332..." type="image/jpeg"/>
   <link rel="http://docs.oasis-open.org/ns/cmis/link/200908/allowableactions" href="http://bettan:28080/alfresco/service/cmis/s/workspaceSmiley FrustratedpacesStore/i/e72eac0c-5440-4eea-b823-a9b570f332...>
   <link rel="http://docs.oasis-open.org/ns/cmis/link/200908/relationships" href="http://bettan:28080/alfresco/service/cmis/s/workspaceSmiley FrustratedpacesStore/i/e72eac0c-5440-4eea-b823-a9b570f332...>
   <link rel="http://docs.oasis-open.org/ns/cmis/link/200908/policies" href="http://bettan:28080/alfresco/service/cmis/s/workspaceSmiley FrustratedpacesStore/i/e72eac0c-5440-4eea-b823-a9b570f332...>
   <link rel="http://docs.oasis-open.org/ns/cmis/link/200908/acl" href="http://bettan:28080/alfresco/service/cmis/s/workspaceSmiley FrustratedpacesStore/i/e72eac0c-5440-4eea-b823-a9b570f332...>
   <link rel="up" href="http://bettan:28080/alfresco/service/cmis/s/workspaceSmiley FrustratedpacesStore/i/e72eac0c-5440-4eea-b823-a9b570f332..." type="application/atom+xml;type=feed"/>
   <link rel="version-history" href="http://bettan:28080/alfresco/service/cmis/s/workspaceSmiley FrustratedpacesStore/i/e72eac0c-5440-4eea-b823-a9b570f332...>
   <link rel="current-version" href="http://bettan:28080/alfresco/service/cmis/s/workspaceSmiley FrustratedpacesStore/i/e72eac0c-5440-4eea-b823-a9b570f332...>
   <link rel="describedby" href="http://bettan:28080/alfresco/service/cmis/type/D:smileytongue:eas:imagemodel'/>
   <link rel="service" href="http://bettan:28080/alfresco/service/cmis'/>
   <published>2011-03-02T11:48:02.098+01:00</published>
   <summary>IMAG0020.jpg</summary>
   <title>IMAG0020.jpg</title>
   <updated>2011-03-02T11:48:03.076+01:00</updated>
   <app:edited>2011-03-02T11:48:03.076+01:00</app:edited>
   <alf:icon>http://bettan:28080/alfresco/images/filetypes/jpg.gif</alf:icon>
   <cmisraSmiley Surprisedbject>
      <cmisSmiley Tongueroperties>
         <cmisSmiley TongueropertyInteger propertyDefinitionId="cmis:contentStreamLength" displayName="Content Stream Length" queryName="cmis:contentStreamLength">
            <cmis:value>1546099</cmis:value>
         </cmisSmiley TongueropertyInteger>
         <cmisSmiley TongueropertyString propertyDefinitionId="cmis:versionSeriesCheckedOutBy" displayName="Version Series Checked Out By" queryName="cmis:versionSeriesCheckedOutBy"/>
         <cmisSmiley TongueropertyId propertyDefinitionId="cmisSmiley SurprisedbjectTypeId" displayName="Object Type Id" queryName="cmisSmiley SurprisedbjectTypeId">
            <cmis:value>D:smileytongue:eas:imagemodel</cmis:value>
         </cmisSmiley TongueropertyId>
         <cmisSmiley TongueropertyId propertyDefinitionId="cmis:versionSeriesCheckedOutId" displayName="Version Series Checked Out Id" queryName="cmis:versionSeriesCheckedOutId"/>
         <cmisSmiley TongueropertyId propertyDefinitionId="cmis:versionSeriesId" displayName="Version series id" queryName="cmis:versionSeriesId">
            <cmis:value>workspace://SpacesStore/e72eac0c-5440-4eea-b823-a9b570f33270</cmis:value>
         </cmisSmiley TongueropertyId>
         <cmisSmiley TongueropertyString propertyDefinitionId="cmis:versionLabel" displayName="Version Label" queryName="cmis:versionLabel">
            <cmis:value>1.1</cmis:value>
         </cmisSmiley TongueropertyString>
         <cmisSmiley TongueropertyBoolean propertyDefinitionId="cmis:isLatestVersion" displayName="Is Latest Version" queryName="cmis:isLatestVersion">
            <cmis:value>true</cmis:value>
         </cmisSmiley TongueropertyBoolean>
         <cmisSmiley TongueropertyBoolean propertyDefinitionId="cmis:isVersionSeriesCheckedOut" displayName="Is Version Series Checked Out" queryName="cmis:isVersionSeriesCheckedOut">
            <cmis:value>false</cmis:value>
         </cmisSmiley TongueropertyBoolean>
         <cmisSmiley TongueropertyString propertyDefinitionId="cmis:lastModifiedBy" displayName="Last Modified By" queryName="cmis:lastModifiedBy">
            <cmis:value>admin</cmis:value>
         </cmisSmiley TongueropertyString>
         <cmisSmiley TongueropertyString propertyDefinitionId="cmis:createdBy" displayName="Created by" queryName="cmis:createdBy">
            <cmis:value>admin</cmis:value>
         </cmisSmiley TongueropertyString>
         <cmisSmiley TongueropertyBoolean propertyDefinitionId="cmis:isLatestMajorVersion" displayName="Is Latest Major Version" queryName="cmis:isLatestMajorVersion">
            <cmis:value>false</cmis:value>
         </cmisSmiley TongueropertyBoolean>
         <cmisSmiley TongueropertyId propertyDefinitionId="cmis:contentStreamId" displayName="Content Stream Id" queryName="cmis:contentStreamId">
            <cmis:value>store://2011/3/2/11/48/29abc156-2bf1-4e61-aa56-cfbb35d71436.bin</cmis:value>
         </cmisSmiley TongueropertyId>
         <cmisSmiley TongueropertyString propertyDefinitionId="cmis:name" displayName="Name" queryName="cmis:name">
            <cmis:value>IMAG0020.jpg</cmis:value>
         </cmisSmiley TongueropertyString>
         <cmisSmiley TongueropertyString propertyDefinitionId="cmis:contentStreamMimeType" displayName="Content Stream MIME Type" queryName="cmis:contentStreamMimeType">
            <cmis:value>image/jpeg</cmis:value>
         </cmisSmiley TongueropertyString>
         <cmisSmiley TongueropertyDateTime propertyDefinitionId="cmis:creationDate" displayName="Creation Date" queryName="cmis:creationDate">
            <cmis:value>2011-03-02T11:48:02.098+01:00</cmis:value>
         </cmisSmiley TongueropertyDateTime>
         <cmisSmiley TongueropertyString propertyDefinitionId="cmis:changeToken" displayName="Change token" queryName="cmis:changeToken"/>
         <cmisSmiley TongueropertyDateTime propertyDefinitionId="peasSmiley TongueublishedDate" displayName="peasSmiley TongueublishedDate" queryName="peasSmiley TongueublishedDate"/>
         <cmisSmiley TongueropertyString propertyDefinitionId="cmis:checkinComment" displayName="Checkin Comment" queryName="cmis:checkinComment"/>
         <cmisSmiley TongueropertyId propertyDefinitionId="cmisSmiley SurprisedbjectId" displayName="Object Id" queryName="cmisSmiley SurprisedbjectId">
            <cmis:value>workspace://SpacesStore/e72eac0c-5440-4eea-b823-a9b570f33270</cmis:value>
         </cmisSmiley TongueropertyId>
         <cmisSmiley TongueropertyBoolean propertyDefinitionId="cmis:isImmutable" displayName="Is Immutable" queryName="cmis:isImmutable">
            <cmis:value>false</cmis:value>
         </cmisSmiley TongueropertyBoolean>
         <cmisSmiley TongueropertyBoolean propertyDefinitionId="cmis:isMajorVersion" displayName="Is Major Version" queryName="cmis:isMajorVersion">
            <cmis:value>false</cmis:value>
         </cmisSmiley TongueropertyBoolean>
         <cmisSmiley TongueropertyString propertyDefinitionId="peas:authorisedBy" displayName="peas:authorisedBy" queryName="peas:authorisedBy"/>
         <cmisSmiley TongueropertyId propertyDefinitionId="cmis:baseTypeId" displayName="Base Type Id" queryName="cmis:baseTypeId">
            <cmis:value>cmis:document</cmis:value>
         </cmisSmiley TongueropertyId>
         <cmisSmiley TongueropertyString propertyDefinitionId="cmis:contentStreamFileName" displayName="Content Stream Filename" queryName="cmis:contentStreamFileName">
            <cmis:value>IMAG0020.jpg</cmis:value>
         </cmisSmiley TongueropertyString>
         <cmisSmiley TongueropertyDateTime propertyDefinitionId="cmis:lastModificationDate" displayName="Last Modified Date" queryName="cmis:lastModificationDate">
            <cmis:value>2011-03-02T11:48:03.076+01:00</cmis:value>
         </cmisSmiley TongueropertyDateTime>
         <alf:aspects>
            <alf:appliedAspects>P:exif:exif</alf:appliedAspects>
            <alfSmiley Tongueroperties>
               <cmisSmiley TongueropertyInteger propertyDefinitionId="exifSmiley TongueixelYDimension" displayName="Image Height" queryName="exifSmiley TongueixelYDimension"/>
               <cmisSmiley TongueropertyString propertyDefinitionId="exif:resolutionUnit" displayName="Resolution Unit" queryName="exif:resolutionUnit"/>
               <cmisSmiley TongueropertyInteger propertyDefinitionId="exifSmiley TongueixelXDimension" displayName="Image Width" queryName="exifSmiley TongueixelXDimension"/>
               <cmisSmiley TongueropertyDecimal propertyDefinitionId="exif:exposureTime" displayName="Exposure Time" queryName="exif:exposureTime"/>
               <cmisSmiley TongueropertyDateTime propertyDefinitionId="exif:dateTimeOriginal" displayName="Date and Time" queryName="exif:dateTimeOriginal"/>
               <cmisSmiley TongueropertyDecimal propertyDefinitionId="exif:xResolution" displayName="Horizontal Resolution" queryName="exif:xResolution"/>
               <cmisSmiley TongueropertyString propertyDefinitionId="exif:manufacturer" displayName="Camera Manufacturer" queryName="exif:manufacturer"/>
               <cmisSmiley TongueropertyDecimal propertyDefinitionId="exif:fNumber" displayName="F Number" queryName="exif:fNumber"/>
               <cmisSmiley TongueropertyString propertyDefinitionId="exif:software" displayName="Camera Software" queryName="exif:software"/>
               <cmisSmiley TongueropertyBoolean propertyDefinitionId="exif:flash" displayName="Flash Activated" queryName="exif:flash"/>
               <cmisSmiley TongueropertyString propertyDefinitionId="exif:model" displayName="Camera Model" queryName="exif:model"/>
               <cmisSmiley TongueropertyDecimal propertyDefinitionId="exif:yResolution" displayName="Vertical Resolution" queryName="exif:yResolution"/>
               <cmisSmiley TongueropertyString propertyDefinitionId="exif:isoSpeedRatings" displayName="ISO Speed" queryName="exif:isoSpeedRatings"/>
               <cmisSmiley TongueropertyInteger propertyDefinitionId="exifSmiley Surprisedrientation" displayName="Orientation" queryName="exifSmiley Surprisedrientation"/>
               <cmisSmiley TongueropertyDecimal propertyDefinitionId="exif:focalLength" displayName="Focal Length" queryName="exif:focalLength"/>
            </alfSmiley Tongueroperties>
         </alf:aspects>
      </cmisSmiley Tongueroperties>
   </cmisraSmiley Surprisedbject>
   <cmisraSmiley TongueathSegment>IMAG0020.jpg</cmisraSmiley TongueathSegment>
</entry>

alfresco_response.html:
The Web Script /alfresco/service/cmis/s/workspaceSmiley FrustratedpacesStore/i/e72eac0c-5440-4eea-b823-a9b570f33270 has responded with a status of 500 - Internal Error.

500 Description:   An error inside the HTTP server which prevented it from fulfilling the request.
Message:   02020130 Wrapped Exception (with status template): 02020174 Error during processing of the template 'Expression node is undefined on line 10, column 6 in org/alfresco/cmis/item.put.atomentry.ftl.'. Please contact your system administrator.
Exception:   freemarker.core.InvalidReferenceException - Expression node is undefined on line 10, column 6 in org/alfresco/cmis/item.put.atomentry.ftl.
freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:134)
freemarker.core.Dot._getAsTemplateModel(Dot.java:78)
freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
freemarker.core.Expression.isTrue(Expression.java:138)
freemarker.core.IfBlock.accept(IfBlock.java:80)
freemarker.core.Environment.visit(Environment.java:210)
freemarker.core.MixedContent.accept(MixedContent.java:92)
freemarker.core.Environment.visit(Environment.java:210)
freemarker.core.Environment.visit(Environment.java:299)
freemarker.core.CompressedBlock.accept(CompressedBlock.java:73)
freemarker.core.Environment.visit(Environment.java:210)
freemarker.core.MixedContent.accept(MixedContent.java:92)
freemarker.core.Environment.visit(Environment.java:210)
freemarker.core.Environment.process(Environment.java:190)
freemarker.template.Template.process(Template.java:237)
org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:197)
org.springframework.extensions.webscripts.AbstractWebScript.renderTemplate(AbstractWebScript.java:589)
org.springframework.extensions.webscripts.DeclarativeWebScript.renderFormatTemplate(DeclarativeWebScript.java:267)
org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:147)
org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:383)
org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:381)
org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:436)
org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:466)
org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:304)
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:333)
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:189)
org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:118)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:58)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Thread.java:619)
Exception:   org.alfresco.service.cmr.repository.TemplateException - 02020174 Error during processing of the template 'Expression node is undefined on line 10, column 6 in org/alfresco/cmis/item.put.atomentry.ftl.'. Please contact your system administrator.
org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:201)
Exception:   org.springframework.extensions.webscripts.WebScriptException - 02020130 Wrapped Exception (with status template): 02020174 Error during processing of the template 'Expression node is undefined on line 10, column 6 in org/alfresco/cmis/item.put.atomentry.ftl.'. Please contact your system administrator.
org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:758)
Server :   Community v3.4.0 (d 3370) schema 4 113

flob
Champ in-the-making
Champ in-the-making
I don't know if it is still relevant to you, but maybe it could help others:

Your request header has to have
'Content-type: application/atom+xml;type=entry'

I guess many people do it with
'Content-type: application/cmisquery+xml'
which provokes the given error
Error during processing of the template 'Expression node is undefined on line 10, column 6

marcus_svensson
Champ in-the-making
Champ in-the-making
Yup that was it, also noted by David Caruana who responded to my support jira ticket

David Caruana added a comment - 07-Apr-11 01:19 PM
The PUT request must have a Content Type of "application/atom+xml;type=entry"