Search in sources :

Example 1 with DomainBuilder

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

the class CreateDomainCommand method createTheDomain.

/**
 * Create the domain.
 *
 * @param domainPath domain path to insert in domainConfig
 * @param domainProperties properties to insert in domainConfig
 * @throws CommandException if domain cannot be created
 */
private void createTheDomain(final String domainPath, Properties domainProperties) throws DomainException, CommandValidationException {
    // 
    // fix for bug# 4930684
    // domain name is validated before the ports
    // 
    String domainFilePath = (domainPath + File.separator + domainName);
    if (FileUtils.safeGetCanonicalFile(new File(domainFilePath)).exists()) {
        throw new CommandValidationException(strings.get("DomainExists", domainName));
    }
    DomainConfig domainConfig = null;
    if (template == null || template.endsWith(".jar")) {
        domainConfig = new DomainConfig(domainName, domainPath, adminUser, adminPassword, masterPassword, saveMasterPassword, adminPort, instancePort, domainProperties);
        domainConfig.put(DomainConfig.K_VALIDATE_PORTS, Boolean.valueOf(checkPorts));
        domainConfig.put(DomainConfig.KEYTOOLOPTIONS, keytoolOptions);
        domainConfig.put(DomainConfig.K_TEMPLATE_NAME, template);
        domainConfig.put(DomainConfig.K_PORTBASE, portBase);
        domainConfig.put(DomainConfig.K_INITIAL_ADMIN_USER_GROUPS, Version.getInitialAdminGroups());
        initSecureAdminSettings(domainConfig);
        try {
            DomainBuilder domainBuilder = new DomainBuilder(domainConfig);
            domainBuilder.validateTemplate();
            domainBuilder.run();
        } catch (Exception e) {
            throw new DomainException(e.getMessage());
        }
    } else {
        throw new DomainException(strings.get("InvalidTemplateValue", template));
    }
    logger.info(strings.get("DomainCreated", domainName));
    Integer aPort = (Integer) domainConfig.get(DomainConfig.K_ADMIN_PORT);
    logger.info(strings.get("DomainPort", domainName, Integer.toString(aPort)));
    if (adminPassword != null && adminPassword.equals(SystemPropertyConstants.DEFAULT_ADMIN_PASSWORD)) {
        logger.info(strings.get("DomainAllowsUnauth", domainName, adminUser));
    } else {
        logger.info(strings.get("DomainAdminUser", domainName, adminUser));
    }
    // checkAsadminPrefsFile();
    if (saveLoginOpt) {
        saveLogin(aPort, adminUser, adminPassword != null ? adminPassword.toCharArray() : null, domainName);
    }
}
Also used : DomainBuilder(com.sun.enterprise.admin.servermgmt.domain.DomainBuilder) CommandValidationException(org.glassfish.api.admin.CommandValidationException) File(java.io.File) CommandException(org.glassfish.api.admin.CommandException) CommandValidationException(org.glassfish.api.admin.CommandValidationException)

Aggregations

DomainBuilder (com.sun.enterprise.admin.servermgmt.domain.DomainBuilder)1 File (java.io.File)1 CommandException (org.glassfish.api.admin.CommandException)1 CommandValidationException (org.glassfish.api.admin.CommandValidationException)1