public boolean backupFiles() throws FileNotFoundException, IOException
{
boolean result = true;
sendBackupStarted(_changeList.size());
FileWrapper localReleaseFile = _util.getLocalReleaseFile();
_util.copyFile(localReleaseFile, _util.getBackupDir());
for (ArtifactStatus status : _changeList)
{
String artifactName = status.getName();
sendFileBackupStarted(artifactName);
// Skip files that are not installed - new files
if (!status.isInstalled())
{
if (s_log.isInfoEnabled())
{
s_log.info("Skipping backup of artifact (" + status + ") which isn't installed.");
}
sendFileBackupComplete(artifactName);
continue;
}
if (status.isCoreArtifact())
{
FileWrapper installDir = getCoreArtifactLocation(artifactName, installRootDir, coreInstallDir);
FileWrapper coreFile = _util.getFile(installDir, artifactName);
FileWrapper backupFile = _util.getFile(coreBackupDir, artifactName);
_util.copyFile(coreFile, backupFile);
}
if (status.isPluginArtifact())
{
// artifact name for plugins is <plugin internal name>.zip
FileWrapper pluginBackupFile = _util.getFile(pluginBackupDir, artifactName);
String pluginDirectory = artifactName.replace(".zip", "");
String pluginJarFilename = artifactName.replace(".zip", ".jar");
ArrayList<FileWrapper> filesToZip = new ArrayList<FileWrapper>();
FileWrapper pluginDirectoryFile = _util.getFile(pluginInstallDir, pluginDirectory);
if (pluginDirectoryFile.exists())
{
filesToZip.add(pluginDirectoryFile);
}
FileWrapper pluginJarFile = _util.getFile(pluginInstallDir, pluginJarFilename);
if (pluginJarFile.exists())
{
filesToZip.add(pluginJarFile);
}
if (filesToZip.size() > 0)
{
_util.createZipFile(pluginBackupFile, filesToZip.toArray(new FileWrapper[filesToZip.size()]));
}
else
{
s_log.error("Plugin (" + status.getName() + ") was listed as already installed, but it's "
+ "files didn't exist and couldn't be backed up: pluginDirectoryFile="
+ pluginDirectoryFile.getAbsolutePath() + " pluginJarFile="
+ pluginJarFile.getAbsolutePath());
}
}
if (status.isTranslationArtifact())
{
FileWrapper translationFile = _util.getFile(i18nInstallDir, artifactName);
FileWrapper backupFile = _util.getFile(translationBackupDir, artifactName);
if (translationFile.exists())
{
_util.copyFile(translationFile, backupFile);
}
}