use of org.glassfish.api.admin.CommandValidationException in project Payara by payara.
the class CreateLocalInstanceCommand method validateNodeInstallDirLocal.
private void validateNodeInstallDirLocal(String nodeInstallDir, String installDir) throws CommandValidationException {
String canonicalNodeInstallDir = FileUtils.safeGetCanonicalPath(new File(nodeInstallDir));
String canonicalInstallDir = FileUtils.safeGetCanonicalPath(new File(installDir));
if (canonicalNodeInstallDir == null || canonicalInstallDir == null) {
throw new CommandValidationException(Strings.get("Instance.installdir.null", node, canonicalInstallDir, canonicalNodeInstallDir));
}
if (!canonicalInstallDir.equals(canonicalNodeInstallDir)) {
throw new CommandValidationException(Strings.get("Instance.installdir.mismatch", node, canonicalInstallDir, canonicalNodeInstallDir));
}
}
use of org.glassfish.api.admin.CommandValidationException in project Payara by payara.
the class RestoreDomainCommand method initRequest.
private void initRequest() throws CommandValidationException {
File backupdir_f = null;
if (backupdir != null) {
backupdir_f = new File(backupdir);
if (!backupdir_f.isAbsolute()) {
throw new CommandValidationException(strings.get("InvalidBackupDirPath", backupdir));
}
}
boolean configonlybackup = false;
if ((configonly != null) && (Boolean.valueOf(configonly))) {
configonlybackup = true;
}
request = new BackupRequest(domainDirParam, domainName, backupdir_f, backupConfig, backupFilename, configonlybackup);
request.setTerse(programOpts.isTerse());
request.setVerbose(verbose);
request.setForce(force);
}
use of org.glassfish.api.admin.CommandValidationException in project Payara by payara.
the class RestoreDomainCommand method validate.
/**
*/
@Override
protected void validate() throws CommandException, CommandValidationException {
boolean domainExists = true;
if (backupFilename == null && domainName == null) {
if (!force) {
throw new CommandException(strings.get("UseForceOption"));
}
// this will properly initialize the domain dir
// see LocalDomainCommand.initDomain())
super.validate();
}
checkOptions();
try {
setDomainName(domainName);
initDomain();
} catch (CommandException e) {
if (e.getCause() != null && (e.getCause() instanceof java.io.IOException)) {
// The domain does not exist which is allowed if the
// force option is used (checked later).
domainExists = false;
} else {
throw e;
}
}
if (domainExists && isRunning()) {
throw new CommandException(strings.get("DomainIsNotStopped", domainName));
}
if (backupFilename != null) {
File f = new File(backupFilename);
if (!f.exists()) {
throw new CommandValidationException(strings.get("FileDoesNotExist", backupFilename));
}
if (!f.canRead()) {
throw new CommandValidationException(strings.get("FileCanNotRead", backupFilename));
}
if (f.isDirectory()) {
throw new CommandValidationException(strings.get("FileIsDirectory", backupFilename));
}
}
setBackupDir(backupdir);
initRequest();
// in case program options changed
initializeLogger();
}
use of org.glassfish.api.admin.CommandValidationException in project Payara by payara.
the class StopDatabaseCommand method executeCommand.
/**
* Executes the command
*
* @throws CommandException
*/
@Override
protected int executeCommand() throws CommandException, CommandValidationException {
try {
prepareProcessExecutor();
CLIProcessExecutor cpe = new CLIProcessExecutor();
cpe.execute("pingDatabaseCmd", pingDatabaseCmd(false), true);
if (cpe.exitValue() > 0) {
// if ping is unsuccesfull then database is not up and running
throw new CommandException(strings.get("StopDatabaseStatus", dbHost, dbPort));
} else if (cpe.exitValue() < 0) {
// Something terribly wrong!
throw new CommandException(strings.get("UnableToStopDatabase", dbManager.getLogFileName()));
} else {
// Database is running so go ahead and stop the database
cpe.execute("stopDatabaseCmd", stopDatabaseCmd(), true);
if (cpe.exitValue() > 0) {
throw new CommandException(strings.get("UnableToStopDatabase", dbManager.getLogFileName()));
}
}
} catch (Exception e) {
throw new CommandException(strings.get("UnableToStopDatabase", dbManager.getLogFileName()), e);
}
return 0;
}
Aggregations