Search in sources :

Example 1 with DomainsManager

use of com.sun.enterprise.admin.servermgmt.DomainsManager in project Payara by payara.

the class DeleteDomainCommand method executeCommand.

/**
 */
@Override
protected int executeCommand() throws CommandException, CommandValidationException {
    try {
        DomainConfig domainConfig = new DomainConfig(getDomainName(), getDomainsDir().getPath());
        checkRunning();
        checkRename();
        DomainsManager manager = new PEDomainsManager();
        manager.deleteDomain(domainConfig);
    // By default, do as what v2 does -- don't delete the entry -
    // might need a revisit (Kedar: 09/16/2009)
    // deleteLoginInfo();
    } catch (Exception e) {
        throw new CommandException(e.getLocalizedMessage());
    }
    logger.fine(strings.get("DomainDeleted", getDomainName()));
    return 0;
}
Also used : PEDomainsManager(com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager) DomainsManager(com.sun.enterprise.admin.servermgmt.DomainsManager) PEDomainsManager(com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager) IOException(java.io.IOException) DomainConfig(com.sun.enterprise.admin.servermgmt.DomainConfig)

Example 2 with DomainsManager

use of com.sun.enterprise.admin.servermgmt.DomainsManager in project Payara by payara.

the class ListDomainsCommand method getDomains.

/**
 * Get a list of domains and their status
 * @return Map<String, Boolean> of domain and status
 * @throws IOException
 * @throws DomainException
 * @throws CommandException
 */
protected Map<String, Boolean> getDomains() throws IOException, DomainException, CommandException {
    Map<String, Boolean> runningDomains = new HashMap<>();
    File domainsDirFile = ok(domainDirParam) ? new File(domainDirParam) : DomainDirs.getDefaultDomainsDir();
    DomainConfig domainConfig = new DomainConfig(null, domainsDirFile.getAbsolutePath());
    DomainsManager manager = new PEDomainsManager();
    String[] domainsList = manager.listDomains(domainConfig);
    // no prompting for passwords
    programOpts.setInteractive(false);
    for (String domain : domainsList) {
        runningDomains.put(domain, getStatus(domain).status);
    }
    return runningDomains;
}
Also used : HashMap(java.util.HashMap) PEDomainsManager(com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager) DomainsManager(com.sun.enterprise.admin.servermgmt.DomainsManager) File(java.io.File) PEDomainsManager(com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager) DomainConfig(com.sun.enterprise.admin.servermgmt.DomainConfig)

Example 3 with DomainsManager

use of com.sun.enterprise.admin.servermgmt.DomainsManager in project Payara by payara.

the class ListDomainsCommand method executeCommand.

@Override
protected int executeCommand() throws CommandException, CommandValidationException {
    try {
        File domainsDirFile = ok(domainDirParam) ? new File(domainDirParam) : DomainDirs.getDefaultDomainsDir();
        DomainConfig domainConfig = new DomainConfig(null, domainsDirFile.getAbsolutePath());
        DomainsManager manager = new PEDomainsManager();
        String[] domainsList = manager.listDomains(domainConfig);
        // no prompting for passwords
        programOpts.setInteractive(false);
        if (domainsList.length > 0) {
            if (longOpt) {
                String[] headings = { "DOMAIN", "ADMIN_HOST", "ADMIN_PORT", "RUNNING", "RESTART_REQUIRED" };
                ColumnFormatter cf = header ? new ColumnFormatter(headings) : new ColumnFormatter();
                for (String dn : domainsList) {
                    DomainInfo di = getStatus(dn);
                    cf.addRow(new Object[] { dn, di.adminAddr.getHost(), di.adminAddr.getPort(), di.status, di.restartRequired });
                }
                logger.info(cf.toString());
            } else {
                for (String dn : domainsList) {
                    logger.info(getStatus(dn).statusMsg);
                }
            }
        } else {
            logger.fine(STRINGS.get("NoDomainsToList"));
        }
    } catch (Exception ex) {
        throw new CommandException(ex.getLocalizedMessage());
    }
    return 0;
}
Also used : PEDomainsManager(com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager) DomainsManager(com.sun.enterprise.admin.servermgmt.DomainsManager) File(java.io.File) PEDomainsManager(com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager) ColumnFormatter(com.sun.enterprise.util.ColumnFormatter) IOException(java.io.IOException) DomainException(com.sun.enterprise.admin.servermgmt.DomainException) DomainConfig(com.sun.enterprise.admin.servermgmt.DomainConfig)

Example 4 with DomainsManager

use of com.sun.enterprise.admin.servermgmt.DomainsManager in project Payara by payara.

the class StopAllDomainsCommand method getDomains.

// Copied from ListDomainCommand.java
private String[] getDomains() throws DomainException, IOException {
    File domainsDirFile = ok(domainDirParam) ? new File(domainDirParam) : DomainDirs.getDefaultDomainsDir();
    DomainConfig domainConfig = new DomainConfig(null, domainsDirFile.getAbsolutePath());
    DomainsManager manager = new PEDomainsManager();
    String[] domainsList = manager.listDomains(domainConfig);
    if (domainsList.length == 0) {
        logger.fine(strings.get("NoDomainsToList"));
    }
    return domainsList;
}
Also used : PEDomainsManager(com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager) DomainsManager(com.sun.enterprise.admin.servermgmt.DomainsManager) File(java.io.File) PEDomainsManager(com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager) DomainConfig(com.sun.enterprise.admin.servermgmt.DomainConfig)

Aggregations

DomainConfig (com.sun.enterprise.admin.servermgmt.DomainConfig)4 DomainsManager (com.sun.enterprise.admin.servermgmt.DomainsManager)4 PEDomainsManager (com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager)4 File (java.io.File)3 IOException (java.io.IOException)2 DomainException (com.sun.enterprise.admin.servermgmt.DomainException)1 ColumnFormatter (com.sun.enterprise.util.ColumnFormatter)1 HashMap (java.util.HashMap)1