cancel
Showing results for 
Search instead for 
Did you mean: 

How to use the move-to script ?

andreim
Champ in-the-making
Champ in-the-making
Hi ,

I need to move a file from one Alfresco space to another using a REST api.

I tried to use the
/alfresco/service/slingshot/doclib/action/move-to/node/{store_type}/{store_id}/{id}/{path}
url with the following parameters:

store_type = workspace
store_id = SpacesStore
id = the id of the file I want to move
path = the path of the space where I want to move the file

I got the following error :
{
    "status" :
  {
    "code" : 500,
    "name" : "Internal Error",
    "description" : "An error inside the HTTP server which prevented it from fulfilling the request.
"
  }, 
 
  "message" : "07250010 Wrapped Exception (with status template): 07250009 Error during processing of
the template 'Error executing macro: resultsJSON\nrequired parameter: results is not specified.'. Please
contact your system administrator.", 
  "exception" : "org.alfresco.web.scripts.WebScriptException - 07250010 Wrapped Exception (with status
template): 07250009 Error during processing of the template 'Error executing macro: resultsJSON\nrequired
parameter: results is not specified.'. Please contact your system administrator.",
 
  "callstack" :
  [
       ""      ,"freemarker.template.TemplateException: Error executing macro: resultsJSON\nrequired parameter
: results is not specified."
      ,"freemarker.core.Macro$Context.sanityCheck(Macro.java:181)"
      ,"freemarker.core.Macro$Context.runMacro(Macro.java:161)"
      ,"freemarker.core.Environment.visit(Environment.java:601)"
      ,"freemarker.core.UnifiedCall.accept(UnifiedCall.java:106)"
      ,"freemarker.core.Environment.visit(Environment.java:208)"
      ,"freemarker.core.MixedContent.accept(MixedContent.java:92)"
      ,"freemarker.core.Environment.visit(Environment.java:208)"
      ,"freemarker.core.Environment.process(Environment.java:188)"
      ,"freemarker.template.Template.process(Template.java:237)"
      ,"org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:202)"
      ,"org.alfresco.web.scripts.AbstractWebScript.renderTemplate(AbstractWebScript.java:523)"
      ,"org.alfresco.web.scripts.DeclarativeWebScript.renderFormatTemplate(DeclarativeWebScript.java
:241)"
      ,"org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:147)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:357)"
      ,"org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper
.java:326)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java
:407)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer
.java:424)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:288
)"
      ,"org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:262)"
      ,"org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:139)"
      ,"org.alfresco.web.scripts.servlet.WebScriptServlet.service(WebScriptServlet.java:122)"
      ,"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.service.cmr.repository.TemplateException: 07250009 Error during processing of the
template 'Error executing macro: resultsJSON\nrequired parameter: results is not specified.'. Please
contact your system administrator."
      ,"org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:206)"
      ,"org.alfresco.web.scripts.WebScriptException: 07250010 Wrapped Exception (with status template
): 07250009 Error during processing of the template 'Error executing macro: resultsJSON\nrequired parameter
: results is not specified.'. Please contact your system administrator."
      ,"org.alfresco.web.scripts.AbstractWebScript.createStatusException(AbstractWebScript.java:613)
"

  ],
 
  "server" : "Alfresco Community v3.2.0 (2039) schema 2,019",
  "time" : "Aug 25, 2009 2:24:28 PM"
}


Could someone please explain why the script returns an error ?

Thanks in advance,
Andrei
6 REPLIES 6

mikeh
Star Contributor
Star Contributor
store_type = workspace
store_id = SpacesStore
id = the id of the file I want to move
path = the path of the space where I want to move the file

Could someone please explain why the script returns an error ?
Because those parameters aren't correct. The nodeRef (or Share site/container/path) in the URL specifies the destination node (path is optional and probably not required for nodeRef URL formats).

You then need to post a JSON body to the web script with a "nodeRefs" variable containing an array of nodeRefs that you want to move to the destination.

e.g.
POST http://localhost:8080/alfresco/service/slingshot/doclib/action/move-to/node/workspace/SpacesStore/12....
Content-Type: application/json;charset=UTF-8

{"nodeRefs":["workspace://SpacesStore/6425469d-8b02-4850-806b-28a538def0e6","workspace://SpacesStore/a9c7fcb8-8827-42fb-a61d-cccf98f93d95","workspace://SpacesStore/38451091-ac67-42d6-9ad5-cabb2f5ef722"]}

Thanks,
Mike

andreim
Champ in-the-making
Champ in-the-making
store_type = workspace
store_id = SpacesStore
id = the id of the file I want to move
path = the path of the space where I want to move the file

Could someone please explain why the script returns an error ?
Because those parameters aren't correct. The nodeRef (or Share site/container/path) in the URL specifies the destination node (path is optional and probably not required for nodeRef URL formats).

You then need to post a JSON body to the web script with a "nodeRefs" variable containing an array of nodeRefs that you want to move to the destination.

e.g.
POST http://localhost:8080/alfresco/service/slingshot/doclib/action/move-to/node/workspace/SpacesStore/12....
Content-Type: application/json;charset=UTF-8

