Managing Trigger Methods

import java.net.URL;
import java.rmi.RemoteException;

import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.transport.http.HttpTransportProperties;

import com.hp.schemas.ucmdb._1.types.CmdbContext;
import com.hp.schemas.ucmdb._1.types.StrList;
import com.hp.schemas.ucmdb.discovery._1.params.AddTriggerCIRequest;
import com.hp.schemas.ucmdb.discovery._1.params.AddTriggerCIRequestDocument;
import com.hp.schemas.ucmdb.discovery._1.params.AddTriggerTQLRequest;
import com.hp.schemas.ucmdb.discovery._1.params.AddTriggerTQLRequestDocument;
import com.hp.schemas.ucmdb.discovery._1.params.DisableTriggerTQLRequest;
import com.hp.schemas.ucmdb.discovery._1.params.DisableTriggerTQLRequestDocument;
import com.hp.schemas.ucmdb.discovery._1.params.GetJobTriggerTqlsRequest;
import com.hp.schemas.ucmdb.discovery._1.params.GetJobTriggerTqlsRequestDocument;
import com.hp.schemas.ucmdb.discovery._1.params.GetJobTriggerTqlsResponseDocument;
import com.hp.schemas.ucmdb.discovery._1.params.RemoveTriggerCIRequestDocument;
import com.hp.schemas.ucmdb.discovery._1.params.RemoveTriggerTQLRequest;
import com.hp.schemas.ucmdb.discovery._1.params.RemoveTriggerTQLRequestDocument;
import com.hp.schemas.ucmdb.discovery._1.params.SetTriggerTQLProbesLimitRequest;
import com.hp.schemas.ucmdb.discovery._1.params.SetTriggerTQLProbesLimitRequestDocument;
import com.hp.ucmdb.generated.DiscoveryServiceStub;
import com.hp.ucmdb.generated.UcmdbFault;


public class TestTriggerCI {
	
	static final String HOST_NAME = "<my_hostname>";
    static final int PORT = 8080;
    private static final String PROTOCOL = "http";
    private static final String FILE = "/axis2/services/DiscoveryService";
    private static final String PASSWORD = "admin";
    private static final String USERNAME = "admin";
    public static CmdbContext cmdbContext = CmdbContext.Factory.newInstance();

    public static DiscoveryServiceStub getService() {

        DiscoveryServiceStub serviceStub=null;
        try {

            URL url = new URL(PROTOCOL, HOST_NAME, PORT, FILE);
            serviceStub = new DiscoveryServiceStub(url.toString());

            HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
            auth.setUsername(USERNAME);
            auth.setPassword(PASSWORD);
            serviceStub._getServiceClient().getOptions()
                    .setProperty(HTTPConstants.AUTHENTICATE, auth);

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

        }

        return serviceStub;
    }
	
	public static void main(String[] args) throws Exception, UcmdbFault{
		//getJobTriggerTqls("Range IPs by ICMP");
		//addTriggerTQL("Range IPs by ICMP","probe_connected_rum");
		//removeTriggerTQL("Range IPs by ICMP","probe_connected_rum");
		//StrList probesLimit = StrList.Factory.newInstance();
		//probesLimit.addStrValue("AMCBTEST02");
		//setTriggerTQLProbesLimit("Range IPs by ICMP","probe_connected_rum",probesLimit);
		disableTriggerTQL("Range IPs by ICMP","probe_connected_rum");
		//addTriggerCI();
		
	}
	public static void addTriggerCI(String jobName,String CIID) throws RemoteException, UcmdbFault{
		 DiscoveryServiceStub serviceStub = getService();
		 cmdbContext.setCallerApplication("addTriggerCI");
		 AddTriggerCIRequest addTriggerCIRequest = AddTriggerCIRequest.Factory.newInstance();
		 addTriggerCIRequest.setCmdbContext(cmdbContext);
		 addTriggerCIRequest.setJobName(jobName);
		 AddTriggerCIRequestDocument addTriggerCIRequestDocument = AddTriggerCIRequestDocument.Factory.newInstance();
		 addTriggerCIRequestDocument.setAddTriggerCIRequest(addTriggerCIRequest);
		 serviceStub.addTriggerCI(addTriggerCIRequestDocument);
		
	}
	public static void addTriggerTQL(String jobName,String TQLName) throws RemoteException, UcmdbFault{
		 DiscoveryServiceStub serviceStub = getService();
		 cmdbContext.setCallerApplication("addTriggerTQL");
		 AddTriggerTQLRequest addTriggerTQLRequest = AddTriggerTQLRequest.Factory.newInstance();
		 addTriggerTQLRequest.setCmdbContext(cmdbContext);
		 addTriggerTQLRequest.setJobName(jobName);
		 addTriggerTQLRequest.setTqlName(TQLName);
		 AddTriggerTQLRequestDocument addTriggerTQLRequestDocument = AddTriggerTQLRequestDocument.Factory.newInstance();
		 addTriggerTQLRequestDocument.setAddTriggerTQLRequest(addTriggerTQLRequest);
		 serviceStub.addTriggerTQL(addTriggerTQLRequestDocument);
		
	}
	public static void disableTriggerTQL(String jobName,String TQLName) throws RemoteException, UcmdbFault{
		 DiscoveryServiceStub serviceStub = getService();
		 cmdbContext.setCallerApplication("DisableTriggerTQL");
		 DisableTriggerTQLRequest disableTriggerTQLRequest = DisableTriggerTQLRequest.Factory.newInstance();
		 disableTriggerTQLRequest.setCmdbContext(cmdbContext);
		 disableTriggerTQLRequest.setJobName(jobName);
		 disableTriggerTQLRequest.setTqlName(TQLName);
		 DisableTriggerTQLRequestDocument disableTriggerTQLRequestDocument = DisableTriggerTQLRequestDocument.Factory.newInstance();
		 disableTriggerTQLRequestDocument.setDisableTriggerTQLRequest(disableTriggerTQLRequest);
		 serviceStub.disableTriggerTQL(disableTriggerTQLRequestDocument);
		
	}
	public static void  removeTriggerTQL(String jobName,String TQLName) throws RemoteException, UcmdbFault{
		 DiscoveryServiceStub serviceStub = getService();
		 cmdbContext.setCallerApplication("removeTriggerTQL");
		RemoveTriggerTQLRequest removeTriggerTQLRequest =RemoveTriggerTQLRequest.Factory.newInstance();
		removeTriggerTQLRequest.setCmdbContext(cmdbContext);
		removeTriggerTQLRequest.setJobName(jobName);
		removeTriggerTQLRequest.setTqlName(TQLName);
		RemoveTriggerTQLRequestDocument removeTriggerTQLRequestDocument =RemoveTriggerTQLRequestDocument.Factory.newInstance();
		removeTriggerTQLRequestDocument.setRemoveTriggerTQLRequest(removeTriggerTQLRequest);
		serviceStub.removeTriggerTQL(removeTriggerTQLRequestDocument);
		
	}
	
