/** * @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; }
/** * Gets the Java options defined in Nuxeo configuration files, e.g. <tt>bin/nuxeo.conf</tt> and * <tt>bin/nuxeoctl</tt>. * * @return the Java options. * @since 9.3 */ public List<String> getJavaOpts(Function<String, String> mapper) { return Arrays.stream(JAVA_OPTS_PATTERN.split(System.getProperty(JAVA_OPTS_PROP, ""))) .map(option -> StringSubstitutor.replace(option, getUserConfig())) .map(mapper) .collect(Collectors.toList()); }
@Override public boolean accepts(ConfigurationGenerator cg) { return !DB_EXCLUDE_CHECK_LIST.contains( cg.getUserConfig().getProperty(ConfigurationGenerator.PARAM_TEMPLATE_DBTYPE)); }
/** * Returns the value of the check timeout parameter in seconds. * If value is not parseable or not set, then use the default value. * @return the timeout check in seconds. * @since 9.3 */ private int getCheckTimeoutInSeconds(ConfigurationGenerator cg) { int checkTimeout = DEFAULT_CHECK_TIMEOUT_IN_SECONDS; try { checkTimeout = Integer.parseInt(cg.getUserConfig().getProperty(PARAM_MONGODB_CHECK_TIMEOUT, String.valueOf(DEFAULT_CHECK_TIMEOUT_IN_SECONDS))); } catch (NumberFormatException e) { log.warn(String.format("Invalid format for %s parameter, using default value instead", PARAM_MONGODB_CHECK_TIMEOUT), e); } return checkTimeout; } }
/** * 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; }
/** * Read the classpath parameter from the template and expand parameters with their value. It allow classpath of the * form ${nuxeo.home}/nxserver/bundles/... * * @param template The name of the template */ // VisibleForTesting String getClasspathForTemplate(String template) { String classPath = configurationGenerator.getUserConfig().getProperty(template + PARAM_CHECK_CLASSPATH_SUFFIX); TextTemplate templateParser = new TextTemplate(configurationGenerator.getUserConfig()); return templateParser.processText(classPath); }
/** * Check if wizard must and can be ran * * @return true if configuration wizard is required before starting Nuxeo * @since 5.4.2 */ public boolean isWizardRequired() { return !"true".equalsIgnoreCase(getUserConfig().getProperty(PARAM_WIZARD_DONE, "true")) && serverConfigurator.isWizardAvailable(); }
public PlatformHelper() { cg = new ConfigurationGenerator(); cg.init(); name = cg.getUserConfig().getProperty(Environment.DISTRIBUTION_NAME); version = cg.getUserConfig().getProperty(Environment.DISTRIBUTION_VERSION); }
userConfig = setupConfigGenerator.getUserConfig(); parameters = new HashMap<>(); advancedParameters = new TreeMap<>();
userConfig = setupConfigGenerator.getUserConfig(); parameters = new HashMap<>(); advancedParameters = new TreeMap<>();
protected RetryPolicy buildRetryPolicy() { RetryPolicy retryPolicy = new RetryPolicy().withMaxRetries(0); Properties userConfig = configurationGenerator.getUserConfig(); if (Boolean.parseBoolean((userConfig.getProperty(PARAM_RETRY_POLICY_ENABLED, "false")))) { int maxRetries = Integer.parseInt( userConfig.getProperty(PARAM_RETRY_POLICY_MAX_RETRIES, PARAM_RETRY_POLICY_DEFAULT_RETRIES)); int delay = Integer.parseInt( userConfig.getProperty(PARAM_RETRY_POLICY_DELAY_IN_MS, PARAM_POLICY_DEFAULT_DELAY_IN_MS)); retryPolicy = retryPolicy.retryOn(ConfigurationException.class).withMaxRetries(maxRetries).withDelay(delay, TimeUnit.MILLISECONDS); } return retryPolicy; }
@Override protected void checkNetwork() throws ConfigurationException { InetAddress bindAddress = generator.getBindAddress(); ConfigurationGenerator.checkPortAvailable(bindAddress, Integer.parseInt(generator.getUserConfig().getProperty(PARAM_HTTP_TOMCAT_ADMIN_PORT))); }
/** * @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); }
/** * @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); }
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; }
@Override public void check(ConfigurationGenerator cg) throws ConfigurationException { MongoClient ret = null; String serverName = cg.getUserConfig().getProperty(ConfigurationGenerator.PARAM_MONGODB_SERVER); String dbName = cg.getUserConfig().getProperty(ConfigurationGenerator.PARAM_MONGODB_NAME); MongoClientOptions.Builder optionsBuilder = MongoClientOptions.builder() .serverSelectionTimeout( (int) TimeUnit.SECONDS.toMillis(getCheckTimeoutInSeconds(cg))) .description("Nuxeo DB Check"); if (serverName.startsWith("mongodb://")) { // allow mongodb:// URI syntax for the server, to pass everything in one string ret = new MongoClient(new MongoClientURI(serverName, optionsBuilder)); } else { ret = new MongoClient(new ServerAddress(serverName), optionsBuilder.build()); } try { Document ping = new Document("ping", "1"); ret.getDatabase(dbName).runCommand(ping); } catch (MongoTimeoutException e) { throw new ConfigurationException( String.format("Unable to connect to MongoDB at %s, please check your connection", serverName)); } finally { ret.close(); } }
CryptoProperties userConfig = generator.getUserConfig(); for (Object item : new TreeSet<>(userConfig.keySet())) { String key = (String) item;
CryptoProperties config = cg.getUserConfig(); String databaseTemplate = config.getProperty(ConfigurationGenerator.PARAM_TEMPLATE_DBNAME); String dbName = config.getProperty(ConfigurationGenerator.PARAM_DB_NAME);
try { conf.saveFilteredConfiguration(params); conf.getServerConfigurator().dumpProperties(conf.getUserConfig());
try { conf.saveFilteredConfiguration(params); conf.getServerConfigurator().dumpProperties(conf.getUserConfig());