Class CmsSetupBean

java.lang.Object
org.opencms.setup.CmsSetupBean
All Implemented Interfaces:
org.opencms.main.I_CmsShellCommands
Direct Known Subclasses:
CmsUpdateBean

public class CmsSetupBean extends Object implements org.opencms.main.I_CmsShellCommands
A java bean as a controller for the OpenCms setup wizard.

It is not allowed to customize this bean with methods for a specific database server setup!

Database server specific settings should be set/read using get/setDbProperty, as for example like:

 setDbProperty("oracle.defaultTablespace", value);
 

Since:
6.0.0
  • Field Details

  • Constructor Details

  • Method Details

    • backupConfiguration

      public void backupConfiguration(String filename, String originalFilename)
      Restores the opencms.xml either to or from a backup file, depending whether the setup wizard is executed the first time (the backup does not exist) or not (the backup exists).
      Parameters:
      filename - something like e.g. "opencms.xml"
      originalFilename - the configurations real file name, e.g. "opencms.xml.ori"
    • buildDepsForAllComponents

      Returns a map of dependencies.

      The component dependencies are get from the setup and module components.properties files found.

      Returns:
      a Map of component ids as keys and a list of dependency names as values
    • checkEthernetAddress

      public void checkEthernetAddress()
      Checks the ethernet address value and generates a dummy address, if necessary.

      *

    • clearCache

      public void clearCache()
      Clears the cache.

    • copyFile

      public void copyFile(String source, String target)
      Copies a given file.

      Parameters:
      source - the source file
      target - the destination file
    • displayError

      public String displayError(String pathPrefix)
      Returns html code to display an error.

      Parameters:
      pathPrefix - to adjust the path
      Returns:
      html code
    • displayErrors

      public String displayErrors(String pathPrefix)
      Returns html code to display the errors occurred.

      Parameters:
      pathPrefix - to adjust the path
      Returns:
      html code
    • getAvailableModules

      public Map<String,org.opencms.module.CmsModule> getAvailableModules()
      Returns a map with all available modules.

      The map contains maps keyed by module package names. Each of these maps contains various information about the module such as the module name, version, description, and a list of it's dependencies. You should refer to the source code of this method to understand the data structure of the map returned by this method!

      Returns:
      a map with all available modules
    • getComponents

      public org.opencms.workplace.tools.CmsIdentifiableObjectContainer<CmsSetupComponent> getComponents()
      Returns the components.

      Returns:
      the components
    • getConfigRfsPath

      Returns the "config" path in the OpenCms web application.

      Returns:
      the config path
    • getContextPath

    • getDatabase

      public String getDatabase()
      Returns the key of the selected database server (e.g. "mysql", "generic" or "oracle").

      Returns:
      the key of the selected database server (e.g. "mysql", "generic" or "oracle")
    • getDatabaseLibs

      public List<String> getDatabaseLibs(String databaseKey)
      Returns a list of needed jar filenames for a database server setup specified by a database key (e.g. "mysql", "generic" or "oracle").

      Parameters:
      databaseKey - a database key (e.g. "mysql", "generic" or "oracle")
      Returns:
      a list of needed jar filenames
    • getDatabaseName

      public String getDatabaseName(String databaseKey)
      Returns the clear text name for a database server setup specified by a database key (e.g. "mysql", "generic" or "oracle").

      Parameters:
      databaseKey - a database key (e.g. "mysql", "generic" or "oracle")
      Returns:
      the clear text name for a database server setup
    • getDatabaseProperties

      Returns a map with the database properties of *all* available database configurations keyed by their database keys (e.g. "mysql", "generic" or "oracle").

      Returns:
      a map with the database properties of *all* available database configurations
    • getDatabases

      Returns a list with they keys (e.g. "mysql", "generic" or "oracle") of all available database server setups found in "/setup/database/".

      Returns:
      a list with they keys (e.g. "mysql", "generic" or "oracle") of all available database server setups
    • getDb

      public String getDb()
      Returns the database name.

      Returns:
      the database name
    • getDbConStrParams

      Returns the JDBC connect URL parameters.

      Returns:
      the JDBC connect URL parameters
    • getDbCreateConStr

      Returns the database create statement.

      Returns:
      the database create statement
    • getDbCreatePwd

      Returns the password used for database creation.

      Returns:
      the password used for database creation
    • getDbCreateUser

      Returns the database user that is used to connect to the database.

      Returns:
      the database user
    • getDbDriver

      public String getDbDriver()
      Returns the database driver belonging to the database from the default configuration.

      Returns:
      name of the database driver
    • getDbProperty

      public String getDbProperty(String key)
      Returns the value for a given key from the database properties.
      Parameters:
      key - the property key
      Returns:
      the string value for a given key
    • getDbTestQuery

      Returns the validation query belonging to the database from the default configuration .

      Returns:
      query used to validate connections
    • getDbWorkConStr

      Returns a connection string.

      Returns:
      the connection string used by the OpenCms core
    • getDbWorkPwd

      public String getDbWorkPwd()
      Returns the password of the database from the properties .

      Returns:
      the password for the OpenCms database user
    • getDbWorkUser

      Returns the user of the database from the properties.

      Returns:
      the database user used by the opencms core
    • getDefaultContentEncoding

      Returns the default content encoding.

      Returns:
      String
    • getDefaultWebApplication

      Returns the name of the default web application, configured in web.xml.

      By default this is "ROOT".

      Returns:
      the name of the default web application, configured in web.xml
    • getDisplayForModule

      public String getDisplayForModule(org.opencms.module.CmsModule module)
      Returns the display string for a given module.

      Parameters:
      module - a module
      Returns:
      the display string for the given module
    • getErrors

      public List<String> getErrors()
      Returns the error messages.

      Returns:
      a vector of error messages
    • getEthernetAddress

      Returns the mac ethernet address.

      Returns:
      the mac ethernet addess
    • getFullDatabaseKey

      Returns the fullDatabaseKey.

      Returns:
      the fullDatabaseKey
    • getHtmlForDbSelection

      Generates the HTML code for the drop down for db selection.

      Returns:
      the generated HTML
    • getHtmlHelpIcon

      public String getHtmlHelpIcon(String id, String pathPrefix)
      Returns a help image icon tag to display a help text in the setup wizard.

      Parameters:
      id - the id of the desired help div
      pathPrefix - the path prefix to the image
      Returns:
      the HTML part for the help icon or an empty String, if the part was not found
    • getHtmlPart

      public String getHtmlPart(String part)
      Returns the specified HTML part of the HTML property file to create the output.

      Parameters:
      part - the name of the desired part
      Returns:
      the HTML part or an empty String, if the part was not found
    • getHtmlPart

      public String getHtmlPart(String part, String replaceString)
      Returns the specified HTML part of the HTML property file to create the output.

      Parameters:
      part - the name of the desired part
      replaceString - String which is inserted in the found HTML part at the location of "$replace$"
      Returns:
      the HTML part or an empty String, if the part was not found
    • getLibFolder

      public String getLibFolder()
      Returns the path to the /WEB-INF/lib folder.

      Returns:
      the path to the /WEB-INF/lib folder
    • getLogName

      public String getLogName()
      Returns the name of the log file.

      Returns:
      the name of the log file
    • getModuleDependencies

      Returns a map with lists of dependent module package names keyed by module package names.

      Returns:
      a map with lists of dependent module package names keyed by module package names
    • getModuleFolder

      Returns the absolute path to the module root folder.

      Returns:
      the absolute path to the module root folder
    • getModulesToInstall

      Returns A list with the package names of the modules to be installed.

      Returns:
      A list with the package names of the modules to be installed
    • getPool

      public String getPool()
      Gets the default pool.

      Returns:
      name of the default pool
    • getProperties

      public org.opencms.configuration.CmsParameterConfiguration getProperties()
      Returns the parameter configuration.

      Returns:
      the parameter configuration
    • getReplacer

      Returns the replacer.

      Returns:
      the replacer
    • getServerName

      Return the OpenCms server name.

      Returns:
      the OpenCms server name
    • getServletConfig

      public javax.servlet.ServletConfig getServletConfig()
      Returns the initial servlet configuration.

      Returns:
      the initial servlet configuration
    • getServletMapping

      Returns the OpenCms servlet mapping, configured in web.xml.

      By default this is "/opencms/*".

      Returns:
      the OpenCms servlet mapping, configured in web.xml
    • getSortedDatabases

      Returns a sorted list with they keys (e.g. "mysql", "generic" or "oracle") of all available database server setups found in "/setup/database/" sorted by their ranking property.

      Returns:
      a sorted list with they keys (e.g. "mysql", "generic" or "oracle") of all available database server setups
    • getWebAppRfsPath

      Returns the absolute path to the OpenCms home directory.

      Returns:
      the path to the OpenCms home directory
    • getWizardEnabled

      public boolean getWizardEnabled()
      Checks if the setup wizard is enabled.

      Returns:
      true if the setup wizard is enables, false otherwise
    • getWorkplaceImportThread

      Returns the workplace import thread.

      Returns:
      the workplace import thread
    • getWorkplaceSite

      Return the OpenCms workplace site.

      Returns:
      the OpenCms workplace site
    • getXmlHelper

      Returns the xml Helper object.

      Returns:
      the xml Helper object
    • hasIndexHtml

      public boolean hasIndexHtml()
      Returns true if there is an index.html file in the default site after the module import.
      Returns:
      true if there is an index.html file
    • htmlComponents

      Returns the html code for component selection.

      Returns:
      html code
    • htmlModuleHelpDescriptions

      Returns html code for the module descriptions in help ballons.

      Returns:
      html code
    • htmlModules

      public String htmlModules()
      Returns html for displaying a module selection box.

      Returns:
      html code
    • importModulesFromSetupBean

      public void importModulesFromSetupBean() throws Exception
      Installed all modules that have been set using setInstallModules(String).

      This method is invoked as a shell command.

      Throws:
      Exception - if something goes wrong
    • init

      public void init(javax.servlet.jsp.PageContext pageContext)
      Creates a new instance of the setup Bean from a JSP page.

      Parameters:
      pageContext - the JSP's page context
    • init

      public void init(javax.servlet.ServletContext servCtx, javax.servlet.ServletConfig servConfig)
    • init

      public void init(String webAppRfsPath, String servletMapping, String defaultWebApplication)
      Creates a new instance of the setup Bean.

      Parameters:
      webAppRfsPath - path to the OpenCms web application
      servletMapping - the OpenCms servlet mapping
      defaultWebApplication - the name of the default web application
    • initHtmlParts

      public void initHtmlParts()
      This method reads the properties from the htmlmsg.property file and sets the HTML part properties with the matching values.

    • initShellCmsObject

      public void initShellCmsObject(org.opencms.file.CmsObject cms, org.opencms.main.CmsShell shell)
      Specified by:
      initShellCmsObject in interface org.opencms.main.I_CmsShellCommands
      See Also:
      • I_CmsShellCommands.initShellCmsObject(org.opencms.file.CmsObject, org.opencms.main.CmsShell)
    • isAutoMode

      public boolean isAutoMode()
      Returns the autoMode.

      Returns:
      the autoMode
    • isChecked

      public String isChecked(String value1, String value2)
      Over simplistic helper to compare two strings to check radio buttons.
      Parameters:
      value1 - the first value
      value2 - the second value
      Returns:
      "checked" if both values are equal, the empty String "" otherwise
    • isInitialized

      public boolean isInitialized()
      Returns true if this setup bean is correctly initialized.

      Returns:
      true if this setup bean is correctly initialized
    • jsComponentDependencies

      Returns js code with array definition for the available component dependencies.

      Returns:
      js code
    • jsComponentModules

      Returns js code with array definition for the component modules.

      Returns:
      js code
    • jsComponentNames

      Returns js code with array definition for the available components names.

      Returns:
      js code
    • jsModuleDependencies

      Returns js code with array definition for the available module dependencies.

      Returns:
      js code
    • jsModuleNames

      Returns js code with array definition for the available module names.

      Returns:
      js code
    • lockWizard

      public void lockWizard()
      Locks (i.e. disables) the setup wizard.

    • prepareStep10

      public void prepareStep10()
      Prepares step 10 of the setup wizard.

    • prepareStep8

      public boolean prepareStep8()
      Prepares step 8 of the setup wizard.

      Returns:
      true if the workplace should be imported
    • prepareStep8b

      public void prepareStep8b()
      Prepares step 8b of the setup wizard.

    • prepareStep8bOutput

      public void prepareStep8bOutput(javax.servlet.jsp.JspWriter out) throws IOException
      Generates the output for step 8b of the setup wizard.

      Parameters:
      out - the JSP print stream
      Throws:
      IOException - in case errors occur while writing to "out"
    • saveProperties

      public void saveProperties(org.opencms.configuration.CmsParameterConfiguration properties, String file, boolean backup)
      Saves properties to specified file.

      Parameters:
      properties - the properties to be saved
      file - the file to save the properties to
      backup - if true, create a backupfile
    • saveProperties

      public void saveProperties(org.opencms.configuration.CmsParameterConfiguration properties, String file, boolean backup, Set<String> forceWrite)
      Saves properties to specified file.

      Parameters:
      properties - the properties to be saved
      file - the file to save the properties to
      backup - if true, create a backupfile
      forceWrite - the keys for the properties which should always be written, even if they don't exist in the configuration file
    • setAutoMode

      public void setAutoMode(boolean autoMode)
      Sets the autoMode.

      Parameters:
      autoMode - the autoMode to set
    • setDatabase

      public void setDatabase(String databaseKey)
      Sets the database drivers to the given value.

      Parameters:
      databaseKey - the key of the selected database server (e.g. "mysql", "generic" or "oracle")
    • setDb

      public void setDb(String db)
      Sets the database name.

      Parameters:
      db - the database name to set
    • setDbConStrParams

      public void setDbConStrParams(String value)
      Sets the JDBC connect URL parameters.

      Parameters:
      value - the JDBC connect URL parameters
    • setDbCreateConStr

      public void setDbCreateConStr(String dbCreateConStr)
      Sets the database create statement.

      Parameters:
      dbCreateConStr - the database create statement
    • setDbCreatePwd

      public void setDbCreatePwd(String dbCreatePwd)
      Sets the password used for the initial OpenCms database creation.

      This password will not be stored permanently, but used only in the setup wizard.

      Parameters:
      dbCreatePwd - the password used for the initial OpenCms database creation
    • setDbCreateUser

      public void setDbCreateUser(String dbCreateUser)
      Set the database user that is used to connect to the database.

      Parameters:
      dbCreateUser - the user to set
    • setDbDriver

      public void setDbDriver(String driver)
      Sets the database driver belonging to the database.

      Parameters:
      driver - name of the opencms driver
    • setDbParamaters

      public boolean setDbParamaters(javax.servlet.http.HttpServletRequest request, String provider)
      Sets the needed database parameters.

      Parameters:
      request - the http request
      provider - the db provider
      Returns:
      true if already submitted
    • setDbParamaters

      public boolean setDbParamaters(Map<String,String[]> request, String provider, String contextPath, javax.servlet.http.HttpSession session)
      Sets the needed database parameters.

      Parameters:
      request - the http request
      provider - the db provider
      contextPath - the context path to use
      session - the session to use or null if running outside a servlet container
      Returns:
      true if already submitted
    • setDbProperty

      public void setDbProperty(String key, String value)
      This method sets the value for a given key in the database properties.

      Parameters:
      key - The key of the property
      value - The value of the property
    • setDbWorkConStr

      public void setDbWorkConStr(String dbWorkConStr)
      Sets the connection string to the database to the given value.

      Parameters:
      dbWorkConStr - the connection string used by the OpenCms core
    • setDbWorkPwd

      public void setDbWorkPwd(String dbWorkPwd)
      Sets the password of the database to the given value.

      Parameters:
      dbWorkPwd - the password for the OpenCms database user
    • setDbWorkUser

      public void setDbWorkUser(String dbWorkUser)
      Sets the user of the database to the given value.

      Parameters:
      dbWorkUser - the database user used by the opencms core
    • setEthernetAddress

      public void setEthernetAddress(String ethernetAddress)
      Set the mac ethernet address, required for UUID generation.

      Parameters:
      ethernetAddress - the mac addess to set
    • setFullDatabaseKey

      public void setFullDatabaseKey(String fullDatabaseKey)
      Sets the fullDatabaseKey.

      Parameters:
      fullDatabaseKey - the fullDatabaseKey to set
    • setInstallModules

      public void setInstallModules(String value)
      Sets the list with the package names of the modules to be installed.

      Parameters:
      value - a string with the package names of the modules to be installed delimited by the pipe symbol "|"
    • setReplacer

      public void setReplacer(Map<String,String> map)
      Sets the replacer.

      Parameters:
      map - the replacer to set
    • setServerName

      public void setServerName(String name)
      Sets the OpenCms server name.

      Parameters:
      name - the OpenCms server name
    • setStartView

      public void setStartView(String userName, String view) throws org.opencms.main.CmsException
      Sets the start view for the given user.

      Parameters:
      userName - the name of the user
      view - the start view path
      Throws:
      org.opencms.main.CmsException - if something goes wrong
    • setWorkplaceSite

      public void setWorkplaceSite(String newSite)
      Sets the OpenCms workplace site.

      Parameters:
      newSite - the OpenCms workplace site
    • shellExit

      public void shellExit()
      Specified by:
      shellExit in interface org.opencms.main.I_CmsShellCommands
      See Also:
      • I_CmsShellCommands.shellExit()
    • shellStart

      public void shellStart()
      Specified by:
      shellStart in interface org.opencms.main.I_CmsShellCommands
      See Also:
      • I_CmsShellCommands.shellStart()
    • sortModules

      public List<String> sortModules(Collection<org.opencms.module.CmsModule> modules)
      Sorts the modules for display.

      Parameters:
      modules - the list of CmsModule objects
      Returns:
      a sorted list of module names
    • updateConfiguration

      public void updateConfiguration()
      Writes configuration changes back to the XML configuration.
    • validateJdbc

      public boolean validateJdbc()
      Checks the jdbc driver.

      Returns:
      true if at least one of the recommended drivers is found
    • addComponentsFromPath

      protected void addComponentsFromPath(String fileName) throws org.opencms.configuration.CmsConfigurationException
      Reads all components from the given location, a folder or a zip file.

      Parameters:
      fileName - the location to read the components from
      Throws:
      org.opencms.configuration.CmsConfigurationException - if something goes wrong
    • getComponentModules

      protected String getComponentModules(List<String> componentIds)
      Returns a pipe separated list of module names for the given list of components.

      Parameters:
      componentIds - the list of component IDs to get the modules for
      Returns:
      a pipe separated list of module names for the given list of components
    • getComponentsProperties

      protected org.opencms.configuration.CmsParameterConfiguration getComponentsProperties(String location) throws FileNotFoundException, org.opencms.configuration.CmsConfigurationException
      Reads all properties from the components.properties file at the given location, a folder or a zip file.

      Parameters:
      location - the location to read the properties from
      Returns:
      the read properties
      Throws:
      FileNotFoundException - if the properties file could not be found
      org.opencms.configuration.CmsConfigurationException - if the something else goes wrong
    • getExtProperty

      protected String getExtProperty(String key)
      Returns the value for a given key from the extended properties.
      Parameters:
      key - the property key
      Returns:
      the string value for a given key
    • htmlComponent

      protected String htmlComponent(CmsSetupComponent component)
      Returns html for the given component to fill the selection list.

      Parameters:
      component - the component to generate the code for
      Returns:
      html code
    • htmlModule

      protected String htmlModule(org.opencms.module.CmsModule module, int pos)
      Returns html for the given module to fill the selection list.

      Parameters:
      module - the module to generate the code for
      pos - the position in the list
      Returns:
      html code
    • importModuleFromDefault

      protected void importModuleFromDefault(String importFile) throws Exception
      Imports a module (zipfile) from the default module directory, creating a temporary project for this.

      Parameters:
      importFile - the name of the import module located in the default module directory
      Throws:
      Exception - if something goes wrong
      See Also:
      • CmsImportExportManager.importData(CmsObject, org.opencms.report.I_CmsReport, CmsImportParameters)
    • initializeComponents

      protected void initializeComponents(Collection<String> modules)
      Initializes and validates the read components.

      Parameters:
      modules - a modifiable list of the modules to be imported
    • isImportRunning

      protected boolean isImportRunning()
      Returns true if the import thread is currently running.

      Returns:
      true if the import thread is currently running
    • readDatabaseConfig

      protected void readDatabaseConfig()
      Stores the properties of all available database configurations in a map keyed by their database key names (e.g. "mysql", "generic" or "oracle").

    • setExtProperty

      protected void setExtProperty(String key, String value)
      This method sets the value for a given key in the extended properties.
      Parameters:
      key - The key of the property
      value - The value of the property