	public static void  getJobTriggerTqls(String jobName) throws RemoteException, UcmdbFault{
		 DiscoveryServiceStub serviceStub = getService();
		 cmdbContext.setCallerApplication("getJobTriggerTqls");
		GetJobTriggerTqlsRequest getJobTriggerTqlsRequest =GetJobTriggerTqlsRequest.Factory.newInstance();
		getJobTriggerTqlsRequest.setCmdbContext(cmdbContext);
		getJobTriggerTqlsRequest.setJobName(jobName);
		GetJobTriggerTqlsRequestDocument getJobTriggerTqlsRequestDocument =GetJobTriggerTqlsRequestDocument.Factory.newInstance();
		getJobTriggerTqlsRequestDocument.setGetJobTriggerTqlsRequest(getJobTriggerTqlsRequest);
		GetJobTriggerTqlsResponseDocument getJobTriggerTqlsResponseDocument = serviceStub.getJobTriggerTqls(getJobTriggerTqlsRequestDocument);
		System.out.println(getJobTriggerTqlsResponseDocument.getGetJobTriggerTqlsResponse().toString());
	}
	
	
	public static void  removeTriggerCI(String jobName,String CIID) throws RemoteException, UcmdbFault{
		 DiscoveryServiceStub serviceStub = getService();
		 cmdbContext.setCallerApplication("removeTriggerCI");
		 AddTriggerCIRequest addTriggerCIRequest = AddTriggerCIRequest.Factory.newInstance();
		 addTriggerCIRequest.setCmdbContext(cmdbContext);
		 addTriggerCIRequest.setJobName(jobName);
		RemoveTriggerCIRequestDocument removeTriggerCIRequestDocument =RemoveTriggerCIRequestDocument.Factory.newInstance();
		removeTriggerCIRequestDocument.setRemoveTriggerCIRequest(addTriggerCIRequest);
		serviceStub.removeTriggerCI(removeTriggerCIRequestDocument);
		
	}
	
	
	public static void  setTriggerTQLProbesLimit(String jobName,String tqlName,StrList probesLimit) throws RemoteException, UcmdbFault{
		 DiscoveryServiceStub serviceStub = getService();
		 cmdbContext.setCallerApplication("setTriggerTQLProbesLimit");
		 SetTriggerTQLProbesLimitRequest setTriggerTQLProbesLimitRequest = SetTriggerTQLProbesLimitRequest.Factory.newInstance();
		 setTriggerTQLProbesLimitRequest.setCmdbContext(cmdbContext);
		 setTriggerTQLProbesLimitRequest.setJobName(jobName);
		 setTriggerTQLProbesLimitRequest.setTqlName(tqlName);
		 setTriggerTQLProbesLimitRequest.setProbesLimit(probesLimit);
		 SetTriggerTQLProbesLimitRequestDocument setTriggerTQLProbesLimitRequestDocument =SetTriggerTQLProbesLimitRequestDocument.Factory.newInstance();
		 setTriggerTQLProbesLimitRequestDocument.setSetTriggerTQLProbesLimitRequest(setTriggerTQLProbesLimitRequest);
		 serviceStub.setTriggerTQLProbesLimit(setTriggerTQLProbesLimitRequestDocument);
		
	}
	

}