📄 jahiaprivatesettings.java
字号:
// $Id: JahiaPrivateSettings.java,v 1.11 2003/11/03 14:51:38 shuber Exp $//// ____.// __/\ ______| |__/\. _______// __ .____| | \ | +----+ \// _______| /--| | | - \ _ | : - \_________// \\______: :---| : : | : | \________>// |__\---\_____________:______: :____|____:_____\// /_____|//// . . . i n j a h i a w e t r u s t . . .////// JahiaPrivateSettings//// 18.11.2000 EV added in jahia.// 22.01.2001 FH created readJahiaPropertiesFile() method and changed.// 06.02.2001 AK set readJahiaPropertiesFile as static method.// 27.03.2001 AK use the properties manager from org.jahia.utils.properties.// 27.07.2001 SB added jahiaLdapDiskPath// 15.01.2002 NK added mime types. mime types are loaded from web.xml files.//// FIXME create an authentification method in order to be sure that// this class is ONLY called by the Jahia servlet...// or crypt the data in the property file ?//package org.jahia.settings;import java.io.*; // Streamsimport java.util.*; // Enumeration, HashMapimport javax.servlet.*; // ServletContextimport org.jahia.tools.files.*; // for mime typesimport org.xml.sax.EntityResolver;import org.jahia.data.constants.JahiaConstants;import org.jahia.utils.*; // JahiaConsoleimport org.jahia.utils.properties.*; // PropertiesManagerimport org.jahia.exceptions.JahiaException;public class JahiaPrivateSettings { private static String mLicenseFilename; private static String propertiesFileName; public Properties properties; public ServletContext context; public ServletConfig config; // this is the famous build number... public int buildNumber; // this is the list of jahia.properties server disk path and context path values... public String server; public String serverHomeDiskPath; public String jahiaHomeDiskPath; public String jahiaTemplatesDiskPath; public String jahiaWebAppsDiskPath; public String jahiaEnginesDiskPath; public String jahiaJspDiskPath; public String jahiaFilesDiskPath; public String jahiaEtcDiskPath; public String jahiaVarDiskPath; public String jahiaFilesBigTextDiskPath; public String jahiaFilesTemplatesDiskPath; public String jahiaLdapDiskPath; public String jahiaHostHttpPath; public String jahiaCoreHttpPath; public String jahiaTemplatesHttpPath; public String jahiaEnginesHttpPath; public String jahiaWebAppsDeployerBaseURL; public String jahiaJavaScriptDiskPath; public String jahiaNewTemplatesDiskPath; public String jahiaNewWebAppsDiskPath; public String jahiaSharedComponentsDiskPath; public String jahiaSharedTemplatesDiskPath; public String jspContext; public String templatesContext; public String enginesContext; public String javascriptContext; public String jahiaJavaScriptHttpPath; public String classDiskPath; public String componentsDiskPath; // directory to output cache configuration file public String jahiaOutputCacheConfigDiskPath; // this is the list of jahia.properties autodeployer values... public int jahiaWebAppsAutoDeploy; public int jahiaTemplatesAutoDeploy; // this is the list of jahia.properties files values... public String jahiaFileRepositoryDiskPath; public int jahiaFileUploadMaxSize; // this is the list of jahia.properties database values... public String db_driver; public String db_url; public String db_username; public String db_password; public int db_min_connections; public int db_max_connections; public boolean db_waitIfBusy; public boolean db_verbose; // Characters encoding private boolean utf8Encoding; // Output cache activation / deactivation private boolean outputCacheActivated; // output cache expiration delay private int outputCacheDefaultExpirationDelay = -1; // Activation / deactivation of site ID in URLs private boolean siteIDInURL; // Activation / deactivation of debug mode private boolean appDebugModeOn; // Flag that indicates whether applications can inherit from Jahia session // attributes. private boolean appInheritJahiaSessionAttributes; // this is the list of jahia.properties mail settings values... public String mail_server; public String mail_administrator; public String mail_from; public int mail_paranoia; private DtdEntityResolver mResolver; protected Properties mimeTypes; private int outputCacheSize = 10000; private int requestCacheSize = 10000; /** * Default constructor. * * @param config The configuration used to get the servlet context. * @param propertiesFilename The jahia.properties file complete path. * @param buildNumber The Jahia build number. */ public JahiaPrivateSettings (ServletConfig config, String propertiesFilename, String licenseFilename, int buildNumber) { this.config = config; this.context = config.getServletContext (); this.propertiesFileName = propertiesFilename; this.buildNumber = buildNumber; mLicenseFilename = licenseFilename; } // end constructor /** * Read the jahia.properties file. * * @return On success return the Jahia properties, or null on any failure. */ public static Properties readJahiaPropertiesFile () { PropertiesManager propertiesManager = new PropertiesManager (propertiesFileName); return propertiesManager.getPropertiesObject (); } // end readJahiaPropertiesFile /** * This method load and convert properties from the jahia.properties file, * and set some variables used by the SettingsBean class. */ public void load () { PropertiesManager propertiesManager = new PropertiesManager (propertiesFileName); properties = propertiesManager.getPropertiesObject (); // try to get values from the properties object... try { // disk path, url's and context... server = properties.getProperty ("server").trim (); serverHomeDiskPath = properties.getProperty ("serverHomeDiskPath").trim (); jahiaTemplatesDiskPath = context.getRealPath (properties.getProperty ("jahiaTemplatesDiskPath").trim ()); jahiaJspDiskPath = context.getRealPath (properties.getProperty ("jahiaJspDiskPath").trim ()); jahiaEnginesDiskPath = context.getRealPath (properties.getProperty ("jahiaEnginesDiskPath").trim ()); jahiaJavaScriptDiskPath = context.getRealPath (properties.getProperty ("jahiaJavaScriptDiskPath").trim ()); classDiskPath = context.getRealPath (properties.getProperty ("classDiskPath").trim ()); componentsDiskPath = context.getRealPath (properties.getProperty ("componentsDiskPath").trim ()); jahiaFilesDiskPath = JahiaTools.convertContexted (properties.getProperty ("jahiaFilesDiskPath").trim (), context); jahiaEtcDiskPath = JahiaTools.convertContexted (properties.getProperty ("jahiaEtcDiskPath").trim (), context); jahiaVarDiskPath = JahiaTools.convertContexted (properties.getProperty ("jahiaVarDiskPath").trim (), context); jahiaFilesBigTextDiskPath = JahiaTools.convertContexted (properties.getProperty ("jahiaFilesBigTextDiskPath").trim (), context); jahiaFilesTemplatesDiskPath = JahiaTools.convertContexted (properties.getProperty ("jahiaFilesTemplatesDiskPath").trim (), context); jahiaLdapDiskPath = JahiaTools.convertContexted (properties.getProperty ("jahiaLdapDiskPath").trim (), context); jahiaNewTemplatesDiskPath = JahiaTools.convertContexted (properties.getProperty ("jahiaNewTemplatesDiskPath").trim (), context); jahiaNewWebAppsDiskPath = JahiaTools.convertContexted (properties.getProperty ("jahiaNewWebAppsDiskPath").trim (), context); jahiaSharedComponentsDiskPath = JahiaTools.convertContexted (properties.getProperty ("jahiaSharedComponentsDiskPath").trim (), context); jahiaSharedTemplatesDiskPath = JahiaTools.convertContexted (properties.getProperty ("jahiaSharedTemplatesDiskPath").trim (), context); jahiaOutputCacheConfigDiskPath = JahiaTools.convertContexted (properties.getProperty ("jahiaOutputCacheConfigDiskPath").trim (), context); jahiaHostHttpPath = properties.getProperty ("jahiaHostHttpPath").trim (); jahiaCoreHttpPath = properties.getProperty ("jahiaCoreHttpPath").trim (); jahiaTemplatesHttpPath = properties.getProperty ("jahiaTemplatesHttpPath").trim (); jahiaEnginesHttpPath = properties.getProperty ("jahiaEnginesHttpPath").trim (); jahiaJavaScriptHttpPath = properties.getProperty ("jahiaJavaScriptHttpPath").trim (); jspContext = properties.getProperty ("jahiaJspDiskPath").trim (); templatesContext = properties.getProperty ("jahiaTemplatesDiskPath").trim (); enginesContext = properties.getProperty ("jahiaEnginesDiskPath").trim (); javascriptContext = properties.getProperty ("jahiaJavaScriptDiskPath").trim (); // jahia real path... File jahiaContextFolder = new File (context.getRealPath ("." + File.separator)); File parent = jahiaContextFolder.getParentFile (); if (server.indexOf (JahiaConstants.SERVER_TOMCAT4_BETA1) != -1) { // the server is tomcatb1... jahiaHomeDiskPath = jahiaContextFolder.getAbsolutePath (); jahiaWebAppsDiskPath = parent.getAbsolutePath () + File.separator; } else if (server.indexOf (JahiaConstants.SERVER_TOMCAT) != -1) { // the server is tomcat jahiaHomeDiskPath = parent.getAbsolutePath (); jahiaWebAppsDiskPath = parent.getParentFile ().getAbsolutePath () + File.separator; /* } else if ( (server.indexOf(JahiaConstants.SERVER_TOMCAT4_BETA2) != -1) || (server.indexOf(JahiaConstants.SERVER_TOMCAT4_BETA3) != -1) || (server.indexOf(JahiaConstants.SERVER_TOMCAT4_BETA6) != -1) ) { // the server is tomcat... jahiaHomeDiskPath = parent.getAbsolutePath(); jahiaWebAppsDiskPath = parent.getParentFile().getAbsolutePath() + File.separator; */ } else if (server.equals (JahiaConstants.SERVER_ORION)) { // the server is orion server... jahiaHomeDiskPath = jahiaContextFolder.getAbsolutePath (); jahiaWebAppsDiskPath = serverHomeDiskPath + "applications" + File.separator; } else { jahiaHomeDiskPath = jahiaContextFolder.getAbsolutePath (); jahiaWebAppsDiskPath = jahiaContextFolder.getAbsolutePath (); } // autodeployer... String webappAutoDeploy = properties.getProperty ("jahiaWebAppsAutoDeploy").trim (); String templateAutoDeploy = properties.getProperty ("jahiaTemplatesAutoDeploy").trim (); if (webappAutoDeploy != null) { jahiaWebAppsAutoDeploy = Integer.parseInt (webappAutoDeploy); } if (templateAutoDeploy != null) { jahiaTemplatesAutoDeploy = Integer.parseInt (templateAutoDeploy); } // files... jahiaFileRepositoryDiskPath = JahiaTools.convertContexted (properties.getProperty ("jahiaFileRepositoryDiskPath").trim (), context); jahiaFileUploadMaxSize = Integer.parseInt (properties.getProperty ("jahiaFileUploadMaxSize").trim ()); // database... db_driver = properties.getProperty ("db_driver").trim (); db_url = properties.getProperty ("db_url").trim (); db_username = properties.getProperty ("db_username").trim ();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -