Domain and Probe Data 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.discovery._1.params.GetDomainTypeRequest;
import com.hp.schemas.ucmdb.discovery._1.params.GetDomainTypeRequestDocument;
import com.hp.schemas.ucmdb.discovery._1.params.GetDomainTypeResponseDocument;
import com.hp.schemas.ucmdb.discovery._1.params.GetDomainsNamesRequest;
import com.hp.schemas.ucmdb.discovery._1.params.GetDomainsNamesRequestDocument;
import com.hp.schemas.ucmdb.discovery._1.params.GetDomainsNamesResponseDocument;
import com.hp.schemas.ucmdb.discovery._1.params.GetProbeIPsRequest;
import com.hp.schemas.ucmdb.discovery._1.params.GetProbeIPsRequestDocument;
import com.hp.schemas.ucmdb.discovery._1.params.GetProbeIPsResponseDocument;
import com.hp.schemas.ucmdb.discovery._1.params.GetProbeScopeRequest;
import com.hp.schemas.ucmdb.discovery._1.params.GetProbeScopeRequestDocument;
import com.hp.schemas.ucmdb.discovery._1.params.GetProbeScopeResponseDocument;
import com.hp.schemas.ucmdb.discovery._1.params.GetProbesNamesRequest;
import com.hp.schemas.ucmdb.discovery._1.params.GetProbesNamesRequestDocument;
import com.hp.schemas.ucmdb.discovery._1.params.GetProbesNamesResponseDocument;
import com.hp.schemas.ucmdb.discovery._1.params.IsProbeConnectedRequest;
import com.hp.schemas.ucmdb.discovery._1.params.IsProbeConnectedRequestDocument;
import com.hp.schemas.ucmdb.discovery._1.params.IsProbeConnectedResponceDocument;
import com.hp.schemas.ucmdb.discovery._1.params.UpdateProbeScopeRequest;
import com.hp.schemas.ucmdb.discovery._1.params.UpdateProbeScopeRequestDocument;
import com.hp.schemas.ucmdb.discovery._1.types.IP;
import com.hp.schemas.ucmdb.discovery._1.types.IPRange;
import com.hp.schemas.ucmdb.discovery._1.types.Scope;
import com.hp.schemas.ucmdb.discovery._1.types.Scope.Include;
import com.hp.ucmdb.generated.DiscoveryServiceStub;
import com.hp.ucmdb.generated.UcmdbFault;


public class TestDomain {
	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 getDomainsNames() throws RemoteException, UcmdbFault{
		 DiscoveryServiceStub serviceStub = getService();
		 cmdbContext.setCallerApplication("GetDomainsNames");
		 GetDomainsNamesRequest getDomainsNamesRequest = GetDomainsNamesRequest.Factory.newInstance();
		 getDomainsNamesRequest.setCmdbContext(cmdbContext);
		
		 GetDomainsNamesRequestDocument getDomainsNamesRequestDocument = GetDomainsNamesRequestDocument.Factory.newInstance();
		 getDomainsNamesRequestDocument.setGetDomainsNamesRequest(getDomainsNamesRequest);
		 GetDomainsNamesResponseDocument getDomainsNamesResponseDocument = serviceStub.getDomainsNames(getDomainsNamesRequestDocument);
		 System.out.println(getDomainsNamesResponseDocument.getGetDomainsNamesResponse().toString());
		
	}
	
