Search in sources :

Example 6 with DomainConfig

use of com.sun.enterprise.admin.servermgmt.DomainConfig 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 7 with DomainConfig

use of com.sun.enterprise.admin.servermgmt.DomainConfig 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)

Example 8 with DomainConfig

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

the class TestDomainPortValidator method testForNullPorts.

@Test(expectedExceptions = DomainException.class)
public void testForNullPorts() throws Exception {
    DomainConfig domainConfig = new DomainConfig("test", null);
    domainConfig.add(DomainConfig.K_VALIDATE_PORTS, Boolean.TRUE);
    _portValidator = new DomainPortValidator(domainConfig, new Properties());
    _portValidator.validateAndSetPorts();
}
Also used : Properties(java.util.Properties) DomainConfig(com.sun.enterprise.admin.servermgmt.DomainConfig) Test(org.testng.annotations.Test)

Example 9 with DomainConfig

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

the class TestDomainPortValidator method testForPortValueZero.

@Test(expectedExceptions = DomainException.class)
public void testForPortValueZero() throws Exception {
    DomainConfig domainConfig = new DomainConfig("test", null);
    domainConfig.add(DomainConfig.K_VALIDATE_PORTS, Boolean.TRUE);
    domainConfig.add(DomainConfig.K_ADMIN_PORT, "0");
    _portValidator = new DomainPortValidator(domainConfig, new Properties());
    _portValidator.validateAndSetPorts();
}
Also used : Properties(java.util.Properties) DomainConfig(com.sun.enterprise.admin.servermgmt.DomainConfig) Test(org.testng.annotations.Test)

Example 10 with DomainConfig

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

the class TestDomainPortValidator method testForNegativePort.

@Test(expectedExceptions = DomainException.class)
public void testForNegativePort() throws Exception {
    DomainConfig domainConfig = new DomainConfig("test", null);
    domainConfig.add(DomainConfig.K_VALIDATE_PORTS, Boolean.TRUE);
    domainConfig.add(DomainConfig.K_ADMIN_PORT, "-2");
    _portValidator = new DomainPortValidator(domainConfig, new Properties());
    _portValidator.validateAndSetPorts();
}
Also used : Properties(java.util.Properties) DomainConfig(com.sun.enterprise.admin.servermgmt.DomainConfig) Test(org.testng.annotations.Test)

Aggregations

DomainConfig (com.sun.enterprise.admin.servermgmt.DomainConfig)10 PEDomainsManager (com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager)5 Properties (java.util.Properties)5 Test (org.testng.annotations.Test)5 DomainsManager (com.sun.enterprise.admin.servermgmt.DomainsManager)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 HostAndPort (com.sun.enterprise.util.HostAndPort)1 HashMap (java.util.HashMap)1 CommandException (org.glassfish.api.admin.CommandException)1