Class ProjectManager
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.plugins.workspaces.project.ProjectManager
- All Implemented Interfaces:
Observer
,PluginAware
,Initializable
,Component
,Contextualizable
,LogEnabled
,Serviceable
public class ProjectManager
extends AbstractLogEnabled
implements Serviceable, Component, Contextualizable, PluginAware, Initializable, Observer
Helper component for managing project workspaces
-
Field Summary
Modifier and TypeFieldDescriptionprotected Context
Avalon contextprotected GroupDirectoryContextHelper
Helper for group directory's contextprotected I18nUtils
The i18n utils.protected WorkspaceModuleExtensionPoint
Module Managers EPprotected PopulationContextHelper
Helper for user populationprotected ProjectMemberManager
The project members' managerprotected AmetysObjectResolver
Ametys object resolverprotected SiteConfigurationManager
Site configuration managerprotected SiteDAO
Site DAOprotected SiteManager
Site managerstatic final String
static final String
static final String
static final String
static final String
static final String
Avalon RoleFields inherited from interface org.ametys.core.observation.Observer
MAX_PRIORITY, MIN_PRIORITY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Creates the cachesprotected Site
_createProjectWorkspace
(Project project, List<String> errors) Create the project workspace for a given project._project2json
(Project project) Get the project's main properties as json objectvoid
Activate the list of module of the projectvoid
addPlaces
(Collection<String> newPlaces) Add project's placesvoid
addTags
(Collection<String> newTags) Add project's tagsboolean
canAccessBO
(Project project) Can the current user access backoffice on the site of the current projectvoid
checkRightsForProjectCreation
(Project.InscriptionStatus inscriptionStatus, SitemapElement catalogPage) Check rights to create projectvoid
checkRightsForProjectEdition
(Project project, Project.InscriptionStatus inscriptionStatus, SitemapElement catalogPage) Check rights to edit projectvoid
Clear the site cachevoid
contextualize
(Context context) createProject
(String name, String title, String description, String emailList, String inscriptionStatus, String defaultProfile) Create a projectcreateProject
(String name, String title, Map<String, Object> additionalValues, Set<String> modulesIds, List<String> errors) Create a projectvoid
deactivateModules
(Project project, Set<String> moduleIds) Remove the explorer root node of the project module, remove all events related to that module and set it to deactivateddeleteProject
(List<Project> projects) Delete a project.deleteProject
(Project project) Delete a project and its sitesdeleteProjectsByIds
(List<String> ids) Delete a list of project.void
editProject
(String id, String title, String description, String mailingList, String inscriptionStatus, String defaultProfile) Edit a projectvoid
editProject
(Project project, String title, String description, String mailingList, String inscriptionStatus, String defaultProfile) Edit a projectGet the site name holding the catalog of projectsGet the projects managed by the usergetManagedProjects
(UserIdentity user, Set<String> filteredCategories) Get the projects managed by the userGet all managersgetModulePages
(Project project, String moduleId) Retrieves the page of the module for all available languagesgetModulePages
(Project project, WorkspaceModule workspaceModule) Get a page in the site of a given project with a specific taggetModules
(Project project) Get the list of activated modules for a projectGet the project of an ametys object inside a project.getParentProject
(AmetysObject object) Get the project of an ametys object inside a project.Get the project's placesint
getPriority
(Event event) Retrieves the priority to observe this event.
This can be used to process a supported event before others observers.getProject
(String projectName) Retrieves a project by its nameRetrieves the project namesGet the list of profiles configured for the workspaces' projectsgetProjectProperties
(String projectId) Retrieves the standard information of a projectgetProjectProperties
(Project project) Retrieves the standard information of a projectRetrieves all projectsgetProjects
(boolean onlyWorking) Retrieves all projectsgetProjects
(Set<String> filteredCategories) Retrieves projects filtered by categoriesgetProjects
(Set<String> filteredCategories, Set<String> filteredKeywords, boolean anyMatch) Retrieves projects filtered by categories and/or keywordsgetProjects
(Set<String> filteredCategories, Set<String> filteredKeywords, String pattern, boolean anyMatch) Retrieves projects filtered by categories and/or keywords and/or patterngetProjects
(Set<String> filteredCategories, Set<String> filteredKeywords, String pattern, boolean anyMatch, boolean excludePrivate) Retrieves projects filtered by categories and/or keywords and/or patternGet the projects categoriesRetrieves the mapping of all the projects name with their title (regarless user rights)Retrieves all projects for client sidegetProjectsForSite
(String siteName) Get the list of project names for a given sitegetProjectsForSite
(Site site) Get the list of project for a given siteGet the projects modulesReturn the root for projects The root node will be created if necessaryRetrieves all projects for client sideRetrieves all projects for client sidegetProjectStatistics
(Project project) Retrieves the standard information of a projectgetProjectUrl
(Project project, String defaultValue) Get the project URL.getTags()
Get the project's tagsGet the tags from the projectsgetUserProjects
(UserIdentity user) Get the user's projectsgetUserProjects
(UserIdentity user, Set<String> filteredCategories) Get the user's projects filtered by categoriesgetUserProjects
(UserIdentity user, Set<String> filteredCategories, Set<String> filteredKeywords) Get the user's projects filtered by categories OR keywordsgetUserProjects
(UserIdentity user, Set<String> filteredCategories, Set<String> filteredKeywords, String pattern, boolean anyMatch) Get the user's projects filtered by categories, keywords and/or patterngetUserProjects
(UserIdentity user, Set<String> filteredCategories, Set<String> filteredKeywords, String pattern, boolean anyMatch, boolean excludePrivate) Get the user's projects filtered by categories, keywords and/or patternGet the user's projects categoriesRetrieves the mapping of all the projects name with their title on which the current user has accessGet the projects modulesGet the site name holding the users directoryboolean
hasProject
(String projectName) Returns true if the given project exists.void
void
initializeModulesSitemap
(Project project, Sitemap sitemap) Initialize the sitemap with the active module of the projectboolean
Determines if the current user is a manager of at least one projectboolean
isManager
(String projectName, UserIdentity user) Determines if the user is a manager of the projectboolean
isManager
(UserIdentity user) Determines if the user is a manager of at least one projectboolean
isManager
(Project project, UserIdentity user) Determines if the user is a manager of the projectboolean
isModuleActivated
(Project project, String moduleId) Determines if a module is activatedboolean
isTagValid
(String tagName) Test if a tag is validboolean
isUserInProjectPopulations
(Project project, UserIdentity user) Check if the user is in one of the populations of projectvoid
Observes an event.pageToModuleRoot
(Page page) Return the possible module roots associated to a pagesearchUserByProject
(String projectName, int limit, String criteria, Map<String, Object> previousSearchData) Retrieves the users that have not been yet added to a project with a given criteriavoid
service
(ServiceManager manager) void
Set the placesvoid
setPluginInfo
(String pluginName, String featureName, String id) Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.void
setProjectSiteTitle
(Site site, String title) Prefix project titlevoid
Set the tagsboolean
Checks if the event is supported.tag
(List<String> projectIds, List<String> tagNames, String mode, Map<String, Object> contextualParameters) Tag the projectsTag the projectsvoid
tagProjectPage
(ModifiablePage page, ModifiableResourceCollection moduleRoot) Mark the given page as this module page.void
untagProjectPage
(ModifiablePage page, ModifiableResourceCollection moduleRoot) Remove the mark on the given page of this module.Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
ROLE
Avalon Role -
REQUEST_PROJECTBYID_CACHE
-
MEMORY_PROJECTIDBYNAMECACHE
-
REQUEST_PAGESBYPROJECTANDMODULE_CACHE
-
MEMORY_PAGESBYIDCACHE
-
MEMORY_SITEASSOCIATION_CACHE
-
_resolver
Ametys object resolver -
_i18nUtils
The i18n utils. -
_siteManager
Site manager -
_siteDao
Site DAO -
_siteConfigurationManager
Site configuration manager -
_moduleManagerEP
Module Managers EP -
_populationContextHelper
Helper for user population -
_groupDirectoryContextHelper
Helper for group directory's context -
_projectMemberManager
The project members' manager -
_context
Avalon context
-
-
Constructor Details
-
ProjectManager
public ProjectManager()
-
-
Method Details
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
setPluginInfo
Description copied from interface:PluginAware
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.- Specified by:
setPluginInfo
in interfacePluginAware
- Parameters:
pluginName
- Unique identifier for the plugin hosting the extensionfeatureName
- Unique feature identifier (unique for a given pluginName)id
- Unique identifier of this component
-
getProjects
Retrieves all projects- Returns:
- the projects
-
getProjects
Retrieves all projects- Parameters:
onlyWorking
- true to retrieve only working projects with non null sites- Returns:
- the projects
-
getProjects
Retrieves projects filtered by categories- Parameters:
filteredCategories
- the filtered categories. Can be empty to no filter by categories.- Returns:
- the projects
-
getProjects
public List<Project> getProjects(Set<String> filteredCategories, Set<String> filteredKeywords, boolean anyMatch) Retrieves projects filtered by categories and/or keywords- Parameters:
filteredCategories
- the filtered categories. Can be empty to no filter by categories.filteredKeywords
- the filtered keywords. Can be empty to no filter by keywords.anyMatch
- true to get projects matching categories OR keywords OR pattern- Returns:
- the projects
-
getProjects
public List<Project> getProjects(Set<String> filteredCategories, Set<String> filteredKeywords, String pattern, boolean anyMatch) Retrieves projects filtered by categories and/or keywords and/or pattern- Parameters:
filteredCategories
- the filtered categories. Can be empty to no filter by categories.filteredKeywords
- the filtered keywords. Can be empty to no filter by keywords.pattern
- to filter on pattern. Can be null or empty to no filter on patternanyMatch
- true to get projects matching categories OR keywords OR pattern- Returns:
- the projects
-
getProjects
public List<Project> getProjects(Set<String> filteredCategories, Set<String> filteredKeywords, String pattern, boolean anyMatch, boolean excludePrivate) Retrieves projects filtered by categories and/or keywords and/or pattern- Parameters:
filteredCategories
- the filtered categories. Can be empty to no filter by categories.filteredKeywords
- the filtered keywords. Can be empty to no filter by keywords.pattern
- to filter on pattern. Can be null or empty to no filter on patternanyMatch
- true to get projects matching categories OR keywords OR patternexcludePrivate
- true to exclude private projects- Returns:
- the projects
-
getProjectsCategories
Get the projects categories- Returns:
- the projects categories
-
getUserProjectsCategories
Get the user's projects categories- Parameters:
user
- the user- Returns:
- the user's projects categories
-
getProjectsModules
Get the projects modules- Returns:
- the projects modules
-
getUserProjectsModules
Get the projects modules- Parameters:
user
- the user- Returns:
- the projects modules
-
getProjectsForClientSide
Retrieves all projects for client side- Returns:
- the projects
-
getProject
Retrieves a project by its name- Parameters:
projectName
- The project name- Returns:
- the project or
null
if not found
-
getUserProjects
Get the user's projects- Parameters:
user
- the user- Returns:
- the user's projects
-
getUserProjects
public Map<Project,JCRProjectMember.MemberType> getUserProjects(UserIdentity user, Set<String> filteredCategories) Get the user's projects filtered by categories- Parameters:
user
- the userfilteredCategories
- the filtered categories. Can be empty to no filter by categories- Returns:
- the user's projects
-
getUserProjects
public Map<Project,JCRProjectMember.MemberType> getUserProjects(UserIdentity user, Set<String> filteredCategories, Set<String> filteredKeywords) Get the user's projects filtered by categories OR keywords- Parameters:
user
- the userfilteredCategories
- the filtered categories. Can be empty to no filter by categoriesfilteredKeywords
- the filtered keywords. Can be empty to no filter by keywords- Returns:
- the user's projects
-
getUserProjects
public Map<Project,JCRProjectMember.MemberType> getUserProjects(UserIdentity user, Set<String> filteredCategories, Set<String> filteredKeywords, String pattern, boolean anyMatch) Get the user's projects filtered by categories, keywords and/or pattern- Parameters:
user
- the userfilteredCategories
- the filtered categories. Can be empty to no filter by categories.filteredKeywords
- the filtered keywords. Can be empty to no filter by keywords.pattern
- to filter on pattern. Can be null or empty to no filter on patternanyMatch
- true to get projects matching categories OR keywords OR pattern- Returns:
- the user's projects
-
getUserProjects
public Map<Project,JCRProjectMember.MemberType> getUserProjects(UserIdentity user, Set<String> filteredCategories, Set<String> filteredKeywords, String pattern, boolean anyMatch, boolean excludePrivate) Get the user's projects filtered by categories, keywords and/or pattern- Parameters:
user
- the userfilteredCategories
- the filtered categories. Can be empty to no filter by categories.filteredKeywords
- the filtered keywords. Can be empty to no filter by keywords.pattern
- to filter on pattern. Can be null or empty to no filter on patternanyMatch
- true to get projects matching categories OR keywords OR patternexcludePrivate
- true to exclude private projects- Returns:
- the user's projects
-
getManagedProjects
Get the projects managed by the user- Parameters:
user
- the user- Returns:
- the projects for which the user is a manager
-
getManagedProjects
Get the projects managed by the user- Parameters:
user
- the userfilteredCategories
- the filtered categories. Can be empty to no filter by categories.- Returns:
- the projects for which the user is a manager
-
hasProject
Returns true if the given project exists.- Parameters:
projectName
- the project name.- Returns:
- true if the given project exists.
-
getManagers
Get all managers- Returns:
- the managers
-
isManager
Determines if the current user is a manager of at least one project- Returns:
- true if the user is a manager
-
isManager
Determines if the user is a manager of at least one project- Parameters:
user
- the user- Returns:
- true if the user is a manager
-
isManager
Determines if the user is a manager of the project- Parameters:
projectName
- the project nameuser
- the user- Returns:
- true if the user is a manager
-
isManager
Determines if the user is a manager of the project- Parameters:
project
- the projectuser
- the user- Returns:
- true if the user is a manager
-
canAccessBO
Can the current user access backoffice on the site of the current project- Parameters:
project
- The non null project to analyse- Returns:
- true if the user can access to the backoffice
-
getUserProjectsData
Retrieves the mapping of all the projects name with their title on which the current user has access- Returns:
- the map (projectName, projectTitle) for all projects
-
searchUserByProject
public Map<String,Object> searchUserByProject(String projectName, int limit, String criteria, Map<String, Object> previousSearchData) Retrieves the users that have not been yet added to a project with a given criteria- Parameters:
projectName
- the project namelimit
- limit of requestcriteria
- the criteria of the searchpreviousSearchData
- the previous search data to compute offset. Null if first search- Returns:
- list of users
-
getProjectsData
Retrieves the mapping of all the projects name with their title (regarless user rights)- Returns:
- the map (projectName, projectTitle) for all projects
-
_project2json
Get the project's main properties as json object- Parameters:
project
- the project- Returns:
- the json representation of project
-
getProjectNames
Retrieves the project names- Returns:
- the project names
-
getProjectsRoot
Return the root for projects The root node will be created if necessary- Returns:
- The root for projects
-
getProjectProperties
Retrieves the standard information of a project- Parameters:
projectId
- Identifier of the project- Returns:
- The map of information
-
getProjectProperties
Retrieves the standard information of a project- Parameters:
project
- The project- Returns:
- The map of information
-
getProjectUrl
Get the project URL.- Parameters:
project
- The projectdefaultValue
- The default value to use if there is no site- Returns:
- The project URL if a site is configured, otherwise return the default value.
-
createProject
public Map<String,Object> createProject(String name, String title, String description, String emailList, String inscriptionStatus, String defaultProfile) Create a project- Parameters:
name
- The project nametitle
- The project titledescription
- The project descriptionemailList
- Project mailing listinscriptionStatus
- The inscription status of the projectdefaultProfile
- The default profile for new members- Returns:
- A map containing the id of the new project or an error key.
-
createProject
public Project createProject(String name, String title, Map<String, Object> additionalValues, Set<String> modulesIds, List<String> errors) Create a project- Parameters:
name
- The project nametitle
- The project titleadditionalValues
- A list of optional additional values. Accepted values are : description, mailingList, inscriptionStatus, defaultProfile, tags, categoryTags, keywords and languagemodulesIds
- The list of modules to activate. Can be null to activate all moduleserrors
- A list that will be populated with the encountered errors. If null, errors will not be tracked.- Returns:
- The id of the new project
-
editProject
public void editProject(String id, String title, String description, String mailingList, String inscriptionStatus, String defaultProfile) Edit a project- Parameters:
id
- The project identifiertitle
- The title to setdescription
- The description to setmailingList
- Project mailing listinscriptionStatus
- The inscription status of the projectdefaultProfile
- The default profile for new members
-
editProject
public void editProject(Project project, String title, String description, String mailingList, String inscriptionStatus, String defaultProfile) Edit a project- Parameters:
project
- The projecttitle
- The title to setdescription
- The description to setmailingList
- Project mailing listinscriptionStatus
- The inscription status of the projectdefaultProfile
- The default profile for new members
-
deleteProjectsByIds
Delete a list of project.- Parameters:
ids
- The ids of projects to delete- Returns:
- The ids of the deleted projects, unknowns projects and the deleted sites
-
deleteProject
Delete a project.- Parameters:
projects
- The list of projects to delete- Returns:
- list of deleted sites (each list entry contains a data map with the id and the name of the delete site).
-
deleteProject
Delete a project and its sites- Parameters:
project
- The project to delete- Returns:
- list of deleted sites (each list entry contains a data map with the id and the name of the delete site).
-
getParentProject
Get the project of an ametys object inside a project. It can be an explorer node, or any type of resource in a module.- Parameters:
id
- The identifier of the ametys object- Returns:
- the project or null if not found
-
getParentProject
Get the project of an ametys object inside a project. It can be an explorer node, or any type of resource in a module.- Parameters:
object
- The ametys object- Returns:
- the project or null if not found
-
getProjectsForSite
Get the list of project names for a given site- Parameters:
siteName
- The site name- Returns:
- the list of project names
-
getProjectsForSite
Get the list of project for a given site- Parameters:
site
- The site- Returns:
- the list of project
-
_createProjectWorkspace
Create the project workspace for a given project.- Parameters:
project
- The project for which the workspace must be createderrors
- A list of possible errors to populate. Can be null if the caller is not interested in error tracking.- Returns:
- The site created for this workspace
-
getTags
Get the project's tags- Returns:
- The project's tags
-
setTags
Set the tags- Parameters:
tags
- The tags to set
-
addTags
Add project's tags- Parameters:
newTags
- The new tags to add
-
getPlaces
Get the project's places- Returns:
- The project's places
-
addPlaces
Add project's places- Parameters:
newPlaces
- The new places to add
-
setPlaces
Set the places- Parameters:
places
- The places to set
-
getModules
Get the list of activated modules for a project- Parameters:
project
- The project- Returns:
- The list of activated modules
-
getModulePages
Retrieves the page of the module for all available languages- Parameters:
project
- The projectmoduleId
- The project module id- Returns:
- the page or null if not found
-
pageToModuleRoot
Return the possible module roots associated to a page- Parameters:
page
- The given page- Returns:
- A non null set of the data of the linked modules
-
tagProjectPage
Mark the given page as this module page. The modified page will not be saved.- Parameters:
page
- The page to changemoduleRoot
- The workspace module that use this page
-
untagProjectPage
Remove the mark on the given page of this module. The modified page will not be saved.- Parameters:
page
- The page to changemoduleRoot
- The workspace module that use this page
-
getModulePages
Get a page in the site of a given project with a specific tag- Parameters:
project
- The projectworkspaceModule
- the module- Returns:
- The module's pages
-
activateModules
public void activateModules(Project project, Set<String> moduleIds, Map<String, Object> additionalValues) Activate the list of module of the project- Parameters:
project
- The projectmoduleIds
- The list of modules. Can be null to activate all modulesadditionalValues
- A list of optional additional values. Accepted values are : description, mailingList, inscriptionStatus, defaultProfile, tags, categoryTags, keywords and language
-
initializeModulesSitemap
Initialize the sitemap with the active module of the project- Parameters:
project
- The projectsitemap
- The sitemap
-
isModuleActivated
Determines if a module is activated- Parameters:
project
- The projectmoduleId
- The id of module- Returns:
- true if the module the currently activated
-
deactivateModules
Remove the explorer root node of the project module, remove all events related to that module and set it to deactivated- Parameters:
project
- The projectmoduleIds
- The id of module to activate
-
getProjectProfiles
Get the list of profiles configured for the workspaces' projects- Returns:
- The list of profiles as JSON
-
getTags
Get the tags from the projects- Parameters:
projectIds
- The ids of the projects- Returns:
- the tags of the projects
-
tag
public Map<String,Object> tag(List<String> projectIds, List<String> tagNames, Map<String, Object> contextualParameters) Tag the projects- Parameters:
projectIds
- the project idstagNames
- the tag namescontextualParameters
- the contextuals parameters- Returns:
- results
-
tag
public Map<String,Object> tag(List<String> projectIds, List<String> tagNames, String mode, Map<String, Object> contextualParameters) Tag the projects- Parameters:
projectIds
- the project idstagNames
- the tag namesmode
- the mode The mode for updating tags: 'REPLACE' to replace tags, 'INSERT' to add tags or 'REMOVE' to remove tags.contextualParameters
- the contextual parameters- Returns:
- results
-
isTagValid
Test if a tag is valid- Parameters:
tagName
- The tag name- Returns:
- True if the tag is valid
-
getCatalogSiteName
Get the site name holding the catalog of projects- Returns:
- the catalog's site name
-
getUsersDirectorySiteName
Get the site name holding the users directory- Returns:
- the users directory's site name
-
supports
Description copied from interface:Observer
Checks if the event is supported. If true, the observe(Event) method will be called. -
getPriority
Description copied from interface:Observer
Retrieves the priority to observe this event.
This can be used to process a supported event before others observers.- Specified by:
getPriority
in interfaceObserver
- Parameters:
event
- the event.- Returns:
- the priority where 0 the max priority and Integer.MAX_VALUE the min priority.
-
observe
Description copied from interface:Observer
Observes an event.- Specified by:
observe
in interfaceObserver
- Parameters:
event
- the event.transientVars
- transientVars passed from one Observer to another when processing a single Event. This may allow optimizations between observers.- Throws:
Exception
- if an error occurs. All exceptions will be logged but not propagated, as the observation mechanism should never fail.
-
setProjectSiteTitle
Prefix project title- Parameters:
site
- the sitetitle
- the title
-
checkRightsForProjectCreation
public void checkRightsForProjectCreation(Project.InscriptionStatus inscriptionStatus, SitemapElement catalogPage) Check rights to create project- Parameters:
inscriptionStatus
- the inscription statuscatalogPage
- the catalog page where projects are created
-
checkRightsForProjectEdition
public void checkRightsForProjectEdition(Project project, Project.InscriptionStatus inscriptionStatus, SitemapElement catalogPage) Check rights to edit project- Parameters:
project
- the projectinscriptionStatus
- the inscription statuscatalogPage
- the catalog page where projects are created
-
clearCaches
Clear the site cache -
_createCaches
Creates the caches -
getProjectsStatisticsForClientSide
Retrieves all projects for client side- Returns:
- the projects
-
getProjectStatistics
Retrieves the standard information of a project- Parameters:
project
- The project- Returns:
- The map of information
-
getProjectsStatisticsColumnsModel
Retrieves all projects for client side- Returns:
- the projects
-
isUserInProjectPopulations
Check if the user is in one of the populations of project- Parameters:
project
- the projectuser
- the user- Returns:
- true if the user is in one of the populations of project
-