public class Utilities extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Utilities.OS
Enumeration of different operating systems.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_ITEMLINK_ENCODING
The default encoding that is used while build an item link
|
static String |
DEFAULT_PASSWORD_ENCODING
Specify the default encoding used for password encryption.
|
static String |
ITEMLINK_ELEMENT_SEPARATOR
The sign that separates item link elements
|
static String |
ITEMLINK_ITEMATTRIBUTE_END
The sign that ends a reference to a subItem that is an attribute value of an item
|
static String |
ITEMLINK_ITEMATTRIBUTE_START
The sign that starts a reference to a subItem that is an attribute value of an item
|
static String |
ITEMLINK_LINK_ID
Placeholder constant for link id.
|
static String |
ITEMLINK_PATTERN_ATTRIBUTE_SEPARATOR
The sign that separates item the attribute qualifiers in the item link pattern
|
static String |
ITEMLINK_PREFIX
The prefix that leads the type configuration for item links
|
static String |
ITEMLINK_PROTOCOLL_SPECIFIER
The protocoll prefix that specifies the URI as an item link
|
static String |
ITEMLINK_REPLACEMENT_TYPE
Placeholder constant for crossreference replacement type.
|
static String |
ITEMLINK_TYPE_PREFIX
The prefix that leads the type field in an item link
|
static String |
ITEMLINK_VALUE_SEPARATOR
The sign that separates item link element values
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
arrayDeepEqualsReverse(Object[] a1,
Object[] a2)
Like Arrays.deepEquals() but it compares the arrays from bottom to top which is faster for our cache (e.g.
|
static Boolean |
booleanObject(boolean b)
Deprecated.
use autoboxing or
Boolean.valueOf(boolean) |
static Boolean |
booleanObject(String booleanString)
Deprecated.
use
Boolean.valueOf(boolean) where needed |
static String |
buildRelativePath(File fromDir,
File toFileOrDir)
Computes the relative file path from the "fromDir" to the "toFileOrDir" argument.
|
static String |
buildStackTraceCompact(Throwable thr)
Gets the stacktrace of a throwable as a String.
|
static String |
calculateLocalCorePlusEndPoint(String extensionName,
String tenantId) |
static Object |
callMethod(Object instance,
Method method,
Object[] params)
Calls method with given name on given object instance and returns the invocation result.
|
static Object |
callMethod(Object instance,
String methodName,
Class[] paramClasses,
Object[] params)
Calls method with given name on given object instance and returns the invocation result.
|
static void |
checkLicence()
Deprecated.
|
static String |
cleanMaliciousSQL(String source)
Deprecated.
Does not confirm to any security standard.
|
static void |
clearMarkModifiedOverrideCache() |
static void |
clearRelationOrderingOverrideCache() |
static Object |
copyViaSerialization(Object originalObject)
Create a copy of the given object by serializing it into memory and then deserializing it again.
|
static Object |
copyViaSerializationIfNecessary(Object s)
Create a copy of the given object unless it is unmodifiable.
|
protected static Object |
copyViaSerializationUsingStandardJava(Object originalObject) |
static String |
createLink(SessionContext ctx,
Item item)
Creates a link text that references to the given item.
|
static String |
createLink(SessionContext ctx,
Item item,
String typeName,
String attributeList)
Creates a link text that references to the given item.
Example: <a href= 'item://type=MyProductType/code=myProductCode/name=myProductName/catalogVersion=(version=catalogVersionID/catalog= (id=catalogID))'>A referencing text here</a>. |
static boolean |
ejbEquals(ItemRemote first,
ItemRemote second)
Checks whether two remote items are equal by calling an equal check on them including null checks.
|
static boolean |
equals(Object o1,
Object o2) |
static String |
escapeHTML(String s)
Escapes all occurrences of special chars with corresponding html escape sequence.
|
static String |
escapeJavaScript(String s)
Escapes given string in the same way that escape function from JavaScript does but serverside.
|
static void |
failLicence(String message,
Licence licence) |
static void |
failProperties(Map<String,String> missing) |
static String |
filterOutHTMLTags(String input)
Filters out all html tags in given string.
|
static String |
formatTime(long milliseconds)
Formats given time to a readable string inf format: 0d 00h:00m:00s:000ms.
|
static Class[] |
getAllInterfaces(Class cl)
Gets all interfaces of given class including interfaces implemented by superclasses.
|
static String |
getAttributeFromLink(SessionContext ctx,
String itemLink,
String attributeName) |
static <T> T |
getCacheBoundVersion(T value) |
static ConfigIntf |
getConfig()
Returns a
ConfigIntf implementation as merged object of all extensions properties. |
static String |
getContextFromRequestUri(String uri) |
static NumberFormat |
getCurrencyInstance()
Deprecated.
use
FormatFactory.createCurrencyFormat() instead |
static NumberFormat |
getCurrencyInstance(Currency jaloCurrency)
Deprecated.
use
FormatFactory.createCurrencyFormat() instead , to
pass a custom CurrencyModel use
SessionService.executeInLocalView(de.hybris.platform.servicelayer.session.SessionExecutionBody)
as below :
sessionService.executeInLocalView(new SessionExecutionBody()
{
public Object execute() {
i18nService.setCurrentLocale(customLocale);
i18nService.setCurrentCurrency(customCurrency);
return formatFactory.createCurrencyFormat();
}
});
|
static NumberFormat |
getCurrencyInstance(Currency jaloCurrency,
Locale loc)
Deprecated.
use
FormatFactory.createCurrencyFormat() instead , to
pass a custom CurrencyModel , Locale use
SessionService.executeInLocalView(de.hybris.platform.servicelayer.session.SessionExecutionBody)
as below :
sessionService.executeInLocalView(new SessionExecutionBody()
{
public Object execute() {
i18nService.setCurrentLocale(customLocale);
i18nService.setCurrentCurrency(customCurrency);
return formatFactory.createCurrencyFormat();
}
});
|
static DateFormat |
getDateInstance(int dateStyle)
Deprecated.
use
FormatFactory.createDateTimeFormat(int, int) instead
formatFactory.createDateTimeFormat(dateStyle,-1);
|
static DateFormat |
getDateInstance(int dateStyle,
Locale loc)
Deprecated.
use
FormatFactory.createDateTimeFormat(int, int) instead
, to pass a custom Locale use
SessionService.executeInLocalView(de.hybris.platform.servicelayer.session.SessionExecutionBody)
as below :
sessionService.executeInLocalView(new SessionExecutionBody()
{
public Object execute() {
i18nService.setCurrentLocale(customLocale);
return formatFactory.createDateTimeFormat(dateStyle ,-1);
}
});
|
static DateFormat |
getDateTimeInstance()
Deprecated.
use
FormatFactory.createDateTimeFormat(int, int) instead
as :
formatFactory.createDateTimeFormat(DateFormat.DEFAULT,DateFormat.DEFAULT);
|
static DateFormat |
getDateTimeInstance(int dateStyle,
int timeStyle)
Deprecated.
use
FormatFactory.createDateTimeFormat(int, int) instead |
static DateFormat |
getDateTimeInstance(int dateStyle,
int timeStyle,
Locale loc)
Deprecated.
use
FormatFactory.createDateTimeFormat(int, int) instead,
to provide a Locale use
SessionService.executeInLocalView(de.hybris.platform.servicelayer.session.SessionExecutionBody)
as below :
sessionService.executeInLocalView(new SessionExecutionBody()
{
public Object execute() {
i18nService.setCurrentLocale(customLocale);
return formatFactory.createDateTimeFormat(dateStyle ,timeStyle);
}
});
|
static DecimalFormat |
getDecimalFormat(String pattern)
Deprecated.
use
FormatFactory.createNumberFormat() instead, to
provide the patten use as below :
(DecimalFormat) factory.createNumberFormat();
df.applyPattern("some pattern");
|
static DecimalFormat |
getDecimalFormat(String pattern,
Locale loc)
Deprecated.
use
FormatFactory.createNumberFormat() instead, to
provide a pattern see :
(DecimalFormat) factory.createNumberFormat();
df.applyPattern("some pattern");
, to provide a custom Locale see :
sessionService.executeInLocalView(new SessionExecutionBody()
{
public Object execute() {
i18nService.setCurrentLocale(customLocale);
return formatFactory.createNumberFormat();
}
});
|
static Calendar |
getDefaultCalendar()
Deprecated.
use plain
Calendar creation :
Calendar calendarInstance = Calendar.getInstance(i18nService
.getCurrentTimeZone(),
i18nService.getCurrentLocale());
|
static Calendar |
getDefaultCalendar(Locale loc)
Deprecated.
use plain
Calendar creation :
Calendar calendarInstance = Calendar.getInstance(i18nService
.getCurrentTimeZone(),
i18nService.getCurrentLocale());
|
static Locale |
getDefaultLocale()
Provides a session context obeying locale.
|
static Class |
getExtensionClass(MasterTenant t,
String name)
Returns the extension manager class belonging to a given extension name.
|
static String |
getExtensionForWebroot(String webroot) |
static String |
getExtensionForWebroot(String webroot,
String tenantID) |
static ExtensionInfo |
getExtensionInfo(String name)
Returns for the given extension name the corresponding
ExtensionInfo object. |
static String |
getExtensionNameFromRequest(HttpServletRequest request) |
static List<String> |
getExtensionNames()
Returns the names of all extensions which are active within the current system.
|
static String |
getInfoAddress(HttpServletRequest req)
Internal use only.
|
static List<String> |
getInstalledExtensionNames(Tenant tenant)
Returns the names of all installed extension.
|
static Collection<String> |
getInstalledPasswordEncodings()
Returns all installed user password encodings.
|
static Map<String,String> |
getInstalledWebModules()
Gets all installed webmodules.
|
static int |
getInt(String intString,
int defaultValue)
Parses given string and returns its integer equivalent.
|
static NumberFormat |
getIntegerInstance()
Deprecated.
use
FormatFactory.createIntegerFormat() instead |
static NumberFormat |
getIntegerInstance(Locale loc)
Deprecated.
use
FormatFactory.createIntegerFormat() instead , to pass
a custom Locale use
SessionService.executeInLocalView(de.hybris.platform.servicelayer.session.SessionExecutionBody)
as below :
sessionService.executeInLocalView(new SessionExecutionBody()
{
public Object execute() {
i18nService.setCurrentLocale(customLocale);
return formatFactory.createIntegerFormat();
}
});
|
static Object |
getIPAddressForLogOutput(String address)
Replaces localhost from given address.
|
static Item |
getItemFromLink(SessionContext ctx,
String itemLink)
Tryes to resolve the given item link and to retrieve the referenced item.
Example of an item link: <a href= 'item://type=MyProductType/code=myProductCode/name=myProductName/catalogVersion=(version=catalogVersionID/catalog= (id=catalogID))'>A referenzing text here</a> |
static String |
getLinkIdFromLink(SessionContext ctx,
String itemLink)
Tryes to resolve the given item link and to retrieve the link id.
|
static Locale |
getLocale(String isoCode)
Deprecated.
use de.hybris.platform.servicelayer.i18n.CommonI18NService#getLocaleForLanguage(LanguageModel) instead
|
static boolean |
getMarkModifiedOverride(String cfgKey) |
static Map<String,String> |
getMySQLSlaveStatus(HybrisDataSource dsi)
This method only works if the Data Source is a mysql db with a master and some slaves.
|
static NumberFormat |
getNumberInstance()
Deprecated.
use
FormatFactory.createNumberFormat() instead |
static NumberFormat |
getNumberInstance(Locale loc)
Deprecated.
use
FormatFactory.createNumberFormat() instead , to pass
a custom Locale use
SessionService.executeInLocalView(de.hybris.platform.servicelayer.session.SessionExecutionBody)
as below :
sessionService.executeInLocalView(new SessionExecutionBody()
{
public Object execute() {
i18nService.setCurrentLocale(customLocale);
return formatFactory.createNumberFormat();
}
});
|
static Enum |
getOS()
Reads the system property 'os.name' and returns this as
Utilities.OS enumeration. |
static PasswordEncoder |
getPasswordEncoder(String encoding)
Returns a specific
PasswordEncoder from the user password encoders configured within
project.properties parameter password.encoders |
static File |
getPathFromResource(Class c,
String resource)
Gets an
File object representing given resource by using the classloader of given class. |
static NumberFormat |
getPercentInstance()
Deprecated.
use
FormatFactory.createPercentFormat() instead |
static PlatformConfig |
getPlatformConfig()
Returns all platform extensions info in their compile order - for bootstrap purposes.
|
static Set<String> |
getPlatformExtensionNames() |
static File |
getPlatformTempDir()
Returns platform temp directory.
|
static boolean |
getRelationOrderingOverride(String cfgKey,
boolean defaultValue) |
static String |
getReplacementTypeFromLink(SessionContext ctx,
String itemLink)
Tryes to resolve the given item link and to retrieve the replacementType
|
static ResourceBundle |
getResourceBundle(Language lang,
String baseName)
Provides access to the resource bundle loaded by class loader of this class.
|
static ResourceBundle |
getResourceBundle(Language lang,
String baseName,
ClassLoader loader)
Provides access to the resource bundle.
|
static ResourceBundle |
getResourceBundle(Locale[] path,
String baseName,
ClassLoader loader)
Provides access to the resource bundle belonging.
|
static ResourceBundle |
getResourceBundle(SessionContext ctx,
String baseName)
Provides access to the resource bundle loaded by class loader of this class.
|
static ResourceBundle |
getResourceBundle(SessionContext ctx,
String baseName,
ClassLoader loader)
Provides access to the resource bundle.
|
static ResourceBundle |
getResourceBundle(String baseName)
Provides access to the resource bundle belonging to the current session language and loaded by class loader of
this class.
|
static ResourceBundle |
getResourceBundle(String baseName,
ClassLoader loader)
Provides access to the resource bundle belonging to the current session language.
|
static <T extends Throwable> |
getRootCauseOfName(Throwable e,
String name)
Iterates over all causes of a given throwable and returns the first one matching the given name.
|
static <T extends Throwable> |
getRootCauseOfType(Throwable e,
Class<T> type)
Iterates over all causes of a given throwable and returns the first one matching the given type.
|
static SimpleDateFormat |
getSimpleDateFormat(String pattern)
Deprecated.
use
FormatFactory.createDateTimeFormat(int, int) instead
as
final SimpleDateFormat format = (SimpleDateFormat)factory.createDateTimeFormat
(DateFormat
.DEFAULT, -1);
format.applyPattern("yyyy-mm-dd");
|
static SimpleDateFormat |
getSimpleDateFormat(String pattern,
Locale loc)
Deprecated.
use
FormatFactory.createDateTimeFormat(int, int) instead,
to provide a Locale use
SessionService.executeInLocalView(de.hybris.platform.servicelayer.session.SessionExecutionBody)
as below :
sessionService.executeInLocalView(new SessionExecutionBody()
{
public Object execute() {
i18nService.setCurrentLocale(customLocale);
final SimpleDateFormat format = (SimpleDateFormat)factory
.createDateTimeFormat
(DateFormat.DEFAULT,
-1);
format.applyPattern(pattern);
return format;
}
});
|
static String |
getStackTraceAsString(Throwable throwable)
Gets full stacktrace of given exception as string.
|
static String |
getSystemID(HybrisDataSource ds)
Deprecated.
use
getTenantID(HybrisDataSource) instead |
static String |
getTenantID(HybrisDataSource ds)
Gets the tenant id associated with given
DataSource. |
static String |
getTenantIdForContext(String servletContextPath,
String defaultTenant)
Retrives a tenant id basing on the static web root configuration for extension per tenant.
|
static Map<String,Properties> |
getTenantInfos()
Returns all tenants information loaded locally from platform/tenant_{tenantID}.properties or
config/local_tenant_{tenantID}.properties files.
|
static TransformerFactory |
getTransformerFactory()
Gets the TransformerFactory that is used in several areas (e.g.
|
static String |
getWebroot(String extensionsName)
Returns mapped webroot
|
static String |
getWebroot(String extensionsName,
String tenantID) |
static void |
invalidateCache(Cache cache,
PK primaryKey)
Internal helper routine to invalidate the cache for a particular item identified by its primary key.
|
static void |
invalidateCache(PK primaryKey)
Internal helper routine to invalidate the cache for a particular item identified by its primary key.
|
static void |
invalidateCache(Transaction tx,
Cache cache,
PK primaryKey)
Internal helper routine to invalidate the cache for a particular item identified by its primary key.
|
static void |
invalidateCache(Transaction tx,
Cache cache,
PK primaryKey,
boolean sendImmediately)
Internal helper routine to invalidate the cache for a particular item identified by its primary key.
|
static boolean |
isDBConnectionValid(String dbUrl,
String dbUser,
String dbPassword,
String driver)
Checks whether a DB connection can be established with given connection parameters.
|
static boolean |
isDBConnectionValid(String dbUrl,
String dbUser,
String dbPassword,
String driver,
String fromJNDI)
Checks whether a DB connection can be established with given connection parameters.
|
static boolean |
isMasterTenantAsTestSystem() |
static boolean |
isSystemInitialized(HybrisDataSource ds)
Checks whether system is initialized using given
DataSource for accessing correct metainformations
table. |
static boolean |
isSystemInitialized(HybrisDataSource ds,
boolean shutdownTenantIfFailed)
Deprecated.
|
static boolean |
isUnix()
Checks whether the current operating system is unix.
|
static boolean |
isWindows()
Checks whether the current operating system is windows.
|
static Properties |
loadPlatformProperties() |
static Properties |
loadPlatformProperties(Class clazz)
Deprecated.
since 5.0 use the
loadPlatformProperties() instead. |
static <T> <any> |
mergeToImmutableSet(Set<T> col1,
Set<T> col2)
Merge two sets to new immutable set.
|
static String[] |
parseLocaleCodes(String isoCodes)
Splits this language's isocode into (at most) 3 parts and transforms it to String[3] object.
trailing characters are not ignored (PLA-10612). |
static void |
printAppInfo()
Logs following platform properties: build number, current session id, max cache size and number of languages.
|
static String |
replaceXMLEntities(String s)
Replaces in the given String all XML entities with XML encoded chars
char
replaced with
&
&
<
<
>
>
"
"
|
static String |
resolveEncoding(EnumerationValue enc)
Converts an encoding given as enumeration value to the related code, checking the encoding for emptiness.
|
static EnumerationValue |
resolveEncoding(String encoding)
Resolves an given encoding string to an encoding instance of the platform if existent.
|
static void |
setJUnitTenant()
Sets the 'junit' tenant if available or the master tenant, if this is a junit system otherwise it throws an
RuntimException.
|
static List<? extends Item> |
sortItemsByPK(Collection<? extends Item> items) |
static String |
toHex(byte val)
Converts given byte to its hex representation as String.
|
static String |
toHex(String val)
Converts given String to its hex representation as String.
|
static String |
toHex1(int number)
Converts given number to its hex representation as String.
|
static void |
touchForReplication(HttpSession session)
Touches all session attributes to be sure the HttpSession is correctly replicated to the other cluster servers
regardless of the appserver's replication settings.
|
static void |
tryToCloseJDBC(Connection connection,
Statement statement,
ResultSet resultSet)
Tries to close given SQL objects.
|
static void |
tryToCloseJDBC(Connection connection,
Statement statement,
ResultSet resultSet,
boolean ignoreErrors) |
public static final String DEFAULT_PASSWORD_ENCODING
SystemEJB.DEFAULT_ENCODING.public static final String DEFAULT_ITEMLINK_ENCODING
public static final String ITEMLINK_PREFIX
public static final String ITEMLINK_PROTOCOLL_SPECIFIER
public static final String ITEMLINK_TYPE_PREFIX
public static final String ITEMLINK_ITEMATTRIBUTE_START
public static final String ITEMLINK_ITEMATTRIBUTE_END
public static final String ITEMLINK_ELEMENT_SEPARATOR
public static final String ITEMLINK_VALUE_SEPARATOR
public static final String ITEMLINK_PATTERN_ATTRIBUTE_SEPARATOR
public static final String ITEMLINK_LINK_ID
public static final String ITEMLINK_REPLACEMENT_TYPE
public static final Enum getOS()
Utilities.OS enumeration. When no name or an unknown name is
set Utilities.OS.UNKNOWN is returned.Utilities.OSpublic static final boolean isUnix()
Utilities.OS.WINDOWS or Utilities.OS.OS2 or Utilities.OS.NETWARE.getOS()public static final boolean isWindows()
Utilities.OS.WINDOWS.getOS()public static File getPlatformTempDir()
public static final Object copyViaSerialization(Object originalObject)
protected static Object copyViaSerializationUsingStandardJava(Object originalObject)
public static final Object copyViaSerializationIfNecessary(Object s)
s - may be null; then null will be returnedcopyViaSerialization(Object)public static final void touchForReplication(HttpSession session)
session - the HttpSession objectpublic static final String replaceXMLEntities(String s)
| char | replaced with |
| & | & |
| < | < |
| > | > |
| " | " |
s - the given XML string@Deprecated public static final String cleanMaliciousSQL(String source)
@Deprecated public static final Boolean booleanObject(boolean b)
Boolean.valueOf(boolean)Boolean.FALSE or Boolean.TRUE (will not allocate new object)@Deprecated public static final Boolean booleanObject(String booleanString)
Boolean.valueOf(boolean) where neededbooleanString - must be legal parameter of Boolean.valueOf(String)public static final int getInt(String intString, int defaultValue)
null the
default value is returned.intString - the string to be parseddefaultValue - the default valuenull@Deprecated public static final Locale getLocale(String isoCode)
isoCode - code for which a locale is neededpublic static final String[] parseLocaleCodes(String isoCodes)
public static List<String> getExtensionNames()
getInstalledExtensionNames(Tenant).public static Class getExtensionClass(MasterTenant t, String name)
public static <T> <any> mergeToImmutableSet(Set<T> col1, Set<T> col2)
public static Map<String,String> getInstalledWebModules()
public static List<String> getInstalledExtensionNames(Tenant tenant)
tenant - public static ExtensionInfo getExtensionInfo(String name)
ExtensionInfo object.name - the extension namenull if nut such ExtensionInfo object exists.public static Set<String> getPlatformExtensionNames()
Set with all extension names which are used in the platform only.public static PlatformConfig getPlatformConfig()
PlatformConfigpublic static ConfigIntf getConfig()
ConfigIntf implementation as merged object of all extensions properties.PlatformConfigpublic static Collection<String> getInstalledPasswordEncodings()
project.properties parameter password.encoders.public static PasswordEncoder getPasswordEncoder(String encoding) throws JaloInvalidParameterException
PasswordEncoder from the user password encoders configured within
project.properties parameter password.encodersencoding - the password encoding name e.g. 'MD5' or '*' for default encodingJaloInvalidParameterException - if the specified encoding does not existspublic static final String getStackTraceAsString(Throwable throwable)
public static <T extends Throwable> Throwable getRootCauseOfType(Throwable e, Class<T> type)
public static <T extends Throwable> Throwable getRootCauseOfName(Throwable e, String name)
public static String escapeJavaScript(String s)
s - string to escapepublic static String escapeHTML(String s)
s - string to escapepublic static String filterOutHTMLTags(String input)
public static String formatTime(long milliseconds)
milliseconds - time to formatpublic static String toHex(String val)
public static String toHex(byte val)
public static String toHex1(int number)
public static final void tryToCloseJDBC(Connection connection, Statement statement, ResultSet resultSet)
public static final void tryToCloseJDBC(Connection connection, Statement statement, ResultSet resultSet, boolean ignoreErrors)
public static Object callMethod(Object instance, String methodName, Class[] paramClasses, Object[] params) throws Exception
Exceptionpublic static Object callMethod(Object instance, Method method, Object[] params) throws Exception
Exceptionpublic static Class[] getAllInterfaces(Class cl)
public static boolean ejbEquals(ItemRemote first, ItemRemote second)
public static File getPathFromResource(Class c, String resource)
File object representing given resource by using the classloader of given class.public static String buildRelativePath(File fromDir, File toFileOrDir)
de.hybris.platform.test.UtilitiesTest#testBuildRelativePath().fromDir - the dir to start fromtoFileOrDir - the dir or file to go topublic static boolean isSystemInitialized(HybrisDataSource ds)
DataSource for accessing correct metainformations
table. If check fails tenant will shutdown.@Deprecated public static boolean isSystemInitialized(HybrisDataSource ds, boolean shutdownTenantIfFailed)
public static String getTenantID(HybrisDataSource ds)
DataSource.@Deprecated public static String getSystemID(HybrisDataSource ds)
getTenantID(HybrisDataSource) insteadpublic static boolean isDBConnectionValid(String dbUrl, String dbUser, String dbPassword, String driver, String fromJNDI)
public static boolean isDBConnectionValid(String dbUrl, String dbUser, String dbPassword, String driver)
public static EnumerationValue resolveEncoding(String encoding) throws UnsupportedEncodingException
encoding - String of the desired encoding instanceUnsupportedEncodingException - encoding can not be resolvedpublic static String resolveEncoding(EnumerationValue enc)
enc - encoding to convertpublic static String buildStackTraceCompact(Throwable thr)
public static boolean arrayDeepEqualsReverse(Object[] a1, Object[] a2)
public static void setJUnitTenant()
throws IllegalStateException
IllegalStateExceptionpublic static boolean isMasterTenantAsTestSystem()
public static void printAppInfo()
public static ResourceBundle getResourceBundle(String baseName, ClassLoader loader)
ResourceBundle.getBundle(String) because the standard java api (of course) cannot obey the hybris
platform fallback language and tenant localization rules.public static ResourceBundle getResourceBundle(String baseName)
ResourceBundle.getBundle(String) because the standard java api
(of course) cannot obey the hybris platform fallback language and tenant localization rules.public static ResourceBundle getResourceBundle(SessionContext ctx, String baseName) throws MissingResourceException
ResourceBundle.getBundle(String) because the standard java api (of course) cannot obey the hybris
platform fallback language and tenant localization rules.MissingResourceExceptionpublic static ResourceBundle getResourceBundle(SessionContext ctx, String baseName, ClassLoader loader) throws MissingResourceException
ResourceBundle.getBundle(String)
because the standard java api (of course) cannot obey the hybris platform fallback language and tenant
localization rules.MissingResourceExceptionpublic static ResourceBundle getResourceBundle(Language lang, String baseName) throws MissingResourceException
ResourceBundle.getBundle(String) because the standard java api (of course) cannot obey the hybris
platform fallback language and tenant localization rules.MissingResourceExceptionpublic static ResourceBundle getResourceBundle(Language lang, String baseName, ClassLoader loader) throws MissingResourceException
ResourceBundle.getBundle(String)
because the standard java api (of course) cannot obey the hybris platform fallback language and tenant
localization rules.MissingResourceExceptionpublic static ResourceBundle getResourceBundle(Locale[] path, String baseName, ClassLoader loader) throws MissingResourceException
ResourceBundle.getBundle(String) because the standard java api (of course) cannot obey the hybris
platform fallback language and tenant localization rules.MissingResourceExceptionpublic static Locale getDefaultLocale()
Locale.getDefault()
because it cannot obey the current session context time zone and locale!SessionContext.getLocale(),
SessionContext.getTimeZone()@Deprecated public static Calendar getDefaultCalendar()
Calendar creation :
Calendar calendarInstance = Calendar.getInstance(i18nService
.getCurrentTimeZone(),
i18nService.getCurrentLocale());
Calendar.getInstance() methods because the cannot obey the current session context time zone and
locale!SessionContext.getLocale(),
SessionContext.getTimeZone()@Deprecated public static Calendar getDefaultCalendar(Locale loc)
Calendar creation :
Calendar calendarInstance = Calendar.getInstance(i18nService
.getCurrentTimeZone(),
i18nService.getCurrentLocale());
Calendar.getInstance() methods because the cannot obey the current session context time zone and
locale! Session context time zones and locales are required e.g. to implement web sites for different target
countries running on one hybris platform instance.loc - a specifiec locale instead of the current session context localeSessionContext.getLocale(),
SessionContext.getTimeZone()@Deprecated public static SimpleDateFormat getSimpleDateFormat(String pattern)
FormatFactory.createDateTimeFormat(int, int) instead
as
final SimpleDateFormat format = (SimpleDateFormat)factory.createDateTimeFormat
(DateFormat
.DEFAULT, -1);
format.applyPattern("yyyy-mm-dd");
SimpleDateFormat.SimpleDateFormat(String) because the java class will
always use the vm defaults for time zone and locale! The main reason for using session context dependent date
formats is to keep any time zone related date conversion logic out of hybris code. Session context time zones and
locales are required e.g. to implement web sites for different target countries running on one hybris platform
instance.pattern - the pattern for the new date formatSessionContext.getLocale(),
SessionContext.getTimeZone()@Deprecated public static SimpleDateFormat getSimpleDateFormat(String pattern, Locale loc)
FormatFactory.createDateTimeFormat(int, int) instead,
to provide a Locale use
SessionService.executeInLocalView(de.hybris.platform.servicelayer.session.SessionExecutionBody)
as below :
sessionService.executeInLocalView(new SessionExecutionBody()
{
public Object execute() {
i18nService.setCurrentLocale(customLocale);
final SimpleDateFormat format = (SimpleDateFormat)factory
.createDateTimeFormat
(DateFormat.DEFAULT,
-1);
format.applyPattern(pattern);
return format;
}
});
SimpleDateFormat.SimpleDateFormat(String) because the java class will
always use the vm defaults for time zone and locale! The main reason for using session context dependent date
formats is to keep any time zone related date conversion logic out of hybris code. Session context time zones and
locales are required e.g. to implement web sites for different target countries running on one hybris platform
instance.pattern - the pattern for the new date formatloc - a specified locale for the new date formatSessionContext.getLocale(),
SessionContext.getTimeZone()@Deprecated public static DateFormat getDateTimeInstance()
FormatFactory.createDateTimeFormat(int, int) instead
as :
formatFactory.createDateTimeFormat(DateFormat.DEFAULT,DateFormat.DEFAULT);
DateFormat.getDateTimeInstance(int, int, Locale) methods because the cannot obey the current session
context time zone and locale! Session context time zones and locales are required e.g. to implement web sites
for different target countries running on one hybris platform instance.SessionContext.getLocale(),
SessionContext.getTimeZone()@Deprecated public static DateFormat getDateTimeInstance(int dateStyle, int timeStyle)
FormatFactory.createDateTimeFormat(int, int) insteadDateFormat.getDateTimeInstance(int, int, Locale) methods because the cannot obey the current session
context time zone and locale! Session context time zones and locales are required e.g. to implement web sites
for different target countries running on one hybris platform instance.dateStyle - date style , see DateFormat.getDateTimeInstance(int, int, Locale) for available valuestimeStyle - time style , see DateFormat.getDateTimeInstance(int, int, Locale) for available valuesSessionContext.getLocale(),
SessionContext.getTimeZone()@Deprecated public static DateFormat getDateTimeInstance(int dateStyle, int timeStyle, Locale loc)
FormatFactory.createDateTimeFormat(int, int) instead,
to provide a Locale use
SessionService.executeInLocalView(de.hybris.platform.servicelayer.session.SessionExecutionBody)
as below :
sessionService.executeInLocalView(new SessionExecutionBody()
{
public Object execute() {
i18nService.setCurrentLocale(customLocale);
return formatFactory.createDateTimeFormat(dateStyle ,timeStyle);
}
});
DateFormat.getDateTimeInstance(int, int, Locale) methods because the cannot obey the current session
context time zone and locale! Session context time zones and locales are required e.g. to implement web sites
for different target countries running on one hybris platform instance.dateStyle - date style , see DateFormat.getDateTimeInstance(int, int, Locale) for available valuestimeStyle - time style , see DateFormat.getDateTimeInstance(int, int, Locale) for available valuesloc - a specific locale instead of the session context localeSessionContext.getLocale(),
SessionContext.getTimeZone()@Deprecated public static DateFormat getDateInstance(int dateStyle)
FormatFactory.createDateTimeFormat(int, int) instead
formatFactory.createDateTimeFormat(dateStyle,-1);
DateFormat.getDateInstance(int, Locale) methods because the cannot obey the current session context time
zone and locale! Session context time zones and locales are required e.g. to implement web sites for different
target countries running on one hybris platform instance.dateStyle - date style , see DateFormat.getDateTimeInstance(int, int, Locale) for available valuesSessionContext.getLocale(),
SessionContext.getTimeZone()@Deprecated public static DateFormat getDateInstance(int dateStyle, Locale loc)
FormatFactory.createDateTimeFormat(int, int) instead
, to pass a custom Locale use
SessionService.executeInLocalView(de.hybris.platform.servicelayer.session.SessionExecutionBody)
as below :
sessionService.executeInLocalView(new SessionExecutionBody()
{
public Object execute() {
i18nService.setCurrentLocale(customLocale);
return formatFactory.createDateTimeFormat(dateStyle ,-1);
}
});
DateFormat.getDateInstance(int, Locale) methods because the cannot obey the current session context time
zone and locale! Session context time zones and locales are required e.g. to implement web sites for different
target countries running on one hybris platform instance.dateStyle - date style , see DateFormat.getDateTimeInstance(int, int, Locale) for available valuesloc - a specific locale instead of the session context localeSessionContext.getLocale(),
SessionContext.getTimeZone()@Deprecated public static DecimalFormat getDecimalFormat(String pattern)
FormatFactory.createNumberFormat() instead, to
provide the patten use as below :
(DecimalFormat) factory.createNumberFormat();
df.applyPattern("some pattern");
DecimalFormat.DecimalFormat(String) methods because the cannot obey the current session context time zone
and locale! Session context time zones and locales are required e.g. to implement web sites for different
target countries running on one hybris platform instance.pattern - the decimal format patterngetNumberInstance(),
getIntegerInstance(),
SessionContext.getLocale(),
SessionContext.getTimeZone()@Deprecated public static DecimalFormat getDecimalFormat(String pattern, Locale loc)
FormatFactory.createNumberFormat() instead, to
provide a pattern see :
(DecimalFormat) factory.createNumberFormat();
df.applyPattern("some pattern");
, to provide a custom Locale see :
sessionService.executeInLocalView(new SessionExecutionBody()
{
public Object execute() {
i18nService.setCurrentLocale(customLocale);
return formatFactory.createNumberFormat();
}
});
DecimalFormat.DecimalFormat(String) methods because the cannot obey the current session context time zone
and locale! Session context time zones and locales are required e.g. to implement web sites for different
target countries running on one hybris platform instance.pattern - the decimal format patternloc - the specified locale for the new formatgetNumberInstance(),
getIntegerInstance(),
SessionContext.getLocale(),
SessionContext.getTimeZone()@Deprecated public static NumberFormat getIntegerInstance()
FormatFactory.createIntegerFormat() insteadNumberFormat.getIntegerInstance() methods because they cannot obey the current session context locale.
Session context time zones and locales are required e.g. to implement web sites for different target countries
running on one hybris platform instance.SessionContext.getLocale()@Deprecated public static NumberFormat getIntegerInstance(Locale loc)
FormatFactory.createIntegerFormat() instead , to pass
a custom Locale use
SessionService.executeInLocalView(de.hybris.platform.servicelayer.session.SessionExecutionBody)
as below :
sessionService.executeInLocalView(new SessionExecutionBody()
{
public Object execute() {
i18nService.setCurrentLocale(customLocale);
return formatFactory.createIntegerFormat();
}
});
NumberFormat.getIntegerInstance() methods because they cannot obey the current session context locale.
Session context time zones and locales are required e.g. to implement web sites for different target countries
running on one hybris platform instance.loc - the specific locale for the new number formatSessionContext.getLocale()@Deprecated public static NumberFormat getNumberInstance()
FormatFactory.createNumberFormat() insteadNumberFormat.getNumberInstance() methods because they cannot obey the current session context locale.
Session context time zones and locales are required e.g. to implement web sites for different target countries
running on one hybris platform instance.SessionContext.getLocale()@Deprecated public static NumberFormat getNumberInstance(Locale loc)
FormatFactory.createNumberFormat() instead , to pass
a custom Locale use
SessionService.executeInLocalView(de.hybris.platform.servicelayer.session.SessionExecutionBody)
as below :
sessionService.executeInLocalView(new SessionExecutionBody()
{
public Object execute() {
i18nService.setCurrentLocale(customLocale);
return formatFactory.createNumberFormat();
}
});
NumberFormat.getNumberInstance() methods because they cannot obey the current session context locale.
Session context time zones and locales are required e.g. to implement web sites for different target countries
running on one hybris platform instance.loc - the specific locale for the new number formatSessionContext.getLocale()@Deprecated public static NumberFormat getPercentInstance()
FormatFactory.createPercentFormat() insteadNumberFormat.getPercentInstance() methods because they cannot obey the current session context locale.
Session context time zones and locales are required e.g. to implement web sites for different target countries
running on one hybris platform instance.SessionContext.getLocale()@Deprecated public static NumberFormat getCurrencyInstance()
FormatFactory.createCurrencyFormat() insteadNumberFormat.getCurrencyInstance() methods because they cannot obey the current session context locale.
Session context time zones and locales are required e.g. to implement web sites for different target countries
running on one hybris platform instance.SessionContext.getLocale()@Deprecated public static NumberFormat getCurrencyInstance(Currency jaloCurrency)
FormatFactory.createCurrencyFormat() instead , to
pass a custom CurrencyModel use
SessionService.executeInLocalView(de.hybris.platform.servicelayer.session.SessionExecutionBody)
as below :
sessionService.executeInLocalView(new SessionExecutionBody()
{
public Object execute() {
i18nService.setCurrentLocale(customLocale);
i18nService.setCurrentCurrency(customCurrency);
return formatFactory.createCurrencyFormat();
}
});
NumberFormat.getCurrencyInstance() methods because they cannot obey the current session context
locale. Session context time zones and locales are required e.g. to implement web sites for different target
countries running on one hybris platform instance.jaloCurrency - a specified jalo currency to get the currency format forSessionContext.getLocale()@Deprecated public static NumberFormat getCurrencyInstance(Currency jaloCurrency, Locale loc)
FormatFactory.createCurrencyFormat() instead , to
pass a custom CurrencyModel , Locale use
SessionService.executeInLocalView(de.hybris.platform.servicelayer.session.SessionExecutionBody)
as below :
sessionService.executeInLocalView(new SessionExecutionBody()
{
public Object execute() {
i18nService.setCurrentLocale(customLocale);
i18nService.setCurrentCurrency(customCurrency);
return formatFactory.createCurrencyFormat();
}
});
NumberFormat.getCurrencyInstance() methods because they cannot obey the current session context
locale. Session context time zones and locales are required e.g. to implement web sites for different target
countries running on one hybris platform instance.jaloCurrency - a specified jalo currency to get the currency format forSessionContext.getLocale()public static TransformerFactory getTransformerFactory()
@Deprecated public static void checkLicence()
public static String getInfoAddress(HttpServletRequest req)
public static String createLink(SessionContext ctx, Item item) throws JaloBusinessException
ctx - The SessionContext that shall be used while retrieving attribute valuesitem - The item for which to create the linkJaloBusinessException - If an attribute could not be red from the item while building the Linkpublic static String createLink(SessionContext ctx, Item item, String typeName, String attributeList) throws JaloBusinessException
ctx - The SessionContext that shall be used while retrieving attribute valuesitem - The item for which to create the linktypeName - The ComposedType's name that that shall be used in the linkattributeList - Comma separated list of attribute qualifiers that shall be used in the link (qualifier and value!)JaloBusinessException - If an attribute could not be red from the item while building the Linkpublic static Item getItemFromLink(SessionContext ctx, String itemLink) throws JaloBusinessException, JaloInvalidParameterException, JaloItemNotFoundException
ctx - The SessionContext that shall be used while retrieving attribute valuesitemLink - The textual item link that references to an itemJaloBusinessException - If an error occured while resolving the item linkJaloInvalidParameterException - If there is no or more then one item foundJaloItemNotFoundException - If the referenced item could not be foundpublic static String getAttributeFromLink(SessionContext ctx, String itemLink, String attributeName) throws JaloBusinessException, JaloInvalidParameterException, JaloItemNotFoundException
public static String getReplacementTypeFromLink(SessionContext ctx, String itemLink) throws JaloBusinessException, JaloInvalidParameterException, JaloItemNotFoundException
public static String getLinkIdFromLink(SessionContext ctx, String itemLink) throws JaloBusinessException, JaloInvalidParameterException, JaloItemNotFoundException
public static void invalidateCache(PK primaryKey)
primaryKey - The primary key of the item to be invalidated in the cache.public static void invalidateCache(Cache cache, PK primaryKey)
primaryKey - The primary key of the item to be invalidated in the cache.cache - the cache instance - must not be nullpublic static void invalidateCache(Transaction tx, Cache cache, PK primaryKey)
primaryKey - The primary key of the item to be invalidated in the cache.cache - the cache instance - must not be nulltx - the transaction to attach the invalidation to - must not be nullpublic static void invalidateCache(Transaction tx, Cache cache, PK primaryKey, boolean sendImmediately)
primaryKey - The primary key of the item to be invalidated in the cache.cache - the cache instance - must not be nulltx - the transaction to attach the invalidation to - must not be nullsendImmediately - if true the invalidation will be send to all other cluster nodes immediately in addition to
attaching it to the given transactionpublic static Object getIPAddressForLogOutput(String address)
address - the address (hostname, ip, whatever you want)public static <T> T getCacheBoundVersion(T value)
public static Map<String,String> getMySQLSlaveStatus(HybrisDataSource dsi)
dsi - The HybrisDataSource must be a mysql DBpublic static List<? extends Item> sortItemsByPK(Collection<? extends Item> items)
public static Map<String,Properties> getTenantInfos()
Properties
object filled with tenant specific configuration.@Deprecated public static Properties loadPlatformProperties(Class clazz)
loadPlatformProperties() instead.public static Properties loadPlatformProperties()
public static String getTenantIdForContext(String servletContextPath, String defaultTenant)
public static String getExtensionNameFromRequest(HttpServletRequest request)
public static boolean getRelationOrderingOverride(String cfgKey, boolean defaultValue)
public static void clearRelationOrderingOverrideCache()
public static boolean getMarkModifiedOverride(String cfgKey)
public static void clearMarkModifiedOverrideCache()
public static String calculateLocalCorePlusEndPoint(String extensionName, String tenantId) throws IllegalArgumentException
IllegalArgumentExceptionCopyright © 2017 SAP SE. All Rights Reserved.