Org.ogce.fileagentservice.client.RemoveUserSpace

From Ogce

 package org.ogce.fileagentservice.client;

 import javax.xml.namespace.QName;

 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.rpc.client.RPCServiceClient;
 import org.ogce.fileagentservice.*;
 import org.ogce.fileagentservice.db.*;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.ArrayList;

 public class RemoveUserSpace{
    public static void main(String[] args) throws AxisFault {
	int option = 0;
	String serviceLoc = "http://gridfarm002.ucs.indiana.edu:8080/axis2/services/FileAgentService";
	String username= null;
	String host=null;
	String port=null;
	String commCertDN=null;
	String protocol=null;
	LinkedList loUS = new LinkedList();
	for (int j = 0; j < args.length; j++){
	    
	    String argVal = args[j];
	    if (argVal.compareToIgnoreCase("--help")==0||
		argVal.compareToIgnoreCase("-help")==0){
		RemoveUserSpace.usage();
		return;
	    }else if(argVal.startsWith("-")){
		if (argVal.compareToIgnoreCase("-f")==0)
		    option =1;
		else if (argVal.compareToIgnoreCase("-l")==0)
		    option = 2;
		else if (argVal.compareToIgnoreCase("-h")==0)
		    option = 3;
		else if (argVal.compareToIgnoreCase("-p")==0)
		    option = 4;
		else if (argVal.compareToIgnoreCase("-dn")==0)
		    option = 5;
		else if (argVal.compareToIgnoreCase("-pr")==0)
		    option = 6;
		else if (argVal.compareToIgnoreCase("-us")==0)
		    option = 7;
		else return;
	    }else if (option > 0){
		if (option ==1)
		    serviceLoc = argVal;
		else if (option ==2)
		    username = argVal;
		else if (option ==3)
		    host = argVal;
		else if (option ==4)
		    port = argVal;
		else if (option ==5)
		    commCertDN = argVal;
		else if (option ==6)
		    protocol = argVal;
		else if (option == 7)
		    loUS.add(argVal);
	    }
	    
	}
	
	FASBean fb = new FASBean();
	if (username != null){
	    fb.setUsername(username);
	}
	if (host != null){
	    fb.setHost(host);
	    }
	if (port != null){
	    fb.setPort(port);
	}
	if (commCertDN != null){
	    fb.setCommCertDN(commCertDN);
	}
	if (protocol != null){
	    fb.setProtocol(protocol);
	}
	if (loUS.size()>0){
	    String [] loUSArray = new String[loUS.size()];
	    for (int k = 0; k < loUS.size(); k++){
		loUSArray[k] = (String)loUS.get(k);
	    }
	    fb.setLogicalUserSpace(loUSArray);
	}
	
	System.out.println(fb.toString());
	RemoveUserSpace.removeDataSpaceInfo(serviceLoc, fb);
    }

    public static void removeDataSpaceInfo(String serviceLoc, FASBean removeBean){
	try{
	    System.out.println(removeBean.toString());
	    RPCServiceClient serviceClient = new RPCServiceClient();
	    
	    Options options = serviceClient.getOptions();
	    
	    EndpointReference targetEPR = new EndpointReference(serviceLoc);
	    
	    options.setTo(targetEPR);
	    
	    QName rem = new QName("http://fileagentservice.ogce.org", "removeDataSpaceInfo");
	    Object[] remArgs = new Object[] { removeBean };
	    
	    serviceClient.invokeRobust(rem, remArgs);
	}catch (Exception e){
	    e.printStackTrace();
	}
    }
    private static void usage(){
	System.out.println("Usage: RemoveUserSpace -f <FAS service location> "+
			   "-l <username> -h <host> -p <port> "+
			   "-dn <Distingushed Name of the community certificate> "+
			   "-pr <protocol> -us <user space>");
	return;
    }

 }
Web site tools