/** * @since 5.6 * @return Configured server URL (may differ from current URL) */ public String getServerURL() { if (cg == null) { cg = new ConfigurationGenerator(); cg.init(); } return cg.getUserConfig().getProperty(ConfigurationGenerator.PARAM_NUXEO_URL); }
/** * Check if the LDAP parameters are correct to bind to a LDAP server. if authenticate argument is true, it will also * check if the authentication against the LDAP server succeeds * * @param authenticate Indicates if authentication against LDAP should be checked. * @since 6.0 */ public void checkLdapConnection(String ldapUrl, String ldapBindDn, String ldapBindPwd, boolean authenticate) throws NamingException { checkLdapConnection(getContextEnv(ldapUrl, ldapBindDn, ldapBindPwd, authenticate)); }
/** * Add template(s) to the {@link #PARAM_TEMPLATES_NAME} list if not already present * * @param templatesToAdd Comma separated templates to add * @since 5.5 */ public void addTemplate(String templatesToAdd) throws ConfigurationException { List<String> templatesList = getTemplateList(); List<String> templatesToAddList = asList(templatesToAdd.split(TEMPLATE_SEPARATOR)); if (templatesList.addAll(templatesToAddList)) { String newTemplatesStr = String.join(TEMPLATE_SEPARATOR, templatesList); HashMap<String, String> parametersToSave = new HashMap<>(); parametersToSave.put(PARAM_TEMPLATES_NAME, newTemplatesStr); saveFilteredConfiguration(parametersToSave); changeTemplates(newTemplatesStr); } }
/** * Create needed directories. Check existence of old paths. If old paths have been found and they cannot be upgraded * automatically, then upgrading message is logged and error thrown. * * @throws ConfigurationException If a deprecated directory has been detected. * @since 5.4.2 * @see ServerConfigurator#verifyInstallation() */ public void verifyInstallation() throws ConfigurationException { checkJavaVersion(); ifNotExistsAndIsDirectoryThenCreate(getLogDir()); ifNotExistsAndIsDirectoryThenCreate(getPidDir()); ifNotExistsAndIsDirectoryThenCreate(getDataDir()); ifNotExistsAndIsDirectoryThenCreate(getTmpDir()); ifNotExistsAndIsDirectoryThenCreate(getPackagesDir()); checkAddressesAndPorts(); serverConfigurator.verifyInstallation(); backingServicesConfigurator.verifyInstallation(); }
public void setDevMode(boolean value) { String feedbackCompId = "changeDevModeForm"; ConfigurationGenerator conf = setupWizardAction.getConfigurationGenerator(); boolean configurable = conf.isConfigurable(); if (!configurable) { facesMessages.addToControl(feedbackCompId, StatusMessage.Severity.ERROR, params.put(Framework.NUXEO_DEV_SYSTEM_PROP, Boolean.toString(value)); try { conf.saveFilteredConfiguration(params); conf.getServerConfigurator().dumpProperties(conf.getUserConfig());
@Override public void write(OutputStream output) throws IOException { try { ConfigurationGenerator configurationGenerator = new ConfigurationGenerator(); configurationGenerator.init(); ConnectBroker connectBroker = new ConnectBroker(configurationGenerator.getEnv()); InstanceInfo info = configurationGenerator.getServerConfigurator().getInfo(getCLID(connectBroker), connectBroker.getPkgList()); JAXBContext context = JAXBContext.newInstance(InstanceInfo.class, DistributionInfo.class, PackageInfo.class, ConfigurationInfo.class, KeyValueInfo.class); Marshaller marshaller = context.createMarshaller(); marshaller.marshal(info, jsonWriter(context, output)); } catch (PackageException | JAXBException cause) { throw new IOException("Cannot write runtime configuration", cause); } }
/** * @return Configured context name * @since 5.4.2 */ public String getContextName() { if (contextName == null) { Properties userConfig = generator.getUserConfig(); if (userConfig != null) { contextName = generator.getUserConfig() .getProperty(ConfigurationGenerator.PARAM_CONTEXT_PATH, DEFAULT_CONTEXT_NAME) .substring(1); } else { contextName = DEFAULT_CONTEXT_NAME.substring(1); } } return contextName; }
@Override protected Command doRun(Task task, Map<String, String> prefs) throws PackageException { Config rollback = new Config(); ConfigurationGenerator cg = new ConfigurationGenerator(); cg.init(); try { if (addtemplate != null) { cg.addTemplate(addtemplate); rollback.rmtemplate = addtemplate; } if (rmtemplate != null) { cg.rmTemplate(rmtemplate); rollback.addtemplate = rmtemplate; } if (set != null) { String[] newValue = set.split("=", 2); String previousValue = cg.setProperty(newValue[0], (newValue[1].length() > 0 ? newValue[1] : null)); if (previousValue == null) { previousValue = ""; } rollback.set = newValue[0] + "=" + previousValue; } } catch (ConfigurationException e) { throw new PackageException(e); } return rollback; }
@Factory(value = "setupConfigGenerator", scope = ScopeType.PAGE) public ConfigurationGenerator getConfigurationGenerator() { if (setupConfigGenerator == null) { setupConfigGenerator = new ConfigurationGenerator(); if (setupConfigGenerator.init()) { setParameters(); } } return setupConfigGenerator; }
nxInstance.NUXEO_CONF = generator.getNuxeoConf().getPath(); nxInstance.NUXEO_HOME = generator.getNuxeoHome().getPath(); File distFile = new File(generator.getConfigDir(), "distribution.properties"); if (!distFile.exists()) { distFile = new File(generator.getNuxeoHome(), "templates"); distFile = new File(distFile, "common"); distFile = new File(distFile, "config"); nxInstance.config.dbtemplate = generator.extractDatabaseTemplateName(); String userTemplates = generator.getUserTemplates(); StringTokenizer st = new StringTokenizer(userTemplates, ","); while (st.hasMoreTokens()) { nxInstance.config.pkgtemplates.add(template); } else { File testBase = new File(generator.getNuxeoHome(), ConfigurationGenerator.TEMPLATES + File.separator + template); if (testBase.exists()) { CryptoProperties userConfig = generator.getUserConfig(); for (Object item : new TreeSet<>(userConfig.keySet())) { String key = (String) item; String value = userConfig.getRawProperty(key); if (JAVA_OPTS.equals(key)) { value = generator.getJavaOptsString();
@Override protected void checkNetwork() throws ConfigurationException { InetAddress bindAddress = generator.getBindAddress(); ConfigurationGenerator.checkPortAvailable(bindAddress, Integer.parseInt(generator.getUserConfig().getProperty(PARAM_HTTP_TOMCAT_ADMIN_PORT))); }
protected Collection<BackingChecker> getCheckers() throws ConfigurationException { if (checkers == null) { checkers = new HashSet<>(); for (String template : configurationGenerator.getTemplateList()) { try { File templateDir = configurationGenerator.getTemplateConf(template).getParentFile(); String classPath = getClasspathForTemplate(template); String checkClass = configurationGenerator.getUserConfig() .getProperty(template + PARAM_CHECK_SUFFIX); Optional<URLClassLoader> ucl = getClassLoaderForTemplate(templateDir, classPath); if (ucl.isPresent()) { Class<?> klass = Class.forName(checkClass, true, ucl.get()); checkers.add((BackingChecker) klass.newInstance()); } } catch (IOException e) { log.warn("Unable to read check configuration for template : " + template, e); } catch (ReflectiveOperationException | ClassCastException e) { throw new ConfigurationException("Unable to check configuration for backing service " + template, e); } } } return checkers; }
CryptoProperties config = cg.getUserConfig(); String databaseTemplate = config.getProperty(ConfigurationGenerator.PARAM_TEMPLATE_DBNAME); String dbName = config.getProperty(ConfigurationGenerator.PARAM_DB_NAME); String dbPort = config.getProperty(ConfigurationGenerator.PARAM_DB_PORT); File databaseTemplateDir = new File(cg.getNuxeoHome(), ConfigurationGenerator.TEMPLATES + File.separator + databaseTemplate); Properties templateProperties = ConfigurationGenerator.loadTrimmedProperties(new File(databaseTemplateDir, ConfigurationGenerator.NUXEO_DEFAULT_CONF)); String classname, connectionUrl;
/** * Make absolute the directory passed in parameter. If it was relative, then store absolute path in user config * instead of relative and return value * * @param key Directory system key * @param directory absolute or relative directory path * @return absolute directory path * @since 5.4.2 */ private String setAbsolutePath(String key, String directory) { if (!new File(directory).isAbsolute()) { directory = new File(generator.getNuxeoHome(), directory).getPath(); generator.getUserConfig().setProperty(key, directory); } return directory; }
/** * Runs the configuration files generation. */ public void run() throws ConfigurationException { if (init()) { if (!serverConfigurator.isConfigured()) { log.info("No current configuration, generating files..."); generateFiles(); } else if (forceGeneration) { log.info("Configuration files generation (nuxeo.force.generation=" + userConfig.getProperty(PARAM_FORCE_GENERATION) + ")..."); generateFiles(); } else { log.info( "Server already configured (set nuxeo.force.generation=true to force configuration files generation)."); } } }
/** * Initialize configurator, check requirements and load current configuration * * @return returns true if current install is configurable, else returns false */ public boolean init() { return init(false); }
/** * Set a property in nuxeo configuration * * @return The old value * @since 5.5 */ public String setProperty(String key, String value) throws ConfigurationException { String oldValue = getStoredConfig().getProperty(key); if (PARAM_TEMPLATES_NAME.equals(key)) { templates = StringUtils.isBlank(value) ? null : value; } HashMap<String, String> newParametersToSave = new HashMap<>(); newParametersToSave.put(key, value); saveFilteredConfiguration(newParametersToSave); setBasicConfiguration(); return oldValue; }
Exception error = null; try { setupConfigGenerator.checkLdapConnection(ldapUrl, null, null, false); } catch (NamingException e) { errorLabel = ERROR_LDAP_CONNECTION;
cg.getServerConfigurator().getServerLibDir().listFiles()); List<URL> urlsList = new ArrayList<>(); if (files != null) {
HashMap::putAll); try { setupConfigGenerator.saveFilteredConfiguration(customParameters); } catch (ConfigurationException e) { log.error(e, e);