Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.launcher.config
Class ConfigurationGenerator

java.lang.Object
  extended by 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
static int ADDRESS_PING_TIMEOUT
           
static String BOUNDARY_BEGIN
           
static String BOUNDARY_END
           
static List<String> DB_LIST
           
 boolean isJBoss
           
 boolean isJetty
           
 boolean isTomcat
           
static int MAX_PORT
           
static int MIN_PORT
           
static String NUXEO_CONF
           
static String NUXEO_HOME
           
static String PARAM_BIND_ADDRESS
           
static String PARAM_CONTEXT_PATH
           
static String PARAM_FAKE_WINDOWS
           
static String PARAM_FORCE_GENERATION
           
static String PARAM_HTTP_PORT
           
static String PARAM_LOOPBACK_URL
           
static String PARAM_STATUS_KEY
           
static String PARAM_TEMPLATE_DBNAME
           
static String PARAM_TEMPLATE_NAME
          Deprecated. use PARAM_TEMPLATES_NAME instead
static String PARAM_TEMPLATES_NAME
          Absolute or relative PATH to the user chosen templates (comma separated list)
static String PARAM_TEMPLATES_NODB
           
static String PARAM_TEMPLATES_PARSING_EXTENSIONS
           
static String PARAM_WIZARD_DONE
           
static String PARAM_WIZARD_RESTART_PARAMS
           
 
Constructor Summary
ConfigurationGenerator()
           
 
Method Summary
 void changeDBTemplate(String dbTemplate)
          Change templates using given database template
 void 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)
           
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
 String extractDatabaseTemplateName()
          Extract a database template from a list of templates.
 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()
           
 File getDataDir()
           
 List<File> getIncludedTemplates()
           
 File getInstallFile()
           
 File getLogDir()
           
 ArrayList<String> getLogFiles()
           
 File getNuxeoConf()
           
 File getNuxeoDefaultConf()
           
 File getNuxeoHome()
           
 File getPidDir()
           
 File getRuntimeHome()
           
 ServerConfigurator getServerConfigurator()
           
 File getTmpDir()
           
 Properties getUserConfig()
           
 boolean init()
          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 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
 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 setWizardOnceToFalse, boolean setWizardFalseToOnce)
          Save changed parameters in nuxeo.conf.
 void saveFilteredConfiguration(Map<String,String> changedParameters)
          Save changed parameters in nuxeo.conf, filtering parameters with #getChangedParametersMap(Map, Map) and calculating templates if changedParameters contains a value for PARAM_TEMPLATE_DBNAME
 void setDirectoryWithProperty(String key)
           
 void setForceGeneration(boolean forceGeneration)
           
 void verifyInstallation()
          Create needed directories.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUXEO_HOME

public static final String NUXEO_HOME
See Also:
Constant Field Values

NUXEO_CONF

public static final String NUXEO_CONF
See Also:
Constant Field Values

PARAM_TEMPLATE_NAME

@Deprecated
public static final String PARAM_TEMPLATE_NAME
Deprecated. use PARAM_TEMPLATES_NAME instead
Absolute or relative PATH to the user chosen template

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_TEMPLATES_NODB

public static final String PARAM_TEMPLATES_NODB
See Also:
Constant Field Values

PARAM_TEMPLATES_PARSING_EXTENSIONS

public static final String PARAM_TEMPLATES_PARSING_EXTENSIONS
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_LIST

public static final List<String> DB_LIST

PARAM_WIZARD_DONE

public static final String PARAM_WIZARD_DONE
See Also:
Constant Field Values

PARAM_WIZARD_RESTART_PARAMS

public static final String PARAM_WIZARD_RESTART_PARAMS
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

public static final String PARAM_STATUS_KEY
See Also:
Constant Field Values

PARAM_CONTEXT_PATH

public static final String PARAM_CONTEXT_PATH
See Also:
Constant Field Values

isJBoss

public boolean isJBoss

isJetty

public boolean isJetty

isTomcat

public boolean isTomcat
Constructor Detail

ConfigurationGenerator

public ConfigurationGenerator()
Method Detail

isConfigurable

public boolean isConfigurable()

setForceGeneration

public void setForceGeneration(boolean forceGeneration)
Parameters:
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 Properties 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

changeTemplates

public void changeTemplates(String newTemplates)

changeDBTemplate

public void changeDBTemplate(String dbTemplate)
Change templates using given database template

Parameters:
dbTemplate - new database template
Since:
5.4.2

setDirectoryWithProperty

public void setDirectoryWithProperty(String key)
Parameters:
key - Directory system key
Since:
5.4.2
See Also:
Environment

getNuxeoHome

public File getNuxeoHome()

getNuxeoDefaultConf

public File getNuxeoDefaultConf()

getIncludedTemplates

public List<File> getIncludedTemplates()

main

public static void main(String[] args)
                 throws ConfigurationException
Throws:
ConfigurationException

saveConfiguration

public void saveConfiguration(Map<String,String> changedParameters)
                       throws ConfigurationException
Save changed parameters in nuxeo.conf. This method does not check values in map. Use saveFilteredConfiguration(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 setWizardOnceToFalse,
                              boolean setWizardFalseToOnce)
                       throws ConfigurationException
Save changed parameters in nuxeo.conf. This method does not check values in map. Use saveFilteredConfiguration(Map) for parameters filtering.

Parameters:
changedParameters - Map of modified parameters
setWizardOnceToFalse - If wizard was on (true or once), then set it to false or not?
setWizardFalseToOnce - If wizard was off (false), then set it to once?
Throws:
ConfigurationException
Since:
5.4.3
See Also:
saveFilteredConfiguration(Map)

saveFilteredConfiguration

public void saveFilteredConfiguration(Map<String,String> changedParameters)
                               throws ConfigurationException
Save changed parameters in nuxeo.conf, filtering parameters with #getChangedParametersMap(Map, Map) and calculating templates if changedParameters contains a value for PARAM_TEMPLATE_DBNAME

Parameters:
changedParameters - Maps of modified parameters
Throws:
ConfigurationException
Since:
5.4.2
See Also:
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 a list of templates. Return the last one if there are multiples

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

getLogDir

public File getLogDir()
Returns:
log directory
Since:
5.4.2

getPidDir

public File getPidDir()
Returns:
pid directory
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

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. #bindAddress must be set before.

Throws:
ConfigurationException
Since:
5.4.3

checkAddressReachable

public static void checkAddressReachable(InetAddress address)
                                  throws ConfigurationException
Parameters:
address - address to check for availability
Throws:
ConfigurationException
Since:
5.4.3

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.4.3

getTmpDir

public File getTmpDir()
Returns:
Temporary directory

getLogFiles

public ArrayList<String> getLogFiles()
Returns:
Log files produced by Log4J configuration without loading this configuration instead of current active one.
Since:
5.4.2

isWizardRequired

public boolean isWizardRequired()
Check if wizard must and can be ran

Returns:
true if configuration wizard is required before starting Nuxeo
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

prepareWizardStart

public void prepareWizardStart()
Ensure the server will start only wizard application, not Nuxeo

Since:
5.4.2

cleanupPostWizard

public void cleanupPostWizard()
Ensure the wizard won't be started and nuxeo is ready for use

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

getInstallFile

public File getInstallFile()
Returns:
Install/upgrade file
Since:
5.4.1

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.