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
FieldsModifier and TypeFieldDescriptionprotected static CurrentUserProviderThe current user providerprotected static GroupManagerThe groups managerprotected static I18nUtilsThe i18n utils instanceprotected static JSONUtilsThe json utilsprotected static final LoggerThe loggerprotected static RightManagerThe right managerprotected static SourceResolverThe source resolverprotected static UserHelperThe user helperprotected static UserManagerThe user managerprotected static VersionsHandlerThe versions handler -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static String_getResourceBase64(Source source) Get the base 64 encoding for the given sourcestatic StringReturns the absolute URI prefix.static StringabsoluteUriPrefix(boolean withWorkspaceURI) Returns the absolute URI prefix.static ObjectReturns the configuration value associated with the given parameter.voidcontextualize(Context context) static StringEscape the given string to be used as JS variable.static StringescapeURLforCSS(String url) Escape the given URL, meant to be used in eg.protected static StringgetAbsoluteUriPrefix(boolean withWorkspaceURI) Get the absolutized version of the context path.protected static StringgetUriPrefix(boolean withWorkspaceURI) Get the application context path.static StringgetValueFromJsonObject(String jsonString, String key) Parse a JSON string as a Map and return the value with the desired keyprotected static StringReturn the current workspace nameprotected static StringReturn the current workspace URIstatic NodeListgroups()Returns the list of the current user's groups.static NodeListReturns the of the given user's group.static NodeListReturns the of the given user's group.static booleanDetermines if the current logged user has right on a String contextstatic booleanGet the current mode of the application for the current user.static booleanisPluginEnabled(String plugin) Check if a given plugin is enabledstatic StringpluginImageBase64(String plugin, String path) Computes the base 64 representation of the image at the specified path in the given plugin.static StringrequestParameter(String parameter) Return the value of a request parameter.voidservice(ServiceManager manager) static StringSplit the text.static StringDeprecated.static StringTranslate an i18n key using current user language.static StringTranslate an i18n keystatic StringTranslate an i18n keystatic StringReturns the current URI prefix.static StringuriPrefix(boolean withWorkspaceURI) Returns the current URI prefix.static Nodeuser()Return the userstatic NodeReturn the given userstatic NodeReturn the given userstatic NodeuserByMail(String email, String populationId) Return the given userstatic Nodeversions()Get the versions of the application.static StringReturn the current workspace namestatic StringReturn the current workspace URIstatic StringReturn the current workspace theme namestatic StringReturn 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 -
_sourceResolver
The source resolver
-
-
Constructor Details
-
AmetysXSLTHelper
public AmetysXSLTHelper()
-
-
Method Details
-
contextualize
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
service
- Specified by:
servicein 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
-
pluginImageBase64
public static String pluginImageBase64(String plugin, String path) throws MalformedURLException, IOException Computes the base 64 representation of the image at the specified path in the given plugin.- Parameters:
plugin- the plugin's name.path- the resource path.- Returns:
- the base 64 encoding for the given resource.
- Throws:
IOException- if an error occurs when trying to get the fileMalformedURLException- if the url is invalid
-
_getResourceBase64
Get the base 64 encoding for the given source- Parameters:
source- the source- Returns:
- the base 64 encoding of the source
-