Package de.hybris.platform.util
Class Utilities
java.lang.Object
de.hybris.platform.util.Utilities
Helper class providing many utility methods.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumeration of different operating systems. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default encoding that is used while build an item linkstatic final StringSpecify the default encoding used for password encryption.static final StringThe sign that separates item link elementsstatic final StringThe sign that ends a reference to a subItem that is an attribute value of an itemstatic final StringThe sign that starts a reference to a subItem that is an attribute value of an itemstatic final StringPlaceholder constant for link id.static final StringThe sign that separates item the attribute qualifiers in the item link patternstatic final StringThe prefix that leads the type configuration for item linksstatic final StringThe protocoll prefix that specifies the URI as an item linkstatic final StringPlaceholder constant for crossreference replacement type.static final StringThe prefix that leads the type field in an item linkstatic final StringThe sign that separates item link element valuesstatic final Stringstatic final String -
Method Summary
Modifier and TypeMethodDescriptionstatic StringapplySpecialPropertiesToDatabaseUrl(String databaseUrl) static booleanarrayDeepEqualsReverse(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 StringbuildRelativePath(File fromDir, File toFileOrDir) Computes the relative file path from the "fromDir" to the "toFileOrDir" argument.static StringGets the stacktrace of a throwable as a String.static StringcalculateLocalCorePlusEndPoint(String extensionName, String tenantId) static ObjectcallMethod(Object instance, Method method, Object[] params) Calls method with given name on given object instance and returns the invocation result.static ObjectcallMethod(Object instance, String methodName, Class[] paramClasses, Object[] params) Calls method with given name on given object instance and returns the invocation result.static voidstatic voidstatic final ObjectcopyViaSerialization(Object originalObject) Create a copy of the given object by serializing it into memory and then deserializing it again.static final ObjectCreate a copy of the given object unless it is unmodifiable.protected static ObjectcopyViaSerializationUsingStandardJava(Object originalObject) static StringcreateLink(SessionContext ctx, Item item) Creates a link text that references to the given item.static StringcreateLink(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 booleanejbEquals(ItemRemote first, ItemRemote second) Checks whether two remote items are equal by calling an equal check on them including null checks.static final booleanstatic StringescapeHTML(String s) Escapes all occurrences of special chars with corresponding html escape sequence.static StringEscapes given string in the same way that escape function from JavaScript does but serverside.static voidfailLicence(String message, Licence licence) static voidfailProperties(Map<String, String> missing) static StringfilterOutHTMLTags(String input) Filters out all html tags in given string.static StringformatTime(long milliseconds) Formats given time to a readable string inf format: 0d 00h:00m:00s:000ms.static booleanfuzzyEquals(double a, double b) static Class[]Gets all interfaces of given class including interfaces implemented by superclasses.static StringgetAttributeFromLink(SessionContext ctx, String itemLink, String attributeName) static <T> TgetCacheBoundVersion(T value) static ConfigIntfReturns aConfigIntfimplementation as merged object of all extensions properties.static Stringstatic NumberFormatgetCurrencyInstance(Currency jaloCurrency) Deprecated, for removal: This API element is subject to removal in a future version.static NumberFormatgetCurrencyInstance(Currency jaloCurrency, Locale loc) Deprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createCurrencyFormat()instead , to pass a customCurrencyModel,LocaleuseSessionService.executeInLocalView(de.hybris.platform.servicelayer.session.SessionExecutionBody)as below :static DateFormatDeprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createDateTimeFormat(int, int)instead as :static DateFormatgetDateTimeInstance(int dateStyle, int timeStyle) Deprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createDateTimeFormat(int, int)insteadstatic DateFormatgetDateTimeInstance(int dateStyle, int timeStyle, Locale loc) Deprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createDateTimeFormat(int, int)instead, to provide aLocaleuseSessionService.executeInLocalView(de.hybris.platform.servicelayer.session.SessionExecutionBody)as below :static DecimalFormatgetDecimalFormat(String pattern) Deprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createNumberFormat()instead, to provide the patten use as below :static DecimalFormatgetDecimalFormat(String pattern, Locale loc) Deprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createNumberFormat()instead, to provide a pattern see :static CalendarDeprecated, for removal: This API element is subject to removal in a future version.since ages - use plainCalendarcreation :static CalendargetDefaultCalendar(Locale loc) Deprecated, for removal: This API element is subject to removal in a future version.since ages - use plainCalendarcreation :static LocaleProvides a session context obeying locale.static ClassgetExtensionClass(MasterTenant t, String name) Returns the extension manager class belonging to a given extension name.static StringgetExtensionForWebroot(String webroot) static StringgetExtensionForWebroot(String webroot, String tenantID) static ExtensionInfogetExtensionInfo(String name) Returns for the given extension name the correspondingExtensionInfoobject.static StringgetExtensionNameFromRequest(javax.servlet.http.HttpServletRequest request) Returns the names of all extensions which are active within the current system.static StringgetInfoAddress(javax.servlet.http.HttpServletRequest req) Internal use only.getInstalledExtensionNames(Tenant tenant) Returns the names of all installed extension.static Collection<String>Returns all installed user password encodings.Gets all installed webmodules.static final intParses given string and returns its integer equivalent.static NumberFormatDeprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createIntegerFormat()insteadstatic NumberFormatgetIntegerInstance(Locale loc) Deprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createIntegerFormat()instead , to pass a customLocaleuseSessionService.executeInLocalView(de.hybris.platform.servicelayer.session.SessionExecutionBody)as below :static ObjectgetIPAddressForLogOutput(String address) Replaces localhost from given address.static ItemgetItemFromLink(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 StringgetLinkIdFromLink(SessionContext ctx, String itemLink) Tryes to resolve the given item link and to retrieve the link id.static final LocaleDeprecated, for removal: This API element is subject to removal in a future version.since ages - use de.hybris.platform.servicelayer.i18n.CommonI18NService#getLocaleForLanguage(LanguageModel) insteadstatic booleangetMarkModifiedOverride(RelationType relation) static booleangetMarkModifiedOverride(String cfgKey) This method only works if the Data Source is a mysql db with a master and some slaves.static NumberFormatDeprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createNumberFormat()insteadstatic NumberFormatgetNumberInstance(Locale loc) Deprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createNumberFormat()instead , to pass a customLocaleuseSessionService.executeInLocalView(de.hybris.platform.servicelayer.session.SessionExecutionBody)as below :static final EnumgetOS()Reads the system property 'os.name' and returns this asUtilities.OSenumeration.static PasswordEncodergetPasswordEncoder(String encoding) Returns a specificPasswordEncoderfrom the user password encoders configured withinproject.propertiesparameterpassword.encodersstatic FilegetPathFromResource(Class c, String resource) Gets anFileobject representing given resource by using the classloader of given class.static NumberFormatDeprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createPercentFormat()insteadstatic PlatformConfigReturns all platform extensions info in their compile order - for bootstrap purposes.static FileReturns platform temp directory.static booleangetRelationOrderingOverride(String cfgKey, boolean defaultValue) static StringgetReplacementTypeFromLink(SessionContext ctx, String itemLink) Tryes to resolve the given item link and to retrieve the replacementTypestatic ResourceBundlegetResourceBundle(Language lang, String baseName) Provides access to the resource bundle loaded by class loader of this class.static ResourceBundlegetResourceBundle(Language lang, String baseName, ClassLoader loader) Provides access to the resource bundle.static ResourceBundlegetResourceBundle(SessionContext ctx, String baseName) Provides access to the resource bundle loaded by class loader of this class.static ResourceBundlegetResourceBundle(SessionContext ctx, String baseName, ClassLoader loader) Provides access to the resource bundle.static ResourceBundlegetResourceBundle(String baseName) Provides access to the resource bundle belonging to the current session language and loaded by class loader of this class.static ResourceBundlegetResourceBundle(String baseName, ClassLoader loader) Provides access to the resource bundle belonging to the current session language.static ResourceBundlegetResourceBundle(Locale[] path, String baseName, ClassLoader loader) Provides access to the resource bundle belonging.getRootCauseOfName(Throwable e, String name) Iterates over all causes of a given throwable and returns the first one matching the given name.getRootCauseOfType(Throwable e, Class<T> type) Iterates over all causes of a given throwable and returns the first one matching the given type.static SimpleDateFormatgetSimpleDateFormat(String pattern) Deprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createDateTimeFormat(int, int)instead asstatic SimpleDateFormatgetSimpleDateFormat(String pattern, Locale loc) Deprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createDateTimeFormat(int, int)instead, to provide aLocaleuseSessionService.executeInLocalView(de.hybris.platform.servicelayer.session.SessionExecutionBody)as below :static final StringgetStackTraceAsString(Throwable throwable) Gets full stacktrace of given exception as string.static StringGets the tenant id associated with givenDataSource.static StringgetTenantIdForContext(String servletContextPath, String defaultTenant) Retrives a tenant id basing on the static web root configuration for extension per tenant.static Map<String,Properties> Returns all tenants information loaded locally from platform/tenant_{tenantID}.properties or config/local_tenant_{tenantID}.properties files.static TransformerFactoryGets the TransformerFactory that is used in several areas (e.g.static StringgetWebroot(String extensionsName) Returns mapped webrootstatic StringgetWebroot(String extensionsName, String tenantID) static voidinvalidateCache(Cache cache, PK primaryKey) Internal helper routine to invalidate the cache for a particular item identified by its primary key.static voidinvalidateCache(PK primaryKey) Internal helper routine to invalidate the cache for a particular item identified by its primary key.static voidinvalidateCache(Transaction tx, Cache cache, PK primaryKey) Internal helper routine to invalidate the cache for a particular item identified by its primary key.static voidinvalidateCache(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 booleanisDBConnectionValid(String dbUrl, String dbUser, String dbPassword, String driver) Checks whether a DB connection can be established with given connection parameters.static booleanChecks whether a DB connection can be established with given connection parameters.static booleanstatic booleanChecks whether system is initialized using givenDataSourcefor accessing correct metainformations table.static booleanisTypeInitialized(String typecode) Checks if given type is known in type system which means update running system was performed.static final booleanisUnix()Checks whether the current operating system is unix.static final booleanChecks whether the current operating system is windows.static Propertiesstatic <T> com.google.common.collect.ImmutableSet<T>mergeToImmutableSet(Set<T> col1, Set<T> col2) Merge two sets to new immutable set.static final 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 voidLogs following platform properties: build number, current session id, max cache size and number of languages.static final StringReplaces in the given String all XML entities with XML encoded chars char replaced with & & < < > > " "static StringConverts an encoding given as enumeration value to the related code, checking the encoding for emptiness.static EnumerationValueresolveEncoding(String encoding) Resolves an given encoding string to an encoding instance of the platform if existent.static voidSets the 'junit' tenant if available or the master tenant, if this is a junit system otherwise it throws an RuntimException.sortItemsByPK(Collection<? extends Item> items) static StringtoHex(byte val) Converts given byte to its hex representation as String.static StringConverts given String to its hex representation as String.static StringtoHex1(int number) Converts given number to its hex representation as String.static final voidtouchForReplication(javax.servlet.http.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 final voidtryToCloseJDBC(Connection connection, Statement statement, ResultSet resultSet) Tries to close given SQL objects.static final voidtryToCloseJDBC(Connection connection, Statement statement, ResultSet resultSet, boolean ignoreErrors)
-
Field Details
-
DEFAULT_PASSWORD_ENCODING
Specify the default encoding used for password encryption. Same asSystemEJB.DEFAULT_ENCODING.- See Also:
-
DEFAULT_ITEMLINK_ENCODING
The default encoding that is used while build an item link- See Also:
-
ITEMLINK_PREFIX
The prefix that leads the type configuration for item links- See Also:
-
ITEMLINK_PROTOCOLL_SPECIFIER
The protocoll prefix that specifies the URI as an item link- See Also:
-
ITEMLINK_TYPE_PREFIX
The prefix that leads the type field in an item link- See Also:
-
ITEMLINK_ITEMATTRIBUTE_START
The sign that starts a reference to a subItem that is an attribute value of an item- See Also:
-
ITEMLINK_ITEMATTRIBUTE_END
The sign that ends a reference to a subItem that is an attribute value of an item- See Also:
-
ITEMLINK_ELEMENT_SEPARATOR
The sign that separates item link elements- See Also:
-
ITEMLINK_VALUE_SEPARATOR
The sign that separates item link element values- See Also:
-
ITEMLINK_PATTERN_ATTRIBUTE_SEPARATOR
The sign that separates item the attribute qualifiers in the item link pattern- See Also:
-
ITEMLINK_LINK_ID
Placeholder constant for link id.- See Also:
-
ITEMLINK_REPLACEMENT_TYPE
Placeholder constant for crossreference replacement type.- See Also:
-
STACKTRACE_START_MARKER
- See Also:
-
STACKTRACE_END_MARKER
- See Also:
-
-
Method Details
-
getOS
Reads the system property 'os.name' and returns this asUtilities.OSenumeration. When no name or an unknown name is setUtilities.OS.UNKNOWNis returned.- Returns:
- the current operating system
- See Also:
-
isUnix
public static final boolean isUnix()Checks whether the current operating system is unix.- Returns:
- true if the operating system is not
Utilities.OS.WINDOWSorUtilities.OS.OS2orUtilities.OS.NETWARE. - See Also:
-
isWindows
public static final boolean isWindows()Checks whether the current operating system is windows.- Returns:
- true if the operating system is
Utilities.OS.WINDOWS. - See Also:
-
getPlatformTempDir
Returns platform temp directory. -
copyViaSerialization
Create a copy of the given object by serializing it into memory and then deserializing it again. This method can be used to enforce RMI pass-by-value semantics.- Returns:
- a copy of the object given as parameter
-
copyViaSerializationUsingStandardJava
-
copyViaSerializationIfNecessary
Create a copy of the given object unless it is unmodifiable.- Parameters:
s- may be null; then null will be returned- See Also:
-
touchForReplication
public static final void touchForReplication(javax.servlet.http.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.- Parameters:
session- the HttpSession object- Since:
- 1.3
-
replaceXMLEntities
Replaces in the given String all XML entities with XML encoded charschar replaced with & & < < > > " " - Parameters:
s- the given XML string- Returns:
- a string
-
getInt
Parses given string and returns its integer equivalent. If the string is not parseable or isnullthe default value is returned.- Parameters:
intString- the string to be parseddefaultValue- the default value- Returns:
- integer equivalent of the given string or the default value if the string is not parseable or is
null
-
getLocale
Deprecated, for removal: This API element is subject to removal in a future version.since ages - use de.hybris.platform.servicelayer.i18n.CommonI18NService#getLocaleForLanguage(LanguageModel) insteadGets the java locale for given isocode- Parameters:
isoCode- code for which a locale is needed- Returns:
- corresponding locale
-
parseLocaleCodes
Splits this language's isocode into (at most) 3 parts and transforms it to String[3] object.
trailing characters are not ignored (PLA-10612). For instance for isocode="pl-PL-Slaskie-zabrze- returns Locale["pl", "PL", "Slaskie-zabrze-"].- Returns:
- String[3] object
-
getExtensionNames
Returns the names of all extensions which are active within the current system. This may be a subset of all installed extensions obtainable viagetInstalledExtensionNames(Tenant). -
getExtensionClass
Returns the extension manager class belonging to a given extension name. -
mergeToImmutableSet
public static <T> com.google.common.collect.ImmutableSet<T> mergeToImmutableSet(Set<T> col1, Set<T> col2) Merge two sets to new immutable set. -
getInstalledWebModules
Gets all installed webmodules.- Returns:
- Map with mapped extension names to corresponding webroot (e.g. storefoundation,/storefoundation)
-
getInstalledExtensionNames
Returns the names of all installed extension. These are configured once per platform deployment.- Parameters:
tenant-
-
getExtensionInfo
Returns for the given extension name the correspondingExtensionInfoobject.- Parameters:
name- the extension name- Returns:
nullif nut such ExtensionInfo object exists.
-
getPlatformExtensionNames
- Returns:
- a unmodifiable
Setwith all extension names which are used in the platform only.
-
getPlatformConfig
Returns all platform extensions info in their compile order - for bootstrap purposes.- Returns:
- the
PlatformConfig
-
getConfig
Returns aConfigIntfimplementation as merged object of all extensions properties.- Returns:
- the
PlatformConfig
-
getInstalledPasswordEncodings
Returns all installed user password encodings. These encodings have to be configured viaproject.propertiesparameterpassword.encoders. -
getPasswordEncoder
public static PasswordEncoder getPasswordEncoder(String encoding) throws JaloInvalidParameterException Returns a specificPasswordEncoderfrom the user password encoders configured withinproject.propertiesparameterpassword.encoders- Parameters:
encoding- the password encoding name e.g. 'MD5' or '*' for default encoding- Throws:
JaloInvalidParameterException- if the specified encoding does not exists
-
getStackTraceAsString
Gets full stacktrace of given exception as string.- Returns:
- full stacktrace of the given exception as string
-
getRootCauseOfType
Iterates over all causes of a given throwable and returns the first one matching the given type. -
getRootCauseOfName
Iterates over all causes of a given throwable and returns the first one matching the given name. -
escapeJavaScript
Escapes given string in the same way that escape function from JavaScript does but serverside.- Parameters:
s- string to escape- Returns:
- escaped string
-
escapeHTML
Escapes all occurrences of special chars with corresponding html escape sequence.- Parameters:
s- string to escape- Returns:
- escaped string
-
filterOutHTMLTags
Filters out all html tags in given string. -
formatTime
Formats given time to a readable string inf format: 0d 00h:00m:00s:000ms.- Parameters:
milliseconds- time to format- Returns:
- formatted string
-
toHex
Converts given String to its hex representation as String. -
toHex
Converts given byte to its hex representation as String. -
toHex1
Converts given number to its hex representation as String. -
tryToCloseJDBC
public static final void tryToCloseJDBC(Connection connection, Statement statement, ResultSet resultSet) Tries to close given SQL objects. Always all objects are tried to close even if an exception occurs at first object. The last exception will be thrown as RuntimeException. -
tryToCloseJDBC
public static final void tryToCloseJDBC(Connection connection, Statement statement, ResultSet resultSet, boolean ignoreErrors) -
callMethod
public static Object callMethod(Object instance, String methodName, Class[] paramClasses, Object[] params) throws Exception Calls method with given name on given object instance and returns the invocation result.- Throws:
Exception
-
callMethod
Calls method with given name on given object instance and returns the invocation result.- Throws:
Exception
-
getAllInterfaces
Gets all interfaces of given class including interfaces implemented by superclasses. -
ejbEquals
Checks whether two remote items are equal by calling an equal check on them including null checks. -
getPathFromResource
Gets anFileobject representing given resource by using the classloader of given class. -
buildRelativePath
Computes the relative file path from the "fromDir" to the "toFileOrDir" argument. See alsode.hybris.platform.test.UtilitiesTest#testBuildRelativePath().- Parameters:
fromDir- the dir to start fromtoFileOrDir- the dir or file to go to- Returns:
- the relative file path from the "fromDir" to the "toFileOrDir" argument
-
isSystemInitialized
Checks whether system is initialized using givenDataSourcefor accessing correct metainformations table. If check fails tenant will shutdown. -
isTypeInitialized
Checks if given type is known in type system which means update running system was performed.- Parameters:
typecode- code of type to check- Returns:
trueif present
-
getTenantID
Gets the tenant id associated with givenDataSource. -
isDBConnectionValid
public 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. If fromJNDI is not null, only a lookup for the JNDI resource will be done and checked whether the lookup is successfully. If fromJNDI is null, it is tried to establish a real db connection. -
isDBConnectionValid
public static boolean isDBConnectionValid(String dbUrl, String dbUser, String dbPassword, String driver) Checks whether a DB connection can be established with given connection parameters. -
resolveEncoding
Resolves an given encoding string to an encoding instance of the platform if existent.- Parameters:
encoding- String of the desired encoding instance- Returns:
- resolved encoding instance
- Throws:
UnsupportedEncodingException- encoding can not be resolved
-
resolveEncoding
Converts an encoding given as enumeration value to the related code, checking the encoding for emptiness.- Parameters:
enc- encoding to convert- Returns:
- code of given encoding or default encoding if encoding is null
-
buildStackTraceCompact
Gets the stacktrace of a throwable as a String. -
arrayDeepEqualsReverse
Like Arrays.deepEquals() but it compares the arrays from bottom to top which is faster for our cache (e.g. because 'hjmp' 'entity' are the first entries in most cases). -
setJUnitTenant
Sets the 'junit' tenant if available or the master tenant, if this is a junit system otherwise it throws an RuntimException.- Throws:
IllegalStateException
-
isMasterTenantAsTestSystem
public static boolean isMasterTenantAsTestSystem() -
printAppInfo
public static void printAppInfo()Logs following platform properties: build number, current session id, max cache size and number of languages. -
getResourceBundle
Provides access to the resource bundle belonging to the current session language. Always use it instead of e.g.ResourceBundle.getBundle(String)because the standard java api (of course) cannot obey the hybris platform fallback language and tenant localization rules. -
getResourceBundle
Provides access to the resource bundle belonging to the current session language and loaded by class loader of this class. Always use it instead of e.g.ResourceBundle.getBundle(String)because the standard java api (of course) cannot obey the hybris platform fallback language and tenant localization rules. -
getResourceBundle
public static ResourceBundle getResourceBundle(SessionContext ctx, String baseName) throws MissingResourceException Provides access to the resource bundle loaded by class loader of this class. Always use it instead of e.g.ResourceBundle.getBundle(String)because the standard java api (of course) cannot obey the hybris platform fallback language and tenant localization rules.- Throws:
MissingResourceException
-
getResourceBundle
public static ResourceBundle getResourceBundle(SessionContext ctx, String baseName, ClassLoader loader) throws MissingResourceException Provides access to the resource bundle. Always use it instead of e.g.ResourceBundle.getBundle(String)because the standard java api (of course) cannot obey the hybris platform fallback language and tenant localization rules.- Throws:
MissingResourceException
-
getResourceBundle
public static ResourceBundle getResourceBundle(Language lang, String baseName) throws MissingResourceException Provides access to the resource bundle loaded by class loader of this class. Always use it instead of e.g.ResourceBundle.getBundle(String)because the standard java api (of course) cannot obey the hybris platform fallback language and tenant localization rules.- Throws:
MissingResourceException
-
getResourceBundle
public static ResourceBundle getResourceBundle(Language lang, String baseName, ClassLoader loader) throws MissingResourceException Provides access to the resource bundle. Always use it instead of e.g.ResourceBundle.getBundle(String)because the standard java api (of course) cannot obey the hybris platform fallback language and tenant localization rules.- Throws:
MissingResourceException
-
getResourceBundle
public static ResourceBundle getResourceBundle(Locale[] path, String baseName, ClassLoader loader) throws MissingResourceException Provides access to the resource bundle belonging. Always use it instead of e.g.ResourceBundle.getBundle(String)because the standard java api (of course) cannot obey the hybris platform fallback language and tenant localization rules.- Throws:
MissingResourceException
-
getDefaultLocale
Provides a session context obeying locale. This should be always preferred toLocale.getDefault()because it 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.- Since:
- 3.0 M2
- See Also:
-
getDefaultCalendar
Deprecated, for removal: This API element is subject to removal in a future version.since ages - use plainCalendarcreation :Calendar calendarInstance = Calendar.getInstance(i18nService .getCurrentTimeZone(), i18nService.getCurrentLocale());Provides a session context obeying default calendar. This should be always preferred to allCalendar.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.- Since:
- 3.0 M2
- See Also:
-
getDefaultCalendar
Deprecated, for removal: This API element is subject to removal in a future version.since ages - use plainCalendarcreation :Calendar calendarInstance = Calendar.getInstance(i18nService .getCurrentTimeZone(), i18nService.getCurrentLocale());Provides a session context obeying default calendar. This should be always preferred to allCalendar.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.- Parameters:
loc- a specifiec locale instead of the current session context locale- Since:
- 3.0 M2
- See Also:
-
getSimpleDateFormat
@Deprecated(since="ages", forRemoval=true) public static SimpleDateFormat getSimpleDateFormat(String pattern) Deprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createDateTimeFormat(int, int)instead asfinal SimpleDateFormat format = (SimpleDateFormat)factory.createDateTimeFormat (DateFormat .DEFAULT, -1); format.applyPattern("yyyy-mm-dd");Provides a way of creating a simple date format which obeys the session context settings for time zone and locale. This should be preferred toSimpleDateFormat(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.- Parameters:
pattern- the pattern for the new date format- Since:
- 3.0 M2
- See Also:
-
getSimpleDateFormat
@Deprecated(since="ages", forRemoval=true) public static SimpleDateFormat getSimpleDateFormat(String pattern, Locale loc) Deprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createDateTimeFormat(int, int)instead, to provide aLocaleuseSessionService.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; } });Provides a way of creating a simple date format which obeys the session context settings for time zone and locale. This should be preferred toSimpleDateFormat(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.- Parameters:
pattern- the pattern for the new date formatloc- a specified locale for the new date format- Since:
- 3.0 M2
- See Also:
-
getDateTimeInstance
Deprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createDateTimeFormat(int, int)instead as :formatFactory.createDateTimeFormat(DateFormat.DEFAULT,DateFormat.DEFAULT);Provides a session context obeying date/time format. This should be always preferred to allDateFormat.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.- Since:
- 3.0 M2
- See Also:
-
getDateTimeInstance
@Deprecated(since="ages", forRemoval=true) public static DateFormat getDateTimeInstance(int dateStyle, int timeStyle) Deprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createDateTimeFormat(int, int)insteadProvides a session context obeying date/time format. This should be always preferred to allDateFormat.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.- Parameters:
dateStyle- date style , seeDateFormat.getDateTimeInstance(int, int, Locale)for available valuestimeStyle- time style , seeDateFormat.getDateTimeInstance(int, int, Locale)for available values- Since:
- 3.0 M2
- See Also:
-
getDateTimeInstance
@Deprecated(since="ages", forRemoval=true) public static DateFormat getDateTimeInstance(int dateStyle, int timeStyle, Locale loc) Deprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createDateTimeFormat(int, int)instead, to provide aLocaleuseSessionService.executeInLocalView(de.hybris.platform.servicelayer.session.SessionExecutionBody)as below :sessionService.executeInLocalView(new SessionExecutionBody() { public Object execute() { i18nService.setCurrentLocale(customLocale); return formatFactory.createDateTimeFormat(dateStyle ,timeStyle); } });Provides a session context obeying date/time format. This should be always preferred to allDateFormat.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.- Parameters:
dateStyle- date style , seeDateFormat.getDateTimeInstance(int, int, Locale)for available valuestimeStyle- time style , seeDateFormat.getDateTimeInstance(int, int, Locale)for available valuesloc- a specific locale instead of the session context locale- Since:
- 3.0 M2
- See Also:
-
getDecimalFormat
@Deprecated(since="ages", forRemoval=true) public static DecimalFormat getDecimalFormat(String pattern) Deprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createNumberFormat()instead, to provide the patten use as below :(DecimalFormat) factory.createNumberFormat(); df.applyPattern("some pattern");Provides a session context obeying decimal format for a given pattern. This should be always preferred to allDecimalFormat(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.- Parameters:
pattern- the decimal format pattern- Since:
- 3.0 M2
- See Also:
-
getDecimalFormat
@Deprecated(since="ages", forRemoval=true) public static DecimalFormat getDecimalFormat(String pattern, Locale loc) Deprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createNumberFormat()instead, to provide a pattern see :(DecimalFormat) factory.createNumberFormat(); df.applyPattern("some pattern");, to provide a custom
Localesee :sessionService.executeInLocalView(new SessionExecutionBody() { public Object execute() { i18nService.setCurrentLocale(customLocale); return formatFactory.createNumberFormat(); } });Provides a session context obeying decimal format for a given pattern. This should be always preferred to allDecimalFormat(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.- Parameters:
pattern- the decimal format patternloc- the specified locale for the new format- Since:
- 3.0 M2
- See Also:
-
getIntegerInstance
Deprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createIntegerFormat()insteadProvides a session context obeying default integer number format. This should always be preferred to allNumberFormat.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.- Since:
- 3.0 M2
- See Also:
-
getIntegerInstance
@Deprecated(since="ages", forRemoval=true) public static NumberFormat getIntegerInstance(Locale loc) Deprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createIntegerFormat()instead , to pass a customLocaleuseSessionService.executeInLocalView(de.hybris.platform.servicelayer.session.SessionExecutionBody)as below :sessionService.executeInLocalView(new SessionExecutionBody() { public Object execute() { i18nService.setCurrentLocale(customLocale); return formatFactory.createIntegerFormat(); } });Provides a session context obeying default integer number format. This should always be preferred to allNumberFormat.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.- Parameters:
loc- the specific locale for the new number format- Since:
- 3.0 M2
- See Also:
-
getNumberInstance
Deprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createNumberFormat()insteadProvides a session context obeying default number format. This should always be preferred to allNumberFormat.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.- Since:
- 3.0 M2
- See Also:
-
getNumberInstance
Deprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createNumberFormat()instead , to pass a customLocaleuseSessionService.executeInLocalView(de.hybris.platform.servicelayer.session.SessionExecutionBody)as below :sessionService.executeInLocalView(new SessionExecutionBody() { public Object execute() { i18nService.setCurrentLocale(customLocale); return formatFactory.createNumberFormat(); } });Provides a session context obeying default number format. This should always be preferred to allNumberFormat.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.- Parameters:
loc- the specific locale for the new number format- Since:
- 3.0 M2
- See Also:
-
getPercentInstance
Deprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createPercentFormat()insteadProvides a session context obeying default percent number format. This should always be preferred to allNumberFormat.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.- Since:
- 3.0 M2
- See Also:
-
getCurrencyInstance
@Deprecated(since="ages", forRemoval=true) public static NumberFormat getCurrencyInstance(Currency jaloCurrency) Deprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createCurrencyFormat()instead , to pass a customCurrencyModeluseSessionService.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(); } });Provides a session context obeying currency format for a given jalo currency. This should always be preferred to allNumberFormat.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.- Parameters:
jaloCurrency- a specified jalo currency to get the currency format for- Since:
- 3.0 M2
- See Also:
-
getCurrencyInstance
@Deprecated(since="ages", forRemoval=true) public static NumberFormat getCurrencyInstance(Currency jaloCurrency, Locale loc) Deprecated, for removal: This API element is subject to removal in a future version.since ages - useFormatFactory.createCurrencyFormat()instead , to pass a customCurrencyModel,LocaleuseSessionService.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(); } });Provides a session context obeying currency format for a given jalo currency. This should always be preferred to allNumberFormat.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.- Parameters:
jaloCurrency- a specified jalo currency to get the currency format for- Since:
- 3.0 M2
- See Also:
-
getTransformerFactory
Gets the TransformerFactory that is used in several areas (e.g. parsing and reordering of hmc.xml, FOP processing). This implementation first looks for a xalan-processor which is bundled with the jdk. If this class could not be loaded the jdk default provided by service locator will be used.- Returns:
- a TransformerFactory
-
failLicence
-
failProperties
-
getInfoAddress
Internal use only. -
createLink
Creates a link text that references to the given item.- Parameters:
ctx- The SessionContext that shall be used while retrieving attribute valuesitem- The item for which to create the link- Returns:
- The link text that references to the given item
- Throws:
JaloBusinessException- If an attribute could not be red from the item while building the Link
-
createLink
public static String createLink(SessionContext ctx, Item item, String typeName, String attributeList) throws JaloBusinessException 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>.- Parameters:
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!)- Returns:
- The link text that references to the given item
- Throws:
JaloBusinessException- If an attribute could not be red from the item while building the Link
-
getItemFromLink
public static Item getItemFromLink(SessionContext ctx, String itemLink) throws JaloBusinessException, JaloInvalidParameterException, JaloItemNotFoundException 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>- Parameters:
ctx- The SessionContext that shall be used while retrieving attribute valuesitemLink- The textual item link that references to an item- Returns:
- The item that is referenced by the given link
- Throws:
JaloBusinessException- 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 found
-
getAttributeFromLink
public static String getAttributeFromLink(SessionContext ctx, String itemLink, String attributeName) throws JaloBusinessException, JaloInvalidParameterException, JaloItemNotFoundException -
getReplacementTypeFromLink
public static String getReplacementTypeFromLink(SessionContext ctx, String itemLink) throws JaloBusinessException, JaloInvalidParameterException, JaloItemNotFoundException Tryes to resolve the given item link and to retrieve the replacementType -
getLinkIdFromLink
public static String getLinkIdFromLink(SessionContext ctx, String itemLink) throws JaloBusinessException, JaloInvalidParameterException, JaloItemNotFoundException Tryes to resolve the given item link and to retrieve the link id. -
invalidateCache
Internal helper routine to invalidate the cache for a particular item identified by its primary key.- Parameters:
primaryKey- The primary key of the item to be invalidated in the cache.
-
invalidateCache
Internal helper routine to invalidate the cache for a particular item identified by its primary key.- Parameters:
primaryKey- The primary key of the item to be invalidated in the cache.cache- the cache instance - must not be null
-
invalidateCache
Internal helper routine to invalidate the cache for a particular item identified by its primary key.- Parameters:
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 null
-
invalidateCache
public 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.- Parameters:
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- iftruethe invalidation will be send to all other cluster nodes immediately in addition to attaching it to the given transaction
-
getIPAddressForLogOutput
Replaces localhost from given address. Gets the same string as the input string with exception if this was "127.0.0.1" or "localhost" or "0:0:0:0:0:0:0:1", then a "127.0.0.1" is being returned- Parameters:
address- the address (hostname, ip, whatever you want)- Returns:
- the same string as the input string with exception if this was "127.0.0.1" or "localhost" or "0:0:0:0:0:0:0:1", then a "127.0.0.1" is being returned
-
getCacheBoundVersion
public static <T> T getCacheBoundVersion(T value) -
getMySQLSlaveStatus
This method only works if the Data Source is a mysql db with a master and some slaves. The method send the sql query "show slave status;" to a given slave and from the result table the columns "Slave_IO_State", "Slave_IO_Running", "Seconds_Behind_Master" - and if an error occures "Last_Error", "Last_Error", "Last_IO_Errno", "Last_IO_Errno" - is returned.- Parameters:
dsi- TheHybrisDataSourcemust be a mysql DB- Returns:
- a map with the columns for putting this into a table
-
equals
-
sortItemsByPK
-
getTenantInfos
Returns all tenants information loaded locally from platform/tenant_{tenantID}.properties or config/local_tenant_{tenantID}.properties files. The key contanis a tenant id , the value aPropertiesobject filled with tenant specific configuration. -
loadPlatformProperties
-
getTenantIdForContext
Retrives a tenant id basing on the static web root configuration for extension per tenant. -
getWebroot
Returns mapped webroot -
getWebroot
-
getExtensionForWebroot
-
getExtensionNameFromRequest
-
getExtensionForWebroot
-
getRelationOrderingOverride
-
clearRelationOrderingOverrideCache
public static void clearRelationOrderingOverrideCache() -
getMarkModifiedOverride
-
getMarkModifiedOverride
-
clearMarkModifiedOverrideCache
public static void clearMarkModifiedOverrideCache() -
calculateLocalCorePlusEndPoint
public static String calculateLocalCorePlusEndPoint(String extensionName, String tenantId) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
getContextFromRequestUri
-
applySpecialPropertiesToDatabaseUrl
-
fuzzyEquals
public static boolean fuzzyEquals(double a, double b)
-
FormatFactory.createCurrencyFormat()instead , to pass a customCurrencyModeluseSessionService.executeInLocalView(de.hybris.platform.servicelayer.session.SessionExecutionBody)as below :