Package org.ametys.core.util
Class AmetysXSLTHelper
java.lang.Object
org.ametys.core.util.AmetysXSLTHelper
- All Implemented Interfaces:
Contextualizable
,Serviceable
- Direct Known Subclasses:
AmetysXSLTHelper
Helper component to be used from XSL stylesheets.
-
Field Summary
Modifier and TypeFieldDescriptionprotected static CurrentUserProvider
The current user providerprotected static GroupManager
The groups managerprotected static I18nUtils
The i18n utils instanceprotected static JSONUtils
The json utilsprotected static final Logger
The loggerprotected static RightManager
The right managerprotected static UserHelper
The user helperprotected static UserManager
The user managerprotected static VersionsHandler
The versions handler -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Returns the absolute URI prefix.static String
absoluteUriPrefix
(boolean withWorkspaceURI) Returns the absolute URI prefix.static Object
Returns the configuration value associated with the given parameter.void
contextualize
(Context context) static String
Escape the given string to be used as JS variable.static String
escapeURLforCSS
(String url) Escape the given URL, meant to be used in eg.protected static String
getAbsoluteUriPrefix
(boolean withWorkspaceURI) Get the absolutized version of the context path.protected static String
getUriPrefix
(boolean withWorkspaceURI) Get the application context path.static String
getValueFromJsonObject
(String jsonString, String key) Parse a JSON string as a Map and return the value with the desired keyprotected static String
Return the current workspace nameprotected static String
Return the current workspace URIstatic NodeList
groups()
Returns the list of the current user's groups.static NodeList
Returns the of the given user's group.static NodeList
Returns the of the given user's group.static boolean
Determines if the current logged user has right on a String contextstatic boolean
Get the current mode of the application for the current user.static boolean
isPluginEnabled
(String plugin) Check if a given plugin is enabledstatic String
requestParameter
(String parameter) Return the value of a request parameter.void
service
(ServiceManager manager) static String
Split the text.static String
Deprecated.static String
Translate an i18n key using current user language.static String
Translate an i18n keystatic String
Translate an i18n keystatic String
Returns the current URI prefix.static String
uriPrefix
(boolean withWorkspaceURI) Returns the current URI prefix.static Node
user()
Return the userstatic Node
Return the given userstatic Node
Return the given userstatic Node
userByMail
(String email, String populationId) Return the given userstatic Node
versions()
Get the versions of the application.static String
Return the current workspace namestatic String
Return the current workspace URIstatic String
Return the current workspace theme namestatic String
Return the current workspace theme url
-
Field Details
-
_LOGGER
The logger -
_i18nUtils
The i18n utils instance -
_versionHandler
The versions handler -
_currentUserProvider
The current user provider -
_groupManager
The groups manager -
_userHelper
The user helper -
_jsonUtils
The json utils -
_rightManager
The right manager -
_userManager
The user manager
-
-
Constructor Details
-
AmetysXSLTHelper
public AmetysXSLTHelper()
-
-
Method Details
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
uriPrefix
Returns the current URI prefix.- Returns:
- the current URI prefix.
-
uriPrefix
Returns the current URI prefix.- Parameters:
withWorkspaceURI
- true to add the workspace URI (recommended)- Returns:
- the current URI prefix.
-
absoluteUriPrefix
Returns the absolute URI prefix.- Returns:
- the absolute URI prefix.
-
absoluteUriPrefix
Returns the absolute URI prefix.- Parameters:
withWorkspaceURI
- true to add the workspace URI (recommended)- Returns:
- the absolute URI prefix.
-
workspaceName
Return the current workspace name- Returns:
- The workspace name. Cannot be empty.
-
workspacePrefix
Return the current workspace URI- Returns:
- The workspace name. Can be empty.
-
workspaceTheme
Return the current workspace theme name- Returns:
- The name
-
workspaceThemeURL
Return the current workspace theme url- Returns:
- The url without any prefix
-
getUriPrefix
Get the application context path. Can be empty if the application resides in the root context. Use it to create a link beginning with the application root.- Parameters:
withWorkspaceURI
- true to add the workspace URI (recommended)- Returns:
- The application context path with workspace URI
- See Also:
-
getAbsoluteUriPrefix
Get the absolutized version of the context path. Use it to create an absolute link beginning with the application root, for instance when sending a mail linking to the application.- Parameters:
withWorkspaceURI
- true to add the workspace URI (recommended)- Returns:
- The absolute context path.
-
getWorkspaceName
Return the current workspace name- Returns:
- The workspace name. Cannot be empty.
-
getWorkspacePrefix
Return the current workspace URI- Returns:
- The workspace name. Can be empty for the default workspace.
-
config
Returns the configuration value associated with the given parameter.- Parameters:
id
- the configuration parameter.- Returns:
- the configuration value associated with the given parameter.
-
requestParameter
Return the value of a request parameter.- Parameters:
parameter
- the parameter name.- Returns:
- the request parameter.
-
translate
Translate an i18n key using current user language.- Parameters:
key
- The key to translate. Specify the catalog this way: "catalogue:KEY"- Returns:
- The translation or null.
-
translate
Translate an i18n key- Parameters:
key
- The key to translate. Specify the catalog this way: "catalogue:KEY"lang
- The language. Can be null to use current user language.- Returns:
- The translation or null.
-
translate
Translate an i18n key- Parameters:
key
- The key to translate. Specify the catalog this way: "catalogue:KEY"lang
- The language. Can be null to use current user language.parameters
- The key parameters. Can be empty.- Returns:
- The translation or null.
-
escapeJS
Escape the given string to be used as JS variable.- Parameters:
str
- the string to escape.- Returns:
- the escaped String.
-
escapeURLforCSS
Escape the given URL, meant to be used in eg. a background-image CSS style- Parameters:
url
- the URL to escape- Returns:
- the escaped URL
-
splitText
Split the text.- Parameters:
textToSplit
- the text to split.tokenizers
- the tokenizer characters.startIndex
- the minimum number of characters of the result string- Returns:
- the split text.
-
splitText
@Deprecated public static String splitText(String textToSplit, String tokenizers, int maxCharacters, int currentCharactersNumber) Deprecated.Split the text.- Parameters:
textToSplit
- the text to split.tokenizers
- the tokenizer characters.maxCharacters
- the maximum number of characters of the result stringcurrentCharactersNumber
- the current character number.- Returns:
- the split text.
-
versions
Get the versions of the application. Default VersionsHandler impl will return Ametys and Application versions- Returns:
- The versions <Version><Version><Name>X</Name><Version>X</Version><Date>X</Date></Version></Versions> (empty tags are removed)
-
isDeveloperMode
Get the current mode of the application for the current user.- Returns:
- True if the application is in developer mode, false if in production mode.
-
user
Return the user- Returns:
- The current connected user object or null
- Throws:
SAXException
- if a problem occured while getting the user
-
user
Return the given user- Parameters:
userIdentity
- the concerned user's login + population- Returns:
- The informations about the given user
- Throws:
SAXException
- If an error occurred while saxing the user
-
user
Return the given user- Parameters:
login
- the concerned user's loginpopulationId
- the concerned user's population id- Returns:
- The informations about the given user
- Throws:
SAXException
- If an error occurred while saxing the user
-
userByMail
Return the given user- Parameters:
email
- the concerned user's emailpopulationId
- the concerned user's population id- Returns:
- The informations about the given user
- Throws:
SAXException
- If an error occurred while saxing the user
-
groups
Returns the list of the current user's groups.- Returns:
- the list of the current user's groups. Can be null if there is no connected user.
-
groups
Returns the of the given user's group.- Parameters:
userIdentity
- the concerned user's login + population- Returns:
- the of the given user's group.
-
groups
Returns the of the given user's group.- Parameters:
login
- the concerned user's login.populationId
- the concerned user's population.- Returns:
- the of the given user's group.
-
getValueFromJsonObject
Parse a JSON string as a Map and return the value with the desired key- Parameters:
jsonString
- the JSON representation of the object.key
- name of the value to return- Returns:
- the value as a String, or empty string if an error occurred or the key was not found.
-
hasRight
Determines if the current logged user has right on a String context- Parameters:
rightId
- The id of rightobjectCtx
- the context. Can be null to search on any context.- Returns:
- true if the current user is allowed, false otherwise
-
isPluginEnabled
Check if a given plugin is enabled- Parameters:
plugin
- the plugin's name.- Returns:
- the plugin is enabled
-