Package lumis.portal.util
Class PortalUtilInternal
- java.lang.Object
-
- lumis.portal.util.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) $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
PortalUtilInternal.ISessionConfigAware<T>
Piece of code that runs with a session config.static interface
PortalUtilInternal.ITransactionAware<T>
Piece of code that runs with a transaction.
-
Field Summary
Fields Modifier and Type Field Description static String
BYPASS_PROPERTYBAG_LOAD
Transaction attribute name of an object to avoid property bag loading.
-
Constructor Summary
Constructors Constructor Description PortalUtilInternal()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
allNotNull(Object... objects)
Returnsfalse
if some of the given objects isnull
ortrue
otherwise.static boolean
allNull(Object... objects)
Returnsfalse
if any of the given objects is notnull
ortrue
otherwise.static boolean
anyNull(Object... objects)
Returnstrue
if some of the given objects isnull
orfalse
otherwise.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.static void
clearThreadLocals()
Clears the thread locals of current thread.static <T> T
execWithSessionConfig(PortalUtilInternal.ISessionConfigAware<T> code)
Executes the given code with the current session config.static <T> T
execWithSessionConfigWithSilentThrow(PortalUtilInternal.ISessionConfigAware<T> code)
Executes the given code with the current session config.static <T> T
execWithSilentThrow(Callable<T> c)
Executes the given code with no exception.static <T> T
execWithTransaction(boolean createIfNeeded, PortalUtilInternal.ITransactionAware<T> code)
Executes the given code with the given transaction.static <T> T
execWithTransaction(PortalUtilInternal.ITransactionAware<T> code)
Executes the given code using the current transaction.static <T> T
execWithTransactionWithSilentThrow(boolean createTransactionIfRequired, PortalUtilInternal.ITransactionAware<T> code)
Executes the given code with the given transaction.static <T> T
execWithTransactionWithSilentThrow(PortalUtilInternal.ITransactionAware<T> code)
Executes the given code using the current transaction.static Document
getDefinitionDocument(String relativePath)
Returns the XML Document for a definition file.static org.jsoup.nodes.Element
getPageHolderHtmlByServiceInterfaceInstance(String lumServiceInterfaceInstance)
Returns the service interface instance pageholder HTML fragment, if there is any.static String
getStackTrace()
Returns a String representation of current stack trace, one entry per line.static String
getStackTrace(int tabCount)
Returns a String representation of current stack trace, one entry per line.static String
getStackTrace(String eachLinePrefix)
Returns a String representation of current stack trace, one entry per line.static boolean
in(String str, String... values)
Returnstrue
if the given string is present in the given values orfalse
otherwise.static boolean
isCXM()
Returns whether this is a CXM environment.static boolean
isInstall()
Returns whether this is an install process.static boolean
isInstallOrUpgrade()
Returns whether this is an install or upgrade process.static boolean
isTestMode()
Returns whether the portal is running in test mode.static boolean
isUpgrade()
Returns whether this is an upgrade process.static URI
newURI(String uri)
Creates a newURI
with minor adjustments for better compatibility.static <T> T
orNull(Callable<T> code)
Returns the given code result.static void
throwUncheckedly(Throwable t)
Throws uncheckedly checked exceptions
-
-
-
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
-
-
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 bethrow 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. IfcreateIfNeeded
parameter istrue
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. IfcreateIfNeeded
parameter istrue
and no transaction is available, a new transaction will be created. UnlikeexecWithTransaction(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
-
execWithTransactionWithSilentThrow
public static <T> T execWithTransactionWithSilentThrow(PortalUtilInternal.ITransactionAware<T> code)
Executes the given code using the current transaction. UnlikeexecWithTransaction(ITransactionAware)
, this method does not declare any throw.- Parameters:
code
- the code.- Returns:
- the code result.
- Since:
- 10.0.0
-
execWithSessionConfigWithSilentThrow
public static <T> T execWithSessionConfigWithSilentThrow(PortalUtilInternal.ISessionConfigAware<T> code)
Executes the given code with the current session config. UnlikeexecWithSessionConfig(ISessionConfigAware)
, this method does not declare any throw.- Parameters:
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 aNullPointerException
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 aNullPointerException
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 oftabCount
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)
Returnsfalse
if any of the given objects is notnull
ortrue
otherwise.- Parameters:
objects
- the objects- Returns:
false
if any of the given objects is notnull
ortrue
otherwise.- Since:
- 12.0.0
-
anyNull
public static boolean anyNull(Object... objects)
Returnstrue
if some of the given objects isnull
orfalse
otherwise.- Parameters:
objects
- the objects- Returns:
true
if some of the given objects isnull
orfalse
otherwise.- Since:
- 12.0.0
-
allNotNull
public static boolean allNotNull(Object... objects)
Returnsfalse
if some of the given objects isnull
ortrue
otherwise.- Parameters:
objects
- the objects- Returns:
false
if some of the given objects isnull
ortrue
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 newURI
with minor adjustments for better compatibility. This method is meant to be a in-place replacement forURI(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
- ifuri
isnull
.URISyntaxException
- if thrown byURI(String)
.- Since:
- 12.5.0
- See Also:
URI(String)
-
in
public static boolean in(String str, String... values)
Returnstrue
if the given string is present in the given values orfalse
otherwise. Acceptnull
value in both, the string and the values.- Parameters:
str
- the stringvalues
- the values- Returns:
true
if the given string is present in the given values orfalse
otherwise- Since:
- 12.5.0
-
-