📄 cmssetupbean.java
字号:
String msg = (String)iter.next();
html.append("\t\t\t\t\t\t");
html.append(msg);
html.append("<br/>");
}
html.append("\t\t\t\t\t</td>");
html.append("\t\t\t\t</tr>");
html.append("\t\t\t</table>");
html.append(getHtmlPart("C_BLOCK_END"));
html.append("\t\t</td>");
html.append("\t</tr>");
html.append("</table>");
return html.toString();
}
/**
* Returns a map with all available modules.<p>
*
* 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!<p>
*
* @return a map with all available modules
*/
public Map getAvailableModules() {
if ((m_availableModules == null) || m_availableModules.isEmpty()) {
m_availableModules = new HashMap();
m_moduleDependencies = new HashMap();
m_moduleFilenames = new HashMap();
try {
Map modules = CmsModuleManager.getAllModulesFromPath(getModuleFolder());
Iterator itMods = modules.entrySet().iterator();
while (itMods.hasNext()) {
Map.Entry entry = (Map.Entry)itMods.next();
CmsModule module = (CmsModule)entry.getKey();
// put the module information into a map keyed by the module packages names
m_availableModules.put(module.getName(), module);
m_moduleFilenames.put(module.getName(), entry.getValue());
}
} 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 + "/" + "step_4_database_setup.jsp";
return CmsStringUtil.substitute(configUri, File.separator, "/");
}
/**
* 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;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -