Class ProjectXsltHelper
- java.lang.Object
-
- org.ametys.plugins.workspaces.project.helper.ProjectXsltHelper
-
- All Implemented Interfaces:
Contextualizable
,LogEnabled
,Serviceable
public class ProjectXsltHelper extends Object implements Serviceable, Contextualizable, LogEnabled
Helper component to be used from XSL stylesheets to get info related to projects.
-
-
Constructor Summary
Constructors Constructor Description ProjectXsltHelper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static boolean
canAccessBO()
Returns true if current user can access to the back-officestatic MapElement
categoryColor(String categoryId)
Return the color associated to the categorystatic MapElement
categoryColor(Category category)
Return the color associated to the categorystatic String
computeDefaultLanguage(String language)
Get the language that will be the default value of the available values.void
contextualize(Context context)
void
enableLogging(Logger logger)
static String
getAlertsRootPageId()
Get the id of alerts root's pagestatic String
getLanguageLabel(String code, String language)
Get the translated label associated to the codestatic String
getModulePage(String moduleId)
Get the module page.static String
getNewsRootPageId()
Get the id of news root's pagestatic boolean
hasRightOnModule(String rightId, String moduleId)
Returns true if the current user has the specified right on the specified workspace modulestatic boolean
isManager()
Determines if the current user is a manager of current projectstatic boolean
isManager(String projectName)
Determines if the current user is a manager for the projectstatic boolean
isManager(String login, String populationId)
Determines if a user is a managerstatic boolean
isManager(String projectName, String login, String populationId)
Determines if the given user is a manager for the projectstatic boolean
isResourceFromWorkspace(String resourceId)
True if the resource comes from workspacesstatic String
project()
Returns the current projectstatic MapElement
projectCategoryColor()
Return the color associated to the first category associated to the current projectstatic MapElement
projectCategoryColor(String projectName)
Return the color associated to the first category associated to the given projectstatic String
projectCategoryLabel()
Return the color associated to the first category associated to the current projectstatic String
projectCategoryLabel(String projectName)
Return the color associated to the first category associated to the given projectstatic String
projectCreationDate()
Returns the creation date of the current projectstatic String
projectCreationDate(String projectName)
Returns the creation date of the given projectstatic String
projectDescription()
Returns the description of the current projectstatic String
projectDescription(String projectName)
Returns the description of the given projectstatic MapElement
projectInfo()
Returns the information of current projectstatic MapElement
projectInfo(String projectName)
Returns the project informationstatic NodeList
projectKeywords()
Returns the keywords of the current projectstatic NodeList
projectKeywords(String projectName)
Returns the project keywordsstatic String
projectLastActivityDate()
Get the date of last activity for current projectstatic String
projectLastActivityDate(String projectName)
Get the date of last activity for a given projectstatic String
projectTitle()
Returns the title of the current projectstatic String
projectTitle(String projectName)
Returns the title of the given projectstatic Node
resourceSite(String projectResourceId)
Get the site of a project's resourcevoid
service(ServiceManager manager)
-
-
-
Constructor Detail
-
ProjectXsltHelper
public ProjectXsltHelper()
-
-
Method Detail
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
enableLogging
public void enableLogging(Logger logger)
- Specified by:
enableLogging
in interfaceLogEnabled
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
projectInfo
public static MapElement projectInfo()
Returns the information of current project- Returns:
- the information of current project
-
projectInfo
public static MapElement projectInfo(String projectName)
Returns the project information- Parameters:
projectName
- The project name- Returns:
- the project information
-
projectTitle
public static String projectTitle()
Returns the title of the current project- Returns:
- the title of the current project
-
projectTitle
public static String projectTitle(String projectName)
Returns the title of the given project- Parameters:
projectName
- The project to consider- Returns:
- the title of the given project or empty otherwise
-
projectDescription
public static String projectDescription()
Returns the description of the current project- Returns:
- the description of the current project
-
projectDescription
public static String projectDescription(String projectName)
Returns the description of the given project- Parameters:
projectName
- The project to consider- Returns:
- the description of the given project or empty otherwise
-
projectKeywords
public static NodeList projectKeywords()
Returns the keywords of the current project- Returns:
- keywords of the current project
-
projectKeywords
public static NodeList projectKeywords(String projectName)
Returns the project keywords- Parameters:
projectName
- the project name- Returns:
- the project keywords
-
projectCreationDate
public static String projectCreationDate()
Returns the creation date of the current project- Returns:
- the creation date of the current project at the ISO format or empty otherwise
-
projectCreationDate
public static String projectCreationDate(String projectName)
Returns the creation date of the given project- Parameters:
projectName
- The project to consider- Returns:
- the creation date of the given project at the ISO format or empty otherwise
-
projectCategoryColor
public static MapElement projectCategoryColor()
Return the color associated to the first category associated to the current project- Returns:
- the hexa code color or the default color if no color is associated to the first category or if not category is associated. <color> <main>#FFFFFF</main> <text>#000000</text> </color>
-
projectCategoryColor
public static MapElement projectCategoryColor(String projectName)
Return the color associated to the first category associated to the given project- Parameters:
projectName
- The project to consider- Returns:
- the hexa code color or the default color if no color is associated to the first category or if not category is associated <color> <main>#FFFFFF</main> <text>#000000</text> </color>
-
categoryColor
public static MapElement categoryColor(String categoryId)
Return the color associated to the category- Parameters:
categoryId
- category id- Returns:
- the hexa code color or the default color if no color is associated to the category or if null <color> <main>#FFFFFF</main> <text>#000000</text> </color>
-
categoryColor
public static MapElement categoryColor(Category category)
Return the color associated to the category- Parameters:
category
- category- Returns:
- the hexa code color or the default color if no color is associated to the category or if null <color> <main>#FFFFFF</main> <text>#000000</text> </color>
-
projectCategoryLabel
public static String projectCategoryLabel()
Return the color associated to the first category associated to the current project- Returns:
- the hexa code color or the default color if no color is associated to the first category or if not category is associated
-
projectCategoryLabel
public static String projectCategoryLabel(String projectName)
Return the color associated to the first category associated to the given project- Parameters:
projectName
- The project to consider- Returns:
- the label or empty if no category
-
projectLastActivityDate
public static String projectLastActivityDate()
Get the date of last activity for current project- Returns:
- the formatted date of last activity or creation date if there is no activity yet
-
projectLastActivityDate
public static String projectLastActivityDate(String projectName)
Get the date of last activity for a given project- Parameters:
projectName
- the project's name- Returns:
- the formatted date of last activity or creation date if there is no activity yet
-
isResourceFromWorkspace
public static boolean isResourceFromWorkspace(String resourceId)
True if the resource comes from workspaces- Parameters:
resourceId
- the resource id- Returns:
- true if the resource comes from workspaces
-
resourceSite
public static Node resourceSite(String projectResourceId)
Get the site of a project's resource- Parameters:
projectResourceId
- The resource id- Returns:
- The site <site id="site://xxx" name="siteName"><title>Site's titleX</title><url>http://...</url>/site>
-
getNewsRootPageId
public static String getNewsRootPageId()
Get the id of news root's page- Returns:
- the id of news root's page or null if not exists
-
getAlertsRootPageId
public static String getAlertsRootPageId()
Get the id of alerts root's page- Returns:
- the id of alerts root's page or null if not exists
-
getModulePage
public static String getModulePage(String moduleId)
Get the module page. Be careful, the read access is not check !- Parameters:
moduleId
- the module id- Returns:
- the module page
-
getLanguageLabel
public static String getLanguageLabel(String code, String language)
Get the translated label associated to the code- Parameters:
code
- The language codelanguage
- The language in which translate the label- Returns:
- The label associated to the code
-
computeDefaultLanguage
public static String computeDefaultLanguage(String language)
Get the language that will be the default value of the available values. First choice will be the page language, 'en' otherwise, first available language otherwise.- Parameters:
language
- The current page language- Returns:
- A language code
-
isManager
public static boolean isManager()
Determines if the current user is a manager of current project- Returns:
- true if the current user is manager
-
isManager
public static boolean isManager(String login, String populationId)
Determines if a user is a manager- Parameters:
login
- the user's loginpopulationId
- the user's population- Returns:
- true if the user is manager
-
isManager
public static boolean isManager(String projectName)
Determines if the current user is a manager for the project- Parameters:
projectName
- the project's name- Returns:
- true if the current user is manager
-
isManager
public static boolean isManager(String projectName, String login, String populationId)
Determines if the given user is a manager for the project- Parameters:
projectName
- the project's namelogin
- the user's loginpopulationId
- the user's population- Returns:
- true if the user is manager
-
hasRightOnModule
public static boolean hasRightOnModule(String rightId, String moduleId)
Returns true if the current user has the specified right on the specified workspace module- Parameters:
rightId
- Right IdmoduleId
- Module Id- Returns:
- true if the current user has the specified right on the specified module
-
canAccessBO
public static boolean canAccessBO()
Returns true if current user can access to the back-office- Returns:
- true if current user can access to the back-office
-
-