Package lumis.portal.theme
Class ThemeUtil
- java.lang.Object
-
- lumis.portal.theme.ThemeUtil
-
public class ThemeUtil extends java.lang.Object
Utility class for theme related actions.- Since:
- 7.0.0
- Version:
- $Revision: 26156 $ $Date: 2024-01-13 10:26:46 -0300 (Sat, 13 Jan 2024) $
-
-
Constructor Summary
Constructors Constructor Description ThemeUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addNewTheme(java.lang.String themeName, java.lang.String themeDescription, java.lang.String themePath, java.lang.String moduleId, IResource resource)
static java.lang.String
getThemeIdByPath(java.lang.String path)
Returns the theme identifier of the given theme path.static java.lang.String
getThemePathById(java.lang.String themeId)
Returns the theme path of the given theme identifier.static IFile
getThemeRootDir(java.lang.String themePath)
static java.util.List<? extends ITheme>
getThemes(PageConfig page)
Returns the applied themes in the given page.static java.util.List<? extends ITheme>
getThemesByChannelId(java.lang.String channelId)
Returns the themes applied (either directly or inherited) on the channel with the given id.static boolean
isEditableTheme(java.lang.String themeId)
Returns whether the given theme is editable.static boolean
isLumisTheme(ITheme theme)
Returns whether the given theme is one of the LumisPortal standard themes.static java.lang.String
resolveDefinitionFilePath(java.lang.String definitionFilePath, java.util.List<? extends ITheme> themes)
Resolves the definition file path with the given applied themes applying the following rules:
If theappliedThemes
parameter isnull
or if it is empty the original resource path will be returned The given resource will be searched through the applied themes' resource (underIThemeSPI.ResourceFolder.DEF
)
If the resource was found in any applied theme, the resolved resource will be compound as: If the resource was not found, the original one will be returnedstatic java.lang.String
resolveLayoutFilePath(java.lang.String layoutFilePath, java.util.List<? extends ITheme> themes)
Resolves the layout file path with the given applied themes applying the following rules:
If theappliedThemes
parameter isnull
or if it is empty the original resource path will be returned The given resource will be searched through the applied themes' resource (underIThemeSPI.ResourceFolder.DEF
)
If the resource was found in any applied theme, the resolved resource will be compound as: If the resource was not found, the original one will be returnedstatic java.lang.String
resolveWWWResourcePath(java.lang.String resourcePath, java.util.List<? extends ITheme> themes, boolean includeFileHash)
Resolves the resources' paths with the given applied themes applying the following rules:
If the resource path start withno theme prefix
, then the returned resource path will be the original one without the prefix If theappliedThemes
parameter isnull
or if it is empty the original resource path will be returned The given resource will be searched through the applied themes' resource (underIThemeSPI.ResourceFolder.WWW
)
If the resource was found in any applied theme, the resolved resource will be compound as: (where<theme www prefix>
isThemeManager.THEME_WWW_RESOURCE_PREFIX
) If the resource was not found, the original one will be returnedstatic java.lang.String
resolveWWWResourcePath(java.lang.String resourcePath, java.util.List<? extends ITheme> themes, boolean includeFileHash, boolean unencodeResourcePath)
Resolves the resources' paths with the given applied themes applying the following rules:
If the resource path start withno theme prefix
, then the returned resource path will be the original one without the prefix If theappliedThemes
parameter isnull
or if it is empty the original resource path will be returned The given resource will be searched through the applied themes' resource (underIThemeSPI.ResourceFolder.WWW
)
If the resource was found in any applied theme, the resolved resource will be compound as: (where<theme www prefix>
isThemeManager.THEME_WWW_RESOURCE_PREFIX
) If the resource was not found, the original one will be returned
-
-
-
Method Detail
-
getThemeIdByPath
public static java.lang.String getThemeIdByPath(java.lang.String path) throws lumis.portal.theme.InvalidThemePathException
Returns the theme identifier of the given theme path.- Parameters:
path
- the path.- Returns:
- the theme identifier of the given theme path.
- Throws:
lumis.portal.theme.InvalidThemePathException
- if the given path is null.lumis.portal.theme.InvalidThemePathException
- if the trimmed version of the given path is empty.- Since:
- 7.0.0
-
getThemePathById
public static java.lang.String getThemePathById(java.lang.String themeId) throws lumis.portal.theme.InvalidThemeIdException
Returns the theme path of the given theme identifier.- Parameters:
themeId
- the theme identifier.- Returns:
- the theme path of the given theme identifier.
- Throws:
lumis.portal.theme.InvalidThemeIdException
- if the given identifier is null.lumis.portal.theme.InvalidThemeIdException
- if the given identifier is empty.- Since:
- 7.0.0
-
resolveWWWResourcePath
public static java.lang.String resolveWWWResourcePath(java.lang.String resourcePath, java.util.List<? extends ITheme> themes, boolean includeFileHash) throws PortalException
Resolves the resources' paths with the given applied themes applying the following rules:
- If the resource path start with
no theme prefix
, then the returned resource path will be the original one without the prefix - If the
appliedThemes
parameter isnull
or if it is empty the original resource path will be returned - The given resource will be searched through the applied themes' resource (under
IThemeSPI.ResourceFolder.WWW
)
- If the resource was found in any applied theme, the resolved resource will be compound as:
(where<theme www prefix>
isThemeManager.THEME_WWW_RESOURCE_PREFIX
) - If the resource was not found, the original one will be returned
- If the resource was found in any applied theme, the resolved resource will be compound as:
- Parameters:
resourcePath
- the requested resource path.themes
- the applied themes.includeFileHash
- indicates whether to include the files' hashes.- Returns:
- the resolved resource path as described above.
- Throws:
java.lang.NullPointerException
- if theresourcePath
isnull
or if theresourceFolder
isnull
.PortalException
- Since:
- 16.1.0
- If the resource path start with
-
resolveWWWResourcePath
public static java.lang.String resolveWWWResourcePath(java.lang.String resourcePath, java.util.List<? extends ITheme> themes, boolean includeFileHash, boolean unencodeResourcePath) throws PortalException
Resolves the resources' paths with the given applied themes applying the following rules:
- If the resource path start with
no theme prefix
, then the returned resource path will be the original one without the prefix - If the
appliedThemes
parameter isnull
or if it is empty the original resource path will be returned - The given resource will be searched through the applied themes' resource (under
IThemeSPI.ResourceFolder.WWW
)
- If the resource was found in any applied theme, the resolved resource will be compound as:
(where<theme www prefix>
isThemeManager.THEME_WWW_RESOURCE_PREFIX
) - If the resource was not found, the original one will be returned
- If the resource was found in any applied theme, the resolved resource will be compound as:
- Parameters:
resourcePath
- the requested resource path.themes
- the applied themes.includeFileHash
- indicates whether to include the files' hashes.unencodeResourcePath
- indicates whether to unencode the resource path.- Returns:
- the resolved resource path as described above.
- Throws:
java.lang.NullPointerException
- if theresourcePath
isnull
or if theresourceFolder
isnull
.PortalException
- Since:
- 16.1.0
- If the resource path start with
-
resolveLayoutFilePath
public static java.lang.String resolveLayoutFilePath(java.lang.String layoutFilePath, java.util.List<? extends ITheme> themes) throws PortalException
Resolves the layout file path with the given applied themes applying the following rules:
- If the
appliedThemes
parameter isnull
or if it is empty the original resource path will be returned - The given resource will be searched through the applied themes' resource (under
IThemeSPI.ResourceFolder.DEF
)
- If the resource was found in any applied theme, the resolved resource will be compound as:
- If the resource was not found, the original one will be returned
- If the resource was found in any applied theme, the resolved resource will be compound as:
- Parameters:
layoutFilePath
- the layout file path to be resolved.themes
- the applied themes.- Returns:
- the resolved layout file path as described above.
- Throws:
java.lang.NullPointerException
- if theresourcePath
isnull
or if theresourceFolder
isnull
.PortalException
- Since:
- 7.0.0
- If the
-
getThemes
public static java.util.List<? extends ITheme> getThemes(PageConfig page) throws PortalException
Returns the applied themes in the given page.- Parameters:
page
- the page- Returns:
- the applied themes in the given page
- Throws:
PortalException
- Since:
- 16.0.0
-
getThemesByChannelId
public static java.util.List<? extends ITheme> getThemesByChannelId(java.lang.String channelId) throws PortalException
Returns the themes applied (either directly or inherited) on the channel with the given id.- Parameters:
channelId
- the channel id- Returns:
- the themes applied (either directly or inherited) on the channel with the given id.
- Throws:
PortalException
- Since:
- 16.0.0
-
resolveDefinitionFilePath
public static java.lang.String resolveDefinitionFilePath(java.lang.String definitionFilePath, java.util.List<? extends ITheme> themes) throws PortalException
Resolves the definition file path with the given applied themes applying the following rules:
- If the
appliedThemes
parameter isnull
or if it is empty the original resource path will be returned - The given resource will be searched through the applied themes' resource (under
IThemeSPI.ResourceFolder.DEF
)
- If the resource was found in any applied theme, the resolved resource will be compound as:
- If the resource was not found, the original one will be returned
- If the resource was found in any applied theme, the resolved resource will be compound as:
- Parameters:
definitionFilePath
- the definition file path to be resolved.themes
- the applied themes.- Returns:
- the resolved definition file path as described above.
- Throws:
java.lang.NullPointerException
- if theresourcePath
isnull
or if theresourceFolder
isnull
.PortalException
- Since:
- 7.0.0
- If the
-
getThemeRootDir
public static IFile getThemeRootDir(java.lang.String themePath) throws PortalException
- Throws:
PortalException
-
addNewTheme
public static void addNewTheme(java.lang.String themeName, java.lang.String themeDescription, java.lang.String themePath, java.lang.String moduleId, IResource resource) throws PortalException
- Throws:
PortalException
-
isLumisTheme
public static boolean isLumisTheme(ITheme theme)
Returns whether the given theme is one of the LumisPortal standard themes.- Parameters:
theme
- the theme- Returns:
- whether the given theme is one of the LumisPortal standard themes.
- Since:
- 8.0.0
-
isEditableTheme
public static boolean isEditableTheme(java.lang.String themeId) throws PortalException
Returns whether the given theme is editable.- Parameters:
themeId
- the theme identifier- Returns:
true
if the given theme is editable.
false
otherwise.- Throws:
PortalException
- Since:
- 10.3.0
-
-