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.
-
-
Field Summary
Fields Modifier and Type Field Description private static ActivityStreamClientInteraction
_activityStream
private static CategoryHelper
_categoryHelper
private static CategoryProviderExtensionPoint
_categoryProviderEP
private static Context
_context
private static CurrentUserProvider
_currentUserProvider
private static I18nUtils
_i18nUtils
private static KeywordsDAO
_keywordsDAO
private static LanguagesManager
_languagesManager
private static Logger
_logger
private static ProjectManager
_projectManager
private static RightManager
_rightManager
private static SiteManager
_siteManager
private static WorkspaceModuleExtensionPoint
_workspaceModuleEP
-
Constructor Summary
Constructors Constructor Description ProjectXsltHelper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static Map<String,String>
_categoryColor(Category category)
private static Category
_getFirstCategory(Project project)
private static Map<String,String>
_projectCategoryColor(Project project)
private static String
_projectCategoryLabel(Project project)
private static String
_projectCreationDate(Project project)
private static List<Map<String,String>>
_projectKeywords(Project project)
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)
-
-
-
Field Detail
-
_siteManager
private static SiteManager _siteManager
-
_projectManager
private static ProjectManager _projectManager
-
_categoryProviderEP
private static CategoryProviderExtensionPoint _categoryProviderEP
-
_categoryHelper
private static CategoryHelper _categoryHelper
-
_i18nUtils
private static I18nUtils _i18nUtils
-
_activityStream
private static ActivityStreamClientInteraction _activityStream
-
_languagesManager
private static LanguagesManager _languagesManager
-
_currentUserProvider
private static CurrentUserProvider _currentUserProvider
-
_workspaceModuleEP
private static WorkspaceModuleExtensionPoint _workspaceModuleEP
-
_rightManager
private static RightManager _rightManager
-
_keywordsDAO
private static KeywordsDAO _keywordsDAO
-
-
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
-
_projectCreationDate
private static String _projectCreationDate(Project project)
-
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>
-
_projectCategoryColor
private static Map<String,String> _projectCategoryColor(Project project)
-
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>
-
_categoryColor
private static Map<String,String> _categoryColor(Category category)
-
_getFirstCategory
private static Category _getFirstCategory(Project project)
-
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
-
_projectCategoryLabel
private static String _projectCategoryLabel(Project project)
-
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
-
-