String loggingDir = getLoggingDirectoryForNode(instanceLogFileDirectory, node, sNode, instanceName);
try {
instanceLogFileNames = sftpClient.ls(loggingDir);
for (int i = 0; i < instanceLogFileNames.size(); i++) {
SFTPv3DirectoryEntry file = (SFTPv3DirectoryEntry) instanceLogFileNames.get(i);
String fileName = file.filename;
// code to remove . and .. file which is return from sftpclient ls method
if (!file.attributes.isDirectory() && !fileName.equals(".") && !fileName.equals("..")
&& fileName.contains(".log") && !fileName.contains(".log.")) {
instanceLogFileNamesAsString.add(fileName);
noFileFound = false;
}
}
} catch (Exception ex) {
// if directory doesn't present or missing on remote machine. It happens due to bug 16451
noFileFound = true;
}
if (noFileFound) {
// this loop is used when user has changed value for server.log but not restarted the server.
loggingDir = getLoggingDirectoryForNodeWhenNoFilesFound(instanceLogFileDirectory, node, sNode, instanceName);
instanceLogFileNames = sftpClient.ls(loggingDir);
for (int i = 0; i < instanceLogFileNames.size(); i++) {
SFTPv3DirectoryEntry file = (SFTPv3DirectoryEntry) instanceLogFileNames.get(i);
String fileName = file.filename;
// code to remove . and .. file which is return from sftpclient ls method
if (!file.attributes.isDirectory() && !fileName.equals(".") && !fileName.equals("..")
&& fileName.contains(".log") && !fileName.contains(".log.")) {
instanceLogFileNamesAsString.add(fileName);
}
}
}
sftpClient.close();
} else if (node.getType().equals("DCOM")) {
String loggingDir = getLoggingDirectoryForNode(instanceLogFileDirectory, node, sNode, instanceName);
try {
DcomInfo info = new DcomInfo(node);
WindowsRemoteFileSystem wrfs = new WindowsRemoteFileSystem(info.getHost(), info.getUser(), info.getPassword());
WindowsRemoteFile wrf = new WindowsRemoteFile(wrfs, loggingDir);
String[] allLogFileNames = wrf.list();
for (int i = 0; i < allLogFileNames.length; i++) {
File file = new File(allLogFileNames[i]);
String fileName = file.getName();
// code to remove . and .. file which is return
if (!fileName.equals(".") && !fileName.equals("..") && fileName.contains(".log")
&& !fileName.contains(".log.")) {
instanceLogFileNamesAsString.add(fileName);
}