Class PortalUtilInternal


  • public class PortalUtilInternal
    extends Object
    General utility class for portal internal use.
    Since:
    6.0.0
    Version:
    $Revision: 24985 $ $Date: 2022-05-02 23:04:30 -0300 (Mon, 02 May 2022) $
    • Field Detail

      • BYPASS_PROPERTYBAG_LOAD

        public static final String BYPASS_PROPERTYBAG_LOAD
        Transaction attribute name of an object to avoid property bag loading.
        Since:
        11.0.0
    • Constructor Detail

      • PortalUtilInternal

        public PortalUtilInternal()
    • Method Detail

      • getDefinitionDocument

        public static Document getDefinitionDocument​(String relativePath)
                                              throws PortalException
        Returns the XML Document for a definition file.
        Parameters:
        relativePath - the relative path of the file. Must not start with '/'.
        Throws:
        PortalException - if the document could not be read.
        Since:
        6.0.0
      • getPageHolderHtmlByServiceInterfaceInstance

        public static org.jsoup.nodes.Element getPageHolderHtmlByServiceInterfaceInstance​(String lumServiceInterfaceInstance)
                                                                                   throws PortalException
        Returns the service interface instance pageholder HTML fragment, if there is any.
        Parameters:
        lumServiceInterfaceInstance - a lumis servince interface instance
        Returns:
        the service interface instance pageholder HTML fragment.
        Throws:
        PortalException
        Since:
        9.0.0
      • throwUncheckedly

        public static void throwUncheckedly​(Throwable t)
        Throws uncheckedly checked exceptions
        Parameters:
        t - the checked exception.
        Since:
        9.0.0
      • execWithSilentThrow

        public static <T> T execWithSilentThrow​(Callable<T> c)
        Executes the given code with no exception. If an exception occur, it will be throw uncheckedly.
        Parameters:
        c - the code.
        Returns:
        the code result.
        Since:
        9.0.0
      • execWithTransaction

        public static <T> T execWithTransaction​(PortalUtilInternal.ITransactionAware<T> code)
                                         throws Exception
        Executes the given code using the current transaction.
        Parameters:
        code - the code.
        Returns:
        the code result.
        Throws:
        Exception
        Since:
        9.0.0
      • execWithTransaction

        public static <T> T execWithTransaction​(boolean createIfNeeded,
                                                PortalUtilInternal.ITransactionAware<T> code)
                                         throws Exception
        Executes the given code with the given transaction. If createIfNeeded parameter is true and no transaction is available, a new transaction will be created.
        Parameters:
        createIfNeeded - indicates whether a transaction should be created if no current transaction is available.
        code - the code.
        Returns:
        the code result.
        Throws:
        Exception
        Since:
        9.0.0
      • execWithTransactionWithSilentThrow

        public static <T> T execWithTransactionWithSilentThrow​(boolean createTransactionIfRequired,
                                                               PortalUtilInternal.ITransactionAware<T> code)
        Executes the given code with the given transaction. If createIfNeeded parameter is true and no transaction is available, a new transaction will be created. Unlike execWithTransaction(boolean, ITransactionAware), this method does not declare any throw.
        Parameters:
        createIfNeeded - indicates whether a transaction should be created if no current transaction is available.
        code - the code.
        Returns:
        the code result.
        Since:
        10.0.0
      • execWithSessionConfig

        public static <T> T execWithSessionConfig​(PortalUtilInternal.ISessionConfigAware<T> code)
                                           throws Exception
        Executes the given code with the current session config.
        Parameters:
        code - the code.
        Returns:
        the code result.
        Throws:
        Exception
        Since:
        9.0.0
      • orNull

        public static <T> T orNull​(Callable<T> code)
        Returns the given code result. In case of a NullPointerException occurs when executing the given code, null will be returned. In case of other exception, it will not be catched.
        Parameters:
        code - the code.
        Returns:
        the code result or null if a NullPointerException occurs when executing the given code.
        Since:
        10.2.0
      • isInstall

        public static boolean isInstall()
        Returns whether this is an install process. Only searches the current thread stack trace to determine it.
        Returns:
        whether this is an install process.
        Since:
        10.3.0
      • isUpgrade

        public static boolean isUpgrade()
        Returns whether this is an upgrade process. Only searches the current thread stack trace to determine it.
        Returns:
        whether this is an upgrade process.
        Since:
        10.3.0
      • isInstallOrUpgrade

        public static boolean isInstallOrUpgrade()
        Returns whether this is an install or upgrade process. Only searches the current thread stack trace to determine it.
        Returns:
        whether this is an install or upgrade process.
        Since:
        10.3.0
      • getStackTrace

        public static String getStackTrace()
        Returns a String representation of current stack trace, one entry per line.
        Returns:
        a String representation of current stack trace, one entry per line.
        Since:
        10.3.0
      • getStackTrace

        public static String getStackTrace​(int tabCount)
        Returns a String representation of current stack trace, one entry per line. Prepends a String of tabCount tab characters.
        Parameters:
        tabCount - the tab characters count.
        Returns:
        a String representation of current stack trace, one entry per line.
        Since:
        10.3.0
      • getStackTrace

        public static String getStackTrace​(String eachLinePrefix)
        Returns a String representation of current stack trace, one entry per line. Prepends the given prefix in each line.
        Parameters:
        eachLinePrefix - the prefix.
        Returns:
        a String representation of current stack trace, one entry per line.
        Since:
        10.3.0
      • checkAndClearThreadData

        public static void checkAndClearThreadData()
        Verifies if any LumisXP related data is leaked in the current thread and clears it and logs warns about it if it happened.
        Since:
        11.0.0
      • clearThreadLocals

        public static void clearThreadLocals()
        Clears the thread locals of current thread.
        Since:
        11.0.0
      • allNull

        public static boolean allNull​(Object... objects)
        Returns false if any of the given objects is not null or true otherwise.
        Parameters:
        objects - the objects
        Returns:
        false if any of the given objects is not null or true otherwise.
        Since:
        12.0.0
      • anyNull

        public static boolean anyNull​(Object... objects)
        Returns true if some of the given objects is null or false otherwise.
        Parameters:
        objects - the objects
        Returns:
        true if some of the given objects is null or false otherwise.
        Since:
        12.0.0
      • allNotNull

        public static boolean allNotNull​(Object... objects)
        Returns false if some of the given objects is null or true otherwise.
        Parameters:
        objects - the objects
        Returns:
        false if some of the given objects is null or true otherwise.
        Since:
        12.0.0
      • isTestMode

        public static boolean isTestMode()
        Returns whether the portal is running in test mode.
        Returns:
        whether the portal is running in test mode.
        Since:
        12.0.0
      • isCXM

        public static boolean isCXM()
        Returns whether this is a CXM environment.
        Returns:
        whether this is a CXM environment.
        Since:
        14.2.0
      • newURI

        public static URI newURI​(String uri)
                          throws URISyntaxException
        Creates a new URI with minor adjustments for better compatibility. This method is meant to be a in-place replacement for URI(String).

        Currently this method encodes invalid characters in the URI's fragment, because most navigators and web servers accept them and there are external systems using them.

        Parameters:
        uri - the URI.
        Returns:
        the URI
        Throws:
        NullPointerException - if uri is null.
        URISyntaxException - if thrown by URI(String).
        Since:
        12.5.0
        See Also:
        URI(String)
      • in

        public static boolean in​(String str,
                                 String... values)
        Returns true if the given string is present in the given values or false otherwise. Accept null value in both, the string and the values.
        Parameters:
        str - the string
        values - the values
        Returns:
        true if the given string is present in the given values or false otherwise
        Since:
        12.5.0