AnsweredAssumed Answered

Update multi value property through metadata webscript

Question asked by dc_noze on Oct 13, 2010
Latest reply on Apr 1, 2015 by sihnu
Hi guys,
i'm trying to update a custom multi value string property through /alfresco/service/script/org/alfresco/repository/metadata/metadata.post webscript.
This is the json data sent to the script:

{properties:{"{myns}myproperty":["string1","string2"]}}
and this is the response:

org.alfresco.web.scripts.WebScriptException - Wrapped Exception (with status template): Failed to execute script '/org/alfresco/repository/metadata/metadata.post.json.js (in classpath store file:/home/daniele/dev-apps/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts)': org.json.JSONArray cannot be cast to java.io.Serializable: Wrapped Exception (with status template): Failed to execute script '/org/alfresco/repository/metadata/metadata.post.json.js (in classpath store file:/home/daniele/dev-apps/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts)': org.json.JSONArray cannot be cast to java.io.Serializable
Callstack:
java.lang.ClassCastException: org.json.JSONArray cannot be cast to java.io.Serializable
org.alfresco.repo.jscript.ValueConverter.convertValueForRepo(ValueConverter.java:153)
org.alfresco.repo.jscript.ScriptNode$NodeValueConverter.convertValueForRepo(ScriptNode.java:2612)
org.alfresco.repo.jscript.ScriptNode.save(ScriptNode.java:1118)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.mozilla.javascript.MemberBox.invoke(MemberBox.java:155)
org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:243)
org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:119)
org.mozilla.javascript.gen.c35._c1(AlfrescoScript:54)
org.mozilla.javascript.gen.c35.call(AlfrescoScript)
org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:108)
org.mozilla.javascript.gen.c35._c0(AlfrescoScript:1)
org.mozilla.javascript.gen.c35.call(AlfrescoScript)
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
org.mozilla.javascript.gen.c35.call(AlfrescoScript)
org.mozilla.javascript.gen.c35.exec(AlfrescoScript)
org.mozilla.javascript.Context.evaluateString(Context.java:1196)
org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:390)
org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:122)
org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:263)
org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript(RepositoryScriptProcessor.java:108)
org.alfresco.web.scripts.AbstractWebScript.executeScript(AbstractWebScript.java:800)
org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:90)
org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:319)
org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:320)
org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:227)
org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:368)
org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:390)
org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:273)
org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:261)
org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:139)
org.alfresco.web.scripts.servlet.WebScriptServlet.service(WebScriptServlet.java:116)
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.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:128)
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:286)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
java.lang.Thread.run(Thread.java:619)
org.alfresco.scripts.ScriptException: Failed to execute script '/org/alfresco/repository/metadata/metadata.post.json.js (in classpath store file:/home/daniele/dev-apps/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts)': org.json.JSONArray cannot be cast to java.io.Serializable
org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:126)
org.alfresco.web.scripts.WebScriptException: Wrapped Exception (with status template): Failed to execute script '/org/alfresco/repository/metadata/metadata.post.json.js (in classpath store file:/home/daniele/dev-apps/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts)': org.json.JSONArray cannot be cast to java.io.Serializable
org.alfresco.web.scripts.AbstractWebScript.createStatusException(AbstractWebScript.java:595)
Alfresco Labs v3.0.0 (Stable 1526) schema 1.002: 13-ott-2010 18.03.15

I have already tried to post a simple custom properties and everything works fine. Any ideas on how to pass the value?

Any help would be appreciated.
Thanks, Daniele.

Outcomes