📄 opencms.java
字号:
throw new CmsException("Database init failed", CmsException.C_RB_INIT_ERROR, e);
}
try {
// initalize the Hashtable with all available mimetypes
m_mt = m_resourceBroker.readMimeTypes(null, null);
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Found mime types : " + m_mt.size() + " entrys");
// Check, if the HTTP streaming should be enabled
m_streaming = conf.getBoolean("httpstreaming.enabled", true);
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Legacy HTTP streaming: " + (m_streaming?"enabled":"disabled"));
// if the System property opencms.disableScheduler is set to true, don't start scheduling
if(!new Boolean(System.getProperty("opencms.disableScheduler")).booleanValue()) {
// now initialise the OpenCms scheduler to launch cronjobs
m_table = new CmsCronTable(m_resourceBroker.readCronTable(null, null));
m_scheduler = new CmsCronScheduler(this, m_table);
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". OpenCms scheduler : enabled");
} else {
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". OpenCms scheduler : disabled");
}
} catch(Exception e) {
if(C_LOGGING && isLogging(C_OPENCMS_CRITICAL)) log(C_OPENCMS_CRITICAL, ". Critical init error/5: " + e.getMessage());
// any exception here is fatal and will cause a stop in processing
throw e;
}
// read flex jsp export url property and save in runtime configuration
String flexExportUrl = (String)conf.getString(CmsJspLoader.C_LOADER_JSPEXPORTURL, null);
if (null != flexExportUrl) {
// if JSP export URL is null it will be set in initStartupClasses()
if (flexExportUrl.endsWith(C_FOLDER_SEPARATOR)) {
flexExportUrl = flexExportUrl.substring(0, flexExportUrl.length()-1);
}
setRuntimeProperty(CmsJspLoader.C_LOADER_JSPEXPORTURL, flexExportUrl);
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". JSP export URL : using value from opencms.properties - " + flexExportUrl);
}
// read flex jsp error page commit property and save in runtime configuration
Boolean flexErrorPageCommit = (Boolean)conf.getBoolean(CmsJspLoader.C_LOADER_ERRORPAGECOMMIT, new Boolean(true));
setRuntimeProperty(CmsJspLoader.C_LOADER_ERRORPAGECOMMIT, flexErrorPageCommit);
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". JSP errorPage commit : " + (flexErrorPageCommit.booleanValue()?"enabled":"disabled"));
// read old (proprietary XML-style) locale backward compatibily support flag
Boolean supportOldLocales = (Boolean)conf.getBoolean("compatibility.support.oldlocales", new Boolean(false));
setRuntimeProperty("compatibility.support.oldlocales", supportOldLocales);
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Old locale support : " + (supportOldLocales.booleanValue()?"enabled":"disabled"));
// convert import files from 4.x versions old webapp URL
String webappUrl = (String)conf.getString("compatibility.support.import.old.webappurl", null);
if (webappUrl != null) {
setRuntimeProperty("compatibility.support.import.old.webappurl", webappUrl);
}
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Old webapp URL : " + ((webappUrl == null)?"not set!":webappUrl));
// Unwanted resource properties which are deleted during import
String[] propNames = conf.getStringArray("compatibility.support.import.remove.propertytags");
if (propNames == null) propNames = new String[0];
List propertyNamesOri = java.util.Arrays.asList(propNames);
ArrayList propertyNames = new ArrayList();
for (int i=0; i<propertyNamesOri.size(); i++) {
// remove possible white space
String name = ((String)propertyNamesOri.get(i)).trim();
if (name != null && ! "".equals(name)) {
propertyNames.add(name);
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Clear import property: " + (i+1) + " - " + name );
}
}
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Remove properties : " + ((propertyNames.size() > 0)?"enabled":"disabled"));
setRuntimeProperty("compatibility.support.import.remove.propertytags", propertyNames);
// old web application names (for editor macro replacement)
String[] appNames = conf.getStringArray("compatibility.support.webAppNames");
if (appNames == null) appNames = new String[0];
List webAppNamesOri = java.util.Arrays.asList(appNames);
ArrayList webAppNames = new ArrayList();
for (int i=0; i<webAppNamesOri.size(); i++) {
// remove possible white space
String name = ((String)webAppNamesOri.get(i)).trim();
if (name != null && ! "".equals(name)) {
webAppNames.add(name);
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Old context path : " + (i+1) + " - " + name );
}
}
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Old context support : " + ((webAppNames.size() > 0)?"enabled":"disabled"));
setRuntimeProperty("compatibility.support.webAppNames", webAppNames);
// Immutable import resources
String[] immuResources = conf.getStringArray("import.immutable.resources");
if (immuResources == null) immuResources = new String[0];
List immutableResourcesOri = java.util.Arrays.asList(immuResources);
ArrayList immutableResources = new ArrayList();
for (int i=0; i<immutableResourcesOri.size(); i++) {
// remove possible white space
String path = ((String)immutableResourcesOri.get(i)).trim();
if (path != null && ! "".equals(path)) {
immutableResources.add(path);
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Immutable resource : " + (i+1) + " - " + path );
}
}
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Immutable resources : " + ((immutableResources.size() > 0)?"enabled":"disabled"));
setRuntimeProperty("import.immutable.resources", immutableResources);
// try to initialize directory translations
try {
boolean translationEnabled = conf.getBoolean("directory.translation.enabled", false);
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Directory translation: " + (translationEnabled?"enabled":"disabled"));
if (translationEnabled) {
String[] translations = conf.getStringArray("directory.translation.rules");
// Directory translation stops after fist match, hence the "false" parameter
m_directoryTranslator = new CmsResourceTranslator(translations, false);
}
} catch(Exception e) {
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Directory translation: non-critical error " + e.toString());
}
// make sure we always have at least an empty array
if (m_directoryTranslator == null) m_directoryTranslator = new CmsResourceTranslator(new String[0], false);
// read the maximum file upload size limit
Integer fileMaxUploadSize = new Integer(conf.getInteger("workplace.file.maxuploadsize", -1));
setRuntimeProperty("workplace.file.maxuploadsize", fileMaxUploadSize);
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". File max. upload size: " + (fileMaxUploadSize.intValue()>0?(fileMaxUploadSize+" KB"):"unlimited"));
// try to initialize filename translations
try {
boolean translationEnabled = conf.getBoolean("filename.translation.enabled", false);
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Filename translation : " + (translationEnabled?"enabled":"disabled"));
if (translationEnabled) {
String[] translations = conf.getStringArray("filename.translation.rules");
// Filename translations applies all rules, hence the true patameters
m_fileTranslator = new CmsResourceTranslator(translations, true);
}
} catch(Exception e) {
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Filename translation : non-critical error " + e.toString());
}
// make sure we always have at last an emtpy array
if (m_fileTranslator == null) m_fileTranslator = new CmsResourceTranslator(new String[0], false);
// try to initialize default file names
try {
m_defaultFilenames = conf.getStringArray("directory.default.files");
for (int i=0; i<m_defaultFilenames.length; i++) {
// remove possible white space
m_defaultFilenames[i] = m_defaultFilenames[i].trim();
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Default file : " + (i+1) + " - " + m_defaultFilenames[i] );
}
} catch(Exception e) {
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Default file : non-critical error " + e.toString());
}
// make sure we always have at last an emtpy array
if (m_defaultFilenames == null) m_defaultFilenames = new String[0];
// try to initialize the flex cache
try {
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Flex cache init : starting");
// com.opencms.flex.cache.CmsFlexCache flexCache = new com.opencms.flex.cache.CmsFlexCache(this);
// the flexCache has static members that must be initialized with "this" object
new com.opencms.flex.cache.CmsFlexCache(this);
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Flex cache init : finished");
} catch(Exception e) {
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Flex cache init : non-critical error " + e.toString());
}
// try to initialize the launchers.
try {
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Launcher init : starting");
m_launcherManager = new CmsLauncherManager(this);
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Launcher init : finished");
} catch(Exception e) {
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Launcher init : non-critical error " + e.toString());
}
// get the password validating class
c_passwordValidatingClass = conf.getString("passwordvalidatingclass", "com.opencms.util.PasswordValidtation");
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Password validation : " + c_passwordValidatingClass);
// read the default user settings
try {
int userDefaultAccessFlags = conf.getInteger("workplace.user.default.flags", C_ACCESS_DEFAULT_FLAGS);
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". User permission init : Default access flags are " + userDefaultAccessFlags);
setUserDefaultAccessFlags(userDefaultAccessFlags);
String userDefaultLanguage = conf.getString("workplace.user.default.language", I_CmsWpConstants.C_DEFAULT_LANGUAGE);
setUserDefaultLanguage(userDefaultLanguage);
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". User permission init : Default language is '" + userDefaultLanguage + "'");
} catch(Exception e) {
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". User permission init : non-critical error " + e.toString());
}
// Check, if the element cache should be enabled
m_enableElementCache = conf.getBoolean("elementcache.enabled", false);
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Element cache : " + (m_enableElementCache?"enabled":"disabled"));
if(m_enableElementCache) {
try {
c_elementCache = new CmsElementCache(conf.getInteger("elementcache.uri", 10000),
conf.getInteger("elementcache.elements", 50000),
conf.getInteger("elementcache.variants", 100));
}catch(Exception e) {
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Element cache : non-critical error " + e.toString());
}
c_variantDeps = new Hashtable();
c_elementCache.getElementLocator().setExternDependencies(c_variantDeps);
}
// now for the link replacement rules there are up to three rulesets for export online and offline
try{
if(C_LOGGING && isLogging(C_OPENCMS_INIT)) log(C_OPENCMS_INIT, ". Link rules init : starting");
String[] staticUrlPrefix = new String[4];
staticUrlPrefix[0]=Utils.replace(conf.getString(C_URL_PREFIX_EXPORT, ""), C_WEB_APP_REPLACE_KEY, CmsBase.getWebAppName());
staticUrlPrefix[1]=Utils.replace(conf.getString(C_URL_PREFIX_HTTP, ""), C_WEB_APP_REPLACE_KEY, CmsBase.getWebAppName());
staticUrlPrefix[2]=Utils.replace(conf.getString(C_URL_PREFIX_HTTPS, ""), C_WEB_APP_REPLACE_KEY, CmsBase.getWebAppName());
staticUrlPrefix[3]=Utils.replace(conf.getString(C_URL_PREFIX_SERVERNAME, ""), C_WEB_APP_REPLACE_KEY, CmsBase.getWebAppName());
c_exportProperties.setUrlPrefixArray(staticUrlPrefix);
// to get the right rulesets we need the default value for the export property
String exportDefault = conf.getString("staticexport.default.export", "true");
c_exportProperties.setExportDefaultValue(exportDefault);
String export = conf.getString("linkrules."+exportDefault+".export");
String[] linkRulesExport;
if(export != null && !"".equals(export)){
linkRulesExport = conf.getStringArray("ruleset."+export);
// now replace ${WEB_APP_NAME} with the correct name of the webapplication and replace the other variables
for(int i = 0; i < linkRulesExport.length; i++) {
linkRulesExport[i] = Utils.replace(linkRulesExport[i], C_WEB_APP_REPLACE_KEY, CmsBase.getWebAppName());
linkRulesExport[i] = Utils.replace(linkRulesExport[i], "${"+C_URL_PREFIX_EXPORT+"}", staticUrlPrefix[0]);
linkRulesExport[i] = Utils.replace(linkRulesExport[i], "${"+C_URL_PREFIX_HTTP+"}", staticUrlPrefix[1]);
linkRulesExport[i] = Utils.replace(linkRulesExport[i], "${"+C_URL_PREFIX_HTTPS+"}", staticUrlPrefix[2]);
linkRulesExport[i] = Utils.replace(linkRulesExport[i], "${"+C_URL_PREFIX_SERVERNAME+"}", staticUrlPrefix[3]);
}
c_exportProperties.setLinkRulesExport(linkRulesExport);
}
String online = conf.getString("linkrules."+exportDefault+".online");
String[] linkRulesOnline;
if(online != null && !"".equals(online)){
linkRulesOnline = conf.getStringArray("ruleset."+online);
// now replace ${WEB_APP_NAME} with the correct name of the webapplication and replace the other variables
for(int i = 0; i < linkRulesOnline.length; i++) {
linkRulesOnline[i] = Utils.replace(linkRulesOnline[i], C_WEB_APP_REPLACE_KEY, CmsBase.getWebAppName());
linkRulesOnline[i] = Utils.replace(linkRulesOnline[i], "${"+C_URL_PREFIX_EXPORT+"}", staticUrlPrefix[0]);
linkRulesOnline[i] = Utils.replace(linkRulesOnline[i], "${"+C_URL_PREFIX_HTTP+"}", staticUrlPrefix[1]);
linkRulesOnline[i] = Utils.replace(linkRulesOnline[i], "${"+C_URL_PREFIX_HTTPS+"}", staticUrlPrefix[2]);
linkRulesOnline[i] = Utils.replace(linkRulesOnline[i], "${"+C_URL_PREFIX_SERVERNAME+"}", staticUrlPrefix[3]);
}
c_exportProperties.setLinkRulesOnline(linkRulesOnline);
}
String offline = conf.getString("linkrules."+exportDefault+".offline");
String[] linkRulesOffline;
if(offline != null && !"".equals(offline)){
linkRulesOffline = conf.getStringArray("ruleset."+offline);
// now replace ${WEB_APP_NAME} with the correct name of the webapplication and replace the other variables
for(int i = 0; i < linkRulesOffline.length; i++) {
linkRulesOffline[i] = Utils.replace(linkRulesOffline[i], C_WEB_APP_REPLACE_KEY, CmsBase.getWebAppName());
linkRulesOffline[i] = Utils.replace(linkRulesOffline[i], "${"+C_URL_PREFIX_EXPORT+"}", staticUrlPrefix[0]);
linkRulesOffline[i] = Utils.replace(linkRulesOffline[i], "${"+C_URL_PREFIX_HTTP+"}", staticUrlPrefix[1]);
linkRulesOffline[i] = Utils.replace(linkRulesOffline[i], "${"+C_URL_PREFIX_HTTPS+"}", staticUrlPrefix[2]);
linkRulesOffline[i] = Utils.replace(linkRulesOffline[i], "${"+C_URL_PREFIX_SERVERNAME+"}", staticUrlPrefix[3]);
}
c_exportProperties.setLinkRulesOffline(linkRulesOffline);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -