package org.spbu.monitor;

import java.rmi.RemoteException;

import com.progress.chimera.common.IChimeraRemoteCommand;
import com.progress.common.util.crypto;
import com.progress.ubroker.tools.IAdminRemote;
import com.progress.ubroker.tools.RemoteCommandClient;
import com.progress.ubroker.tools.UBCmdClient;
import com.progress.ubroker.tools.UBToolsMsg;

public class Test extends RemoteCommandClient{

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		//UBCmdClient.printUsage(2);
		Test localClient = new Test();
		//int servertype = 2;
	    crypto localcrypto = new crypto();
	    localClient.m_host = "localhost";
	    localClient.m_rmiPort = "20931";
	    //localClient.m_rmiService = "Chimera";
	    localClient.m_userName = localcrypto.encrypt("Administrator");
	    localClient.m_password = localcrypto.encrypt("vice1988");
	    IChimeraRemoteCommand command = localClient.connect("asbroker1");
	    if (command != null)
	    {
	    	try{
	    	System.out.println(command.getDisplayName());
	        String[] arrayOfString = new String[2];
	        arrayOfString[0] = "AS";
	        arrayOfString[1] = "q";
	        int result = command.runIt(arrayOfString);
	        if(result==0) System.out.println(command.getSystemOutput());
	        else if(result==-2) System.out.println(UBToolsMsg.getMsg(7094295313015382998L, new Object[]{command.getDisplayName()}));
	        else{
	        	String error = command.getSystemError();
	            if (error == null)
	            {
	              error = UBToolsMsg.getMsg(7094295313015385900L, new Object[]{command.getDisplayName()}); }
	            System.out.println(error);
	        }
	    	}catch(RemoteException re){
	    		re.printStackTrace();
	    	}
	    }
	}

}
