📄 cmssetupbean.java
字号:
}
} catch (CmsConfigurationException e) {
throw new CmsRuntimeException(e.getMessageContainer());
}
}
return m_availableModules;
}
/**
* Returns the "config" path in the OpenCms web application.<p>
*
* @return the config path
*/
public String getConfigRfsPath() {
return m_configRfsPath;
}
/**
* Returns the key of the selected database server (e.g. "mysql", "generic" or "oracle").<p>
*
* @return the key of the selected database server (e.g. "mysql", "generic" or "oracle")
*/
public String getDatabase() {
if (m_databaseKey == null) {
m_databaseKey = getExtProperty("db.name");
}
if (CmsStringUtil.isEmpty(m_databaseKey)) {
m_databaseKey = (String)getSortedDatabases().get(0);
}
return m_databaseKey;
}
/**
* Returns the URI of a database config page (in step 3) for a specified database key.<p>
*
* @param key the database key (e.g. "mysql", "generic" or "oracle")
* @return the URI of a database config page
*/
public String getDatabaseConfigPage(String key) {
// don't use File.separatorChar here, result must be a valid URL with "/" path delimiters
String configUri = FOLDER_DATABASE + key + File.separatorChar + "step_4_database_setup.jsp";
return configUri.replace(File.separatorChar, '/');
}
/**
* Returns a list of needed jar filenames for a database server setup specified by a database key (e.g. "mysql", "generic" or "oracle").<p>
*
* @param databaseKey a database key (e.g. "mysql", "generic" or "oracle")
*
* @return a list of needed jar filenames
*/
public List getDatabaseLibs(String databaseKey) {
return CmsStringUtil.splitAsList((String)((Map)getDatabaseProperties().get(databaseKey)).get(databaseKey
+ ".libs"), ',', true);
}
/**
* Returns the clear text name for a database server setup specified by a database key (e.g. "mysql", "generic" or "oracle").<p>
*
* @param databaseKey a database key (e.g. "mysql", "generic" or "oracle")
* @return the clear text name for a database server setup
*/
public String getDatabaseName(String databaseKey) {
return (String)((Map)getDatabaseProperties().get(databaseKey)).get(databaseKey + ".name");
}
/**
* Returns a map with the database properties of *all* available database configurations keyed
* by their database keys (e.g. "mysql", "generic" or "oracle").<p>
*
* @return a map with the database properties of *all* available database configurations
*/
public Map getDatabaseProperties() {
if (m_databaseProperties != null) {
return m_databaseProperties;
}
readDatabaseConfig();
return m_databaseProperties;
}
/**
* Returns a list with they keys (e.g. "mysql", "generic" or "oracle") of all available
* database server setups found in "/setup/database/".<p>
*
* @return a list with they keys (e.g. "mysql", "generic" or "oracle") of all available database server setups
*/
public List getDatabases() {
File databaseSetupFolder = null;
File[] childResources = null;
File childResource = null;
File setupFile = null;
boolean hasMissingSetupFiles = false;
if (m_databaseKeys != null) {
return m_databaseKeys;
}
try {
m_databaseKeys = new ArrayList();
databaseSetupFolder = new File(m_webAppRfsPath + FOLDER_SETUP + FOLDER_DATABASE);
if (databaseSetupFolder.exists()) {
childResources = databaseSetupFolder.listFiles();
if (childResources != null) {
for (int i = 0; i < childResources.length; i++) {
childResource = childResources[i];
hasMissingSetupFiles = false;
if (childResource.exists() && childResource.isDirectory() && childResource.canRead()) {
for (int j = 0; j < REQUIRED_DB_SETUP_FILES.length; j++) {
setupFile = new File(childResource.getPath()
+ File.separatorChar
+ REQUIRED_DB_SETUP_FILES[j]);
if (!setupFile.exists() || !setupFile.isFile() || !setupFile.canRead()) {
hasMissingSetupFiles = true;
System.err.println("["
+ getClass().getName()
+ "] missing or unreadable database setup file: "
+ setupFile.getPath());
break;
}
}
if (!hasMissingSetupFiles) {
m_databaseKeys.add(childResource.getName().trim());
}
}
}
}
}
} catch (Exception e) {
System.err.println(e.toString());
e.printStackTrace(System.err);
}
return m_databaseKeys;
}
/**
* Returns the database name.<p>
*
* @return the database name
*/
public String getDb() {
return getDbProperty(m_databaseKey + ".dbname");
}
/**
* Returns the JDBC connect URL parameters.<p>
*
* @return the JDBC connect URL parameters
*/
public String getDbConStrParams() {
return getDbProperty(m_databaseKey + ".constr.params");
}
/**
* Returns the database create statement.<p>
*
* @return the database create statement
*/
public String getDbCreateConStr() {
return getDbProperty(m_databaseKey + ".constr");
}
/**
* Returns the password used for database creation.<p>
*
* @return the password used for database creation
*/
public String getDbCreatePwd() {
return (m_dbCreatePwd != null) ? m_dbCreatePwd : "";
}
/**
* Returns the database user that is used to connect to the database.<p>
*
* @return the database user
*/
public String getDbCreateUser() {
return getDbProperty(m_databaseKey + ".user");
}
/**
* Returns the database driver belonging to the database
* from the default configuration.<p>
*
* @return name of the database driver
*/
public String getDbDriver() {
return getDbProperty(m_databaseKey + ".driver");
}
/**
* Returns the value for a given key from the database properties.
*
* @param key the property key
* @return the string value for a given key
*/
public String getDbProperty(String key) {
// extract the database key out of the entire key
String databaseKey = key.substring(0, key.indexOf('.'));
Map databaseProperties = (Map)getDatabaseProperties().get(databaseKey);
Object value = databaseProperties.get(key);
return (value != null) ? (String)value : "";
}
/**
* Returns the validation query belonging to the database
* from the default configuration .<p>
*
* @return query used to validate connections
*/
public String getDbTestQuery() {
return getDbProperty(m_databaseKey + ".testQuery");
}
/**
* Returns a connection string.<p>
*
* @return the connection string used by the OpenCms core
*/
public String getDbWorkConStr() {
if (m_provider.equals(POSTGRESQL_PROVIDER)) {
return getDbProperty(m_databaseKey + ".constr.newDb");
} else {
return getExtProperty(CmsDbPool.KEY_DATABASE_POOL + '.' + getPool() + ".jdbcUrl");
}
}
/**
* Returns the password of the database from the properties .<p>
*
* @return the password for the OpenCms database user
*/
public String getDbWorkPwd() {
return getExtProperty(CmsDbPool.KEY_DATABASE_POOL + '.' + getPool() + ".password");
}
/**
* Returns the user of the database from the properties.<p>
*
* @return the database user used by the opencms core
*/
public String getDbWorkUser() {
String user = getExtProperty(CmsDbPool.KEY_DATABASE_POOL + '.' + getPool() + ".user");
if (CmsStringUtil.isEmptyOrWhitespaceOnly(user)) {
return getDbCreateUser();
}
return user;
}
/**
* Returns the default content encoding.<p>
* @return String
*/
public String getDefaultContentEncoding() {
return getExtProperty("defaultContentEncoding");
}
/**
* Returns the name of the default web application, configured in <code>web.xml</code>.<p>
*
* By default this is <code>"ROOT"</code>.<p>
*
* @return the name of the default web application, configured in <code>web.xml</code>
*/
public String getDefaultWebApplication() {
return m_defaultWebApplication;
}
/**
* Returns the display string for a given module.<p>
*
* @param module a module
*
* @return the display string for the given module
*/
public String getDisplayForModule(CmsModule module) {
String name = module.getNiceName();
String group = module.getGroup();
String version = module.getVersion().getVersion();
String display = name;
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(group)) {
display = group + ": " + display;
}
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(version)) {
display += " (" + version + ")";
}
return display;
}
/**
* Returns the error messages.<p>
*
* @return a vector of error messages
*/
public List getErrors() {
return m_errors;
}
/**
* Returns the mac ethernet address.<p>
*
* @return the mac ethernet addess
*/
public String getEthernetAddress() {
return getExtProperty("server.ethernet.address");
}
/**
* Returns a help image icon tag to display a help text in the setup wizard.<p>
*
* @param id the id of the desired help div
* @param pathPrefix the path prefix to the image
* @return the HTML part for the help icon or an empty String, if the part was not found
*/
public String getHtmlHelpIcon(String id, String pathPrefix) {
String value = m_htmlProps.getProperty("C_HELP_IMG");
if (value == null) {
return "";
} else {
value = CmsStringUtil.substitute(value, "$replace$", id);
return CmsStringUtil.substitute(value, "$path$", pathPrefix);
}
}
/**
* Returns the specified HTML part of the HTML property file to create the output.<p>
*
* @param part the name of the desired part
* @return the HTML part or an empty String, if the part was not found
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -