Class Utilities

java.lang.Object
de.hybris.platform.util.Utilities

public class Utilities extends Object
Helper class providing many utility methods.
  • Field Details

    • DEFAULT_PASSWORD_ENCODING

      public static final String DEFAULT_PASSWORD_ENCODING
      Specify the default encoding used for password encryption. Same as SystemEJB.DEFAULT_ENCODING.
      See Also:
    • STACKTRACE_START_MARKER

      public static final String STACKTRACE_START_MARKER
      See Also:
    • STACKTRACE_END_MARKER

      public static final String STACKTRACE_END_MARKER
      See Also:
  • Method Details

    • getOS

      public static final 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:
    • isUnix

      public static final boolean isUnix()
      Checks whether the current operating system is unix.
      Returns:
      true if the operating system is not Utilities.OS.WINDOWS or Utilities.OS.OS2 or Utilities.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

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

      public static final Object copyViaSerialization(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 Object copyViaSerializationUsingStandardJava(Object originalObject)
    • copyViaSerializationIfNecessary

      public static final Object copyViaSerializationIfNecessary(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:
    • 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 String replaceXMLEntities(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(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(since="ages", forRemoval=true) public static final Locale getLocale(String isoCode)
      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) instead
      Gets the java locale for given isocode
      Parameters:
      isoCode - code for which a locale is needed
      Returns:
      corresponding locale
    • parseLocaleCodes

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

      public static List<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 Class getExtensionClass(MasterTenant t, String name)
      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

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

      public static List<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(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 Set<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
    • getConfig

      public static ConfigIntf getConfig()
      Returns a ConfigIntf implementation as merged object of all extensions properties.
      Returns:
      the PlatformConfig
    • getInstalledPasswordEncodings

      public static Collection<String> getInstalledPasswordEncodings()
      Returns all installed user password encodings. These encodings have to be configured via project.properties parameter password.encoders.
      See Also:
    • getPasswordEncoder

      public static PasswordEncoder getPasswordEncoder(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 String getStackTraceAsString(Throwable throwable)
      Gets full stacktrace of given exception as string.
      Returns:
      full stacktrace of the given exception as string
    • getRootCauseOfType

      public static <T extends Throwable> Throwable getRootCauseOfType(Throwable e, 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 Throwable> Throwable getRootCauseOfName(Throwable e, String name)
      Iterates over all causes of a given throwable and returns the first one matching the given name.
    • escapeJavaScript

      public static String escapeJavaScript(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 String escapeHTML(String s)
      Escapes all occurrences of special chars with corresponding html escape sequence.
      Parameters:
      s - string to escape
      Returns:
      escaped string
    • filterOutHTMLTags

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

      public static 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 String toHex(String val)
      Converts given String to its hex representation as String.
    • toHex

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

      public static String toHex1(int number)
      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

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

      public static Class[] getAllInterfaces(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 File getPathFromResource(Class c, String resource)
      Gets an File object representing given resource by using the classloader of given class.
    • buildRelativePath

      public static String buildRelativePath(File fromDir, 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(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 String getTenantID(HybrisDataSource ds)
      Gets the tenant id associated with given DataSource.
    • 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

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

      public static 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 String buildStackTraceCompact(Throwable thr)
      Gets the stacktrace of a throwable as a String.
    • arrayDeepEqualsReverse

      public static boolean arrayDeepEqualsReverse(Object[] a1, Object[] a2)
      Like Arrays.deepEquals() but it compares the arrays from bottom to top which is faster for our cache (e.g. because 'hjmp' 'entity' are the first entries in most cases).
    • setJUnitTenant

      public static void setJUnitTenant() throws IllegalStateException
      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

      public static ResourceBundle getResourceBundle(String baseName, 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 ResourceBundle getResourceBundle(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 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

      public static 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:
    • getDefaultCalendar

      @Deprecated(since="ages", forRemoval=true) public static Calendar getDefaultCalendar()
      Deprecated, for removal: This API element is subject to removal in a future version.
      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:
    • getDefaultCalendar

      @Deprecated(since="ages", forRemoval=true) public static Calendar getDefaultCalendar(Locale loc)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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:
    • 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 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:
    • 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 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:
    • getDateTimeInstance

      @Deprecated(since="ages", forRemoval=true) public static DateFormat 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 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:
    • 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.
      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:
    • 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 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:
    • 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 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:
    • 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 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:
    • getIntegerInstance

      @Deprecated(since="ages", forRemoval=true) public static NumberFormat getIntegerInstance()
      Deprecated, for removal: This API element is subject to removal in a future version.
      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:
    • 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 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:
    • getNumberInstance

      @Deprecated(since="ages", forRemoval=true) public static NumberFormat getNumberInstance()
      Deprecated, for removal: This API element is subject to removal in a future version.
      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:
    • getNumberInstance

      @Deprecated(since="ages", forRemoval=true) public static NumberFormat getNumberInstance(Locale loc)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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:
    • getPercentInstance

      @Deprecated(since="ages", forRemoval=true) public static NumberFormat getPercentInstance()
      Deprecated, for removal: This API element is subject to removal in a future version.
      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:
    • 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 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:
    • 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 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:
    • getTransformerFactory

      public static 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 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

      public static void failLicence(String message, Licence licence)
    • failProperties

      public static void failProperties(Map<String,String> missing)
    • getInfoAddress

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

      public static 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 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 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

      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
    • getAttributeFromLink

      public static String getAttributeFromLink(SessionContext ctx, String itemLink, String attributeName) throws JaloBusinessException, JaloInvalidParameterException, JaloItemNotFoundException
      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
      Throws:
      JaloBusinessException
      JaloInvalidParameterException
      JaloItemNotFoundException
    • getLinkIdFromLink

      Tryes to resolve the given item link and to retrieve the link id.
      Throws:
      JaloBusinessException
      JaloInvalidParameterException
      JaloItemNotFoundException
    • 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 Object getIPAddressForLogOutput(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 Map<String,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(Object o1, Object o2)
    • sortItemsByPK

      public static List<? extends Item> sortItemsByPK(Collection<? extends Item> items)
    • getTenantInfos

      public static Map<String,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 Properties loadPlatformProperties()
    • getTenantIdForContext

      public static String getTenantIdForContext(String servletContextPath, String defaultTenant)
      Retrives a tenant id basing on the static web root configuration for extension per tenant.
    • getWebroot

      public static String getWebroot(String extensionsName)
      Returns mapped webroot
    • getWebroot

      public static String getWebroot(String extensionsName, String tenantID)
    • getExtensionForWebroot

      public static String getExtensionForWebroot(String webroot)
    • getExtensionNameFromRequest

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

      public static String getExtensionForWebroot(String webroot, String tenantID)
    • getRelationOrderingOverride

      public static boolean getRelationOrderingOverride(String cfgKey, boolean defaultValue)
    • clearRelationOrderingOverrideCache

      public static void clearRelationOrderingOverrideCache()
    • getMarkModifiedOverride

      public static boolean getMarkModifiedOverride(String cfgKey)
    • getMarkModifiedOverride

      public static boolean getMarkModifiedOverride(RelationType relation)
    • clearMarkModifiedOverrideCache

      public static void clearMarkModifiedOverrideCache()
    • calculateLocalCorePlusEndPoint

      public static String calculateLocalCorePlusEndPoint(String extensionName, String tenantId) throws IllegalArgumentException
      Throws:
      IllegalArgumentException
    • getContextFromRequestUri

      public static String getContextFromRequestUri(String uri)
    • applySpecialPropertiesToDatabaseUrl

      public static String applySpecialPropertiesToDatabaseUrl(String databaseUrl)
    • fuzzyEquals

      public static boolean fuzzyEquals(double a, double b)