Search in sources :

Example 1 with RepositoryConfig

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

the class ChangeNodeMasterPasswordCommand method encryptKeystore.

/*
     * This will encrypt the keystore
     */
public void encryptKeystore(String f) throws CommandException {
    RepositoryConfig nodeConfig = new RepositoryConfig(f, new File(nodeDir, node).toString(), f);
    NodeKeystoreManager km = new NodeKeystoreManager();
    try {
        km.encryptKeystore(nodeConfig, oldPassword, newPassword);
    } catch (Exception e) {
        throw new CommandException(strings.get("Keystore.not.encrypted"), e);
    }
}
Also used : RepositoryConfig(com.sun.enterprise.admin.servermgmt.RepositoryConfig) NodeKeystoreManager(com.sun.enterprise.admin.servermgmt.NodeKeystoreManager) CommandException(org.glassfish.api.admin.CommandException) File(java.io.File) MiniXmlParserException(com.sun.enterprise.universal.xml.MiniXmlParserException) CommandException(org.glassfish.api.admin.CommandException)

Example 2 with RepositoryConfig

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

the class UpgradeLogging method doUpgrade.

private void doUpgrade(Config config) {
    // v3 uses logging.properties to configure the logging facility.
    // move all log-service elements to logging.properties
    final LogService logService = config.getLogService();
    // check if null and exit
    if (logService == null)
        return;
    try {
        RepositoryConfig rc = new RepositoryConfig();
        String configDir = rc.getRepositoryRoot() + File.separator + rc.getRepositoryName() + File.separator + rc.getInstanceName() + File.separator + "config";
        PEFileLayout layout = new PEFileLayout(rc);
        File src = new File(layout.getTemplatesDir(), PEFileLayout.LOGGING_PROPERTIES_FILE);
        File dest = new File(configDir, PEFileLayout.LOGGING_PROPERTIES_FILE);
        if (!dest.exists())
            FileUtils.copy(src, dest);
    } catch (IOException ioe) {
        getLogger().log(Level.SEVERE, FAIL_CREATE_LOG_PROPS, ioe);
    }
    try {
        // Get the logLevels
        ModuleLogLevels mll = logService.getModuleLogLevels();
        Map<String, String> logLevels = mll.getAllLogLevels();
        String file = logService.getFile();
        String payaraNotificationFile = logService.getPayaraNotificationFile();
        String instanceRoot = System.getProperty("com.sun.aas.instanceRoot");
        if (file.contains(instanceRoot)) {
            file = file.replace(instanceRoot, "${com.sun.aas.instanceRoot}");
        }
        if (payaraNotificationFile.contains(instanceRoot)) {
            payaraNotificationFile = payaraNotificationFile.replace(instanceRoot, "${com.sun.aas.instanceRoot}");
        }
        logLevels.put("file", file);
        logLevels.put("payara-notification-file", payaraNotificationFile);
        logLevels.put("use-system-logging", logService.getUseSystemLogging());
        // this can have multiple values so need to add
        logLevels.put("log-handler", logService.getLogHandler());
        logLevels.put("log-filter", logService.getLogFilter());
        logLevels.put("log-to-file", logService.getLogToFile());
        logLevels.put("payara-notification-log-to-file", logService.getPayaraNotificationLogToFile());
        logLevels.put("log-to-console", logService.getLogToConsole());
        logLevels.put("log-rotation-limit-in-bytes", logService.getLogRotationLimitInBytes());
        logLevels.put("fast-logging", logService.getFastLogging());
        logLevels.put("payara-notification-log-rotation-limit-in-bytes", logService.getPayaraNotificationLogRotationLimitInBytes());
        logLevels.put("log-rotation-timelimit-in-minutes", logService.getLogRotationTimelimitInMinutes());
        logLevels.put("payara-notification-log-rotation-timelimit-in-minutes", logService.getPayaraNotificationLogRotationTimelimitInMinutes());
        logLevels.put("alarms", logService.getAlarms());
        logLevels.put("retain-error-statistics-for-hours", logService.getRetainErrorStatisticsForHours());
        logLevels.put("log-standard-streams", logService.getLogStandardStreams());
        final Map<String, String> m = new HashMap<String, String>(logLevels);
        ConfigSupport.apply(new SingleConfigCode<Config>() {

            @Override
            public Object run(Config c) throws PropertyVetoException, TransactionFailure {
                try {
                    // update logging.properties
                    logConfig.setLoggingProperties(m);
                    c.setLogService(null);
                } catch (IOException e) {
                    getLogger().log(Level.SEVERE, FAIL_UPDATE_LOG_PROPS, e);
                }
                return null;
            }
        }, config);
    } catch (TransactionFailure tf) {
        getLogger().log(Level.SEVERE, FAIL_UPGRADE_LOG_SERVICE, tf);
        throw new RuntimeException(tf);
    }
}
Also used : RepositoryConfig(com.sun.enterprise.admin.servermgmt.RepositoryConfig) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) HashMap(java.util.HashMap) RepositoryConfig(com.sun.enterprise.admin.servermgmt.RepositoryConfig) IOException(java.io.IOException) PropertyVetoException(java.beans.PropertyVetoException) PEFileLayout(com.sun.enterprise.admin.servermgmt.pe.PEFileLayout) File(java.io.File)

Aggregations

RepositoryConfig (com.sun.enterprise.admin.servermgmt.RepositoryConfig)2 File (java.io.File)2 NodeKeystoreManager (com.sun.enterprise.admin.servermgmt.NodeKeystoreManager)1 PEFileLayout (com.sun.enterprise.admin.servermgmt.pe.PEFileLayout)1 MiniXmlParserException (com.sun.enterprise.universal.xml.MiniXmlParserException)1 PropertyVetoException (java.beans.PropertyVetoException)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 CommandException (org.glassfish.api.admin.CommandException)1 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)1