Package org.nuxeo.launcher.config
Class ConfigurationGenerator
- java.lang.Object
-
- org.nuxeo.launcher.config.ConfigurationGenerator
-
public class ConfigurationGenerator extends Object
Builder for server configuration and datasource files from templates and properties.- Author:
- jcarsique
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ConfigurationGenerator()
ConfigurationGenerator(boolean quiet, boolean debug)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addTemplate(String templatesToAdd)
Add template(s) to thePARAM_TEMPLATES_NAME
list if not already presentvoid
changeDBTemplate(String dbTemplate)
Change templates using given database templateString
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 connectionstatic Charset
checkFileCharset(File propsFile)
protected void
checkForDeprecatedParameters(Properties properties)
Check for deprecated parametersvoid
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(String ldapUrl, String ldapBindDn, String ldapBindPwd, boolean authenticate)
Check if the LDAP parameters are correct to bind to a LDAP server.void
checkLdapConnection(Hashtable<Object,Object> contextEnv)
static void
checkPortAvailable(InetAddress address, int port)
Checks if port is available on given address.protected Map<String,String>
evalDynamicProperties()
Generate properties which values are based on othersprotected 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 neededstatic InetAddress
getBindAddress(String hostName)
Checks hostName bind address is not 0.0.0.0 and replaces it with 127.0.0.1 if neededMap<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 aHashtable
which contains environment properties to instantiate aInitialDirContext
Crypto
getCrypto()
File
getDataDir()
File
getDistributionMPDir()
Deprecated.since 11.1, Nuxeo Wizard has been removed.File
getDumpedConfig()
Environment
getEnv()
protected String
getEnvironment(String key)
protected String
getEnvironment(String key, String defaultValue)
List<File>
getIncludedTemplates()
File
getInstallFile()
protected String
getJavaOpts(String key, String value)
Deprecated.Since 9.3.List<String>
getJavaOpts(Function<String,String> mapper)
Gets the Java options defined in Nuxeo configuration files, e.g.protected String
getJavaOptsString()
File
getLogDir()
List<String>
getLogFiles()
File
getNuxeoBinDir()
File
getNuxeoConf()
File
getNuxeoDefaultConf()
Deprecated.since 11.1, unusedprotected String
getNuxeoEnvironmentConfName()
File
getNuxeoHome()
File
getPidDir()
File
getRuntimeHome()
ServerConfigurator
getServerConfigurator()
protected Properties
getStoredConfig()
File
getTemplateConf(String template)
Deprecated.since 11.1, there's several configuration files, usegetTemplateDirectory(String)
insteadFile
getTemplateDirectory(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 configurationboolean
init(boolean forceReload)
Initialize configurator, check requirements and load current configurationvoid
initLogs()
Delegate logs initialization to serverConfigurator instanceboolean
isConfigurable()
boolean
isForceGeneration()
boolean
isInstallInProgress()
protected boolean
isInvalidNuxeoDefaults(File templateDir)
protected Properties
loadNuxeoDefaults(File directory)
Loads thenuxeo.defaults
andnuxeo.NUXEO_ENVIRONMENT
files.static Properties
loadTrimmedProperties(File propsFile)
protected static Properties
loadTrimmedProperties(Properties props, File propsFile)
static void
loadTrimmedProperties(Properties props, InputStreamReader propsIS)
String
rebuildTemplatesStr(String dbTemplate)
Rebuild a templates string for use in nuxeo.confprotected void
replaceBackslashes()
Read nuxeo.conf, replace backslashes in paths and write new nuxeo.confvoid
rmTemplate(String templatesToRm)
Remove template(s) from thePARAM_TEMPLATES_NAME
listvoid
run()
Runs the configuration files generation.void
saveConfiguration(Map<String,String> changedParameters)
Save changed parameters innuxeo.conf
.void
saveConfiguration(Map<String,String> changedParameters, boolean setGenerationOnceToFalse, boolean setGenerationFalseToOnce)
Save changed parameters innuxeo.conf
calculating templates if changedParameters contains a value forPARAM_TEMPLATE_DBNAME
.void
saveFilteredConfiguration(Map<String,String> changedParameters)
Save changed parameters innuxeo.conf
, filtering parameters withgetChangedParameters(Map)
void
setDirectoryWithProperty(String key)
void
setForceGeneration(boolean forceGeneration)
Map<String,String>
setProperties(String template, Map<String,String> newParametersToSave)
Set properties in the given template, if it existsMap<String,String>
setProperties(Map<String,String> newParametersToSave)
Set properties in nuxeo configurationString
setProperty(String key, String value)
Set a property in nuxeo configurationvoid
verifyInstallation()
Create needed directories.
-
-
-
Field Detail
-
NUXEO_ENVIRONMENT
public static final String NUXEO_ENVIRONMENT
- Since:
- 11.1
- See Also:
- Constant Field Values
-
NUXEO_PROFILES
public static final String NUXEO_PROFILES
- Since:
- 11.1
- See Also:
- Constant Field Values
-
TEMPLATE_SEPARATOR
public static final String TEMPLATE_SEPARATOR
- Since:
- 6.0
- See Also:
- Constant Field Values
- Implementation Note:
- also used for profiles
-
COMPLIANT_JAVA_VERSIONS
public static final String[] COMPLIANT_JAVA_VERSIONS
Accurate but not used internally. NXP-18023: Java 8 update 40+ required- Since:
- 5.7
-
CONFIGURATION_PROPERTIES
protected static final String CONFIGURATION_PROPERTIES
- Since:
- 5.6
- See Also:
- Constant Field Values
-
NUXEO_CONF
public static final String NUXEO_CONF
- See Also:
- Constant Field Values
-
TEMPLATES
public static final String TEMPLATES
- See Also:
- Constant Field Values
-
NUXEO_DEFAULT_CONF
public static final String NUXEO_DEFAULT_CONF
- See Also:
- Constant Field Values
-
NUXEO_ENVIRONMENT_CONF_FORMAT
public static final String NUXEO_ENVIRONMENT_CONF_FORMAT
- Since:
- 11.1
- See Also:
- Constant Field Values
-
PARAM_TEMPLATES_NAME
public static final String PARAM_TEMPLATES_NAME
Absolute or relative PATH to the user chosen templates (comma separated list)- See Also:
- Constant Field Values
-
PARAM_TEMPLATE_DBNAME
public static final String PARAM_TEMPLATE_DBNAME
- See Also:
- Constant Field Values
-
PARAM_TEMPLATE_DBSECONDARY_NAME
public static final String PARAM_TEMPLATE_DBSECONDARY_NAME
- Since:
- 9.3
- See Also:
- Constant Field Values
-
PARAM_TEMPLATE_DBTYPE
public static final String PARAM_TEMPLATE_DBTYPE
- See Also:
- Constant Field Values
-
PARAM_TEMPLATE_DBSECONDARY_TYPE
public static final String PARAM_TEMPLATE_DBSECONDARY_TYPE
- Since:
- 9.3
- See Also:
- Constant Field Values
-
OLD_PARAM_TEMPLATES_PARSING_EXTENSIONS
public static final String OLD_PARAM_TEMPLATES_PARSING_EXTENSIONS
- See Also:
- Constant Field Values
-
PARAM_TEMPLATES_PARSING_EXTENSIONS
public static final String PARAM_TEMPLATES_PARSING_EXTENSIONS
- See Also:
- Constant Field Values
-
PARAM_TEMPLATES_FREEMARKER_EXTENSIONS
public static final String PARAM_TEMPLATES_FREEMARKER_EXTENSIONS
- See Also:
- Constant Field Values
-
PARAM_INCLUDED_TEMPLATES
protected static final String PARAM_INCLUDED_TEMPLATES
Absolute or relative PATH to the included templates (comma separated list)- See Also:
- Constant Field Values
-
PARAM_FORCE_GENERATION
public static final String PARAM_FORCE_GENERATION
- See Also:
- Constant Field Values
-
BOUNDARY_BEGIN
public static final String BOUNDARY_BEGIN
- See Also:
- Constant Field Values
-
BOUNDARY_END
public static final String BOUNDARY_END
- See Also:
- Constant Field Values
-
DB_SECONDARY_LIST
public static final List<String> DB_SECONDARY_LIST
-
DB_EXCLUDE_CHECK_LIST
public static final List<String> DB_EXCLUDE_CHECK_LIST
-
PARAM_WIZARD_DONE
@Deprecated(since="11.1") public static final String PARAM_WIZARD_DONE
Deprecated.since 11.1, Nuxeo Wizard has been removed.- See Also:
- Constant Field Values
-
PARAM_WIZARD_RESTART_PARAMS
@Deprecated(since="11.1") public static final String PARAM_WIZARD_RESTART_PARAMS
Deprecated.since 11.1, Nuxeo Wizard has been removed.- See Also:
- Constant Field Values
-
PARAM_FAKE_WINDOWS
public static final String PARAM_FAKE_WINDOWS
- See Also:
- Constant Field Values
-
PARAM_LOOPBACK_URL
public static final String PARAM_LOOPBACK_URL
- See Also:
- Constant Field Values
-
MIN_PORT
public static final int MIN_PORT
- See Also:
- Constant Field Values
-
MAX_PORT
public static final int MAX_PORT
- See Also:
- Constant Field Values
-
ADDRESS_PING_TIMEOUT
public static final int ADDRESS_PING_TIMEOUT
- See Also:
- Constant Field Values
-
PARAM_BIND_ADDRESS
public static final String PARAM_BIND_ADDRESS
- See Also:
- Constant Field Values
-
PARAM_HTTP_PORT
public static final String PARAM_HTTP_PORT
- See Also:
- Constant Field Values
-
PARAM_STATUS_KEY
@Deprecated public static final String PARAM_STATUS_KEY
Deprecated.Since 7.4. UseEnvironment.SERVER_STATUS_KEY
instead- See Also:
- Constant Field Values
-
PARAM_CONTEXT_PATH
public static final String PARAM_CONTEXT_PATH
- See Also:
- Constant Field Values
-
PARAM_MP_DIR
@Deprecated(since="11.1") public static final String PARAM_MP_DIR
Deprecated.since 11.1, Nuxeo Wizard has been removed.- See Also:
- Constant Field Values
-
DISTRIBUTION_MP_DIR
@Deprecated(since="11.1") public static final String DISTRIBUTION_MP_DIR
Deprecated.since 11.1, Nuxeo Wizard has been removed.- See Also:
- Constant Field Values
-
INSTALL_AFTER_RESTART
public static final String INSTALL_AFTER_RESTART
- See Also:
- Constant Field Values
-
PARAM_DB_DRIVER
public static final String PARAM_DB_DRIVER
- See Also:
- Constant Field Values
-
PARAM_DB_JDBC_URL
public static final String PARAM_DB_JDBC_URL
- See Also:
- Constant Field Values
-
PARAM_DB_HOST
public static final String PARAM_DB_HOST
- See Also:
- Constant Field Values
-
PARAM_DB_PORT
public static final String PARAM_DB_PORT
- See Also:
- Constant Field Values
-
PARAM_DB_NAME
public static final String PARAM_DB_NAME
- See Also:
- Constant Field Values
-
PARAM_DB_USER
public static final String PARAM_DB_USER
- See Also:
- Constant Field Values
-
PARAM_DB_PWD
public static final String PARAM_DB_PWD
- See Also:
- Constant Field Values
-
PARAM_MONGODB_NAME
@Deprecated(since="11.1") public static final String PARAM_MONGODB_NAME
Deprecated.since 11.1, seems unused- Since:
- 8.1
- See Also:
- Constant Field Values
-
PARAM_MONGODB_SERVER
@Deprecated(since="11.1") public static final String PARAM_MONGODB_SERVER
Deprecated.since 11.1, seems unused- Since:
- 8.1
- See Also:
- Constant Field Values
-
JAVA_OPTS_PATTERN
protected static final Pattern JAVA_OPTS_PATTERN
Java options split by spaces followed by an even number of quotes (or zero).- Since:
- 9.3
-
SECRET_KEYS
public static final List<String> SECRET_KEYS
Keys which value must be displayed thoughtfully- Since:
- 8.1
-
PARAM_PRODUCT_NAME
@Deprecated public static final String PARAM_PRODUCT_NAME
Deprecated.Since 7.10. UseEnvironment.PRODUCT_NAME
- See Also:
- Constant Field Values
-
PARAM_PRODUCT_VERSION
@Deprecated public static final String PARAM_PRODUCT_VERSION
Deprecated.Since 7.10. UseEnvironment.PRODUCT_VERSION
- See Also:
- Constant Field Values
-
PARAM_NUXEO_URL
public static final String PARAM_NUXEO_URL
- Since:
- 5.6
- See Also:
- Constant Field Values
-
NUXEO_DEV_SYSTEM_PROP
public static final String NUXEO_DEV_SYSTEM_PROP
Global dev property, duplicated from runtime framework- Since:
- 5.6
- See Also:
- Constant Field Values
-
SEAM_DEBUG_SYSTEM_PROP
public static final String SEAM_DEBUG_SYSTEM_PROP
Seam hot reload property, also controlled byNUXEO_DEV_SYSTEM_PROP
- Since:
- 5.6
- See Also:
- Constant Field Values
-
JVMCHECK_PROP
public static final String JVMCHECK_PROP
- Since:
- 8.4
- See Also:
- Constant Field Values
-
JVMCHECK_FAIL
public static final String JVMCHECK_FAIL
- Since:
- 8.4
- See Also:
- Constant Field Values
-
JVMCHECK_NOFAIL
public static final String JVMCHECK_NOFAIL
- Since:
- 8.4
- See Also:
- Constant Field Values
-
JAVA_OPTS_PROP
public static final String JAVA_OPTS_PROP
Java options configured inbin/nuxeo.conf
andbin/nuxeoctl
.- Since:
- 9.3
- See Also:
- Constant Field Values
-
VERSIONED_REGEX
public static final String VERSIONED_REGEX
- See Also:
- Constant Field Values
-
BOOTSTRAP_JAR_REGEX
public static final String BOOTSTRAP_JAR_REGEX
- See Also:
- Constant Field Values
-
JULI_JAR_REGEX
public static final String JULI_JAR_REGEX
- See Also:
- Constant Field Values
-
parametersMigration
protected static final Map<String,String> parametersMigration
-
-
Constructor Detail
-
ConfigurationGenerator
public ConfigurationGenerator()
-
ConfigurationGenerator
public ConfigurationGenerator(boolean quiet, boolean debug)
- Parameters:
quiet
- Suppress info level messages from the console outputdebug
- Activate debug level logging- Since:
- 5.6
-
-
Method Detail
-
isConfigurable
public boolean isConfigurable()
-
getStoredConfig
protected Properties getStoredConfig()
- Since:
- 5.7
-
hideDeprecationWarnings
public void hideDeprecationWarnings(boolean hide)
-
setForceGeneration
public void setForceGeneration(boolean forceGeneration)
- See Also:
PARAM_FORCE_GENERATION
-
isForceGeneration
public boolean isForceGeneration()
- Returns:
- true if configuration will be generated from templates
- Since:
- 5.4.2
- See Also:
PARAM_FORCE_GENERATION
-
getUserConfig
public CryptoProperties getUserConfig()
-
getServerConfigurator
public final ServerConfigurator getServerConfigurator()
- Since:
- 5.4.2
-
run
public void run() throws ConfigurationException
Runs the configuration files generation.- Throws:
ConfigurationException
-
init
public boolean init()
Initialize configurator, check requirements and load current configuration- Returns:
- returns true if current install is configurable, else returns false
-
init
public boolean init(boolean forceReload)
Initialize configurator, check requirements and load current configuration- Parameters:
forceReload
- If true, forces configuration reload.- Returns:
- returns true if current install is configurable, else returns false
- Since:
- 5.6
-
changeTemplates
public String changeTemplates(String newTemplates)
- Returns:
- Old templates
-
changeDBTemplate
public void changeDBTemplate(String dbTemplate)
Change templates using given database template- Parameters:
dbTemplate
- new database template- Since:
- 5.4.2
-
includeTemplates
protected void includeTemplates() throws IOException
- Throws:
IOException
- Since:
- 5.7
-
evalDynamicProperties
protected Map<String,String> evalDynamicProperties() throws ConfigurationException
Generate properties which values are based on others- Returns:
- Map with new parameters to save in
nuxeoConf
- Throws:
ConfigurationException
- Since:
- 5.5
-
evalEnvironmentVariables
protected void evalEnvironmentVariables(Map<String,String> newParametersToSave)
Expand environment variable for properties values of the form ${env:MY_VAR}.- Since:
- 9.1
-
replaceBackslashes
protected void replaceBackslashes() throws ConfigurationException
Read nuxeo.conf, replace backslashes in paths and write new nuxeo.conf- Throws:
ConfigurationException
- if any error reading or writing nuxeo.conf- Since:
- 5.4.1
-
setDirectoryWithProperty
public void setDirectoryWithProperty(String key)
- Parameters:
key
- Directory system key- Since:
- 5.4.2
- See Also:
Environment
-
getUserTemplates
public String getUserTemplates()
-
generateFiles
protected void generateFiles() throws ConfigurationException
- Throws:
ConfigurationException
-
checkForDeprecatedParameters
protected void checkForDeprecatedParameters(Properties properties)
Check for deprecated parameters- Since:
- 5.6
-
getNuxeoHome
public File getNuxeoHome()
-
getNuxeoBinDir
public File getNuxeoBinDir()
-
getNuxeoDefaultConf
@Deprecated(since="11.1") public File getNuxeoDefaultConf()
Deprecated.since 11.1, unused
-
getIncludedTemplates
public List<File> getIncludedTemplates()
-
saveConfiguration
public void saveConfiguration(Map<String,String> changedParameters) throws ConfigurationException
Save changed parameters innuxeo.conf
. This method does not check values in map. UsesaveFilteredConfiguration(Map)
for parameters filtering.- Parameters:
changedParameters
- Map of modified parameters- Throws:
ConfigurationException
- See Also:
saveFilteredConfiguration(Map)
-
saveConfiguration
public void saveConfiguration(Map<String,String> changedParameters, boolean setGenerationOnceToFalse, boolean setGenerationFalseToOnce) throws ConfigurationException
Save changed parameters innuxeo.conf
calculating templates if changedParameters contains a value forPARAM_TEMPLATE_DBNAME
. If a parameter value is empty ("" or null), then the property is unset.PARAM_TEMPLATES_NAME
andPARAM_FORCE_GENERATION
cannot be unset, but their value can be changed.This method does not check values in map: use
saveFilteredConfiguration(Map)
for parameters filtering.- Parameters:
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?- Throws:
ConfigurationException
- Since:
- 5.5
- See Also:
saveFilteredConfiguration(Map)
-
saveFilteredConfiguration
public void saveFilteredConfiguration(Map<String,String> changedParameters) throws ConfigurationException
Save changed parameters innuxeo.conf
, filtering parameters withgetChangedParameters(Map)
- Parameters:
changedParameters
- Maps of modified parameters- Throws:
ConfigurationException
- Since:
- 5.4.2
- See Also:
saveConfiguration(Map)
,getChangedParameters(Map)
-
getChangedParameters
public 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)- Parameters:
changedParameters
- parameters to be filtered- Returns:
- filtered map
- Since:
- 5.4.2
-
extractDatabaseTemplateName
public String extractDatabaseTemplateName()
Extract a database template from the current list of templates. Return the last one if there are multiples.- See Also:
rebuildTemplatesStr(String)
-
extractSecondaryDatabaseTemplateName
public String extractSecondaryDatabaseTemplateName()
Extract a NoSQL database template from the current list of templates. Return the last one if there are multiples.- Since:
- 8.1
- See Also:
rebuildTemplatesStr(String)
-
getNuxeoConf
public File getNuxeoConf()
- Returns:
- nuxeo.conf file used
-
initLogs
public void initLogs()
Delegate logs initialization to serverConfigurator instance- Since:
- 5.4.2
-
getDataDir
public File getDataDir()
- Returns:
- Data directory
- Since:
- 5.4.2
-
verifyInstallation
public void verifyInstallation() throws ConfigurationException
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 Also:
ServerConfigurator.verifyInstallation()
-
checkJavaVersion
public void checkJavaVersion() throws ConfigurationException
Check that the process is executed with a supported Java version. See J2SE SDK/JRE Version String Naming Convention- Throws:
ConfigurationException
- Since:
- 5.6
-
checkJavaVersion
protected static void checkJavaVersion(String version, String[] compliantVersions) throws ConfigurationException
Check the java version compared to compliant ones.- Parameters:
version
- the java versioncompliantVersions
- the compliant java versions- Throws:
ConfigurationException
- Since:
- 9.1
-
checkJavaVersion
protected static boolean checkJavaVersion(String version, String requiredVersion, boolean allowNoFailFlag, boolean warnIfLooseCompliance)
Checks the java version compared to the required one.Loose compliance is assumed if the major version is greater than the required major version or a jvmcheck=nofail flag is set.
- Parameters:
version
- the java versionrequiredVersion
- the required java versionallowNoFailFlag
- iftrue
then check jvmcheck=nofail flag to always have loose compliancewarnIfLooseCompliance
- iftrue
then log a WARN if the is loose compliance- Returns:
- true if the java version is compliant (maybe loosely) with the required version
- Since:
- 8.4
-
checkJavaVersion
public static boolean checkJavaVersion(String version, String requiredVersion)
Checks the java version compared to the required one.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.
- Parameters:
version
- the java versionrequiredVersion
- the required java version- Returns:
- true if the java version is compliant with the required version
- Since:
- 8.4
-
checkAddressesAndPorts
public void checkAddressesAndPorts() throws ConfigurationException
Will check the configured addresses are reachable and Nuxeo required ports are available on those addresses. Server specific implementations should override this method in order to check for server specific ports.PARAM_BIND_ADDRESS
must be set before.- Throws:
ConfigurationException
- Since:
- 5.5
- See Also:
ServerConfigurator.verifyInstallation()
-
getBindAddress
public InetAddress getBindAddress() throws ConfigurationException
Checks the userConfig bind address is not 0.0.0.0 and replaces it with 127.0.0.1 if needed- Returns:
- the userConfig bind address if not 0.0.0.0 else 127.0.0.1
- Throws:
ConfigurationException
- Since:
- 5.7
-
getBindAddress
public static InetAddress getBindAddress(String hostName) throws ConfigurationException
Checks hostName bind address is not 0.0.0.0 and replaces it with 127.0.0.1 if needed- Parameters:
hostName
- the hostname of Nuxeo server (works also with the IP)- Returns:
- the bind address matching hostName parameter if not 0.0.0.0 else 127.0.0.1
- Throws:
ConfigurationException
- Since:
- 9.2
-
checkAddressReachable
public static void checkAddressReachable(InetAddress address) throws ConfigurationException
- Parameters:
address
- address to check for availability- Throws:
ConfigurationException
- Since:
- 5.5
-
checkPortAvailable
public static void checkPortAvailable(InetAddress address, int port) throws ConfigurationException
Checks if port is available on given address.- Parameters:
port
- port to check for availability- Throws:
ConfigurationException
- Throws an exception if address is unavailable.- Since:
- 5.5
-
getLogFiles
public List<String> getLogFiles()
- Returns:
- Log files produced by Log4J configuration without loading this configuration instead of current active one.
- Since:
- 5.4.2
-
rebuildTemplatesStr
public String rebuildTemplatesStr(String dbTemplate)
Rebuild a templates string for use in nuxeo.conf- Parameters:
dbTemplate
- database template to use instead of current one- Returns:
- new templates string using given dbTemplate
- Since:
- 5.4.2
- See Also:
extractDatabaseTemplateName()
,changeDBTemplate(String)
,changeTemplates(String)
-
getConfigDir
public File getConfigDir()
- Returns:
- Nuxeo config directory
- Since:
- 5.4.2
-
getRuntimeHome
public File getRuntimeHome()
- Returns:
- Nuxeo runtime home
-
isInstallInProgress
public boolean isInstallInProgress()
- Returns:
- true if there's an install in progress
- Since:
- 5.4.2
-
getDistributionMPDir
@Deprecated(since="11.1") public File getDistributionMPDir()
Deprecated.since 11.1, Nuxeo Wizard has been removed.- Returns:
- File pointing to the directory containing the marketplace packages included in the distribution
- Since:
- 5.6
-
getInstallFile
public File getInstallFile()
- Returns:
- Install/upgrade file
- Since:
- 5.4.1
-
addTemplate
public void addTemplate(String templatesToAdd) throws ConfigurationException
Add template(s) to thePARAM_TEMPLATES_NAME
list if not already present- Parameters:
templatesToAdd
- Comma separated templates to add- Throws:
ConfigurationException
- Since:
- 5.5
-
getTemplateList
public List<String> getTemplateList()
Return the list of templates.- Since:
- 9.2
-
rmTemplate
public void rmTemplate(String templatesToRm) throws ConfigurationException
Remove template(s) from thePARAM_TEMPLATES_NAME
list- Parameters:
templatesToRm
- Comma separated templates to remove- Throws:
ConfigurationException
- Since:
- 5.5
-
setProperty
public String setProperty(String key, String value) throws ConfigurationException
Set a property in nuxeo configuration- Returns:
- The old value
- Throws:
ConfigurationException
- Since:
- 5.5
-
setProperties
public Map<String,String> setProperties(Map<String,String> newParametersToSave) throws ConfigurationException
Set properties in nuxeo configuration- Returns:
- The old values
- Throws:
ConfigurationException
- Since:
- 7.4
-
setProperties
public Map<String,String> setProperties(String template, Map<String,String> newParametersToSave) throws ConfigurationException, IOException
Set properties in the given template, if it exists- Returns:
- The old values
- Throws:
ConfigurationException
IOException
- Since:
- 7.4
-
checkDatabaseConnection
public void checkDatabaseConnection(String databaseTemplate, String dbName, String dbUser, String dbPassword, String dbHost, String dbPort) throws IOException, DatabaseDriverException, SQLException
Check driver availability and database connection- Parameters:
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.conf- Throws:
IOException
DatabaseDriverException
SQLException
- Since:
- 5.6
-
getEnv
public Environment getEnv()
- Returns:
- an
Environment
initialized with a few basics - Since:
- 5.6
-
checkFileCharset
public static Charset checkFileCharset(File propsFile) throws IOException
- Parameters:
propsFile
- Properties file- Returns:
- String with the charset encoding for this file
- Throws:
IOException
- Since:
- 10.2
-
loadNuxeoDefaults
protected Properties loadNuxeoDefaults(File directory) throws IOException
Loads thenuxeo.defaults
andnuxeo.NUXEO_ENVIRONMENT
files.This method assumes
nuxeo.defaults
exists and is readable.- Throws:
IOException
-
loadTrimmedProperties
public static Properties loadTrimmedProperties(File propsFile) throws IOException
- Parameters:
propsFile
- Properties file- Returns:
- new Properties containing trimmed keys and values read in
propsFile
- Throws:
IOException
- Since:
- 5.6
-
loadTrimmedProperties
protected static Properties loadTrimmedProperties(Properties props, File propsFile) throws IOException
- Throws:
IOException
-
loadTrimmedProperties
public static void loadTrimmedProperties(Properties props, InputStreamReader propsIS) throws IOException
- Parameters:
props
- Properties object to be filledpropsIS
- Properties InputStream- Throws:
IOException
- Since:
- 5.6
-
getDumpedConfig
public File getDumpedConfig()
- Returns:
- The generated properties file with dumped configuration.
- Since:
- 5.6
-
getContextEnv
public Hashtable<Object,Object> getContextEnv(String ldapUrl, String bindDn, String bindPassword, boolean checkAuthentication)
Build aHashtable
which contains environment properties to instantiate aInitialDirContext
- Since:
- 6.0
-
checkLdapConnection
public void checkLdapConnection(String ldapUrl, String ldapBindDn, String ldapBindPwd, boolean authenticate) throws NamingException
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- Parameters:
authenticate
- Indicates if authentication against LDAP should be checked.- Throws:
NamingException
- Since:
- 6.0
-
checkLdapConnection
public void checkLdapConnection(Hashtable<Object,Object> contextEnv) throws NamingException
- Parameters:
contextEnv
- Environment properties to build aInitialDirContext
- Throws:
NamingException
- Since:
- 6.0
-
getTemplateConf
@Deprecated(since="11.1") public File getTemplateConf(String template) throws ConfigurationException
Deprecated.since 11.1, there's several configuration files, usegetTemplateDirectory(String)
instead- Parameters:
template
- path to configuration template directory- Returns:
- A
nuxeo.defaults
file if it exists. - Throws:
ConfigurationException
- if the template file is not found.- Since:
- 7.4
-
getTemplateDirectory
public File getTemplateDirectory(String template) throws ConfigurationException
- Throws:
ConfigurationException
- if the template directory is not valid- Since:
- 11.1
-
isInvalidNuxeoDefaults
protected boolean isInvalidNuxeoDefaults(File templateDir)
-
getJavaOpts
@Deprecated protected String getJavaOpts(String key, String value)
Deprecated.Since 9.3. UsegetJavaOptsString()
instead.Gets the Java options with 'nuxeo.*' properties substituted. It enables usage of property like ${nuxeo.log.dir} inside JAVA_OPTS.- Returns:
- the Java options string.
-
getJavaOpts
public List<String> getJavaOpts(Function<String,String> mapper)
Gets the Java options defined in Nuxeo configuration files, e.g.bin/nuxeo.conf
andbin/nuxeoctl
.- Returns:
- the Java options.
- Since:
- 9.3
-
getJavaOptsString
protected String getJavaOptsString()
- Returns:
- the Java options string.
- Since:
- 9.3
- See Also:
getJavaOpts(Function)
-
getEnvironment
protected String getEnvironment(String key)
- Returns:
- the value of an environment variable
- Since:
- 9.1
- API Note:
- exists to be overridden by tests
-
getEnvironment
protected String getEnvironment(String key, String defaultValue)
- Returns:
- the value of an environment variable
- Since:
- 11.1
- See Also:
getEnvironment(String)
-
getNuxeoEnvironmentConfName
protected String getNuxeoEnvironmentConfName()
- Returns:
- the nuxeo.defaults file for current
NUXEO_ENVIRONMENT
- Since:
- 11.1
-
-