blob: 7b126a61dcef55d9575914fdf3f018be5aed0240 [file] [log] [blame]
/**
*
* Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
*/
package org.eclipse.osbp.preferences;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import javax.sql.CommonDataSource;
import org.eclipse.osbp.preferences.ProductConfigurationPrefs.DDL_GENERATION;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Access to the Product Configuration!<br>
* <i>For now empty configuration data will be <u>auto-generated to hit out
* internal development configuration</u>!</i>
*/
public class ProductConfiguration {
public static final String SHIRO_DTO_REALM = ProductConfigurationPrefs.SHIRO_DTO_REALM;
public static final String SHIRO_LDAP_REALM = "LDAPRealm";
public static final String SHIRO_STATIC_REALM = "StaticRealm";
public static final String WORKSPACE_NAME = "Workspace";
private static final Logger LOGGER = LoggerFactory.getLogger(ProductConfiguration.class);
private static ProductConfigurationPrefs workspacePrefs = null;
private static ProductConfigurationPrefs activePrefs = null;
private ProductConfiguration() {
}
public static ProductConfigurationPrefs workspacePrefs() {
if (workspacePrefs == null) {
workspacePrefs = new ProductConfigurationPrefs(WORKSPACE_NAME, new ProductInstanceScope(), true, null);
if(workspacePrefs.getScopeContext() != null && workspacePrefs.getScopeContext().getLocation() != null) {
String msg = workspacePrefs.getScopeContext().getLocation().toOSString();
LOGGER.debug("ProductConfigurationFile: {}", msg);
}
}
return workspacePrefs;
}
public static ProductConfigurationPrefs prefs() {
if (activePrefs == null) {
activePrefs = workspacePrefs();
}
return activePrefs;
}
/**
* sets the flag, that the configuration has to be reloaded. Deregisters all
* watchers/listeners on preference changes due to preference dialog and
* file modification
*/
@SuppressWarnings("unused")
private static void forceReloadConfiguration() { // NOSONAR
prefs().forceReloadConfiguration();
}
/**
* @return <ul><li><code>false</code>, if the server name or ip is defintively non-reasonable.</li><li><code>true</code> otherwise, but it <b>does not guarantee</b> an existing or reachable server name or ip address</li></ul>
*/
public static boolean isServerReasonable(String serverNameOrIp) {
return !(serverNameOrIp.contains("<") || serverNameOrIp.contains(">"));
}
/**
* @see http://www.ecb.europa.eu/stats/exchange/eurofxref/html/index.en.html
* @return URL to server with the daily Euro Foreign Exchange Reference
* Rates
*/
public static String getEuroXRefRatesURLDaily() {
return prefs().getEuroXRefRatesURLDaily();
}
/**
* @see http://www.ecb.europa.eu/stats/exchange/eurofxref/html/index.en.html
* @return URL to server with the previous Euro Foreign Exchange Reference
* Rates
*/
public static String getEuroXRefRatesURLPrevious() {
return prefs().getEuroXRefRatesURLPrevious();
}
/**
* see {@link IProductConfigurationPrefs#getEmailServerIp()}
*/
public static String getActiveMqBrokerServerName() {
return prefs().getActiveMqBrokerServerName();
}
/**
* see {@link IProductConfigurationPrefs#getActiveMqBrokerServerPort()}
*/
public static int getActiveMqBrokerServerPort() {
return prefs().getActiveMqBrokerServerPort();
}
/**
* @return milliseconds for refresher in an active hybrid ccng view
*/
public static int getHybridRefresherMilliSecsActive() {
return prefs().getHybridRefresherMilliSecsActive();
}
/**
* @return milliseconds for refresher in an inactive hybrid ccng view
*/
public static int getHybridRefresherMilliSecsInactive() {
return prefs().getHybridRefresherMilliSecsInactive();
}
/**
* @return list of name of all defined DataSources
*/
public static Set<String> getDataSourceNames() {
return prefs().getDataSourceNames();
}
/**
* @param jndiName
* the requested DataSource
* @return the properties to define a DataSource
*/
public static Properties getDataSourceProperties(String jndiName) {
return prefs().getDataSourceProperties(jndiName);
}
public static DataSourceConfiguration getDataSource(String jndiName) {
return prefs().getDataSource(jndiName);
}
/**
* @param jndiName
* the requested DataSource
* @return name of the JDBC driver class
*/
public static String getDataSourceDriverClass(String jndiName) {
return prefs().getDataSourceDriverClass(jndiName);
}
/**
* @param jndiName
* the requested DataSource
* @return the properties to define a JPA connection
*/
public static Properties getJpaProperties(String jndiName) {
return prefs().getJpaProperties(jndiName);
}
/**
* @return list of name of all defined DataSources
*/
public static Set<String> getPersistenceUnitNames() {
return prefs().getPersistenceUnitNames();
}
/**
* @return JNDI name for the given persistence unit
*/
public static String getPersistenceUnitJndiName(String persistenceUnitName) {
return prefs().getPersistenceUnitJndiName(persistenceUnitName);
}
public static String getPersistenceUnitHibernateDialect(String persistenceUnitName) {
return prefs().getPersistenceUnitHibernateDialect(persistenceUnitName);
}
public static String getJndiNameHibernateDialect(String jndiName) {
return prefs().getJndiNameHibernateDialect(jndiName);
}
public static String getPersistenceUnitParameterizedEclipseLinkDdlGeneration(String persistenceUnitName) {
return prefs().getPersistenceUnitParameterizedEclipseLinkDdlGeneration(persistenceUnitName);
}
/**
* @param persistenceUnitName
* @return
*/
public static String getPersistenceUnitEffectiveEclipseLinkDdlGeneration(String persistenceUnitName) {
return prefs().getPersistenceUnitEffectiveEclipseLinkDdlGeneration(persistenceUnitName);
}
/**
* @param persistenceUnitName
* @return
*/
public static String getPersistenceUnitEffectiveHibernateDdlGeneration(String persistenceUnitName) {
return DDL_GENERATION.hibernate(prefs().getPersistenceUnitEffectiveEclipseLinkDdlGeneration(persistenceUnitName));
}
/**
* @param jndiName
* the requested DataSource
* @return the properties to define a DataSource
*/
public static Properties getPersistenceUnitProperties(
String persistenceUnitName, CommonDataSource dataSource, ClassLoader classLoader) {
return prefs().getPersistenceUnitProperties(persistenceUnitName, dataSource, classLoader);
}
public static final String getAuthenticationOrganizationId() {
return prefs().getAuthenticationOrganizationId();
}
/**
* @return port of the RESTful authentication API, needed by the hybrid
* WebClient cxauth
*/
public static final int getAuthRESTfulPort() {
return prefs().getAuthRESTfulPort();
}
/**
* @return decide remember-me function performs an auto-login or not
*/
public static final boolean hasAutoLogin() {
return prefs().hasAutoLogin();
}
/**
* @return hide remember-me function if true
*/
public static final boolean hasNoRememberMe() {
return prefs().hasNoRememberMe();
}
/**
* @return administrator email when login depends on email adress. default = admin@support.com
*/
public static final String getAdminEmail() {
return prefs().getAdminEmail();
}
public static final String getAdminEmailUsername() {
return prefs().getAdminEmailUsername();
}
public static final String getAdminEmailPassword() {
return prefs().getAdminEmailPassword();
}
/**
* @return maximum failed login attempts
*/
public static final int getMaxLoginAttempts() {
return prefs().getMaxLoginAttempts();
}
public static final String getProtocolDatasource() {
return prefs().getProtocolDatasource();
}
public static final String getProtocolUnit() {
return prefs().getProtocolUnit();
}
public static final boolean getIdentifyByUsername() {
return prefs().getIdentifyByUsername();
}
/**
* @return the corresponding INI string for all authentication realms needed
* for Shiro
*/
public static final String getShiroConfiguration(String staticRealmClassName) {
return prefs().getShiroConfiguration(staticRealmClassName);
}
public static String getLocation() {
return prefs().getLocation();
}
public static Map<String, Locale> getLanguages() {
return prefs().getLanguages();
}
public static boolean isLanguagesAutotranslate() {
return prefs().isLanguagesAutotranslate();
}
public static boolean willLanguagesAutocreate() {
return prefs().willLanguagesAutocreate();
}
public static boolean isUomoMetricUnit() {
return prefs().isUomoMetricUnit();
}
public static boolean showLanguageSelectInRespectiveLocale() {
return prefs().showLanguageSelectInRespectiveLocale();
}
/**
* @param generator class of the requested mock data generator
* @return either null, if no entry is set, or the timestamp as String
*/
public static String isMockDataGeneratorDone(Object generator) {
return prefs().isMockDataGeneratorDone(generator);
}
public static void setMockDataGeneratorDone(Object generator) {
prefs().setMockDataGeneratorDone(generator);
}
/**
* @param organizationID The name of the Organization to be used for authentication
*/
public static void setAuthenticationOrganizationId(String organizationID) {
prefs().setAuthenticationOrganizationId( organizationID );
}
public static String getBusinessBundleClassNameReadOnly() {
return prefs().getBusinessBundleClassNameReadOnly();
}
public static String getBpmServerIp() {
return prefs().getBpmServerIp();
}
/**
* see {@link IProductConfigurationPrefs#getBpmServerPort()}
*/
public static int getBpmServerPort() {
return prefs().getBpmServerPort();
}
public static int getBpmResponseTimeout() {
return prefs().getBpmResponseTimeout();
}
public static boolean isBpmEngineHibernateShowSql() {
return prefs().isBpmEngineHibernateShowSql();
}
public static boolean isBpmEngineHibernateFormatSql() {
return prefs().isBpmEngineHibernateFormatSql();
}
public static boolean isBpmEngineLogging() {
return prefs().isBpmEngineLogging();
}
public static int getBpmEngineHibernateMaxFetchDepth() {
return prefs().getBpmEngineHibernateMaxFetchDepth();
}
public static String getBpmEnginePersistenceUnit() {
return prefs().getBpmEnginePersistenceUnit();
}
public static String getBpmEngineHibernateSchemaName(String persistenceUnit) {
return prefs().getBpmEngineHibernateSchemaName(persistenceUnit);
}
public static String getBpmInitialProcess() {
return prefs().getBpmInitialProcess();
}
/**
* @return show theme tool control if true
*/
public static boolean hasDemoToolsTheme() {
return prefs().hasDemoToolsTheme();
}
/**
* @return show langauge tool control if true
*/
public static boolean hasDemoToolsLanguage() {
return prefs().hasDemoToolsLanguage();
}
public static boolean hasToolsPrintService() {
return prefs().hasToolsPrintService();
}
public static boolean projectWizardUsesAbsoluteLocation() {
return prefs().projectWizardUsesAbsoluteLocation();
}
/**
* see {@link IProductConfigurationPrefs#getEmailServerIp()}
*/
public static String getEmailServerIp() {
return prefs().getEmailServerIp();
}
public static int getEmailSmtpPort() {
return prefs().getEmailSmtpPort();
}
public static boolean isEmailUseSslOnConnect() {
return prefs().isEmailUseSslOnConnect();
}
public static boolean isMavenActivated() {
return prefs().isMavenActivated();
}
public static String getJavaPosConfiguration() {
return prefs().getJavaPosConfiguration();
}
public static String getJavaPosPortConfiguration() {
return prefs().getJavaPosPortConfiguration();
}
public static boolean hasJavaPosUploadedBitmaps() {
return prefs().hasJavaPosUploadedBitmaps();
}
public static String getDatainterchangeConfiguration() {
return prefs().getDatainterchangeConfiguration();
}
/**
* @return show user menu control if true
*/
public static boolean hideUserMenu() {
return prefs().hideUserMenu();
}
}