AnsweredAssumed Answered

executing a java script through web script ..

Question asked by linton on Feb 13, 2010
Latest reply on Feb 15, 2010 by linton
         I have a javascript which assigns a work-flow to a user. I placed this script in side the scripts folder.
I use the webscript command/script/execute interface to execute this.
for example ..
if i type the following url in the browser the asignworkflow.js script is executed and a review workflow is assigned to admin_signup.txt doc..


This works fine when i type the url in the browser and presses enter key..

But i want to make in automatic that is when ever a new document is added , i want this script to be called with the document name so the workflow is attached to that file.

SO i wrote the following java code…

HttpClient client = new HttpClient();
       client.getHostConfiguration().setHost("localhost", 8080);
       String strURL="http://localhost:8080/alfresco/command/script/execute?scriptPath=/Company%20Home/Data%20Dictionary/Scripts/assignworkflow.js&contextPath=/Company%20Home/admin_signup.txt";
      HostConfiguration h = new HostConfiguration();
      h.setHost("localhost", 8080);
      GetMethod get = new GetMethod(strURL);
      try {
         int result = client.executeMethod(h,get);
         System.out.println("Servelt Call for Excute java script Result == " + result);
      } catch (HttpException e) {
         // TODO Auto-generated catch block

but it always throws 500 status code. which means bad request…

with the same java code if i call
String strURL = "http://localhost:8080/alfresco/wcservice/ui/myspaces?f=0&p=/Company%20Home";
i get 200 as status which means success..

I am not able to fix this.
can anyone help me…

waiting for your replies..
Thank you