public class AmetysXSLTHelper extends Object implements Contextualizable, Serviceable
Modifier and Type | Field and Description |
---|---|
private static Context |
_context |
protected static CurrentUserProvider |
_currentUserProvider
The current user provider
|
protected static GroupManager |
_groupManager
The groups manager
|
protected static I18nUtils |
_i18nUtils
The i18n utils instance
|
protected static JSONUtils |
_jsonUtils
The json utils
|
protected static Logger |
_LOGGER
The logger
|
protected static UserHelper |
_userHelper
The user helper
|
protected static UserManager |
_userManager
The users manager
|
protected static VersionsHandler |
_versionHandler
The versions handler
|
Constructor and Description |
---|
AmetysXSLTHelper() |
Modifier and Type | Method and Description |
---|---|
static String |
absoluteUriPrefix()
Returns the absolute URI prefix.
|
static String |
absoluteUriPrefix(boolean withWorkspaceURI)
Returns the absolute URI prefix.
|
static String |
config(String id)
Returns the configuration value associated with the given parameter.
|
void |
contextualize(Context context) |
static String |
escapeJS(String str)
Escape the given string to be used as JS variable.
|
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 key
|
protected static String |
getWorkspaceName()
Return the current workspace name
|
protected static String |
getWorkspacePrefix()
Return the current workspace URI
|
static NodeList |
groups()
Returns the list of the current user's groups.
|
static NodeList |
groups(String userIdentity)
Returns the of the given user's group.
|
static NodeList |
groups(String login,
String populationId)
Returns the of the given user's group.
|
static boolean |
isDeveloperMode()
Get the current mode of the application for the current user.
|
static String |
requestParameter(String parameter)
Return the value of a request parameter.
|
void |
service(ServiceManager manager) |
static String |
splitText(String textToSplit,
String tokenizers,
int startIndex)
Split the text.
|
static String |
splitText(String textToSplit,
String tokenizers,
int maxCharacters,
int currentCharactersNumber)
Deprecated.
|
static String |
translate(String key)
Translate an i18n key using current user language.
|
static String |
translate(String key,
String lang,
NodeList parameters)
Translate an i18n key
|
static String |
uriPrefix()
Returns the current URI prefix.
|
static String |
uriPrefix(boolean withWorkspaceURI)
Returns the current URI prefix.
|
static String |
urlEncode(String url)
Encode the string to be url compliant
|
static Node |
user()
Return the user
|
static Node |
user(String userIdentity)
Return the given user
|
static Node |
user(String login,
String populationId)
Return the given user
|
static Node |
versions()
Get the versions of the application.
|
static String |
workspaceName()
Return the current workspace name
|
static String |
workspacePrefix()
Return the current workspace URI
|
static String |
workspaceTheme()
Return the current workspace theme name
|
static String |
workspaceThemeURL()
Return the current workspace theme url
|
protected static I18nUtils _i18nUtils
protected static VersionsHandler _versionHandler
protected static CurrentUserProvider _currentUserProvider
protected static UserManager _userManager
protected static GroupManager _groupManager
protected static UserHelper _userHelper
protected static JSONUtils _jsonUtils
public AmetysXSLTHelper()
public void contextualize(Context context) throws ContextException
contextualize
in interface Contextualizable
ContextException
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public static String uriPrefix()
public static String uriPrefix(boolean withWorkspaceURI)
withWorkspaceURI
- true to add the workspace URI (recommended)public static String absoluteUriPrefix()
public static String absoluteUriPrefix(boolean withWorkspaceURI)
withWorkspaceURI
- true to add the workspace URI (recommended)public static String workspaceName()
public static String workspacePrefix()
public static String workspaceTheme()
public static String workspaceThemeURL()
protected static String getUriPrefix(boolean withWorkspaceURI)
withWorkspaceURI
- true to add the workspace URI (recommended)Request.getContextPath()
protected static String getAbsoluteUriPrefix(boolean withWorkspaceURI)
withWorkspaceURI
- true to add the workspace URI (recommended)protected static String getWorkspaceName()
protected static String getWorkspacePrefix()
public static String config(String id)
id
- the configuration parameter.public static String requestParameter(String parameter)
parameter
- the parameter name.public static String translate(String key)
key
- The key to translate. Specify the catalog this way: "catalogue:KEY"public static String translate(String key, String lang, NodeList 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.public static String getValueFromJsonObject(String jsonString, String key)
jsonString
- the JSON representation of the object.key
- name of the value to returnpublic static String escapeJS(String str)
str
- the string to escape.public static String urlEncode(String url)
url
- The url to encodepublic static String splitText(String textToSplit, String tokenizers, int startIndex)
textToSplit
- the text to split.tokenizers
- the tokenizer characters.startIndex
- the minimum number of characters of the result string@Deprecated public static String splitText(String textToSplit, String tokenizers, int maxCharacters, int currentCharactersNumber)
textToSplit
- the text to split.tokenizers
- the tokenizer characters.maxCharacters
- the maximum number of characters of the result stringcurrentCharactersNumber
- the current character number.public static Node versions()
public static boolean isDeveloperMode()
public static Node user() throws SAXException
SAXException
- if a problem occured while getting the userpublic static Node user(String userIdentity) throws SAXException
userIdentity
- the concerned user's login + populationSAXException
- If an error occurred while saxing the userpublic static Node user(String login, String populationId) throws SAXException
login
- the concerned user's loginpopulationId
- the concerned user's population idSAXException
- If an error occurred while saxing the userpublic static NodeList groups()
public static NodeList groups(String userIdentity)
userIdentity
- the concerned user's login + population