} else if (targetServer != null && targetServer.isInstance()) {
// This loop if target standalone instance
String instanceName = targetServer.getName();
String serverNode = targetServer.getNodeRef();
Node node = domain.getNodes().getNode(serverNode);
String zipFile = "";
File targetDir = null;
String logFileDetails = "";
try {
// getting log file values from logging.propertie file.
logFileDetails = getInstanceLogFileDirectory(targetServer);
} catch (Exception ex) {
final String errorMsg = localStrings.getLocalString(
"collectlogfiles.errGettingLogFiles", "Error while getting log file attribute for {0}.", target);
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setMessage(errorMsg);
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
targetDir = makingDirectoryOnDas(targetServer.getName(), report);
try {
if (node.isLocal()) {
String sourceDir = getLogDirForLocalNode(logFileDetails, node, serverNode, instanceName);
copyLogFilesForLocalhost(sourceDir, targetDir.getAbsolutePath(), report, instanceName);
} else {
new LogFilterForInstance().downloadAllInstanceLogFiles(habitat, targetServer,
domain, logger, instanceName, targetDir.getAbsolutePath(), logFileDetails);
}
}
catch (Exception ex) {
final String errorMsg = localStrings.getLocalString(
"collectlogfiles.errInstanceDownloading", "Error while downloading log files from {0}.", instanceName);
report.setMessage(errorMsg);
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
try {
// Creating zip file and returning zip file absolute path.
zipFile = loggingConfig.createZipFile(getZipFilePath().getAbsolutePath());
if (zipFile == null || new File(zipFile) == null) {
// Failure during zip
final String errorMsg = localStrings.getLocalString(
"collectlogfiles.creatingZip", "Error while creating zip file {0}.", zipFile);
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setMessage(errorMsg);
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
}
catch (Exception ex) {
final String errorMsg = localStrings.getLocalString(
"collectlogfiles.creatingZip", "Error while creating zip file {0}.", zipFile);
report.setMessage(errorMsg);
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
if (this.retrieve) {
retrieveFile(zipFile, context, getZipFilePath(), props, report);
report.setMessage(localStrings.getLocalString(
"collectlogfiles.instance.success", "Created Zip file under {0}.", retrieveFilePath + File.separator + new File(zipFile).getName()));
} else {
report.setMessage(localStrings.getLocalString(
"collectlogfiles.instance.success", "Created Zip file under {0}.", zipFile));
}
} else {
// This loop if target is cluster
String finalMessage = "";
String zipFile = "";
File targetDir = null;
// code to download server.log file for DAS. Bug fix 16088
String logFileDetails = "";
try {
// getting log file values from logging.propertie file.
logFileDetails = loggingConfig.getLoggingFileDetails();
} catch (Exception ex) {
final String errorMsg = localStrings.getLocalString(
"collectlogfiles.errGettingLogFiles", "Error while getting log file attribute for {0}.", target);
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setMessage(errorMsg);
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
targetDir = makingDirectoryOnDas(SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME, report);
try {
String sourceDir = "";
if (logFileDetails.contains("${com.sun.aas.instanceRoot}/logs")) {
sourceDir = env.getDomainRoot() + File.separator + "logs";
} else {
sourceDir = logFileDetails.substring(0, logFileDetails.lastIndexOf(File.separator));
}
copyLogFilesForLocalhost(sourceDir, targetDir.getAbsolutePath(), report,
SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME);
} catch (Exception ex) {
final String errorMsg = localStrings.getLocalString(
"collectlogfiles.errInstanceDownloading", "Error while downloading log files from {0}.", target);
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setMessage(errorMsg);
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
/******************************************************/
com.sun.enterprise.config.serverbeans.Cluster cluster = domain.getClusterNamed(target);
List<Server> instances = cluster.getInstances();
int instanceCount = 0;
int errorCount = 0;
for (Server instance : instances) {
// downloading log files for all instances which is part of cluster under temp directory.
String instanceName = instance.getName();
String serverNode = instance.getNodeRef();
Node node = domain.getNodes().getNode(serverNode);
boolean errorOccur = false;
instanceCount++;
logFileDetails = "";
try {
// getting log file values from logging.propertie file.
logFileDetails = getInstanceLogFileDirectory(domain.getServerNamed(instanceName));
} catch (Exception ex) {
final String errorMsg = localStrings.getLocalString(
"collectlogfiles.errGettingLogFiles", "Error while getting log file attribute for {0}.", target);
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setMessage(errorMsg);
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
try {
targetDir = makingDirectoryOnDas(instanceName, report);
if (node.isLocal()) {
String sourceDir = getLogDirForLocalNode(logFileDetails, node, serverNode, instanceName);
copyLogFilesForLocalhost(sourceDir, targetDir.getAbsolutePath(), report, instanceName);
} else {
new LogFilterForInstance().downloadAllInstanceLogFiles(habitat, instance,
domain, logger, instanceName, targetDir.getAbsolutePath(), logFileDetails);