Search in sources :

Example 51 with CommandException

use of org.glassfish.api.admin.CommandException in project Payara by payara.

the class CreateLocalInstanceCommand method isRegisteredToDAS.

private boolean isRegisteredToDAS() {
    boolean isRegistered = false;
    try {
        RemoteCLICommand rc = new RemoteCLICommand("get", this.programOpts, this.env);
        rc.executeAndReturnOutput("get", INSTANCE_DOTTED_NAME);
        isRegistered = true;
    } catch (CommandException ex) {
        logger.log(Level.FINER, "{0} is not yet registered to DAS.", instanceName);
        isRegistered = false;
    }
    return isRegistered;
}
Also used : CommandException(org.glassfish.api.admin.CommandException) RemoteCLICommand(com.sun.enterprise.admin.cli.remote.RemoteCLICommand)

Example 52 with CommandException

use of org.glassfish.api.admin.CommandException in project Payara by payara.

the class InstallNodeBaseCommand method executeCommand.

@Override
protected int executeCommand() throws CommandException {
    File zipFile = null;
    try {
        ArrayList<String> binDirFiles = new ArrayList<String>();
        precopy();
        zipFile = createZipFileIfNeeded(binDirFiles);
        copyToHosts(zipFile, binDirFiles);
    } catch (CommandException e) {
        throw e;
    } catch (Exception e) {
        throw new CommandException(e);
    } finally {
        if (!save && delete) {
            if (zipFile != null) {
                if (!zipFile.delete())
                    zipFile.deleteOnExit();
            }
        }
    }
    return SUCCESS;
}
Also used : ArrayList(java.util.ArrayList) CommandException(org.glassfish.api.admin.CommandException) File(java.io.File) SmartFile(com.sun.enterprise.universal.io.SmartFile) IOException(java.io.IOException) CommandException(org.glassfish.api.admin.CommandException) ZipFileException(com.sun.enterprise.util.zip.ZipFileException)

Example 53 with CommandException

use of org.glassfish.api.admin.CommandException in project Payara by payara.

the class InstallNodeDcomCommand method precopy.

/**
 * bnevins: This is exclusively a "user-performance" enhancement.
 * We are forcing the failure
 * to happen before the very very slow zipfile creation.
 * FAIL FAST principle
 * This adds a bit of extra overhead to the command...
 * Note that allowing multiple hosts makes things MUCH more complicated.
 * @throws WindowsException
 */
@Override
final void precopy() throws CommandException {
    remoteInstallDirString = getInstallDir().replace('/', '\\');
    try {
        for (String host : hosts) {
            String remotePassword = getWindowsPassword(host);
            passwords.add(new HostAndPassword(host, remotePassword));
            if (!getForce()) {
                WindowsRemoteFileSystem wrfs = new WindowsRemoteFileSystem(host, getRemoteUser(), remotePassword);
                WindowsRemoteFile remoteInstallDir = new WindowsRemoteFile(wrfs, remoteInstallDirString);
                if (remoteInstallDir.exists())
                    throw new CommandException(Strings.get("install.dir.exists", remoteInstallDir));
            }
        }
    } catch (WindowsException ex) {
        throw new CommandException(ex);
    }
}
Also used : WindowsRemoteFile(com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFile) WindowsRemoteFileSystem(com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFileSystem) CommandException(org.glassfish.api.admin.CommandException) WindowsException(com.sun.enterprise.util.cluster.windows.process.WindowsException)

Example 54 with CommandException

use of org.glassfish.api.admin.CommandException in project Payara by payara.

the class UninstallNodeDcomCommand method deleteFromHosts.

@Override
final void deleteFromHosts() throws CommandException {
    for (String host : hosts) {
        try {
            String pw = getWindowsPassword(host);
            WindowsRemoteFileSystem wrfs = new WindowsRemoteFileSystem(host, getRemoteUser(), pw);
            WindowsRemoteFile remoteInstallDir = new WindowsRemoteFile(wrfs, getInstallDir());
            if (!remoteInstallDir.exists()) {
                throw new CommandException(Strings.get("remote.install.dir.already.gone", getInstallDir()));
            }
            remoteInstallDir.delete();
            // make sure it's gone now...
            if (remoteInstallDir.exists()) {
                throw new CommandException(Strings.get("remote.install.dir.cant.delete", getInstallDir()));
            }
        } catch (CommandException ce) {
            throw ce;
        } catch (Exception e) {
            throw new CommandException(e);
        }
    }
}
Also used : WindowsRemoteFile(com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFile) WindowsRemoteFileSystem(com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFileSystem) CommandException(org.glassfish.api.admin.CommandException) CommandException(org.glassfish.api.admin.CommandException)

Example 55 with CommandException

use of org.glassfish.api.admin.CommandException in project Payara by payara.

the class RestartDomainsCommand method executeCommand.

@Override
protected int executeCommand() throws CommandException {
    try {
        String[] domains = userArgDomainName.split(",");
        for (String domainName : domains) {
            setDomainName(domainName);
            super.executeCommand();
            logger.fine("Restarted domain " + domainName);
        }
        return 0;
    } catch (Exception ex) {
        throw new CommandException(ex.getLocalizedMessage());
    }
}
Also used : CommandException(org.glassfish.api.admin.CommandException) CommandException(org.glassfish.api.admin.CommandException) CommandValidationException(org.glassfish.api.admin.CommandValidationException)

Aggregations

CommandException (org.glassfish.api.admin.CommandException)61 File (java.io.File)20 CommandValidationException (org.glassfish.api.admin.CommandValidationException)16 IOException (java.io.IOException)13 ParameterMap (org.glassfish.api.admin.ParameterMap)11 InvalidCommandException (org.glassfish.api.admin.InvalidCommandException)10 ActionReport (org.glassfish.api.ActionReport)9 ArrayList (java.util.ArrayList)6 RemoteCLICommand (com.sun.enterprise.admin.cli.remote.RemoteCLICommand)5 MiniXmlParserException (com.sun.enterprise.universal.xml.MiniXmlParserException)5 HostAndPort (com.sun.enterprise.util.HostAndPort)4 BackupException (com.sun.enterprise.backup.BackupException)3 BackupWarningException (com.sun.enterprise.backup.BackupWarningException)3 SmartFile (com.sun.enterprise.universal.io.SmartFile)3 FileNotFoundException (java.io.FileNotFoundException)3 UnknownHostException (java.net.UnknownHostException)3 Logger (java.util.logging.Logger)3 SFTPClient (org.glassfish.cluster.ssh.sftp.SFTPClient)3 CLIProcessExecutor (com.sun.enterprise.admin.cli.CLIProcessExecutor)2 PEDomainsManager (com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager)2