PrintStream debug)
throws ExecutionProblem {
String identityAuthorization = this.args.getGridftpID();
String delUrlString = this.getRemoteUserBaseURLString() + vmName;
final GlobusURL delURL;
try {
delURL = new GlobusURL(delUrlString);
} catch (Exception e) {
throw new ExecutionProblem("Problem constructing delete URL: " +
e.getMessage());
}
final GridFTPClient ftp;
try {
ftp = new GridFTPClient(delURL.getHost(), delURL.getPort());
} catch (Exception e) {
throw new ExecutionProblem("Problem constructing GridFTPClient: " +
e.getMessage());
}
final Authorization auth;
if (identityAuthorization == null) {
auth = HostAuthorization.getInstance();
if (debug != null) {
debug.println(
"Using host-based authorization of remote server");
}
} else {
auth = new IdentityAuthorization(identityAuthorization);
if (debug != null) {
debug.println("Using identity-based authorization of remote " +
"server: '" + identityAuthorization + "'");
}
}
ftp.setAuthorization(auth);
PrintStream pr = null;
if (info != null) {
pr = info;
} else if (debug != null) {
pr = debug;
}
if (pr != null) {
pr.println("\nDeleting: " + delUrlString);
pr.println();
}
try {
ftp.authenticate(null);
ftp.deleteFile(delURL.getPath());
} catch (IOException e) {
throw new ExecutionProblem(e.getMessage(), e);
} catch (ServerException e) {
throw new ExecutionProblem(e.getMessage(), e);
}