public class PortalUtilInternal extends Object
Modifier and Type | Class and 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.
|
Modifier and Type | Field and Description |
---|---|
static String |
BYPASS_PROPERTYBAG_LOAD
Transaction attribute name of an object to avoid property bag loading.
|
Constructor and Description |
---|
PortalUtilInternal() |
Modifier and Type | Method and Description |
---|---|
static boolean |
allNotNull(Object... objects)
Returns
false if some of the given objects is null or true otherwise. |
static boolean |
allNull(Object... objects)
Returns
false if any of the given objects is not null or true otherwise. |
static boolean |
anyNull(Object... objects)
Returns
true if some of the given objects is null or false 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)
Returns
true if the given string is present in the given values or false otherwise. |
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 new
URI 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
|
public static final String BYPASS_PROPERTYBAG_LOAD
public static Document getDefinitionDocument(String relativePath) throws PortalException
relativePath
- the relative path of the file. Must not start with '/'.PortalException
- if the document could not be read.public static org.jsoup.nodes.Element getPageHolderHtmlByServiceInterfaceInstance(String lumServiceInterfaceInstance) throws PortalException
lumServiceInterfaceInstance
- a lumis servince interface instancePortalException
public static void throwUncheckedly(Throwable t)
t
- the checked exception.public static <T> T execWithSilentThrow(Callable<T> c)
throw uncheckedly
.c
- the code.public static <T> T execWithTransaction(PortalUtilInternal.ITransactionAware<T> code) throws Exception
code
- the code.Exception
public static <T> T execWithTransaction(boolean createIfNeeded, PortalUtilInternal.ITransactionAware<T> code) throws Exception
createIfNeeded
parameter
is true
and no transaction is available, a new transaction will be created.createIfNeeded
- indicates whether a transaction should be created if no current transaction is available.code
- the code.Exception
public static <T> T execWithTransactionWithSilentThrow(boolean createTransactionIfRequired, PortalUtilInternal.ITransactionAware<T> code)
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.createIfNeeded
- indicates whether a transaction should be created if no current transaction is available.code
- the code.public static <T> T execWithTransactionWithSilentThrow(PortalUtilInternal.ITransactionAware<T> code)
execWithTransaction(ITransactionAware)
, this method does not declare any throw.code
- the code.public static <T> T execWithSessionConfigWithSilentThrow(PortalUtilInternal.ISessionConfigAware<T> code)
execWithSessionConfig(ISessionConfigAware)
, this method does not declare any throw.code
- the code.public static <T> T execWithSessionConfig(PortalUtilInternal.ISessionConfigAware<T> code) throws Exception
code
- the code.Exception
public static <T> T orNull(Callable<T> code)
NullPointerException
occurs when executing the given code, null
will be returned.
In case of other exception, it will not be catched.code
- the code.null
if a NullPointerException
occurs when executing the given code.public static boolean isInstall()
public static boolean isUpgrade()
public static boolean isInstallOrUpgrade()
public static String getStackTrace()
public static String getStackTrace(int tabCount)
tabCount
tab characters.tabCount
- the tab characters count.public static String getStackTrace(String eachLinePrefix)
eachLinePrefix
- the prefix.public static void checkAndClearThreadData()
public static void clearThreadLocals()
public static boolean allNull(Object... objects)
false
if any of the given objects is not null
or true
otherwise.objects
- the objectsfalse
if any of the given objects is not null
or true
otherwise.public static boolean anyNull(Object... objects)
true
if some of the given objects is null
or false
otherwise.objects
- the objectstrue
if some of the given objects is null
or false
otherwise.public static boolean allNotNull(Object... objects)
false
if some of the given objects is null
or true
otherwise.objects
- the objectsfalse
if some of the given objects is null
or true
otherwise.public static boolean isTestMode()
public static URI newURI(String uri) throws URISyntaxException
URI
with minor adjustments for better compatibility. This method is meant to be a in-place
replacement for URI.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.
uri
- the URI.NullPointerException
- if uri
is null
.URISyntaxException
- if thrown by URI.URI(String)
.URI.URI(String)
public static boolean in(String str, String... values)
true
if the given string is present in the given values or false
otherwise.
Accept null
value in both, the string and the values.str
- the stringvalues
- the valuestrue
if the given string is present in the given values or false
otherwiseLumisXP 12.5.0.200928 - Copyright © 2006–2020 Lumis EIP Tecnologia da Informação LTDA. All Rights Reserved.