Class Utilities


  • public class Utilities
    extends java.lang.Object
    Helper class providing many utility methods.
    • Field Detail

      • DEFAULT_ITEMLINK_ENCODING

        public static final java.lang.String DEFAULT_ITEMLINK_ENCODING
        The default encoding that is used while build an item link
        See Also:
        Constant Field Values
      • ITEMLINK_PREFIX

        public static final java.lang.String ITEMLINK_PREFIX
        The prefix that leads the type configuration for item links
        See Also:
        Constant Field Values
      • ITEMLINK_PROTOCOLL_SPECIFIER

        public static final java.lang.String ITEMLINK_PROTOCOLL_SPECIFIER
        The protocoll prefix that specifies the URI as an item link
        See Also:
        Constant Field Values
      • ITEMLINK_TYPE_PREFIX

        public static final java.lang.String ITEMLINK_TYPE_PREFIX
        The prefix that leads the type field in an item link
        See Also:
        Constant Field Values
      • ITEMLINK_ITEMATTRIBUTE_START

        public static final java.lang.String ITEMLINK_ITEMATTRIBUTE_START
        The sign that starts a reference to a subItem that is an attribute value of an item
        See Also:
        Constant Field Values
      • ITEMLINK_ITEMATTRIBUTE_END

        public static final java.lang.String ITEMLINK_ITEMATTRIBUTE_END
        The sign that ends a reference to a subItem that is an attribute value of an item
        See Also:
        Constant Field Values
      • ITEMLINK_ELEMENT_SEPARATOR

        public static final java.lang.String ITEMLINK_ELEMENT_SEPARATOR
        The sign that separates item link elements
        See Also:
        Constant Field Values
      • ITEMLINK_VALUE_SEPARATOR

        public static final java.lang.String ITEMLINK_VALUE_SEPARATOR
        The sign that separates item link element values
        See Also:
        Constant Field Values
      • ITEMLINK_PATTERN_ATTRIBUTE_SEPARATOR

        public static final java.lang.String ITEMLINK_PATTERN_ATTRIBUTE_SEPARATOR
        The sign that separates item the attribute qualifiers in the item link pattern
        See Also:
        Constant Field Values
      • ITEMLINK_LINK_ID

        public static final java.lang.String ITEMLINK_LINK_ID
        Placeholder constant for link id.
        See Also:
        Constant Field Values
      • ITEMLINK_REPLACEMENT_TYPE

        public static final java.lang.String ITEMLINK_REPLACEMENT_TYPE
        Placeholder constant for crossreference replacement type.
        See Also:
        Constant Field Values
      • STACKTRACE_START_MARKER

        public static final java.lang.String STACKTRACE_START_MARKER
        See Also:
        Constant Field Values
      • STACKTRACE_END_MARKER

        public static final java.lang.String STACKTRACE_END_MARKER
        See Also:
        Constant Field Values
    • Method Detail

      • getOS

        public static final java.lang.Enum getOS()
        Reads the system property 'os.name' and returns this as Utilities.OS enumeration. When no name or an unknown name is set Utilities.OS.UNKNOWN is returned.
        Returns:
        the current operating system
        See Also:
        Utilities.OS
      • 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:
        getOS()
      • getPlatformTempDir

        public static java.io.File getPlatformTempDir()
        Returns platform temp directory.
      • copyViaSerialization

        public static final 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. This method can be used to enforce RMI pass-by-value semantics.
        Returns:
        a copy of the object given as parameter
      • copyViaSerializationUsingStandardJava

        protected static java.lang.Object copyViaSerializationUsingStandardJava​(java.lang.Object originalObject)
      • copyViaSerializationIfNecessary

        public static final java.lang.Object copyViaSerializationIfNecessary​(java.lang.Object s)
        Create a copy of the given object unless it is unmodifiable.
        Parameters:
        s - may be null; then null will be returned
        See Also:
        copyViaSerialization(Object)
      • 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

        public static final java.lang.String replaceXMLEntities​(java.lang.String s)
        Replaces in the given String all XML entities with XML encoded chars
        char replaced with
        & &
        < &lt;
        > &gt;
        " &quot;
        Parameters:
        s - the given XML string
        Returns:
        a string
      • getInt

        public static final int getInt​(java.lang.String intString,
                                       int defaultValue)
        Parses given string and returns its integer equivalent. If the string is not parseable or is null the default value is returned.
        Parameters:
        intString - the string to be parsed
        defaultValue - 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
        public static final java.util.Locale getLocale​(java.lang.String isoCode)
        Deprecated.
        since ages - use de.hybris.platform.servicelayer.i18n.CommonI18NService#getLocaleForLanguage(LanguageModel) instead
        Gets the java locale for given isocode
        Parameters:
        isoCode - code for which a locale is needed
        Returns:
        corresponding locale
      • parseLocaleCodes

        public static final 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). For instance for isocode="pl-PL-Slaskie-zabrze- returns Locale["pl", "PL", "Slaskie-zabrze-"].
        Returns:
        String[3] object
      • getExtensionNames

        public static java.util.List<java.lang.String> getExtensionNames()
        Returns the names of all extensions which are active within the current system.

        This may be a subset of all installed extensions obtainable via getInstalledExtensionNames(Tenant).

      • getExtensionClass

        public static java.lang.Class getExtensionClass​(MasterTenant t,
                                                        java.lang.String name)
        Returns the extension manager class belonging to a given extension name.
      • mergeToImmutableSet

        public static <T> com.google.common.collect.ImmutableSet<T> mergeToImmutableSet​(java.util.Set<T> col1,
                                                                                        java.util.Set<T> col2)
        Merge two sets to new immutable set.
      • getInstalledWebModules

        public static java.util.Map<java.lang.String,​java.lang.String> getInstalledWebModules()
        Gets all installed webmodules.
        Returns:
        Map with mapped extension names to corresponding webroot (e.g. storefoundation,/storefoundation)
      • getInstalledExtensionNames

        public static java.util.List<java.lang.String> getInstalledExtensionNames​(Tenant tenant)
        Returns the names of all installed extension. These are configured once per platform deployment.
        Parameters:
        tenant -
      • getExtensionInfo

        public static ExtensionInfo getExtensionInfo​(java.lang.String name)
        Returns for the given extension name the corresponding ExtensionInfo object.
        Parameters:
        name - the extension name
        Returns:
        null if nut such ExtensionInfo object exists.
      • getPlatformExtensionNames

        public static java.util.Set<java.lang.String> getPlatformExtensionNames()
        Returns:
        a unmodifiable Set with all extension names which are used in the platform only.
      • getPlatformConfig

        public static PlatformConfig getPlatformConfig()
        Returns all platform extensions info in their compile order - for bootstrap purposes.
        Returns:
        the PlatformConfig
      • getPasswordEncoder

        public static PasswordEncoder getPasswordEncoder​(java.lang.String encoding)
                                                  throws JaloInvalidParameterException
        Returns a specific PasswordEncoder from the user password encoders configured within project.properties parameter password.encoders
        Parameters:
        encoding - the password encoding name e.g. 'MD5' or '*' for default encoding
        Throws:
        JaloInvalidParameterException - if the specified encoding does not exists
      • getStackTraceAsString

        public static final java.lang.String getStackTraceAsString​(java.lang.Throwable throwable)
        Gets full stacktrace of given exception as string.
        Returns:
        full stacktrace of the given exception as string
      • getRootCauseOfType

        public static <T extends java.lang.Throwable> 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.
      • getRootCauseOfName

        public static <T extends java.lang.Throwable> 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.
      • escapeJavaScript

        public static java.lang.String escapeJavaScript​(java.lang.String s)
        Escapes given string in the same way that escape function from JavaScript does but serverside.
        Parameters:
        s - string to escape
        Returns:
        escaped string
      • escapeHTML

        public static java.lang.String escapeHTML​(java.lang.String s)
        Escapes all occurrences of special chars with corresponding html escape sequence.
        Parameters:
        s - string to escape
        Returns:
        escaped string
      • filterOutHTMLTags

        public static java.lang.String filterOutHTMLTags​(java.lang.String input)
        Filters out all html tags in given string.
      • formatTime

        public static java.lang.String formatTime​(long milliseconds)
        Formats given time to a readable string inf format: 0d 00h:00m:00s:000ms.
        Parameters:
        milliseconds - time to format
        Returns:
        formatted string
      • toHex

        public static java.lang.String toHex​(java.lang.String val)
        Converts given String to its hex representation as String.
      • toHex

        public static java.lang.String toHex​(byte val)
        Converts given byte to its hex representation as String.
      • toHex1

        public static java.lang.String toHex1​(int number)
        Converts given number to its hex representation as String.
      • tryToCloseJDBC

        public static final void tryToCloseJDBC​(java.sql.Connection connection,
                                                java.sql.Statement statement,
                                                java.sql.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​(java.sql.Connection connection,
                                                java.sql.Statement statement,
                                                java.sql.ResultSet resultSet,
                                                boolean ignoreErrors)
      • callMethod

        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
        Calls method with given name on given object instance and returns the invocation result.
        Throws:
        java.lang.Exception
      • callMethod

        public static java.lang.Object callMethod​(java.lang.Object instance,
                                                  java.lang.reflect.Method method,
                                                  java.lang.Object[] params)
                                           throws java.lang.Exception
        Calls method with given name on given object instance and returns the invocation result.
        Throws:
        java.lang.Exception
      • getAllInterfaces

        public static java.lang.Class[] getAllInterfaces​(java.lang.Class cl)
        Gets all interfaces of given class including interfaces implemented by superclasses.
      • ejbEquals

        public static boolean ejbEquals​(ItemRemote first,
                                        ItemRemote second)
        Checks whether two remote items are equal by calling an equal check on them including null checks.
      • getPathFromResource

        public 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.
      • buildRelativePath

        public 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. See also de.hybris.platform.test.UtilitiesTest#testBuildRelativePath().
        Parameters:
        fromDir - the dir to start from
        toFileOrDir - the dir or file to go to
        Returns:
        the relative file path from the "fromDir" to the "toFileOrDir" argument
      • isSystemInitialized

        public static boolean isSystemInitialized​(HybrisDataSource ds)
        Checks whether system is initialized using given DataSource for accessing correct metainformations table. If check fails tenant will shutdown.
      • isTypeInitialized

        public static boolean isTypeInitialized​(java.lang.String typecode)
        Checks if given type is known in type system which means update running system was performed.
        Parameters:
        typecode - code of type to check
        Returns:
        true if present
      • getTenantID

        public static java.lang.String getTenantID​(HybrisDataSource ds)
        Gets the tenant id associated with given DataSource.
      • isDBConnectionValid

        public 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. 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​(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.
      • resolveEncoding

        public static EnumerationValue resolveEncoding​(java.lang.String encoding)
                                                throws java.io.UnsupportedEncodingException
        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:
        java.io.UnsupportedEncodingException - encoding can not be resolved
      • resolveEncoding

        public static java.lang.String resolveEncoding​(EnumerationValue enc)
        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

        public static java.lang.String buildStackTraceCompact​(java.lang.Throwable thr)
        Gets the stacktrace of a throwable as a String.
      • arrayDeepEqualsReverse

        public 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. because 'hjmp' 'entity' are the first entries in most cases).
      • setJUnitTenant

        public static void setJUnitTenant()
                                   throws java.lang.IllegalStateException
        Sets the 'junit' tenant if available or the master tenant, if this is a junit system otherwise it throws an RuntimException.
        Throws:
        java.lang.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

        public 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. 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 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. 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 java.util.ResourceBundle getResourceBundle​(SessionContext ctx,
                                                                 java.lang.String baseName)
                                                          throws java.util.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:
        java.util.MissingResourceException
      • getResourceBundle

        public static java.util.ResourceBundle getResourceBundle​(SessionContext ctx,
                                                                 java.lang.String baseName,
                                                                 java.lang.ClassLoader loader)
                                                          throws java.util.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:
        java.util.MissingResourceException
      • getResourceBundle

        public static java.util.ResourceBundle getResourceBundle​(Language lang,
                                                                 java.lang.String baseName)
                                                          throws java.util.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:
        java.util.MissingResourceException
      • getResourceBundle

        public static java.util.ResourceBundle getResourceBundle​(Language lang,
                                                                 java.lang.String baseName,
                                                                 java.lang.ClassLoader loader)
                                                          throws java.util.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:
        java.util.MissingResourceException
      • getResourceBundle

        public static java.util.ResourceBundle getResourceBundle​(java.util.Locale[] path,
                                                                 java.lang.String baseName,
                                                                 java.lang.ClassLoader loader)
                                                          throws java.util.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:
        java.util.MissingResourceException
      • getDefaultLocale

        public static java.util.Locale getDefaultLocale()
        Provides a session context obeying locale. This should be always preferred to Locale.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:
        SessionContext.getLocale(), SessionContext.getTimeZone()
      • getDefaultCalendar

        @Deprecated
        public static java.util.Calendar getDefaultCalendar()
        Deprecated.
        since ages - use plainCalendar creation :

                                             
                                                        Calendar calendarInstance = Calendar.getInstance(i18nService
                                                        .getCurrentTimeZone(),
                                                        i18nService.getCurrentLocale());
                                             
         
        Provides a session context obeying default calendar. This should be always preferred to all 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.
        Since:
        3.0 M2
        See Also:
        SessionContext.getLocale(), SessionContext.getTimeZone()
      • getDefaultCalendar

        @Deprecated
        public static java.util.Calendar getDefaultCalendar​(java.util.Locale loc)
        Deprecated.
        since ages - use plainCalendar creation :

                                             
                                                        Calendar calendarInstance = Calendar.getInstance(i18nService
                                                        .getCurrentTimeZone(),
                                                        i18nService.getCurrentLocale());
                                             
         
        Provides a session context obeying default calendar. This should be always preferred to all 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.
        Parameters:
        loc - a specifiec locale instead of the current session context locale
        Since:
        3.0 M2
        See Also:
        SessionContext.getLocale(), SessionContext.getTimeZone()
      • getSimpleDateFormat

        @Deprecated
        public static java.text.SimpleDateFormat getSimpleDateFormat​(java.lang.String pattern)
        Deprecated.
        since ages - useFormatFactory.createDateTimeFormat(int, int) instead as

                                             
                                                final 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 to 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.
        Parameters:
        pattern - the pattern for the new date format
        Since:
        3.0 M2
        See Also:
        SessionContext.getLocale(), SessionContext.getTimeZone()
      • getSimpleDateFormat

        @Deprecated
        public static java.text.SimpleDateFormat getSimpleDateFormat​(java.lang.String pattern,
                                                                     java.util.Locale loc)
        Deprecated.
        since ages - useFormatFactory.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;
                                                        }
                                               });
                                             
         
        Provides a way of creating a simple date format which obeys the session context settings for time zone and locale. This should be preferred to 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.
        Parameters:
        pattern - the pattern for the new date format
        loc - a specified locale for the new date format
        Since:
        3.0 M2
        See Also:
        SessionContext.getLocale(), SessionContext.getTimeZone()
      • getDateTimeInstance

        @Deprecated
        public static java.text.DateFormat getDateTimeInstance()
        Deprecated.
        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 all 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.
        Since:
        3.0 M2
        See Also:
        SessionContext.getLocale(), SessionContext.getTimeZone()
      • getDateTimeInstance

        @Deprecated
        public static java.text.DateFormat getDateTimeInstance​(int dateStyle,
                                                               int timeStyle)
        Deprecated.
        Provides a session context obeying date/time format. This should be always preferred to all 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.
        Parameters:
        dateStyle - date style , see DateFormat.getDateTimeInstance(int, int, Locale) for available values
        timeStyle - time style , see DateFormat.getDateTimeInstance(int, int, Locale) for available values
        Since:
        3.0 M2
        See Also:
        SessionContext.getLocale(), SessionContext.getTimeZone()
      • getDateTimeInstance

        @Deprecated
        public static java.text.DateFormat getDateTimeInstance​(int dateStyle,
                                                               int timeStyle,
                                                               java.util.Locale loc)
        Deprecated.
        since ages - useFormatFactory.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);
                                                        }
                                               });
                                             
         
        Provides a session context obeying date/time format. This should be always preferred to all 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.
        Parameters:
        dateStyle - date style , see DateFormat.getDateTimeInstance(int, int, Locale) for available values
        timeStyle - time style , see DateFormat.getDateTimeInstance(int, int, Locale) for available values
        loc - a specific locale instead of the session context locale
        Since:
        3.0 M2
        See Also:
        SessionContext.getLocale(), SessionContext.getTimeZone()
      • getDecimalFormat

        @Deprecated
        public static java.text.DecimalFormat getDecimalFormat​(java.lang.String pattern)
        Deprecated.
        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 all 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.
        Parameters:
        pattern - the decimal format pattern
        Since:
        3.0 M2
        See Also:
        getNumberInstance(), getIntegerInstance(), SessionContext.getLocale(), SessionContext.getTimeZone()
      • getDecimalFormat

        @Deprecated
        public static java.text.DecimalFormat getDecimalFormat​(java.lang.String pattern,
                                                               java.util.Locale loc)
        Deprecated.
        since ages - useFormatFactory.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();
                                                        }
                                               });
                                             
         
        Provides a session context obeying decimal format for a given pattern. This should be always preferred to all 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.
        Parameters:
        pattern - the decimal format pattern
        loc - the specified locale for the new format
        Since:
        3.0 M2
        See Also:
        getNumberInstance(), getIntegerInstance(), SessionContext.getLocale(), SessionContext.getTimeZone()
      • getIntegerInstance

        @Deprecated
        public static java.text.NumberFormat getIntegerInstance()
        Deprecated.
        since ages - useFormatFactory.createIntegerFormat() instead
        Provides a session context obeying default integer number format. This should always be preferred to all 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.
        Since:
        3.0 M2
        See Also:
        SessionContext.getLocale()
      • getIntegerInstance

        @Deprecated
        public static java.text.NumberFormat getIntegerInstance​(java.util.Locale loc)
        Deprecated.
        since ages - useFormatFactory.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();
                                                        }
                                               });
                                             
         
        Provides a session context obeying default integer number format. This should always be preferred to all 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.
        Parameters:
        loc - the specific locale for the new number format
        Since:
        3.0 M2
        See Also:
        SessionContext.getLocale()
      • getNumberInstance

        @Deprecated
        public static java.text.NumberFormat getNumberInstance()
        Deprecated.
        since ages - useFormatFactory.createNumberFormat() instead
        Provides a session context obeying default number format. This should always be preferred to all 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.
        Since:
        3.0 M2
        See Also:
        SessionContext.getLocale()
      • getNumberInstance

        @Deprecated
        public static java.text.NumberFormat getNumberInstance​(java.util.Locale loc)
        Deprecated.
        since ages - useFormatFactory.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();
                                                        }
                                               });
                                             
         
        Provides a session context obeying default number format. This should always be preferred to all 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.
        Parameters:
        loc - the specific locale for the new number format
        Since:
        3.0 M2
        See Also:
        SessionContext.getLocale()
      • getPercentInstance

        @Deprecated
        public static java.text.NumberFormat getPercentInstance()
        Deprecated.
        since ages - useFormatFactory.createPercentFormat() instead
        Provides a session context obeying default percent number format. This should always be preferred to all NumberFormat.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:
        SessionContext.getLocale()
      • getCurrencyInstance

        @Deprecated
        public static java.text.NumberFormat getCurrencyInstance​(Currency jaloCurrency)
        Deprecated.
        since ages - useFormatFactory.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();
                                                        }
                                               });
                                             
         
        Provides a session context obeying currency format for a given jalo currency. This should always be preferred to all 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.
        Parameters:
        jaloCurrency - a specified jalo currency to get the currency format for
        Since:
        3.0 M2
        See Also:
        SessionContext.getLocale()
      • getCurrencyInstance

        @Deprecated
        public static java.text.NumberFormat getCurrencyInstance​(Currency jaloCurrency,
                                                                 java.util.Locale loc)
        Deprecated.
        since ages - useFormatFactory.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();
                                                        }
                                               });
         
        Provides a session context obeying currency format for a given jalo currency. This should always be preferred to all 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.
        Parameters:
        jaloCurrency - a specified jalo currency to get the currency format for
        Since:
        3.0 M2
        See Also:
        SessionContext.getLocale()
      • getTransformerFactory

        public static javax.xml.transform.TransformerFactory 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 (xalan-2.7.0) which is bundled with the platform (org.apache.xalan.processor.TransformerFactoryImpl). if this class could not be loaded the jdk default is being used.
        Returns:
        a TransformerFactory
      • failLicence

        public static void failLicence​(java.lang.String message,
                                       Licence licence)
      • failProperties

        public static void failProperties​(java.util.Map<java.lang.String,​java.lang.String> missing)
      • getInfoAddress

        public static java.lang.String getInfoAddress​(javax.servlet.http.HttpServletRequest req)
        Internal use only.
      • createLink

        public static java.lang.String createLink​(SessionContext ctx,
                                                  Item item)
                                           throws JaloBusinessException
        Creates a link text that references to the given item.
        Parameters:
        ctx - The SessionContext that shall be used while retrieving attribute values
        item - 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 java.lang.String createLink​(SessionContext ctx,
                                                  Item item,
                                                  java.lang.String typeName,
                                                  java.lang.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 values
        item - The item for which to create the link
        typeName - The ComposedType's name that that shall be used in the link
        attributeList - 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,
                                           java.lang.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 values
        itemLink - 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 link
        JaloInvalidParameterException - If there is no or more then one item found
        JaloItemNotFoundException - If the referenced item could not be found
      • invalidateCache

        public static void invalidateCache​(PK primaryKey)
        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

        public static void invalidateCache​(Cache cache,
                                           PK primaryKey)
        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

        public 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.
        Parameters:
        primaryKey - The primary key of the item to be invalidated in the cache.
        cache - the cache instance - must not be null
        tx - 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 null
        tx - the transaction to attach the invalidation to - must not be null
        sendImmediately - if true the invalidation will be send to all other cluster nodes immediately in addition to attaching it to the given transaction
      • getIPAddressForLogOutput

        public static java.lang.Object getIPAddressForLogOutput​(java.lang.String address)
        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

        public 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. 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 - The HybrisDataSource must be a mysql DB
        Returns:
        a map with the columns for putting this into a table
      • equals

        public static final boolean equals​(java.lang.Object o1,
                                           java.lang.Object o2)
      • sortItemsByPK

        public static java.util.List<? extends Item> sortItemsByPK​(java.util.Collection<? extends Item> items)
      • getTenantInfos

        public 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. The key contanis a tenant id , the value a Properties object filled with tenant specific configuration.
      • loadPlatformProperties

        public static java.util.Properties loadPlatformProperties()
      • getTenantIdForContext

        public 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.
      • getWebroot

        public static java.lang.String getWebroot​(java.lang.String extensionsName)
        Returns mapped webroot
      • getWebroot

        public static java.lang.String getWebroot​(java.lang.String extensionsName,
                                                  java.lang.String tenantID)
      • getExtensionForWebroot

        public static java.lang.String getExtensionForWebroot​(java.lang.String webroot)
      • getExtensionNameFromRequest

        public static java.lang.String getExtensionNameFromRequest​(javax.servlet.http.HttpServletRequest request)
      • getExtensionForWebroot

        public static java.lang.String getExtensionForWebroot​(java.lang.String webroot,
                                                              java.lang.String tenantID)
      • getRelationOrderingOverride

        public static boolean getRelationOrderingOverride​(java.lang.String cfgKey,
                                                          boolean defaultValue)
      • clearRelationOrderingOverrideCache

        public static void clearRelationOrderingOverrideCache()
      • getMarkModifiedOverride

        public static boolean getMarkModifiedOverride​(java.lang.String cfgKey)
      • clearMarkModifiedOverrideCache

        public static void clearMarkModifiedOverrideCache()
      • calculateLocalCorePlusEndPoint

        public static java.lang.String calculateLocalCorePlusEndPoint​(java.lang.String extensionName,
                                                                      java.lang.String tenantId)
                                                               throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • getContextFromRequestUri

        public static java.lang.String getContextFromRequestUri​(java.lang.String uri)
      • applySpecialPropertiesToDatabaseUrl

        public static java.lang.String applySpecialPropertiesToDatabaseUrl​(java.lang.String databaseUrl)