AnsweredAssumed Answered

webscript for publishing content

Question asked by hanu on Sep 7, 2009
Latest reply on Jan 28, 2011 by romschn
Hi,

How to call webscript for publishing assets from java. I nee to do to it programatically.  I tried with the following code.
Please suggest me anyone have idea on this.

HttpClient pubClient = new HttpClient();           
            pubClient.getState().setCredentials(new AuthScope("localhost", 8080, "Alfresco"),new UsernamePasswordCredentials("admin", "admin"));
              PostMethod puPost = new PostMethod("http://localhost:8080/alfresco/service/api/wcm/webprojects/Content/sandboxes/Content--admin/submitter");
              //PostMethod puPost = new PostMethod("http://localhost:8080/alfresco/service/api/wcm/webprojects/Content/sandboxes/Content--admin/admin");
              puPost.setDoAuthentication( true );
                          
              JSONObject myObject = new JSONObject();
              myObject.put("label", "Publish");
           myObject.put("comment", "Publish IRSContent");
           myObject.put("all", "true");
           myObject.put("assets", "");
           myObject.put("paths", "");
            puPost.addParameter("store", "IRSContent–admin");
              puPost.addParameter("json", myObject.toString());
             
              String resultString="";
            try {
               int status = pubClient.executeMethod( puPost );
              System.out.println("status is:"+status);
               resultString = puPost.getResponseBodyAsString();
               System.out.println("result string is:"+resultString);
            }

Outcomes