package edu.indiana.dde.catalog.catalogtester; import edu.indiana.dde.metadata.catalog.types.*; import edu.indiana.dde.catalog.catalogclient.*; /** * This test is used to move one object within a user's workspace under a new * parent in that workspace. Any subtree of objects under the object being moved * are also moved. * @author Scott Jensen scjensen@cs.indiana.edu * */ public class TestMoveObject extends TesterBase { /** * @param args */ public static void main(String[] args) throws Exception{ int option = 0; String objectGuid = null; String newParentGuid = null; String hostName = "localhost"; String portNum = "8080"; String myDn = null; String errorDelivery = "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("-g") == 0) option = 1; //object GUID else if (argVal.compareToIgnoreCase("-pg") == 0) option = 2; //new parent guid else if (argVal.compareToIgnoreCase("-dn") == 0) option = 3; //distinguished name else if (argVal.compareToIgnoreCase("-h") == 0) option = 4; //host name else if (argVal.compareToIgnoreCase("-p") == 0) option = 5; //port else if (argVal.compareToIgnoreCase("-ed") == 0) option = 6; // Error Delivery else //invalid option = 0; } else if (option > 0) { if (option == 1) objectGuid = argVal; else if (option == 2) newParentGuid = argVal; else if (option == 3) myDn = argVal; else if (option == 4) hostName = argVal; else if (option == 5) portNum = argVal; else if (option == 6) { 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 (objectGuid == null || newParentGuid == null || myDn == null) { usage(); return; } CatalogServiceStub stub = getStub(hostName, portNum, myDn); MoveObjectRequestDocument doc = MoveObjectRequestDocument.Factory.newInstance(); MoveObjectRequestDocument.MoveObjectRequest request = doc.addNewMoveObjectRequest(); request.setErrorDeliveryMethod(CatalogDeliveryType.Enum.forString(errorDelivery) ); request.setObjectId(objectGuid); request.setParentId(newParentGuid); System.out.println(doc.toString() ); //invoke service MoveObjectResponseDocument myResponse = stub.moveObject(doc); System.out.println(myResponse.getMoveObjectResponse().getCatalogOperationStatus().getStatus().toString() ); System.out.println("\nResponse Document:\n******************\n" + myResponse.toString() ); if (myResponse.validate() ) System.out.println("Valid"); else System.out.println("Sorry Charlie - Not Valid"); stub.cleanup(); return; } //end of main private static void usage() { System.out.println("Usage: TestMoveObject -g -pg -dn -ed -h -p \n" + "Defaults:\n" + "ed = DIRECT\n" + "host = localhost\n" + "port = 8080"); return; } //end of usage } //end of class