package edu.indiana.dde.catalog.catalogtester; import edu.indiana.dde.metadata.catalog.types.*; import edu.indiana.dde.catalog.catalogclient.*; public class TestWhiteboardId extends TesterBase { /** * @param args The only required argument is the DN of the user who's whiteboard * is being sought. The host and port can also be specified but are optional. * See the usage method or execute with --help as the only parameter. * * @author Scott Jensen scjensen@cs.indiana.edu */ public static void main(String[] args) throws Exception { String myDn = null; String hostName = "localhost"; String portNum = "8080"; String errorDelivery = "DIRECT"; int option = 0; for (int j = 0; j < args.length; j++) { String argVal = args[j]; if ( argVal.compareToIgnoreCase("--help") == 0 || argVal.compareToIgnoreCase("-help") == 0) { usage(); return; } else if (argVal.startsWith("-")) { if (argVal.compareToIgnoreCase("-dn") == 0) option = 1; //user DN else if (argVal.compareToIgnoreCase("-ed") == 0) option = 2; //error delivery else if (argVal.compareToIgnoreCase("-h") == 0) option = 4; //host name else if (argVal.compareToIgnoreCase("-p") == 0) option = 5; //port else //invalid option = 0; } else if (option > 0) { if (option == 1) myDn = argVal; else if (option == 4) hostName = argVal; else if (option == 5) portNum = argVal; else if (option == 2) { String priorMethod = errorDelivery; if (argVal.compareToIgnoreCase("STREAMING") == 0) errorDelivery = "STREAMING"; else if(argVal.compareToIgnoreCase("DIRECT") == 0) errorDelivery = "DIRECT"; else { errorDelivery = priorMethod; String msg = "The error delivery method specified (" + argVal + ") is not valid. Restored prior setting: " + priorMethod; System.out.println(msg); } } option = 0; //reset } //end of option setting } //loop through parameters if (myDn == null) { usage(); return; } CatalogServiceStub stub = getStub(hostName, portNum, myDn); //create the request WhiteboardIdRequestDocument doc = WhiteboardIdRequestDocument.Factory.newInstance(); WhiteboardIdRequestDocument.WhiteboardIdRequest request = doc.addNewWhiteboardIdRequest(); request.setErrorDeliveryMethod(CatalogDeliveryType.Enum.forString(errorDelivery) ); System.out.println("Request Document:\n" + doc.toString() ); //invoke service WhiteboardIdResponseDocument myResponse = stub.whiteboardId(doc); if (myResponse.getWhiteboardIdResponse().getCatalogOperationStatus().getStatus() == CatalogStatusType.Enum.forString("OPERATION_SUCCESSFUL") ) { String myWhiteboard = myResponse.getWhiteboardIdResponse().getObjectId(); System.out.println("The Whiteboard ID: " + myWhiteboard); } else { System.out.println(myResponse.getWhiteboardIdResponse().getCatalogOperationStatus().toString() ); } System.out.println("Response Doc:\n" + myResponse.toString() ); stub.cleanup(); } //end of main private static void usage() { System.out.println("Usage: TestWhiteboardId -dn -ed -h -p \n" + "Defaults:\n" + "errors = DIRECT\n" + "host = localhost\n" + "port = 8080\n" + "Error Delivery Options: STREAMING, DIRECT"); return; } //end of usage } //end of TestWhiteboardId class