@Deprecated public synchronized boolean copy(String srcmachine, String destmachine,
String srcfile, String destfile,
boolean append) {
FileAgent srcf, destf = null;
FileService srcfilep = null, destfilep = null;
int sidx = machinesList.indexOf(srcmachine);
int didx = machinesList.indexOf(destmachine);
byte[] buf;
if (sidx == didx && srcfile.equals(destfile)) {
return (true);
}
if (srcfile.equals(destfile)) {
try {
String dest = cmdp.get(didx).getHostName();
String src = cmdp.get(sidx).getHostName();
if (dest == src) {
return true;
}
} catch (Exception e) {
logger.severe("CmdService: Copying - CmdAgent getHostName exception");
logger.log(Level.FINE, "Exception", e);
}
}
logger.fine("CmdService: Copying " + srcfile + " from " + srcmachine + " to " + destfile + " in " + destmachine);
srcf = filep.get(sidx);
destf = filep.get(didx);
try {
srcfilep = srcf.open(srcfile, FileAgent.READ);
if (append) {
destfilep = destf.open(destfile, FileAgent.APPEND);
} else {
destfilep = destf.open(destfile, FileAgent.WRITE);
}
// Read from src and write to dest.
buf = srcfilep.read();
destfilep.write(buf);
srcfilep.close();
destfilep.close();
} catch (Exception ie) {
logger.log(Level.WARNING, "CmdService: Could not copy " +
srcmachine + ":" + srcfile + " to " + destmachine + ":" +
destfile, ie);