Powered By Blogger

Monday, February 6, 2012

Calling the WebScript from command line and Java class

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;

/**
*
*/

/**
* @author basanagowda.patil
*
*/
public class Test2 {

/**
* Main class of entry point
*
* @param args
*/
public static void main(final String[] args) {
System.out.println("Lucene Backup is been triggered");
final String url = "http://ecmdev.patil.com/alfresco/wcservice/patils/tags/all";
final HttpClient client = new HttpClient();
final GetMethod httpGet = new GetMethod(url);

try {

httpGet.addRequestHeader("CTUSER", "HFPBB101");
client.executeMethod(httpGet);
final String response = (httpGet.getResponseBodyAsString());
System.out.println(response);


System.out.println("StatusText:::"+ httpGet.getStatusText());
httpGet.releaseConnection();

} catch (final Exception e) {
e.printStackTrace();
}

}
}




You can call the webscripts from the CURL .

1. By passing the header

curl --header "CTUSER:HFPBB01" http://ecmdev.patil.com/alfresco/wcservice/patil/tags/all

2. By passing username and password

curl -uhfpbb101:8999 http://ecmdev.patil.com/alfresco/s/cmis

The first one is the preferred approach. Now we can write the webscript which triggers lucene backup and call that webscript as mentioned above.


There are other ways of backing the lucene indexes trigger

1. JMX

2.Command line

Refer to the link http://wiki.alfresco.com/wiki/Backup_and_Restore#

3. To get the http code

curl -sL -w "%{http_code} %{url_effective}\\n" --header "CTUSER:55551" "http://halfd01.patil.com:8080/alfresco/wcservice/patils/tags/all" -o /dev/null

No comments:

Post a Comment