public class Utilities
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Utilities.OS
Enumeration of different operating systems.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_ITEMLINK_ENCODING
The default encoding that is used while build an item link
|
static java.lang.String |
DEFAULT_PASSWORD_ENCODING
Specify the default encoding used for password encryption.
|
static java.lang.String |
ITEMLINK_ELEMENT_SEPARATOR
The sign that separates item link elements
|
static java.lang.String |
ITEMLINK_ITEMATTRIBUTE_END
The sign that ends a reference to a subItem that is an attribute value of an item
|
static java.lang.String |
ITEMLINK_ITEMATTRIBUTE_START
The sign that starts a reference to a subItem that is an attribute value of an item
|
static java.lang.String |
ITEMLINK_LINK_ID
Placeholder constant for link id.
|
static java.lang.String |
ITEMLINK_PATTERN_ATTRIBUTE_SEPARATOR
The sign that separates item the attribute qualifiers in the item link pattern
|
static java.lang.String |
ITEMLINK_PREFIX
The prefix that leads the type configuration for item links
|
static java.lang.String |
ITEMLINK_PROTOCOLL_SPECIFIER
The protocoll prefix that specifies the URI as an item link
|
static java.lang.String |
ITEMLINK_REPLACEMENT_TYPE
Placeholder constant for crossreference replacement type.
|
static java.lang.String |
ITEMLINK_TYPE_PREFIX
The prefix that leads the type field in an item link
|
static java.lang.String |
ITEMLINK_VALUE_SEPARATOR
The sign that separates item link element values
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
arrayDeepEqualsReverse(java.lang.Object[] a1,
java.lang.Object[] a2)
Like Arrays.deepEquals() but it compares the arrays from bottom to top which is faster for our cache (e.g.
|
static java.lang.String |
buildRelativePath(java.io.File fromDir,
java.io.File toFileOrDir)
Computes the relative file path from the "fromDir" to the "toFileOrDir" argument.
|
static java.lang.String |
buildStackTraceCompact(java.lang.Throwable thr)
Gets the stacktrace of a throwable as a String.
|
static java.lang.String |
calculateLocalCorePlusEndPoint(java.lang.String extensionName,
java.lang.String tenantId) |
static java.lang.Object |
callMethod(java.lang.Object instance,
java.lang.reflect.Method method,
java.lang.Object[] params)
Calls method with given name on given object instance and returns the invocation result.
|
static java.lang.Object |
callMethod(java.lang.Object instance,
java.lang.String methodName,
java.lang.Class[] paramClasses,
java.lang.Object[] params)
Calls method with given name on given object instance and returns the invocation result.
|
static void |
clearMarkModifiedOverrideCache() |
static void |
clearRelationOrderingOverrideCache() |
static java.lang.Object |
copyViaSerialization(java.lang.Object originalObject)
Create a copy of the given object by serializing it into memory and then deserializing it again.
|
static java.lang.Object |
copyViaSerializationIfNecessary(java.lang.Object s)
Create a copy of the given object unless it is unmodifiable.
|
protected static java.lang.Object |
copyViaSerializationUsingStandardJava(java.lang.Object originalObject) |
static java.lang.String |
createLink(SessionContext ctx,
Item item)
Creates a link text that references to the given item.
|
static java.lang.String |
createLink(SessionContext ctx,
Item item,
java.lang.String typeName,
java.lang.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(java.lang.Object o1,
java.lang.Object o2) |
static java.lang.String |
escapeHTML(java.lang.String s)
Escapes all occurrences of special chars with corresponding html escape sequence.
|
static java.lang.String |
escapeJavaScript(java.lang.String s)
Escapes given string in the same way that escape function from JavaScript does but serverside.
|
static void |
failLicence(java.lang.String message,
Licence licence) |
static void |
failProperties(java.util.Map<java.lang.String,java.lang.String> missing) |
static java.lang.String |
filterOutHTMLTags(java.lang.String input)
Filters out all html tags in given string.
|
static java.lang.String |
formatTime(long milliseconds)
Formats given time to a readable string inf format: 0d 00h:00m:00s:000ms.
|
static java.lang.Class[] |
getAllInterfaces(java.lang.Class cl)
Gets all interfaces of given class including interfaces implemented by superclasses.
|
static java.lang.String |
getAttributeFromLink(SessionContext ctx,
java.lang.String itemLink,
java.lang.String attributeName) |
static <T> T |
getCacheBoundVersion(T value) |
static ConfigIntf |
getConfig()
Returns a
ConfigIntf implementation as merged object of all extensions properties. |
static java.lang.String |
getContextFromRequestUri(java.lang.String uri) |
static java.text.NumberFormat |
getCurrencyInstance(Currency jaloCurrency)
Deprecated.
since ages - 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 java.text.NumberFormat |
getCurrencyInstance(Currency jaloCurrency,
java.util.Locale loc)
Deprecated.
since ages - 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 java.text.DateFormat |
getDateTimeInstance()
Deprecated.
since ages - use
FormatFactory.createDateTimeFormat(int, int) instead
as :
formatFactory.createDateTimeFormat(DateFormat.DEFAULT,DateFormat.DEFAULT);
|
static java.text.DateFormat |
getDateTimeInstance(int dateStyle,
int timeStyle)
Deprecated.
since ages - use
FormatFactory.createDateTimeFormat(int, int) instead |
static java.text.DateFormat |
getDateTimeInstance(int dateStyle,
int timeStyle,
java.util.Locale loc)
Deprecated.
since ages - 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 java.text.DecimalFormat |
getDecimalFormat(java.lang.String pattern)
Deprecated.
since ages - use
FormatFactory.createNumberFormat() instead, to
provide the patten use as below :
(DecimalFormat) factory.createNumberFormat();
df.applyPattern("some pattern");
|
static java.text.DecimalFormat |
getDecimalFormat(java.lang.String pattern,
java.util.Locale loc)
Deprecated.
since ages - 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 java.util.Calendar |
getDefaultCalendar()
Deprecated.
since ages - use plain
Calendar creation :
Calendar calendarInstance = Calendar.getInstance(i18nService
.getCurrentTimeZone(),
i18nService.getCurrentLocale());
|
static java.util.Calendar |
getDefaultCalendar(java.util.Locale loc)
Deprecated.
since ages - use plain
Calendar creation :
Calendar calendarInstance = Calendar.getInstance(i18nService
.getCurrentTimeZone(),
i18nService.getCurrentLocale());
|
static java.util.Locale |
getDefaultLocale()
Provides a session context obeying locale.
|
static java.lang.Class |
getExtensionClass(MasterTenant t,
java.lang.String name)
Returns the extension manager class belonging to a given extension name.
|
static java.lang.String |
getExtensionForWebroot(java.lang.String webroot) |
static java.lang.String |
getExtensionForWebroot(java.lang.String webroot,
java.lang.String tenantID) |
static ExtensionInfo |
getExtensionInfo(java.lang.String name)
Returns for the given extension name the corresponding
ExtensionInfo object. |
static java.lang.String |
getExtensionNameFromRequest(HttpServletRequest request) |
static java.util.List<java.lang.String> |
getExtensionNames()
Returns the names of all extensions which are active within the current system.
|
static java.lang.String |
getInfoAddress(HttpServletRequest req)
Internal use only.
|
static java.util.List<java.lang.String> |
getInstalledExtensionNames(Tenant tenant)
Returns the names of all installed extension.
|
static java.util.Collection<java.lang.String> |
getInstalledPasswordEncodings()
Returns all installed user password encodings.
|
static java.util.Map<java.lang.String,java.lang.String> |
getInstalledWebModules()
Gets all installed webmodules.
|
static int |
getInt(java.lang.String intString,
int defaultValue)
Parses given string and returns its integer equivalent.
|
static java.text.NumberFormat |
getIntegerInstance()
Deprecated.
since ages - use
FormatFactory.createIntegerFormat() instead |
static java.text.NumberFormat |
getIntegerInstance(java.util.Locale loc)
Deprecated.
since ages - 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 java.lang.Object |
getIPAddressForLogOutput(java.lang.String address)
Replaces localhost from given address.
|
static Item |
getItemFromLink(SessionContext ctx,
java.lang.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 java.lang.String |
getLinkIdFromLink(SessionContext ctx,
java.lang.String itemLink)
Tryes to resolve the given item link and to retrieve the link id.
|
static java.util.Locale |
getLocale(java.lang.String isoCode)
Deprecated.
since ages - use de.hybris.platform.servicelayer.i18n.CommonI18NService#getLocaleForLanguage(LanguageModel) instead
|
static boolean |
getMarkModifiedOverride(java.lang.String cfgKey) |
static java.util.Map<java.lang.String,java.lang.String> |
getMySQLSlaveStatus(HybrisDataSource dsi)
This method only works if the Data Source is a mysql db with a master and some slaves.
|
static java.text.NumberFormat |
getNumberInstance()
Deprecated.
since ages - use
FormatFactory.createNumberFormat() instead |
static java.text.NumberFormat |
getNumberInstance(java.util.Locale loc)
Deprecated.
since ages - 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 java.lang.Enum |
getOS()
Reads the system property 'os.name' and returns this as
Utilities.OS enumeration. |
static PasswordEncoder |
getPasswordEncoder(java.lang.String encoding)
Returns a specific
PasswordEncoder from the user password encoders configured within
project.properties parameter password.encoders |
static java.io.File |
getPathFromResource(java.lang.Class c,
java.lang.String resource)
Gets an
File object representing given resource by using the classloader of given class. |
static java.text.NumberFormat |
getPercentInstance()
Deprecated.
since ages - use
FormatFactory.createPercentFormat() instead |
static PlatformConfig |
getPlatformConfig()
Returns all platform extensions info in their compile order - for bootstrap purposes.
|
static java.util.Set<java.lang.String> |
getPlatformExtensionNames() |
static java.io.File |
getPlatformTempDir()
Returns platform temp directory.
|
static boolean |
getRelationOrderingOverride(java.lang.String cfgKey,
boolean defaultValue) |
static java.lang.String |
getReplacementTypeFromLink(SessionContext ctx,
java.lang.String itemLink)
Tryes to resolve the given item link and to retrieve the replacementType
|
static java.util.ResourceBundle |
getResourceBundle(Language lang,
java.lang.String baseName)
Provides access to the resource bundle loaded by class loader of this class.
|
static java.util.ResourceBundle |
getResourceBundle(Language lang,
java.lang.String baseName,
java.lang.ClassLoader loader)
Provides access to the resource bundle.
|
static java.util.ResourceBundle |
getResourceBundle(java.util.Locale[] path,
java.lang.String baseName,
java.lang.ClassLoader loader)
Provides access to the resource bundle belonging.
|
static java.util.ResourceBundle |
getResourceBundle(SessionContext ctx,
java.lang.String baseName)
Provides access to the resource bundle loaded by class loader of this class.
|
static java.util.ResourceBundle |
getResourceBundle(SessionContext ctx,
java.lang.String baseName,
java.lang.ClassLoader loader)
Provides access to the resource bundle.
|
static java.util.ResourceBundle |
getResourceBundle(java.lang.String baseName)
Provides access to the resource bundle belonging to the current session language and loaded by class loader of
this class.
|
static java.util.ResourceBundle |
getResourceBundle(java.lang.String baseName,
java.lang.ClassLoader loader)
Provides access to the resource bundle belonging to the current session language.
|
static <T extends java.lang.Throwable> |
getRootCauseOfName(java.lang.Throwable e,
java.lang.String name)
Iterates over all causes of a given throwable and returns the first one matching the given name.
|
static <T extends java.lang.Throwable> |
getRootCauseOfType(java.lang.Throwable e,
java.lang.Class<T> type)
Iterates over all causes of a given throwable and returns the first one matching the given type.
|
static java.text.SimpleDateFormat |
getSimpleDateFormat(java.lang.String pattern)
Deprecated.
since ages - use
FormatFactory.createDateTimeFormat(int, int) instead
as
final SimpleDateFormat format = (SimpleDateFormat)factory.createDateTimeFormat
(DateFormat
.DEFAULT, -1);
format.applyPattern("yyyy-mm-dd");
|
static java.text.SimpleDateFormat |
getSimpleDateFormat(java.lang.String pattern,
java.util.Locale loc)
Deprecated.
since ages - 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 java.lang.String |
getStackTraceAsString(java.lang.Throwable throwable)
Gets full stacktrace of given exception as string.
|
static java.lang.String |
getTenantID(HybrisDataSource ds)
Gets the tenant id associated with given
DataSource. |
static java.lang.String |
getTenantIdForContext(java.lang.String servletContextPath,
java.lang.String defaultTenant)
Retrives a tenant id basing on the static web root configuration for extension per tenant.
|
static java.util.Map<java.lang.String,java.util.Properties> |
getTenantInfos()
Returns all tenants information loaded locally from platform/tenant_{tenantID}.properties or
config/local_tenant_{tenantID}.properties files.
|
static javax.xml.transform.TransformerFactory |
getTransformerFactory()
Gets the TransformerFactory that is used in several areas (e.g.
|
static java.lang.String |
getWebroot(java.lang.String extensionsName)
Returns mapped webroot
|
static java.lang.String |
getWebroot(java.lang.String extensionsName,
java.lang.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(java.lang.String dbUrl,
java.lang.String dbUser,
java.lang.String dbPassword,
java.lang.String driver)
Checks whether a DB connection can be established with given connection parameters.
|
static boolean |
isDBConnectionValid(java.lang.String dbUrl,
java.lang.String dbUser,
java.lang.String dbPassword,
java.lang.String driver,
java.lang.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 |
isTypeInitialized(java.lang.String typecode)
Checks if given type is known in type system which means update running system was performed.
|
static boolean |
isUnix()
Checks whether the current operating system is unix.
|
static boolean |
isWindows()
Checks whether the current operating system is windows.
|
static java.util.Properties |
loadPlatformProperties() |
static <T> <any> |
mergeToImmutableSet(java.util.Set<T> col1,
java.util.Set<T> col2)
Merge two sets to new immutable set.
|
static java.lang.String[] |
parseLocaleCodes(java.lang.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 java.lang.String |
replaceXMLEntities(java.lang.String s)
Replaces in the given String all XML entities with XML encoded chars
char
replaced with
&
&
<
<
>
>
"
"
|
static java.lang.String |
resolveEncoding(EnumerationValue enc)
Converts an encoding given as enumeration value to the related code, checking the encoding for emptiness.
|
static EnumerationValue |
resolveEncoding(java.lang.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 java.util.List<? extends Item> |
sortItemsByPK(java.util.Collection<? extends Item> items) |
static java.lang.String |
toHex(byte val)
Converts given byte to its hex representation as String.
|
static java.lang.String |
toHex(java.lang.String val)
Converts given String to its hex representation as String.
|
static java.lang.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(java.sql.Connection connection,
java.sql.Statement statement,
java.sql.ResultSet resultSet)
Tries to close given SQL objects.
|
static void |
tryToCloseJDBC(java.sql.Connection connection,
java.sql.Statement statement,
java.sql.ResultSet resultSet,
boolean ignoreErrors) |
public static final java.lang.String DEFAULT_PASSWORD_ENCODING
SystemEJB.DEFAULT_ENCODING.public static final java.lang.String DEFAULT_ITEMLINK_ENCODING
public static final java.lang.String ITEMLINK_PREFIX
public static final java.lang.String ITEMLINK_PROTOCOLL_SPECIFIER
public static final java.lang.String ITEMLINK_TYPE_PREFIX
public static final java.lang.String ITEMLINK_ITEMATTRIBUTE_START
public static final java.lang.String ITEMLINK_ITEMATTRIBUTE_END
public static final java.lang.String ITEMLINK_ELEMENT_SEPARATOR
public static final java.lang.String ITEMLINK_VALUE_SEPARATOR
public static final java.lang.String ITEMLINK_PATTERN_ATTRIBUTE_SEPARATOR
public static final java.lang.String ITEMLINK_LINK_ID
public static final java.lang.String ITEMLINK_REPLACEMENT_TYPE
public static final java.lang.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 java.io.File getPlatformTempDir()
public static final java.lang.Object copyViaSerialization(java.lang.Object originalObject)
protected static java.lang.Object copyViaSerializationUsingStandardJava(java.lang.Object originalObject)
public static final java.lang.Object copyViaSerializationIfNecessary(java.lang.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 java.lang.String replaceXMLEntities(java.lang.String s)
| char | replaced with |
| & | & |
| < | < |
| > | > |
| " | " |
s - the given XML stringpublic static final int getInt(java.lang.String intString,
int defaultValue)
null the
default value is returned.intString - the string to be parseddefaultValue - the default valuenull@Deprecated public static final java.util.Locale getLocale(java.lang.String isoCode)
isoCode - code for which a locale is neededpublic static final java.lang.String[] parseLocaleCodes(java.lang.String isoCodes)
public static java.util.List<java.lang.String> getExtensionNames()
getInstalledExtensionNames(Tenant).public static java.lang.Class getExtensionClass(MasterTenant t, java.lang.String name)
public static <T> <any> mergeToImmutableSet(java.util.Set<T> col1,
java.util.Set<T> col2)
public static java.util.Map<java.lang.String,java.lang.String> getInstalledWebModules()
public static java.util.List<java.lang.String> getInstalledExtensionNames(Tenant tenant)
tenant - public static ExtensionInfo getExtensionInfo(java.lang.String name)
ExtensionInfo object.name - the extension namenull if nut such ExtensionInfo object exists.public static java.util.Set<java.lang.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 java.util.Collection<java.lang.String> getInstalledPasswordEncodings()
project.properties parameter password.encoders.public static PasswordEncoder getPasswordEncoder(java.lang.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 java.lang.String getStackTraceAsString(java.lang.Throwable throwable)
public static <T extends java.lang.Throwable> java.lang.Throwable getRootCauseOfType(java.lang.Throwable e,
java.lang.Class<T> type)
public static <T extends java.lang.Throwable> java.lang.Throwable getRootCauseOfName(java.lang.Throwable e,
java.lang.String name)
public static java.lang.String escapeJavaScript(java.lang.String s)
s - string to escapepublic static java.lang.String escapeHTML(java.lang.String s)
s - string to escapepublic static java.lang.String filterOutHTMLTags(java.lang.String input)
public static java.lang.String formatTime(long milliseconds)
milliseconds - time to formatpublic static java.lang.String toHex(java.lang.String val)
public static java.lang.String toHex(byte val)
public static java.lang.String toHex1(int number)
public static final void tryToCloseJDBC(java.sql.Connection connection,
java.sql.Statement statement,
java.sql.ResultSet resultSet)
public static final void tryToCloseJDBC(java.sql.Connection connection,
java.sql.Statement statement,
java.sql.ResultSet resultSet,
boolean ignoreErrors)
public static java.lang.Object callMethod(java.lang.Object instance,
java.lang.String methodName,
java.lang.Class[] paramClasses,
java.lang.Object[] params)
throws java.lang.Exception
java.lang.Exceptionpublic static java.lang.Object callMethod(java.lang.Object instance,
java.lang.reflect.Method method,
java.lang.Object[] params)
throws java.lang.Exception
java.lang.Exceptionpublic static java.lang.Class[] getAllInterfaces(java.lang.Class cl)
public static boolean ejbEquals(ItemRemote first, ItemRemote second)
public static java.io.File getPathFromResource(java.lang.Class c,
java.lang.String resource)
File object representing given resource by using the classloader of given class.public static java.lang.String buildRelativePath(java.io.File fromDir,
java.io.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.public static boolean isTypeInitialized(java.lang.String typecode)
typecode - code of type to checktrue if presentpublic static java.lang.String getTenantID(HybrisDataSource ds)
DataSource.public static boolean isDBConnectionValid(java.lang.String dbUrl,
java.lang.String dbUser,
java.lang.String dbPassword,
java.lang.String driver,
java.lang.String fromJNDI)
public static boolean isDBConnectionValid(java.lang.String dbUrl,
java.lang.String dbUser,
java.lang.String dbPassword,
java.lang.String driver)
public static EnumerationValue resolveEncoding(java.lang.String encoding) throws java.io.UnsupportedEncodingException
encoding - String of the desired encoding instancejava.io.UnsupportedEncodingException - encoding can not be resolvedpublic static java.lang.String resolveEncoding(EnumerationValue enc)
enc - encoding to convertpublic static java.lang.String buildStackTraceCompact(java.lang.Throwable thr)
public static boolean arrayDeepEqualsReverse(java.lang.Object[] a1,
java.lang.Object[] a2)
public static void setJUnitTenant()
throws java.lang.IllegalStateException
java.lang.IllegalStateExceptionpublic static boolean isMasterTenantAsTestSystem()
public static void printAppInfo()
public static java.util.ResourceBundle getResourceBundle(java.lang.String baseName,
java.lang.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 java.util.ResourceBundle getResourceBundle(java.lang.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 java.util.ResourceBundle getResourceBundle(SessionContext ctx, java.lang.String baseName) throws java.util.MissingResourceException
ResourceBundle.getBundle(String) because the standard java api (of course) cannot obey the hybris
platform fallback language and tenant localization rules.java.util.MissingResourceExceptionpublic static java.util.ResourceBundle getResourceBundle(SessionContext ctx, java.lang.String baseName, java.lang.ClassLoader loader) throws java.util.MissingResourceException
ResourceBundle.getBundle(String)
because the standard java api (of course) cannot obey the hybris platform fallback language and tenant
localization rules.java.util.MissingResourceExceptionpublic static java.util.ResourceBundle getResourceBundle(Language lang, java.lang.String baseName) throws java.util.MissingResourceException
ResourceBundle.getBundle(String) because the standard java api (of course) cannot obey the hybris
platform fallback language and tenant localization rules.java.util.MissingResourceExceptionpublic static java.util.ResourceBundle getResourceBundle(Language lang, java.lang.String baseName, java.lang.ClassLoader loader) throws java.util.MissingResourceException
ResourceBundle.getBundle(String)
because the standard java api (of course) cannot obey the hybris platform fallback language and tenant
localization rules.java.util.MissingResourceExceptionpublic static java.util.ResourceBundle getResourceBundle(java.util.Locale[] path,
java.lang.String baseName,
java.lang.ClassLoader loader)
throws java.util.MissingResourceException
ResourceBundle.getBundle(String) because the standard java api (of course) cannot obey the hybris
platform fallback language and tenant localization rules.java.util.MissingResourceExceptionpublic static java.util.Locale getDefaultLocale()
Locale.getDefault()
because it cannot obey the current session context time zone and locale!SessionContext.getLocale(),
SessionContext.getTimeZone()@Deprecated public static java.util.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 java.util.Calendar getDefaultCalendar(java.util.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 java.text.SimpleDateFormat getSimpleDateFormat(java.lang.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 java.text.SimpleDateFormat getSimpleDateFormat(java.lang.String pattern,
java.util.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 java.text.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 java.text.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 java.text.DateFormat getDateTimeInstance(int dateStyle,
int timeStyle,
java.util.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 java.text.DecimalFormat getDecimalFormat(java.lang.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 java.text.DecimalFormat getDecimalFormat(java.lang.String pattern,
java.util.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 java.text.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 java.text.NumberFormat getIntegerInstance(java.util.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 java.text.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 java.text.NumberFormat getNumberInstance(java.util.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 java.text.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 java.text.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 java.text.NumberFormat getCurrencyInstance(Currency jaloCurrency, java.util.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 javax.xml.transform.TransformerFactory getTransformerFactory()
public static void failLicence(java.lang.String message,
Licence licence)
public static void failProperties(java.util.Map<java.lang.String,java.lang.String> missing)
public static java.lang.String getInfoAddress(HttpServletRequest req)
public static java.lang.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 java.lang.String createLink(SessionContext ctx, Item item, java.lang.String typeName, java.lang.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, java.lang.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 java.lang.String getAttributeFromLink(SessionContext ctx, java.lang.String itemLink, java.lang.String attributeName) throws JaloBusinessException, JaloInvalidParameterException, JaloItemNotFoundException
public static java.lang.String getReplacementTypeFromLink(SessionContext ctx, java.lang.String itemLink) throws JaloBusinessException, JaloInvalidParameterException, JaloItemNotFoundException
public static java.lang.String getLinkIdFromLink(SessionContext ctx, java.lang.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 java.lang.Object getIPAddressForLogOutput(java.lang.String address)
address - the address (hostname, ip, whatever you want)public static <T> T getCacheBoundVersion(T value)
public static java.util.Map<java.lang.String,java.lang.String> getMySQLSlaveStatus(HybrisDataSource dsi)
dsi - The HybrisDataSource must be a mysql DBpublic static final boolean equals(java.lang.Object o1,
java.lang.Object o2)
public static java.util.List<? extends Item> sortItemsByPK(java.util.Collection<? extends Item> items)
public static java.util.Map<java.lang.String,java.util.Properties> getTenantInfos()
Properties
object filled with tenant specific configuration.public static java.util.Properties loadPlatformProperties()
public static java.lang.String getTenantIdForContext(java.lang.String servletContextPath,
java.lang.String defaultTenant)
public static java.lang.String getWebroot(java.lang.String extensionsName)
public static java.lang.String getWebroot(java.lang.String extensionsName,
java.lang.String tenantID)
public static java.lang.String getExtensionForWebroot(java.lang.String webroot)
public static java.lang.String getExtensionNameFromRequest(HttpServletRequest request)
public static java.lang.String getExtensionForWebroot(java.lang.String webroot,
java.lang.String tenantID)
public static boolean getRelationOrderingOverride(java.lang.String cfgKey,
boolean defaultValue)
public static void clearRelationOrderingOverrideCache()
public static boolean getMarkModifiedOverride(java.lang.String cfgKey)
public static void clearMarkModifiedOverrideCache()
public static java.lang.String calculateLocalCorePlusEndPoint(java.lang.String extensionName,
java.lang.String tenantId)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentExceptionpublic static java.lang.String getContextFromRequestUri(java.lang.String uri)
Copyright © 2018 SAP SE. All Rights Reserved.