// disallow backup & restore if server is running. list-backups is OK anytime...
if(command == CmdType.BACKUP || command == CmdType.RESTORE)
{
if(!isNotRunning())
{
throw new CommandValidationException(getLocalizedString("DomainIsNotStopped",
new String[] {command.name} ));
}
}
// make sure we have a domainsDir
if(domainsDir == null || domainsDir.length() <= 0)
{
throw new CommandValidationException(getLocalizedString("InvalidDomainPath",
new String[] {domainsDir}) );
}
File domainsDirFile = new File(domainsDir);
// make sure domainsDir exists and is a directory
if(!domainsDirFile.isDirectory())
{
throw new CommandValidationException(getLocalizedString("InvalidDomainPath",
new String[] {domainsDir}) );
}
File domainFile = new File(domainsDirFile, domainName);
// BACKUP, LIST: make sure the domain dir exists and is
// a directory and is writable
// RESTORE: It must exist if backupFilename isn't set.
boolean domainDirDoesNotHaveToExist =
(command == CmdType.RESTORE) && backupFilename != null;
if(!domainDirDoesNotHaveToExist)
{
if(!domainFile.isDirectory() || !domainFile.canWrite())
{
throw new CommandValidationException(getLocalizedString("InvalidDirectory",
new String[] {domainFile.getPath()}) );
}
}
if(backupFilename != null)
{
File f = new File(backupFilename);
if(!f.exists() || !f.canRead())
{
throw new CommandValidationException(getLocalizedString("FileDoesNotExist",
new String[] { backupFilename } ));
}
}
}