private void initializeRemoteTargetDirectory() { JwFtpClient logFtpClient = null; try { logFtpClient = AcFtpClient.getLogFtpClient(); JwList<String> v = logFtpClient.getDirectoryNames(getTargetRootPath()); if (!v.contains(getLocalHostname())) logFtpClient.createDir(getTargetLogPath()); } finally { if (logFtpClient != null) logFtpClient.close(); } }
private JwList<String> getLocalFilenames(String path) { File f = new File(path); if (!f.exists()) return new JwList<String>(); JwList<String> v = new JwList<String>(); for (File e : f.listFiles()) { if (e.isFile()) v.add(e.getName()); } return v; }
public void run() { if (_currentLog == null) return; if (!isLogCopyEnabled()) return; initializeTargetDirectory(); JwList<String> sourceFilenames = getSourceLogFilenames(); if (sourceFilenames.isEmpty()) return; sourceFilenames.remove(_currentLog.getFilename()); JwList<String> targetFilenames = getTargetLogFilenames(); JwList<String> missingFilenames = getMissingFilenames(sourceFilenames, targetFilenames); copyMissingSourceLogsToTargetLogs(missingFilenames); }
private void copyMissingSourceLogsToTargetLogs(JwList<String> missingFilenames) { if (missingFilenames.isEmpty()) return; String targetPath = getTargetLogPath(); String sourcePath = getSourceLogPath(); if (isFtpEnabled()) ftpMissingLogs(missingFilenames, targetPath, sourcePath); else copyMissingLogs(missingFilenames, targetPath, sourcePath); }
private JwList<String> getMissingFilenames( JwList<String> sourceFilenames, JwList<String> targetFilenames) { JwList<String> v = new JwList<String>(); for (String e : sourceFilenames) if (!targetFilenames.contains(e)) v.add(e); return v; }