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
|
protected void |
checkForDeprecatedParameters(Properties properties)
Check for deprecated parameters
|
void |
checkJavaVersion()
Check that the process is executed with a supported Java version.
|
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
|
String |
extractDatabaseTemplateName()
Extract a database template from the current list of templates.
|
protected void |
generateFiles() |
InetAddress |
getBindAddress() |
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() |
List<File> |
getIncludedTemplates() |
File |
getInstallFile() |
File |
getLogDir() |
ArrayList<String> |
getLogFiles() |
File |
getNuxeoConf() |
File |
getNuxeoDefaultConf() |
File |
getNuxeoHome() |
File |
getPidDir() |
File |
getRuntimeHome() |
ServerConfigurator |
getServerConfigurator() |
protected Properties |
getStoredConfig() |
File |
getTemplateConf(String template) |
File |
getTmpDir() |
CryptoProperties |
getUserConfig() |
String |
getUserTemplates() |
protected boolean |
hasSeamDebugFile()
Deprecated.
since 5.6
|
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,
InputStream propsIS) |
static void |
main(String[] args) |
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
@Deprecated public static final String NUXEO_HOME
Environment#NUXEO_HOME
insteadpublic static final String NUXEO_CONF
public static final String TEMPLATES
public static final String NUXEO_DEFAULT_CONF
@Deprecated public static final String PARAM_TEMPLATE_NAME
PARAM_TEMPLATES_NAME
insteadpublic static final String PARAM_TEMPLATES_NAME
public static final String PARAM_TEMPLATE_DBNAME
public static final String PARAM_TEMPLATE_DBTYPE
@Deprecated public static final String PARAM_TEMPLATES_NODB
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_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
@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
@Deprecated public static final String SEAM_HOT_RELOAD_GLOBAL_CONFIG_FILE
SEAM_DEBUG_SYSTEM_PROP
in nuxeo.conf is enough now.public boolean isJBoss
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)
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)
newTemplates
- public void changeDBTemplate(String dbTemplate)
dbTemplate
- new database templateprotected void includeTemplates() throws IOException
IOException
@Deprecated protected boolean hasSeamDebugFile()
On 5.6, using the config generator to get the info from the nuxeo.conf file makes it possible to get the property
value this early, so adding an empty file at SEAM_HOT_RELOAD_GLOBAL_CONFIG_FILE
is no longer needed.
protected HashMap<String,String> evalDynamicProperties() throws ConfigurationException
nuxeoConf
ConfigurationException
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)
properties
- public File getNuxeoHome()
public File getNuxeoDefaultConf()
public List<File> getIncludedTemplates()
public static void main(String[] args) throws ConfigurationException
ConfigurationException
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 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
public void checkAddressesAndPorts() throws ConfigurationException
PARAM_BIND_ADDRESS
must be set before.ConfigurationException
ServerConfigurator.verifyInstallation()
public InetAddress getBindAddress() throws ConfigurationException
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 ArrayList<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 void rmTemplate(String templatesToRm) throws ConfigurationException
PARAM_TEMPLATES_NAME
listtemplatesToRm
- Comma separated templates to removeConfigurationException
public String setProperty(String key, String value) throws ConfigurationException
key
- value
- ConfigurationException
public Map<String,String> setProperties(Map<String,String> newParametersToSave) throws ConfigurationException
newParametersToSave
- ConfigurationException
public Map<String,String> setProperties(String template, Map<String,String> newParametersToSave) throws ConfigurationException, IOException
newParametersToSave
- ConfigurationException
IOException
public void checkDatabaseConnection(String databaseTemplate, String dbName, String dbUser, String dbPassword, String dbHost, String dbPort) throws FileNotFoundException, 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.confDatabaseDriverException
IOException
FileNotFoundException
SQLException
public Environment getEnv()
Environment
initialized with a few basicspublic static Properties loadTrimmedProperties(File propsFile) throws IOException
propsFile
- Properties filepropsFile
IOException
public static void loadTrimmedProperties(Properties props, InputStream 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
ldapUrl
- ldapBindDn
- ldapBindPwd
- 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.Copyright © 2015 Nuxeo SA. All rights reserved.