{"nodeRefs":["workspace://SpacesStore/6425469d-8b02-4850-806b-28a538def0e6","workspace://SpacesStore/a9c7fcb8-8827-42fb-a61d-cccf98f93d95","workspace://SpacesStore/38451091-ac67-42d6-9ad5-cabb2f5ef722"]}

Thanks,
Mike

I tried with the
'/alfresco/service/slingshot/doclib/action/move-to/node/workspace/SpacesStore/destination_folder_id{"nodeRefs":["workspace://SpacesStore/file_I_want_to_move_id"]}'
url and with the
'/alfresco/service/slingshot/doclib/action/move-to/node/workspace/SpacesStore/destination_folder_id/{"nodeRefs":["workspace://SpacesStore/file_I_want_to_move_id"]}'
url but it didn't work.

I always get the following error :
{
    "status" :
  {
    "code" : 500,
    "name" : "Internal Error",
    "description" : "An error inside the HTTP server which prevented it from fulfilling the request.
"
  }, 
 
  "message" : "07250037 Wrapped Exception (with status template): 07250036 Error during processing of
the template 'Error executing macro: resultsJSON\nrequired parameter: results is not specified.'. Please
contact your system administrator.", 
  "exception" : "org.alfresco.web.scripts.WebScriptException - 07250037 Wrapped Exception (with status
template): 07250036 Error during processing of the template 'Error executing macro: resultsJSON\nrequired
parameter: results is not specified.'. Please contact your system administrator.",
 
  "callstack" :
  [
       ""      ,"freemarker.template.TemplateException: Error executing macro: resultsJSON\nrequired parameter
: results is not specified."
      ,"freemarker.core.Macro$Context.sanityCheck(Macro.java:181)"
      ,"freemarker.core.Macro$Context.runMacro(Macro.java:161)"
      ,"freemarker.core.Environment.visit(Environment.java:601)"
      ,"freemarker.core.UnifiedCall.accept(UnifiedCall.java:106)"
      ,"freemarker.core.Environment.visit(Environment.java:208)"
      ,"freemarker.core.MixedContent.accept(MixedContent.java:92)"
      ,"freemarker.core.Environment.visit(Environment.java:208)"
      ,"freemarker.core.Environment.process(Environment.java:188)"
      ,"freemarker.template.Template.process(Template.java:237)"
      ,"org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:202)"
      ,"org.alfresco.web.scripts.AbstractWebScript.renderTemplate(AbstractWebScript.java:523)"
      ,"org.alfresco.web.scripts.DeclarativeWebScript.renderFormatTemplate(DeclarativeWebScript.java
:241)"
      ,"org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:147)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:357)"
      ,"org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper
.java:326)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java
:407)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer
.java:424)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:288
)"
      ,"org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:262)"
      ,"org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:139)"
      ,"org.alfresco.web.scripts.servlet.WebScriptServlet.service(WebScriptServlet.java:122)"
      ,"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.service.cmr.repository.TemplateException: 07250036 Error during processing of the
template 'Error executing macro: resultsJSON\nrequired parameter: results is not specified.'. Please
contact your system administrator."
      ,"org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:206)"
      ,"org.alfresco.web.scripts.WebScriptException: 07250037 Wrapped Exception (with status template
): 07250036 Error during processing of the template 'Error executing macro: resultsJSON\nrequired parameter
: results is not specified.'. Please contact your system administrator."
      ,"org.alfresco.web.scripts.AbstractWebScript.createStatusException(AbstractWebScript.java:613)
"

  ],
 
  "server" : "Alfresco Community v3.2.0 (2039) schema 2,019",
  "time" : "Aug 25, 2009 4:31:25 PM"
}


Is the url correct or should I pass the json body to the webscript in a different way ?
Could you please tell me where is the mistake ?

Thanks,
Andrei

mikeh
Star Contributor
Star Contributor
Is the url correct or should I pass the json body to the webscript in a different way ?
Could you please tell me where is the mistake ?

Thanks,
Andrei
The JSON needs to be in the request body, not on the URL.

Mike

andreim
Champ in-the-making
Champ in-the-making
Is the url correct or should I pass the json body to the webscript in a different way ?
Could you please tell me where is the mistake ?

Thanks,
Andrei
The JSON needs to be in the request body, not on the URL.

Mike

Thank you for your replies.

Could you please tell me how to access the request body ?
I need to call the web script via an Ajax call.
How can I pass the json to the Ajax request ?

Thanks,
Andrei

mikeh
Star Contributor
Star Contributor
Easiest way is with a JavaScript framework like YUI:
YAHOO.util.Connect.asyncRequest(method, url, callback, dataStr);
Where dataStr would be the JSON body, e.g.
dataStr = YAHOO.lang.JSON.stringify(nodeRefsArray);

Mike

andreim
Champ in-the-making
Champ in-the-making
Easiest way is with a JavaScript framework like YUI:
YAHOO.util.Connect.asyncRequest(method, url, callback, dataStr);
Where dataStr would be the JSON body, e.g.
dataStr = YAHOO.lang.JSON.stringify(nodeRefsArray);

Mike

Thanks, it worked.