} // main() /* **************************************************************************** * process() **************************************************************************** */ /** * Executes the xritracert command as indicated by the input args. See * outputUsage for the forms of invocation and details about the program * arguments. * * @param sArgs - command line arguments (e.g., from main) * @param sOutput - program output (e.g., for stdout) * * @return SUCCESS or FAILURE */ public int process(StringBuilder sOutput, String[] sArgs) { try { // re-initialize variables so this may be called more than once sOutput.setLength(0); msTargetXRI = null; mbIsVerbose = false; mbDontOutputHeader = false; msRootEqualsURI = ROOT_DEF_URI; msRootAtURI = ROOT_DEF_URI; // exit with message if no arguments passed on the command line if (sArgs.length == 0) { outputPleaseTypeHelp(sOutput); return FAILURE; } // this is the "help" form of invocation (usage 2) if (sArgs[0].equalsIgnoreCase(CMD_HELP)) { outputUsage(sOutput); return SUCCESS; } // from here on, we're dealing with the "normal" form of invocation // (usage 1). // scan the args, setting member variables for options, rootURI, // and resolve XRI int iResult = scanArgs(sOutput, sArgs); if (iResult == FAILURE) { return FAILURE; } // validate that the root uris are ok iResult = validateRootURIs(sOutput); if (iResult == FAILURE) { return FAILURE; } // create and configure a resolver Resolver resolver = new Resolver(); XRD eqRoot = new XRD(); Service eqAuthService = new Service(); eqAuthService.addMediaType(Tags.CONTENT_TYPE_XRDS + ";trust=none"); eqAuthService.addType(Tags.SERVICE_AUTH_RES); eqAuthService.addURI(msRootEqualsURI); eqRoot.addService(eqAuthService); XRD atRoot = new XRD(); Service atAuthService = new Service(); atAuthService.addMediaType(Tags.CONTENT_TYPE_XRDS + ";trust=none"); atAuthService.addType(Tags.SERVICE_AUTH_RES); atAuthService.addURI(msRootAtURI); atRoot.addService(atAuthService); resolver.setAuthority("=", eqRoot); resolver.setAuthority("@", atRoot); // invoke the tracert tracert(sOutput, resolver); } catch (Throwable oThrowable) { outputException(sOutput, oThrowable); return FAILURE; } return SUCCESS; }