package edu.indiana.dde.catalog.catalogtester; import edu.indiana.dde.metadata.catalog.types.*; import edu.indiana.dde.catalog.catalogclient.*; /** * This small test program is for the Property Definition Query operation. See the * usage method or execute with --help as the only parameter. The only parameter is the * DN of the user making the request. * The results of this query are used to build the query interface dynamically. * * @author Scott Jensen scjensen@cs.indiana.edu * */ public class TestPropertyDefQuery extends TesterBase { public static void main(String[] args) throws Exception { int option = 0; String hostName = "localhost"; String portNum = "8080"; String myDn = null; String errorDelivery = "DIRECT"; String resultDelivery = "DIRECT"; 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 = 3; //distinguished name else if (argVal.compareToIgnoreCase("-rd") == 0) option = 1; //result delivery 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 == 3) myDn = argVal; else if (option == 4) hostName = argVal; else if (option == 5) portNum = argVal; else if (option == 1) { String priorMethod = resultDelivery; if (argVal.compareToIgnoreCase("STREAMING") == 0) resultDelivery = "STREAMING"; else if(argVal.compareToIgnoreCase("DIRECT") == 0) resultDelivery = "DIRECT"; else { resultDelivery = priorMethod; String msg = "The result delivery method specified (" + argVal + ") is not valid. Restored prior setting: " + priorMethod; System.out.println(msg); } } //end of result delivery 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); } }//end of error delivery option = 0; //reset } //end of option setting } //loop through parameters if (myDn == null) { usage(); return; } CatalogServiceStub stub = getStub(hostName, portNum, myDn); QueryPropertyDefinitionsRequestDocument doc = QueryPropertyDefinitionsRequestDocument.Factory.newInstance(); QueryPropertyDefinitionsRequestDocument.QueryPropertyDefinitionsRequest request = doc.addNewQueryPropertyDefinitionsRequest(); request.setResultDeliveryMethod(CatalogDeliveryType.Enum.forString(resultDelivery) ); request.setErrorDeliveryMethod(CatalogDeliveryType.Enum.forString(errorDelivery) ); System.out.println(doc.toString() ); //invoke service QueryPropertyDefinitionsResponseDocument myResponse = stub.queryPropertyDefinitions(doc); System.out.println(myResponse.getQueryPropertyDefinitionsResponse().getCatalogOperationStatus().getStatus().toString() ); System.out.println("\nResponse Document:\n******************\n" + myResponse.toString() ); stub.cleanup(); return; } //end of main private static void usage() { System.out.println("Usage: TestPropertyDefQuery -dn -rd -ed -h -p \n" + "Defaults:\n" + "results = DIRECT\n" + "errors = DIRECT\n" + "host = localhost\n" + "port = 8080\n" + "Result and Error Delivery Options: STREAMING, DIRECT"); return; } //end of usage } //end of TestPropertyDefQuery