use of org.jahia.utils.properties.PropertiesManager in project jahia by Jahia.
the class JournalEventReader method readStartRevision.
private long readStartRevision(String key) {
long startRevision = 0;
String value = new PropertiesManager(lastProcessedRevisionFilePath).getProperty(getPropertyKey(key));
if (StringUtils.isNotEmpty(value)) {
startRevision = Long.parseLong(value.trim());
}
return startRevision;
}
use of org.jahia.utils.properties.PropertiesManager in project jahia by Jahia.
the class JournalEventReader method rememberLastProcessedJournalRevision.
/**
* Stores in a dedicated properties file the last processed journal revision.
*
* @param key the key is associate to the last processed journal revision value, it allow to identify the property
*/
public void rememberLastProcessedJournalRevision(String key) {
if (!isEnabled()) {
return;
}
ClusterNode cn = SpringJackrabbitRepository.getInstance().getClusterNode();
if (cn != null) {
String revision = String.valueOf(cn.getRevision());
PropertiesManager propManager = new PropertiesManager(lastProcessedRevisionFilePath);
String propertyKey = getPropertyKey(key);
if (!StringUtils.equals(propManager.getProperty(propertyKey), revision)) {
propManager.setProperty(propertyKey, revision);
propManager.storeProperties();
logger.info("Remembered last processed journal revision as {}", revision);
}
}
}
use of org.jahia.utils.properties.PropertiesManager in project jahia by Jahia.
the class SettingsBean method load.
/**
* This method load and convert properties from the jahia.properties file,
* and set some variables used by the SettingsBean class.
*/
@Override
public void load() {
if (properties == null && propertiesFileName != null) {
properties = new PropertiesManager(propertiesFileName).getPropertiesObject();
}
// try to get values from the properties object...
try {
detectServer();
// disk path, url's and context...
maintenanceMode = getBoolean("maintenanceMode", false);
sessionExpiryTime = getInt("sessionExpiryTime", 60);
initPaths();
// files...
jahiaFileUploadMaxSize = getLong("jahiaFileUploadMaxSize", 104857600);
studioMaxDisplayableFileSize = getLong("studioMaxDisplayableFileSize", 1048576);
characterEncoding = getString("characterEncoding", "UTF-8");
if (System.getProperty(ZipEntryCharsetDetector.ZIP_ENTRY_ALTERNATIVE_ENCODING) == null) {
String zipEntryCharsets = getString(ZipEntryCharsetDetector.ZIP_ENTRY_ALTERNATIVE_ENCODING, null);
if (StringUtils.isNotEmpty(zipEntryCharsets)) {
System.setProperty(ZipEntryCharsetDetector.ZIP_ENTRY_ALTERNATIVE_ENCODING, zipEntryCharsets);
}
}
// Activation / deactivation of relative URLs, instead of absolute URLs, when generating URL to exit the Admin Menu for example
useRelativeSiteURLs = getBoolean("useRelativeSiteURLs", false);
jahiaJCRUserCountLimit = getLong("jahiaJCRUserCountLimit", -1);
// base URL (schema, host, port) to call the web apps deployer service.
jahiaWebAppsDeployerBaseURL = getString("jahiaWebAppsDeployerBaseURL", "http://127.0.0.1:8080/manager");
// multi language default language code property.
defaultLanguageCode = getString("org.jahia.multilang.default_language_code", "en");
defaultLocale = LanguageCodeConverters.languageCodeToLocale(defaultLanguageCode);
considerDefaultJVMLocale = getBoolean("considerDefaultJVMLocale", false);
considerPreferredLanguageAfterLogin = getBoolean("considerPreferredLanguageAfterLogin", false);
// mail notification settings...
mail_maxRegroupingOfPreviousException = getInt("mail_maxRegroupingOfPreviousException", 500);
isProcessingServer = getBoolean("processingServer", true);
siteURLPortOverride = getInt("siteURLPortOverride", 0);
isSiteErrorEnabled = getBoolean("site.error.enabled", false);
operatingMode = getString("operatingMode", "development");
productionMode = !"development".equalsIgnoreCase(operatingMode);
distantPublicationServerMode = "distantPublicationServer".equalsIgnoreCase(operatingMode);
permanentMoveForVanityURL = getBoolean("permanentMoveForVanityURL", true);
dumpErrorsToFiles = getBoolean("dumpErrorsToFiles", true);
ErrorFileDumper.setFileDumpActivated(dumpErrorsToFiles);
fileDumpMaxRegroupingOfPreviousException = getInt("fileDumpMaxRegroupingOfPreviousException", 500);
useJstackForThreadDumps = getBoolean("useJstackForThreadDumps", false);
urlRewriteSeoRulesEnabled = getBoolean("urlRewriteSeoRulesEnabled", false);
urlRewriteRemoveCmsPrefix = getBoolean("urlRewriteRemoveCmsPrefix", false);
urlRewriteUseAbsoluteUrls = getBoolean("urlRewriteUseAbsoluteUrls", true);
disableJsessionIdParameter = getBoolean("disableJsessionIdParameter", true);
jsessionIdParameterName = getString("jsessionIdParameterName", "jsessionid");
guestUserResourceModuleName = getString("guestUserResourceModuleName");
guestUserResourceKey = getString("guestUserResourceKey");
guestGroupResourceModuleName = getString("guestGroupResourceModuleName");
guestGroupResourceKey = getString("guestGroupResourceKey");
fileServletStatisticsEnabled = getBoolean("jahia.fileServlet.statisticsEnabled", false);
importMaxBatch = getInt("importMaxBatch", 500);
maxNameSize = getInt("jahia.jcr.maxNameSize", 32);
expandImportedFilesOnDisk = getBoolean("expandImportedFilesOnDisk", false);
expandImportedFilesOnDiskPath = getString("expandImportedFilesOnDiskPath", "/tmp");
accessManagerPathPermissionCacheMaxSize = getInt("accessManagerPathPermissionCacheMaxSize", 100);
queryApproxCountLimit = getInt("queryApproxCountLimit", 100);
readOnlyMode = getBoolean("readOnlyMode", false);
internetExplorerCompatibility = getString("internetExplorerCompatibility", "IE=10");
atmosphereAsyncSupport = getString("atmosphere.asyncSupport", null);
useWebsockets = getBoolean("atmosphere.useWebsockets", false);
areaAutoActivated = getBoolean("area.auto.activated", true);
moduleSpringBeansWaitingTimeout = getInt("jahia.moduleSpringBeansWaitingTimeout", 5 * 60);
moduleStartLevel = getInt("jahia.moduleStartLevel", 90);
jahiaSiteImportScannerInterval = getInt("jahia.site.import.scanner.interval", 1000);
atmosphereHeartbeatFrequency = getString("jahia.atmosphere.heartbeat", "60");
String authorizedRedirectHostsStr = getString("authorizedRedirectHosts", null);
authorizedRedirectHosts = StringUtils.isBlank(authorizedRedirectHostsStr) ? new String[0] : authorizedRedirectHostsStr.trim().split("\\s*,\\s*");
settings.put("userManagementUserNamePattern", getString("userManagementUserNamePattern", "[\\w\\{\\}\\-]+"));
settings.put("userManagementGroupNamePattern", getString("userManagementGroupNamePattern", "[\\w\\{\\}\\-]+"));
settings.put("default_templates_set", getString("default_templates_set"));
settings.put("legacy.import.externalLink.internationalized", getBoolean("legacy.import.externalLink.internationalized", false));
settings.put("legacy.import.externalLink.nodeType", getString("legacy.import.externalLink.nodeType", Constants.JAHIANT_EXTERNAL_PAGE_LINK));
settings.put("legacy.import.externalLink.urlPropertyName", getString("legacy.import.externalLink.urlPropertyName", Constants.URL));
settings.setFast(true);
clusterActivated = getBoolean("cluster.activated", false);
setSystemProperty("cluster.activated", Boolean.toString(clusterActivated));
if (System.getProperty("cluster.node.serverId") == null) {
setSystemProperty("cluster.node.serverId", getString("cluster.node.serverId", "jahiaServer1"));
}
DatabaseUtils.setDatasource(dataSource);
initJcrSystemProperties();
initStartupOptions();
if (clusterActivated) {
clusterSettingsInitializer.initClusterSettings(this);
}
checkIndexConsistencyIfNeeded();
reindexIfNeeded();
readTldConfigJarsToSkip();
initJerichoLogging();
initDatabaseIfNeeded();
if (isProcessingServer()) {
Patcher.getInstance().executeScripts("contextInitializing");
}
// Init String substitutor
Map<String, StringLookup> l = new HashMap<>();
l.put("jahia", this::getPropertyValue);
stringSubstitutor = new StringSubstitutor(StringLookupFactory.INSTANCE.interpolatorStringLookup(l, null, true));
stringSubstitutor.setEnableSubstitutionInVariables(true);
} catch (NullPointerException | NumberFormatException e) {
logger.error("Properties file is not valid...!", e);
}
}
Aggregations