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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ConfigurationGenerator.Builder
-
Field Summary
Fields Modifier and Type Field Description static String
BOOTSTRAP_JAR_REGEX
protected static Path
DEFAULT_NUXEO_CONF_PATH
protected static Pattern
JAVA_OPTS_PATTERN
Java options split by spaces followed by an even number of quotes (or zero).static String
JAVA_OPTS_PROP
Java options configured inbin/nuxeo.conf
andbin/nuxeoctl
.static String
JULI_JAR_REGEX
static String
NUXEO_ENVIRONMENT_CONF_FORMAT
protected static String
PARAM_INCLUDED_TEMPLATES
Absolute or relative PATH to the included templates (comma separated list).protected Properties
systemProperties
System properties used to load the configuration, generallySystem.getProperties()
.static String
TEMPLATE_SEPARATOR
static String
VERSIONED_REGEX
-
Constructor Summary
Constructors Modifier Constructor Description ConfigurationGenerator()
Deprecated.since 11.5, usebuild()
instead.ConfigurationGenerator(boolean quiet, boolean debug)
Deprecated.since 11.5, usebuilder()
instead.protected
ConfigurationGenerator(ConfigurationGenerator.Builder builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTemplate(String templatesToAdd)
Add template(s) to theConfigurationConstants.PARAM_TEMPLATES_NAME
list if not already presentstatic ConfigurationGenerator
build()
static ConfigurationGenerator.Builder
builder()
protected void
createDirectoriesIfNotExist(Path path)
protected Map<String,String>
evalDynamicProperties()
Generate properties which values are based on othersprotected void
generateFiles()
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)ConfigurationHolder
getConfigurationHolder()
Returns theConfigurationHolder
held by the generator.Crypto
getCrypto()
Environment
getEnv()
List<String>
getJavaOpts(Function<String,String> mapper)
Gets the Java options defined in Nuxeo configuration files, e.g.CryptoProperties
getUserConfig()
protected void
includeTemplates()
boolean
init()
Initialize configurator, check requirements and load current configurationboolean
init(boolean forceReload)
Initialize configurator, check requirements and load current configurationprotected static void
initLogsIfNeeded(ConfigurationHolder configHolder)
Initializes log configuration if it doesn't exist.void
rmTemplate(String templatesToRm)
Remove template(s) from theConfigurationConstants.PARAM_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
.void
saveFilteredConfiguration(Map<String,String> changedParameters)
Save changed parameters innuxeo.conf
, filtering parameters withgetChangedParameters(Map)
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
-
TEMPLATE_SEPARATOR
public static final String TEMPLATE_SEPARATOR
- Since:
- 6.0
- See Also:
- Constant Field Values
- Implementation Note:
- also used for profiles
-
NUXEO_ENVIRONMENT_CONF_FORMAT
public static final String NUXEO_ENVIRONMENT_CONF_FORMAT
- Since:
- 11.1
- 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
-
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
-
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
-
DEFAULT_NUXEO_CONF_PATH
protected static final Path DEFAULT_NUXEO_CONF_PATH
- Since:
- 11.5
-
systemProperties
protected final Properties systemProperties
System properties used to load the configuration, generallySystem.getProperties()
.- Since:
- 11.5
-
-
Constructor Detail
-
ConfigurationGenerator
@Deprecated(since="11.5") public ConfigurationGenerator()
Deprecated.since 11.5, usebuild()
instead.
-
ConfigurationGenerator
@Deprecated(since="11.5") public ConfigurationGenerator(boolean quiet, boolean debug)
Deprecated.since 11.5, usebuilder()
instead.- Parameters:
quiet
- Suppress info level messages from the console outputdebug
- Activate debug level logging- Since:
- 5.6
-
ConfigurationGenerator
protected ConfigurationGenerator(ConfigurationGenerator.Builder builder)
- Since:
- 11.5
-
-
Method Detail
-
build
public static ConfigurationGenerator build()
- Since:
- 11.5
-
builder
public static ConfigurationGenerator.Builder builder()
- Since:
- 11.5
-
initLogsIfNeeded
protected static void initLogsIfNeeded(ConfigurationHolder configHolder)
Initializes log configuration if it doesn't exist.This is called in
ConfigurationGenerator(Builder)
, so the givenconfigHolder
is not yetloaded
.- Since:
- 11.5
-
getUserConfig
public CryptoProperties getUserConfig()
-
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
-
includeTemplates
protected void includeTemplates() throws ConfigurationException
- Throws:
ConfigurationException
- 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
-
generateFiles
protected void generateFiles() throws ConfigurationException
- Throws:
ConfigurationException
-
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
. If a parameter value is empty ("" or null), then the property is unset.ConfigurationConstants.PARAM_TEMPLATES_NAME
andConfigurationConstants.PARAM_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
-
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
-
createDirectoriesIfNotExist
protected void createDirectoriesIfNotExist(Path path) throws IOException
- Throws:
IOException
- Since:
- 11.5
-
addTemplate
public void addTemplate(String templatesToAdd) throws ConfigurationException
Add template(s) to theConfigurationConstants.PARAM_TEMPLATES_NAME
list if not already present- Parameters:
templatesToAdd
- Comma separated templates to add- Throws:
ConfigurationException
- Since:
- 5.5
-
rmTemplate
public void rmTemplate(String templatesToRm) throws ConfigurationException
Remove template(s) from theConfigurationConstants.PARAM_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
Set properties in the given template, if it exists- Returns:
- The old values
- Throws:
ConfigurationException
- Since:
- 7.4
-
getEnv
public Environment getEnv()
- Returns:
- an
Environment
initialized with a few basics - Since:
- 5.6
-
getCrypto
public Crypto getCrypto()
-
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
-
getConfigurationHolder
public ConfigurationHolder getConfigurationHolder()
Returns theConfigurationHolder
held by the generator.This configuration could be empty if the
init()
method hasn't been called.- Returns:
- the
ConfigurationHolder
held by the generator. - Since:
- 11.5
- See Also:
init()
-
-