Data Refresh 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.CheckDiscoveryProgressRequest;
import com.hp.schemas.ucmdb.discovery._1.params.CheckDiscoveryProgressRequestDocument;
import com.hp.schemas.ucmdb.discovery._1.params.CheckDiscoveryProgressResponseDocument;
import com.hp.schemas.ucmdb.discovery._1.params.CheckViewDiscoveryProgressRequest;
import com.hp.schemas.ucmdb.discovery._1.params.CheckViewDiscoveryProgressRequestDocument;
import com.hp.schemas.ucmdb.discovery._1.params.CheckViewDiscoveryProgressResponseDocument;
import com.hp.schemas.ucmdb.discovery._1.params.RediscoverCIsRequest;
import com.hp.schemas.ucmdb.discovery._1.params.RediscoverCIsRequestDocument;
import com.hp.schemas.ucmdb.discovery._1.params.RediscoverCIsResponseDocument;
import com.hp.schemas.ucmdb.discovery._1.params.RediscoverViewCIsRequest;
import com.hp.schemas.ucmdb.discovery._1.params.RediscoverViewCIsRequestDocument;
import com.hp.schemas.ucmdb.discovery._1.params.RediscoverViewCIsResponseDocument;
import com.hp.ucmdb.generated.DiscoveryServiceStub;
import com.hp.ucmdb.generated.UcmdbFault;


public class TestDataRefresh {
	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 rediscoverCIs(StrList cmdbIDs) throws RemoteException, UcmdbFault{
		 DiscoveryServiceStub serviceStub = getService();
		 cmdbContext.setCallerApplication("RediscoverCIs");
		 RediscoverCIsRequest rediscoverCIsRequest = RediscoverCIsRequest.Factory.newInstance();
		 rediscoverCIsRequest.setCmdbContext(cmdbContext);
		 rediscoverCIsRequest.setCmdbIDs(cmdbIDs);
		 RediscoverCIsRequestDocument rediscoverCIsRequestDocument = RediscoverCIsRequestDocument.Factory.newInstance();
		 rediscoverCIsRequestDocument.setRediscoverCIsRequest(rediscoverCIsRequest);
		 RediscoverCIsResponseDocument rediscoverCIsResponseDocument = serviceStub.rediscoverCIs(rediscoverCIsRequestDocument);
		 System.out.println(rediscoverCIsResponseDocument.getRediscoverCIsResponse().toString());
		
	}
	
	public static void rediscoverViewCIs(String viewName) throws RemoteException, UcmdbFault{
		 DiscoveryServiceStub serviceStub = getService();
		 cmdbContext.setCallerApplication("rediscoverViewCIs");
		 RediscoverViewCIsRequest rediscoverViewCIsRequest = RediscoverViewCIsRequest.Factory.newInstance();
		 rediscoverViewCIsRequest.setCmdbContext(cmdbContext);
		 rediscoverViewCIsRequest.setViewName(viewName);
		 RediscoverViewCIsRequestDocument rediscoverViewCIsRequestDocument = RediscoverViewCIsRequestDocument.Factory.newInstance();
		 rediscoverViewCIsRequestDocument.setRediscoverViewCIsRequest(rediscoverViewCIsRequest);
		 RediscoverViewCIsResponseDocument rediscoverViewCIsResponseDocument = serviceStub.rediscoverViewCIs(rediscoverViewCIsRequestDocument);
		 System.out.println(rediscoverViewCIsResponseDocument.getRediscoverViewCIsResponse().toString());
		
	}
	
	public static void checkDiscoveryProgress(StrList cmdbIDs) throws RemoteException, UcmdbFault{
		 DiscoveryServiceStub serviceStub = getService();
		 cmdbContext.setCallerApplication("RediscoverCIs");
		 CheckDiscoveryProgressRequest checkDiscoveryProgressRequest = CheckDiscoveryProgressRequest.Factory.newInstance();
		 checkDiscoveryProgressRequest.setCmdbContext(cmdbContext);
		 checkDiscoveryProgressRequest.setCmdbIDs(cmdbIDs);
		 CheckDiscoveryProgressRequestDocument checkDiscoveryProgressRequestDocument = CheckDiscoveryProgressRequestDocument.Factory.newInstance();
		 checkDiscoveryProgressRequestDocument.setCheckDiscoveryProgressRequest(checkDiscoveryProgressRequest);
		 CheckDiscoveryProgressResponseDocument checkDiscoveryProgressResponseDocument =  serviceStub.checkDiscoveryProgress(checkDiscoveryProgressRequestDocument);
		 System.out.println(checkDiscoveryProgressResponseDocument.getCheckDiscoveryProgressResponse().toString());
		
	}
	public static void checkViewDiscoveryProgresss(String viewName) throws RemoteException, UcmdbFault{
		 DiscoveryServiceStub serviceStub = getService();
		 cmdbContext.setCallerApplication("RediscoverCIs");
		 CheckViewDiscoveryProgressRequest   checkViewDiscoveryProgressRequest = CheckViewDiscoveryProgressRequest.Factory.newInstance();
		 checkViewDiscoveryProgressRequest.setCmdbContext(cmdbContext);
		 checkViewDiscoveryProgressRequest.setViewName(viewName);
		 CheckViewDiscoveryProgressRequestDocument checkViewDiscoveryProgressRequestDocument = CheckViewDiscoveryProgressRequestDocument.Factory.newInstance();
		 checkViewDiscoveryProgressRequestDocument.setCheckViewDiscoveryProgressRequest(checkViewDiscoveryProgressRequest);
		 CheckViewDiscoveryProgressResponseDocument checkViewDiscoveryProgressResponseDocument =  serviceStub.checkViewDiscoveryProgress(checkViewDiscoveryProgressRequestDocument);
		 System.out.println(checkViewDiscoveryProgressResponseDocument.getCheckViewDiscoveryProgressResponse().toString());
		
	}
	public static void main(String[] args) throws RemoteException, Exception{
		StrList cmdbIDs = StrList.Factory.newInstance();
		cmdbIDs.addStrValue("");
		rediscoverCIs(cmdbIDs);
	}

}