	public static void getProbesNames(String domainName) throws RemoteException, UcmdbFault{
		 DiscoveryServiceStub serviceStub = getService();
		 cmdbContext.setCallerApplication("GetProbesNames");
		 GetProbesNamesRequest getProbesNamesRequest = GetProbesNamesRequest.Factory.newInstance();
		 getProbesNamesRequest.setCmdbContext(cmdbContext);
		 getProbesNamesRequest.setDomainName(domainName);
		 GetProbesNamesRequestDocument getProbesNamesRequestDocument = GetProbesNamesRequestDocument.Factory.newInstance();
		 getProbesNamesRequestDocument.setGetProbesNamesRequest(getProbesNamesRequest);
		 GetProbesNamesResponseDocument getProbesNamesResponseDocument = serviceStub.getProbesNames(getProbesNamesRequestDocument);
		 System.out.println(getProbesNamesResponseDocument.getGetProbesNamesResponse().toString());
		
	}
	public static void getProbeScope(String domainName,String probeName) throws RemoteException, UcmdbFault{
		 DiscoveryServiceStub serviceStub = getService();
		 cmdbContext.setCallerApplication("GetProbeScope");
		 GetProbeScopeRequest getProbeScopeRequest = GetProbeScopeRequest.Factory.newInstance();
		 getProbeScopeRequest.setCmdbContext(cmdbContext);
		 getProbeScopeRequest.setDomainName(domainName);
		 getProbeScopeRequest.setProbeName(probeName);
		 GetProbeScopeRequestDocument getProbeScopeRequestDocument = GetProbeScopeRequestDocument.Factory.newInstance();
		 getProbeScopeRequestDocument.setGetProbeScopeRequest(getProbeScopeRequest);
		 GetProbeScopeResponseDocument getProbeScopeResponseDocument = serviceStub.getProbeScope(getProbeScopeRequestDocument);
		 System.out.println(getProbeScopeResponseDocument.getGetProbeScopeResponse().toString());
		
	}
	public static void getProbeIPs(String domainName,String probeName) throws RemoteException, UcmdbFault{
		 DiscoveryServiceStub serviceStub = getService();
		 cmdbContext.setCallerApplication("GetProbeIPs");
		 GetProbeIPsRequest getProbeIPsRequest = GetProbeIPsRequest.Factory.newInstance();
		 getProbeIPsRequest.setCmdbContext(cmdbContext);
		 getProbeIPsRequest.setDomainName(domainName);
		 getProbeIPsRequest.setProbeName(probeName);
		 GetProbeIPsRequestDocument getProbeIPsRequestDocument = GetProbeIPsRequestDocument.Factory.newInstance();
		 getProbeIPsRequestDocument.setGetProbeIPsRequest(getProbeIPsRequest);
		 GetProbeIPsResponseDocument getProbeIPsResponseDocument = serviceStub.getProbeIPs(getProbeIPsRequestDocument);
		 System.out.println(getProbeIPsResponseDocument.getGetProbeIPsResponse().toString());
		
	}
	public static void getDomainType(String domainName) throws RemoteException, UcmdbFault{
		 DiscoveryServiceStub serviceStub = getService();
		 cmdbContext.setCallerApplication("GetProbeScope");
		 GetDomainTypeRequest getDomainTypeRequest = GetDomainTypeRequest.Factory.newInstance();
		 getDomainTypeRequest.setCmdbContext(cmdbContext);
		 getDomainTypeRequest.setDomainName(domainName);
		 GetDomainTypeRequestDocument getDomainTypeRequestDocument = GetDomainTypeRequestDocument.Factory.newInstance();
		 getDomainTypeRequestDocument.setGetDomainTypeRequest(getDomainTypeRequest);
		 GetDomainTypeResponseDocument getDomainTypeResponseDocument = serviceStub.getDomainType(getDomainTypeRequestDocument);
		 System.out.println(getDomainTypeResponseDocument.getGetDomainTypeResponse().toString());
		
	}
	
	public static void isProbeConnected(String domainName,String probeName) throws RemoteException, UcmdbFault{
		 DiscoveryServiceStub serviceStub = getService();
		 cmdbContext.setCallerApplication("isProbeConnected");
		 IsProbeConnectedRequest isProbeConnectedRequest = IsProbeConnectedRequest.Factory.newInstance();
		 isProbeConnectedRequest.setCmdbContext(cmdbContext);
		 isProbeConnectedRequest.setDomainName(domainName);
		 isProbeConnectedRequest.setProbeName(probeName);
		 IsProbeConnectedRequestDocument isProbeConnectedRequestDocument = IsProbeConnectedRequestDocument.Factory.newInstance();
		 isProbeConnectedRequestDocument.setIsProbeConnectedRequest(isProbeConnectedRequest);
		 IsProbeConnectedResponceDocument IsProbeConnectedResponceDocument  = serviceStub.isProbeConnected(isProbeConnectedRequestDocument);
		 System.out.println(IsProbeConnectedResponceDocument.getIsProbeConnectedResponce());
		
	}
	public static void updateProbeScope(String domainName,String probeName,Scope newScope) throws RemoteException, UcmdbFault{
		 DiscoveryServiceStub serviceStub = getService();
		 cmdbContext.setCallerApplication("UpdateProbeScope");
		 UpdateProbeScopeRequest updateProbeScopeRequest = UpdateProbeScopeRequest.Factory.newInstance();
		 updateProbeScopeRequest.setCmdbContext(cmdbContext);
		 updateProbeScopeRequest.setDomainName(domainName);
		 updateProbeScopeRequest.setProbeName(probeName);
		 updateProbeScopeRequest.setNewScope(newScope);
		 UpdateProbeScopeRequestDocument updateProbeScopeRequestDocument = UpdateProbeScopeRequestDocument.Factory.newInstance();
		 updateProbeScopeRequestDocument.setUpdateProbeScopeRequest(updateProbeScopeRequest);
		 serviceStub.updateProbeScope(updateProbeScopeRequestDocument);
		
		
	}
	
	
	public static void main(String[] args) throws Exception{
		//getDomainsNames();
		//getProbesNames("DefaultDomain");
		//getProbeScope("DefaultDomain","AMCBTEST02");
		//isProbeConnected("DefaultDomain","AMCBTEST02");
		//getProbeIPs("DefaultDomain","AMCBTEST02");
		//getDomainType("DefaultDomain");
		
	}
	


}