CommandException exc = null;
try {
/*
* First, synchronize the config directory.
*/
SyncRequest sr = getModTimes("config", SyncLevel.FILES);
synchronizeFiles(sr);
/*
* Was domain.xml updated?
* If not, we're all done.
*/
if (domainXml.lastModified() == dtime) {
if (logger.isLoggable(Level.FINE))
logger.fine(Strings.get("Sync.alreadySynced"));
if (!syncState.delete())
logger.warning(
Strings.get("Sync.cantDeleteSyncState", syncState));
/*
* Note that we earlier marked the token for reuse. It's OK
* to return immediately here with the DAS still willing to
* accept the same token again. The token will expire and be
* cleaned up in a little while and it was never exposed in a
* way that could be intercepted and used illicitly.
*/
return true;
}
/*
* Now synchronize the applications.
*/
sr = getModTimes("applications", SyncLevel.DIRECTORY);
synchronizeFiles(sr);
/*
* Did we get any archive files? If so,
* have to unzip them in the applications
* directory.
*/
File appsDir = new File(instanceDir, "applications");
File archiveDir = new File(appsDir, "__internal");
for (File adir : FileUtils.listFiles(archiveDir)) {
File[] af = FileUtils.listFiles(adir);
if (af.length != 1) {
if (logger.isLoggable(Level.FINER))
logger.finer("IGNORING " + adir + ", # files " +
af.length);
continue;
}
File archive = af[0];
File appDir = new File(appsDir, adir.getName());
if (logger.isLoggable(Level.FINER))
logger.finer("UNZIP " + archive + " TO " + appDir);
try {
expand(appDir, archive);
} catch (Exception ex) { }
}
FileUtils.whack(archiveDir);
/*
* Next, the libraries.
* We assume there's usually very few files in the
* "lib" directory so we check them all individually.
*/
sr = getModTimes("lib", SyncLevel.RECURSIVE);
synchronizeFiles(sr);
/*
* Next, the docroot.
* The docroot could be full of files, so we only check
* one level.
*/
sr = getModTimes("docroot", SyncLevel.DIRECTORY);
synchronizeFiles(sr);
/*
* Check any subdirectories of the instance config directory.
* We only expect one - the config-specific directory,
* but since we don't have an easy way of knowing the
* name of that directory, we include them all. The
* DAS will tell us to remove anything that shouldn't
* be there.
*/
sr = new SyncRequest();
sr.instance = instanceName;
sr.dir = "config-specific";
File configDir = new File(instanceDir, "config");
for (File f : configDir.listFiles()) {
if (!f.isDirectory())