public class ConfigurationGenerator extends Object
Constructor and Description |
---|
ConfigurationGenerator() |
ConfigurationGenerator(boolean quiet,
boolean debug) |
Modifier and Type | Method and Description |
---|---|
void |
addTemplate(String templatesToAdd)
Add template(s) to the
PARAM_TEMPLATES_NAME list if not already present |
void |
changeDBTemplate(String dbTemplate)
Change templates using given database template
|
String |
changeTemplates(String newTemplates) |
void |
checkAddressesAndPorts()
Will check the configured addresses are reachable and Nuxeo required ports are available on those addresses.
|
static void |
checkAddressReachable(InetAddress address) |
void |
checkDatabaseConnection(String databaseTemplate,
String dbName,
String dbUser,
String dbPassword,
String dbHost,
String dbPort)
Check driver availability and database connection
|
static Charset |
checkFileCharset(File propsFile) |
protected void |
checkForDeprecatedParameters(Properties properties)
Check for deprecated parameters
|
void |
checkJavaVersion()
Check that the process is executed with a supported Java version.
|
static boolean |
checkJavaVersion(String version,
String requiredVersion)
Checks the java version compared to the required one.
|
protected static void |
checkJavaVersion(String version,
String[] compliantVersions)
Check the java version compared to compliant ones.
|
protected static boolean |
checkJavaVersion(String version,
String requiredVersion,
boolean allowNoFailFlag,
boolean warnIfLooseCompliance)
Checks the java version compared to the required one.
|
void |
checkLdapConnection(Hashtable<Object,Object> contextEnv) |
void |
checkLdapConnection(String ldapUrl,
String ldapBindDn,
String ldapBindPwd,
boolean authenticate)
Check if the LDAP parameters are correct to bind to a LDAP server.
|
static void |
checkPortAvailable(InetAddress address,
int port)
Checks if port is available on given address.
|
void |
cleanupPostWizard()
Ensure the wizard won't be started and nuxeo is ready for use
|
protected HashMap<String,String> |
evalDynamicProperties()
Generate properties which values are based on others
|
protected void |
evalEnvironmentVariables(Map<String,String> newParametersToSave)
Expand environment variable for properties values of the form ${env:MY_VAR}.
|
String |
extractDatabaseTemplateName()
Extract a database template from the current list of templates.
|
String |
extractSecondaryDatabaseTemplateName()
Extract a NoSQL database template from the current list of templates.
|
protected void |
generateFiles() |
InetAddress |
getBindAddress()
Checks the userConfig bind address is not 0.0.0.0 and replaces it with 127.0.0.1 if needed
|
static InetAddress |
getBindAddress(String hostName)
Checks hostName bind address is not 0.0.0.0 and replaces it with 127.0.0.1 if needed
|
Map<String,String> |
getChangedParameters(Map<String,String> changedParameters)
Filters given parameters including them only if (there was no previous value and new value is not empty/null) or
(there was a previous value and it differs from the new value)
|
File |
getConfigDir() |
Hashtable<Object,Object> |
getContextEnv(String ldapUrl,
String bindDn,
String bindPassword,
boolean checkAuthentication)
Build a
Hashtable which contains environment properties to instantiate a InitialDirContext |
Crypto |
getCrypto() |
File |
getDataDir() |
File |
getDistributionMPDir() |
File |
getDumpedConfig() |
Environment |
getEnv() |
protected String |
getEnvironmentVariableValue(String key) |
List<File> |
getIncludedTemplates() |
File |
getInstallFile() |
List<String> |
getJavaOpts(Function<String,String> mapper)
Gets the Java options defined in Nuxeo configuration files, e.g.
|
protected String |
getJavaOpts(String key,
String value)
Deprecated.
Since 9.3. Use
getJavaOptsString() instead. |
protected String |
getJavaOptsString() |
File |
getLogDir() |
List<String> |
getLogFiles() |
File |
getNuxeoConf() |
File |
getNuxeoDefaultConf() |
File |
getNuxeoHome() |
File |
getPidDir() |
File |
getRuntimeHome() |
ServerConfigurator |
getServerConfigurator() |
protected Properties |
getStoredConfig() |
File |
getTemplateConf(String template) |
List<String> |
getTemplateList()
Return the list of templates.
|
File |
getTmpDir() |
CryptoProperties |
getUserConfig() |
String |
getUserTemplates() |
void |
hideDeprecationWarnings(boolean hide) |
protected void |
includeTemplates() |
boolean |
init()
Initialize configurator, check requirements and load current configuration
|
boolean |
init(boolean forceReload)
Initialize configurator, check requirements and load current configuration
|
void |
initLogs()
Delegate logs initialization to serverConfigurator instance
|
boolean |
isConfigurable() |
boolean |
isForceGeneration() |
boolean |
isInstallInProgress() |
boolean |
isWizardRequired()
Check if wizard must and can be ran
|
static Properties |
loadTrimmedProperties(File propsFile) |
static void |
loadTrimmedProperties(Properties props,
InputStreamReader propsIS) |
void |
prepareWizardStart()
Ensure the server will start only wizard application, not Nuxeo
|
String |
rebuildTemplatesStr(String dbTemplate)
Rebuild a templates string for use in nuxeo.conf
|
protected void |
replaceBackslashes()
Read nuxeo.conf, replace backslashes in paths and write new nuxeo.conf
|
void |
rmTemplate(String templatesToRm)
Remove template(s) from the
PARAM_TEMPLATES_NAME list |
void |
run()
Runs the configuration files generation.
|
void |
saveConfiguration(Map<String,String> changedParameters)
Save changed parameters in
nuxeo.conf . |
void |
saveConfiguration(Map<String,String> changedParameters,
boolean setGenerationOnceToFalse,
boolean setGenerationFalseToOnce)
Save changed parameters in
nuxeo.conf calculating templates if changedParameters contains a value for
PARAM_TEMPLATE_DBNAME . |
void |
saveFilteredConfiguration(Map<String,String> changedParameters)
Save changed parameters in
nuxeo.conf , filtering parameters with getChangedParameters(Map) |
void |
setDirectoryWithProperty(String key) |
void |
setForceGeneration(boolean forceGeneration) |
Map<String,String> |
setProperties(Map<String,String> newParametersToSave)
Set properties in nuxeo configuration
|
Map<String,String> |
setProperties(String template,
Map<String,String> newParametersToSave)
Set properties in the given template, if it exists
|
String |
setProperty(String key,
String value)
Set a property in nuxeo configuration
|
void |
verifyInstallation()
Create needed directories.
|
public static final String TEMPLATE_SEPARATOR
public static final String[] COMPLIANT_JAVA_VERSIONS
protected static final String CONFIGURATION_PROPERTIES
public static final String NUXEO_CONF
public static final String TEMPLATES
public static final String NUXEO_DEFAULT_CONF
public static final String PARAM_TEMPLATES_NAME
public static final String PARAM_TEMPLATE_DBNAME
public static final String PARAM_TEMPLATE_DBSECONDARY_NAME
public static final String PARAM_TEMPLATE_DBTYPE
public static final String PARAM_TEMPLATE_DBSECONDARY_TYPE
public static final String OLD_PARAM_TEMPLATES_PARSING_EXTENSIONS
public static final String PARAM_TEMPLATES_PARSING_EXTENSIONS
public static final String PARAM_TEMPLATES_FREEMARKER_EXTENSIONS
protected static final String PARAM_INCLUDED_TEMPLATES
public static final String PARAM_FORCE_GENERATION
public static final String BOUNDARY_BEGIN
public static final String BOUNDARY_END
public static final List<String> DB_SECONDARY_LIST
public static final List<String> DB_EXCLUDE_CHECK_LIST
public static final String PARAM_WIZARD_DONE
public static final String PARAM_WIZARD_RESTART_PARAMS
public static final String PARAM_FAKE_WINDOWS
public static final String PARAM_LOOPBACK_URL
public static final int MIN_PORT
public static final int MAX_PORT
public static final int ADDRESS_PING_TIMEOUT
public static final String PARAM_BIND_ADDRESS
public static final String PARAM_HTTP_PORT
@Deprecated public static final String PARAM_STATUS_KEY
Environment.SERVER_STATUS_KEY
insteadpublic static final String PARAM_CONTEXT_PATH
public static final String PARAM_MP_DIR
public static final String DISTRIBUTION_MP_DIR
public static final String INSTALL_AFTER_RESTART
public static final String PARAM_DB_DRIVER
public static final String PARAM_DB_JDBC_URL
public static final String PARAM_DB_HOST
public static final String PARAM_DB_PORT
public static final String PARAM_DB_NAME
public static final String PARAM_DB_USER
public static final String PARAM_DB_PWD
public static final String PARAM_MONGODB_NAME
public static final String PARAM_MONGODB_SERVER
protected static final Pattern JAVA_OPTS_PATTERN
public static final List<String> SECRET_KEYS
@Deprecated public static final String PARAM_PRODUCT_NAME
Environment.PRODUCT_NAME
@Deprecated public static final String PARAM_PRODUCT_VERSION
Environment.PRODUCT_VERSION
public static final String PARAM_NUXEO_URL
public static final String NUXEO_DEV_SYSTEM_PROP
public static final String SEAM_DEBUG_SYSTEM_PROP
NUXEO_DEV_SYSTEM_PROP
public static final String JVMCHECK_PROP
public static final String JVMCHECK_FAIL
public static final String JVMCHECK_NOFAIL
public static final String JAVA_OPTS_PROP
public boolean isJetty
public boolean isTomcat
protected static final Map<String,String> parametersMigration
public ConfigurationGenerator()
public ConfigurationGenerator(boolean quiet, boolean debug)
quiet
- Suppress info level messages from the console outputdebug
- Activate debug level loggingpublic boolean isConfigurable()
protected Properties getStoredConfig()
public void hideDeprecationWarnings(boolean hide)
public void setForceGeneration(boolean forceGeneration)
PARAM_FORCE_GENERATION
public boolean isForceGeneration()
PARAM_FORCE_GENERATION
public CryptoProperties getUserConfig()
public final ServerConfigurator getServerConfigurator()
public void run() throws ConfigurationException
ConfigurationException
public boolean init()
public boolean init(boolean forceReload)
forceReload
- If true, forces configuration reload.public String changeTemplates(String newTemplates)
public void changeDBTemplate(String dbTemplate)
dbTemplate
- new database templateprotected void includeTemplates() throws IOException
IOException
protected HashMap<String,String> evalDynamicProperties() throws ConfigurationException
nuxeoConf
ConfigurationException
protected void evalEnvironmentVariables(Map<String,String> newParametersToSave)
protected void replaceBackslashes() throws ConfigurationException
ConfigurationException
- if any error reading or writing nuxeo.confpublic void setDirectoryWithProperty(String key)
key
- Directory system keyEnvironment
public String getUserTemplates()
protected void generateFiles() throws ConfigurationException
ConfigurationException
protected void checkForDeprecatedParameters(Properties properties)
public File getNuxeoHome()
public File getNuxeoDefaultConf()
public List<File> getIncludedTemplates()
public void saveConfiguration(Map<String,String> changedParameters) throws ConfigurationException
nuxeo.conf
. This method does not check values in map. Use
saveFilteredConfiguration(Map)
for parameters filtering.changedParameters
- Map of modified parametersConfigurationException
saveFilteredConfiguration(Map)
public void saveConfiguration(Map<String,String> changedParameters, boolean setGenerationOnceToFalse, boolean setGenerationFalseToOnce) throws ConfigurationException
nuxeo.conf
calculating templates if changedParameters contains a value for
PARAM_TEMPLATE_DBNAME
. If a parameter value is empty ("" or null), then the property is unset.
PARAM_WIZARD_DONE
, PARAM_TEMPLATES_NAME
and PARAM_FORCE_GENERATION
cannot be unset,
but their value can be changed.saveFilteredConfiguration(Map)
for parameters filtering.changedParameters
- Map of modified parameterssetGenerationOnceToFalse
- If generation was on (true or once), then set it to false or not?setGenerationFalseToOnce
- If generation was off (false), then set it to once?ConfigurationException
saveFilteredConfiguration(Map)
public void saveFilteredConfiguration(Map<String,String> changedParameters) throws ConfigurationException
nuxeo.conf
, filtering parameters with getChangedParameters(Map)
changedParameters
- Maps of modified parametersConfigurationException
saveConfiguration(Map)
,
getChangedParameters(Map)
public Map<String,String> getChangedParameters(Map<String,String> changedParameters)
changedParameters
- parameters to be filteredpublic String extractDatabaseTemplateName()
rebuildTemplatesStr(String)
public String extractSecondaryDatabaseTemplateName()
rebuildTemplatesStr(String)
public File getNuxeoConf()
public void initLogs()
public File getDataDir()
public void verifyInstallation() throws ConfigurationException
ConfigurationException
- If a deprecated directory has been detected.ServerConfigurator.verifyInstallation()
public void checkJavaVersion() throws ConfigurationException
ConfigurationException
protected static void checkJavaVersion(String version, String[] compliantVersions) throws ConfigurationException
version
- the java versioncompliantVersions
- the compliant java versionsConfigurationException
protected static boolean checkJavaVersion(String version, String requiredVersion, boolean allowNoFailFlag, boolean warnIfLooseCompliance)
Loose compliance is assumed if the major version is greater than the required major version or a jvmcheck=nofail flag is set.
version
- the java versionrequiredVersion
- the required java versionallowNoFailFlag
- if true
then check jvmcheck=nofail flag to always have loose compliancewarnIfLooseCompliance
- if true
then log a WARN if the is loose compliancepublic static boolean checkJavaVersion(String version, String requiredVersion)
If major version is same as required major version and minor is greater or equal, it is compliant.
If major version is greater than required major version, it is compliant.
version
- the java versionrequiredVersion
- the required java versionpublic void checkAddressesAndPorts() throws ConfigurationException
PARAM_BIND_ADDRESS
must be set before.ConfigurationException
ServerConfigurator.verifyInstallation()
public InetAddress getBindAddress() throws ConfigurationException
ConfigurationException
public static InetAddress getBindAddress(String hostName) throws ConfigurationException
hostName
- the hostname of Nuxeo server (works also with the IP)ConfigurationException
public static void checkAddressReachable(InetAddress address) throws ConfigurationException
address
- address to check for availabilityConfigurationException
public static void checkPortAvailable(InetAddress address, int port) throws ConfigurationException
port
- port to check for availabilityConfigurationException
- Throws an exception if address is unavailable.public List<String> getLogFiles()
public boolean isWizardRequired()
public String rebuildTemplatesStr(String dbTemplate)
dbTemplate
- database template to use instead of current oneextractDatabaseTemplateName()
,
changeDBTemplate(String)
,
changeTemplates(String)
public File getConfigDir()
public void prepareWizardStart()
public void cleanupPostWizard()
public File getRuntimeHome()
public boolean isInstallInProgress()
public File getDistributionMPDir()
public File getInstallFile()
public void addTemplate(String templatesToAdd) throws ConfigurationException
PARAM_TEMPLATES_NAME
list if not already presenttemplatesToAdd
- Comma separated templates to addConfigurationException
public List<String> getTemplateList()
public void rmTemplate(String templatesToRm) throws ConfigurationException
PARAM_TEMPLATES_NAME
listtemplatesToRm
- Comma separated templates to removeConfigurationException
public String setProperty(String key, String value) throws ConfigurationException
ConfigurationException
public Map<String,String> setProperties(Map<String,String> newParametersToSave) throws ConfigurationException
ConfigurationException
public Map<String,String> setProperties(String template, Map<String,String> newParametersToSave) throws ConfigurationException, IOException
ConfigurationException
IOException
public void checkDatabaseConnection(String databaseTemplate, String dbName, String dbUser, String dbPassword, String dbHost, String dbPort) throws IOException, DatabaseDriverException, SQLException
databaseTemplate
- Nuxeo database templatedbName
- nuxeo.db.name parameter in nuxeo.confdbUser
- nuxeo.db.user parameter in nuxeo.confdbPassword
- nuxeo.db.password parameter in nuxeo.confdbHost
- nuxeo.db.host parameter in nuxeo.confdbPort
- nuxeo.db.port parameter in nuxeo.confIOException
DatabaseDriverException
SQLException
public Environment getEnv()
Environment
initialized with a few basicspublic static Charset checkFileCharset(File propsFile) throws IOException
propsFile
- Properties fileIOException
public static Properties loadTrimmedProperties(File propsFile) throws IOException
propsFile
- Properties filepropsFile
IOException
public static void loadTrimmedProperties(Properties props, InputStreamReader propsIS) throws IOException
props
- Properties object to be filledpropsIS
- Properties InputStreamIOException
public File getDumpedConfig()
public Hashtable<Object,Object> getContextEnv(String ldapUrl, String bindDn, String bindPassword, boolean checkAuthentication)
Hashtable
which contains environment properties to instantiate a InitialDirContext
public void checkLdapConnection(String ldapUrl, String ldapBindDn, String ldapBindPwd, boolean authenticate) throws NamingException
authenticate
- Indicates if authentication against LDAP should be checked.NamingException
public void checkLdapConnection(Hashtable<Object,Object> contextEnv) throws NamingException
contextEnv
- Environment properties to build a InitialDirContext
NamingException
public File getTemplateConf(String template) throws ConfigurationException
template
- path to configuration template directorynuxeo.defaults
file if it exists.ConfigurationException
- if the template file is not found.@Deprecated protected String getJavaOpts(String key, String value)
getJavaOptsString()
instead.public List<String> getJavaOpts(Function<String,String> mapper)
protected String getJavaOptsString()
getJavaOpts(Function)
protected String getEnvironmentVariableValue(String key)
Copyright © 2019 Nuxeo. All rights reserved.