public Vector getInstanceLogFileNames(ServiceLocator habitat, Server targetServer, Domain domain, Logger logger,
String instanceName, String instanceLogFileDirectory) throws IOException {
// helper method to get all log file names for given instance
String sNode = targetServer.getNodeRef();
Node node = domain.getNodes().getNode(sNode);
Vector instanceLogFileNames = null;
Vector instanceLogFileNamesAsString = new Vector();
// this code is used when DAS and instances are running on the same machine
if (node.isLocal()) {
String loggingDir = getLoggingDirectoryForNode(instanceLogFileDirectory, node, sNode, instanceName);
File logsDir = new File(loggingDir);
File allLogFileNames[] = logsDir.listFiles();
boolean noFileFound = true;
if (allLogFileNames != null) { // This check for, if directory doesn't present or missing on machine. It happens due to bug 16451
for (int i = 0; i < allLogFileNames.length; i++) {
File file = allLogFileNames[i];
String fileName = file.getName();
// code to remove . and .. file which is return
if (file.isFile() && !fileName.equals(".") && !fileName.equals("..") && fileName.contains(".log")
&& !fileName.contains(".log.")) {
instanceLogFileNamesAsString.add(fileName);
noFileFound = false;
}
}
}
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);
logsDir = new File(loggingDir);
allLogFileNames = logsDir.listFiles();
for (int i = 0; i < allLogFileNames.length; i++) {
File file = allLogFileNames[i];
String fileName = file.getName();
// code to remove . and .. file which is return
if (file.isFile() && !fileName.equals(".") && !fileName.equals("..") && fileName.contains(".log")
&& !fileName.contains(".log.")) {
instanceLogFileNamesAsString.add(fileName);
}
}
}
} else if (node.getType().equals("SSH")) {
// this code is used if DAS and instance are running on different machine
SSHLauncher sshL = getSSHL(habitat);
sshL.init(node, logger);
SFTPClient sftpClient = sshL.getSFTPClient();
boolean noFileFound = true;
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);