Class ProjectManager
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.plugins.workspaces.project.ProjectManager
-
- All Implemented Interfaces:
PluginAware
,Initializable
,Component
,Contextualizable
,LogEnabled
,Serviceable
public class ProjectManager extends AbstractLogEnabled implements Serviceable, Component, Contextualizable, PluginAware, Initializable
Helper component for managing project workspaces
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ProjectManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Site
_createProjectWorkspace(Project project, List<String> errors)
Create the project workspace for a given project.private Cache<String,List<Pair<String,String>>>
_getCache()
private <A extends AmetysObject>
A_getOrCreateObject(ModifiableTraversableAmetysObject parent, String name, String type)
Utility method to get or create an ametys objectprivate Set<String>
_getProjectNonEmptyElements(Project project, Function<? super Site,? extends String> function)
private Map<String,Object>
_tag2json(Tag tag)
void
activateModules(Project project, Set<String> moduleIds)
Activate the list of module of the projectvoid
addPlaces(Collection<String> newPlaces)
Add project's placesvoid
addTags(Collection<String> newTags)
Add project's tagsvoid
contextualize(Context context)
Map<String,Object>
createProject(String name, String title, String description, String emailList, String inscriptionStatus, String defaultProfile)
Create a projectProject
createProject(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 deactivatedList<Map<String,String>>
deleteProject(List<Project> projects)
Delete a project.List<Map<String,String>>
deleteProject(Project project)
Delete a project and its sitesMap<String,Object>
deleteProjectsByIds(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 projectString
getCatalogSiteName()
Get the site name holding the catalog of projectsAmetysObjectIterable<Page>
getModulePages(Project project, String moduleId, String language)
Retrieves the page of the module for all available languagesList<WorkspaceModule>
getModules(Project project)
Get the list of activated modules for a projectProject
getParentProject(String id)
Get the project of an ametys object inside a project.Project
getParentProject(AmetysObject object)
Get the project of an ametys object inside a project.List<String>
getPlaces()
Get the project's placesProject
getProject(String name)
Retrieves a project by its nameAmetysObjectIterable<Page>
getProjectDashboardPage(Project project, String language)
Get the dashboard page in the site of a given projectCollection<String>
getProjectNames()
Retrieves the project namesSet<String>
getProjectNames(Project project)
Get the availables project names.AmetysObjectIterable<Page>
getProjectPages(Project project, String tagName, String language)
Get a page in the site of a given project with a specific tagMap<String,Object>
getProjectProfiles()
Get the list of profiles configured for the workspaces' projectsMap<String,Object>
getProjectProperties(String projectId)
Retrieves the standard information of a projectMap<String,Object>
getProjectProperties(Project project)
Retrieves the standard information of a projectAmetysObjectIterable<Project>
getProjects()
Retrieves all projectsList<Map<String,String>>
getProjectsData()
Retrieves the mapping of all the projects name with their title (regarless user rights)List<Map<String,Object>>
getProjectsForClientSide()
Retrieves all projects for client sideList<String>
getProjectsForSite(String siteName)
Get the list of project names for a given siteList<Project>
getProjectsForSite(Site site)
Get the list of project for a given siteModifiableTraversableAmetysObject
getProjectsRoot()
Return the root for projects The root node will be created if necessarySet<String>
getProjectUrls(Project project)
Get the availables project URLs.List<String>
getTags()
Get the project's tagsSet<String>
getTags(List<String> projectIds)
Get the tags from the projectsList<Project>
getUserProjects(UserIdentity user)
Get the user's projectsList<Map<String,String>>
getUserProjectsData()
Retrieves the mapping of all the projects name with their title on which the current user has accessString
getUsersDirectorySiteName()
Get the site name holding the users directoryboolean
hasProject(String projectName)
Returns true if the given project exists.void
initialize()
void
initializeModulesSitemap(Project project, Sitemap sitemap)
Initialize the sitemap with the active module of the projectboolean
isModuleActivated(Project project, String moduleId)
Determines if a module is activatedboolean
isTagValid(String tagName)
Test if a tag is validvoid
service(ServiceManager manager)
void
setPlaces(List<String> places)
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
setTags(List<String> tags)
Set the tagsMap<String,Object>
tag(List<String> projectIds, List<String> tagNames, String mode, Map<String,Object> contextualParameters)
Tag the projectsMap<String,Object>
tag(List<String> projectIds, List<String> tagNames, Map<String,Object> contextualParameters)
Tag the projects-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
__WORKSPACES_PLUGIN_NODE_NAME
private static final String __WORKSPACES_PLUGIN_NODE_NAME
Workspaces plugin node name- See Also:
- Constant Field Values
-
__WORKSPACES_PLUGIN_NODE_TYPE
private static final String __WORKSPACES_PLUGIN_NODE_TYPE
Workspaces plugin node name- See Also:
- Constant Field Values
-
__PROJECTS_ROOT_NODE_NAME
private static final String __PROJECTS_ROOT_NODE_NAME
The name of the projects root node- See Also:
- Constant Field Values
-
__PROJECTS_ROOT_NODE_TYPE
private static final String __PROJECTS_ROOT_NODE_TYPE
The type of the projects root node- See Also:
- Constant Field Values
-
__PROJECTS_TAGS_PROPERTY
private static final String __PROJECTS_TAGS_PROPERTY
Constants for tags metadata- See Also:
- Constant Field Values
-
__PROJECTS_PLACES_PROPERTY
private static final String __PROJECTS_PLACES_PROPERTY
Constants for places metadata- See Also:
- Constant Field Values
-
_resolver
protected AmetysObjectResolver _resolver
Ametys object resolver
-
_i18nUtils
protected I18nUtils _i18nUtils
The i18n utils.
-
_siteManager
protected SiteManager _siteManager
Site manager
-
_siteConfigurationManager
protected SiteConfigurationManager _siteConfigurationManager
Site configuration manager
-
_moduleManagerEP
protected WorkspaceModuleExtensionPoint _moduleManagerEP
Module Managers EP
-
_observationManager
private ObservationManager _observationManager
-
_currentUserProvider
private CurrentUserProvider _currentUserProvider
-
_projectMembers
private ProjectMemberManager _projectMembers
-
_pluginName
private String _pluginName
-
_projectRightHelper
private ProjectRightHelper _projectRightHelper
-
_projectTagProviderEP
private ProjectTagProviderExtensionPoint _projectTagProviderEP
-
_categoryProviderEP
private CategoryProviderExtensionPoint _categoryProviderEP
-
_userHelper
private UserHelper _userHelper
-
_cacheManager
private AbstractCacheManager _cacheManager
-
-
Constructor Detail
-
ProjectManager
public ProjectManager()
-
-
Method Detail
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
setPluginInfo
public void setPluginInfo(String pluginName, String featureName, String id)
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
public AmetysObjectIterable<Project> getProjects()
Retrieves all projects- Returns:
- the projects
-
getProjectsForClientSide
public List<Map<String,Object>> getProjectsForClientSide()
Retrieves all projects for client side- Returns:
- the projects
-
getProject
public Project getProject(String name)
Retrieves a project by its name- Parameters:
name
- The project name- Returns:
- the project or
null
if not found
-
getUserProjects
public List<Project> getUserProjects(UserIdentity user)
Get the user's projects- Parameters:
user
- the user- Returns:
- the user's projects
-
hasProject
public boolean hasProject(String projectName)
Returns true if the given project exists.- Parameters:
projectName
- the project name.- Returns:
- true if the given project exists.
-
getUserProjectsData
public List<Map<String,String>> 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
-
getProjectsData
public List<Map<String,String>> getProjectsData()
Retrieves the mapping of all the projects name with their title (regarless user rights)- Returns:
- the map (projectName, projectTitle) for all projects
-
getProjectNames
public Collection<String> getProjectNames()
Retrieves the project names- Returns:
- the project names
-
getProjectsRoot
public ModifiableTraversableAmetysObject getProjectsRoot()
Return the root for projects The root node will be created if necessary- Returns:
- The root for projects
-
getProjectProperties
public Map<String,Object> getProjectProperties(String projectId)
Retrieves the standard information of a project- Parameters:
projectId
- Identifier of the project- Returns:
- The map of information
-
getProjectProperties
public Map<String,Object> getProjectProperties(Project project)
Retrieves the standard information of a project- Parameters:
project
- The project- Returns:
- The map of information
-
getProjectUrls
public Set<String> getProjectUrls(Project project)
Get the availables project URLs.- Parameters:
project
- The project- Returns:
- The availables project URLs, can be empty.
-
getProjectNames
public Set<String> getProjectNames(Project project)
Get the availables project names.- Parameters:
project
- The project- Returns:
- The availables project names, can be empty.
-
_getProjectNonEmptyElements
private Set<String> _getProjectNonEmptyElements(Project project, Function<? super Site,? extends String> function)
-
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 and keywordsmodulesIds
- 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
public Map<String,Object> deleteProjectsByIds(List<String> ids)
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
public List<Map<String,String>> deleteProject(List<Project> projects)
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
public List<Map<String,String>> deleteProject(Project project)
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).
-
_getOrCreateObject
private <A extends AmetysObject> A _getOrCreateObject(ModifiableTraversableAmetysObject parent, String name, String type) throws AmetysRepositoryException
Utility method to get or create an ametys object- Type Parameters:
A
- A sub class of AmetysObject- Parameters:
parent
- The parent objectname
- The ametys object nametype
- The ametys object type- Returns:
- ametys object
- Throws:
AmetysRepositoryException
- if an repository error occurs
-
getParentProject
public Project getParentProject(String id)
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
public Project getParentProject(AmetysObject object)
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
public List<String> getProjectsForSite(String siteName)
Get the list of project names for a given site- Parameters:
siteName
- The site name- Returns:
- the list of project names
-
getProjectsForSite
public List<Project> getProjectsForSite(Site site)
Get the list of project for a given site- Parameters:
site
- The site- Returns:
- the list of project
-
_createProjectWorkspace
protected Site _createProjectWorkspace(Project project, List<String> errors)
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
-
addTags
public void addTags(Collection<String> newTags)
Add project's tags- Parameters:
newTags
- The new tags to add
-
addPlaces
public void addPlaces(Collection<String> newPlaces)
Add project's places- Parameters:
newPlaces
- The new places to add
-
setPlaces
public void setPlaces(List<String> places)
Set the places- Parameters:
places
- The places to set
-
getModules
public List<WorkspaceModule> getModules(Project project)
Get the list of activated modules for a project- Parameters:
project
- The project- Returns:
- The list of activated modules
-
getModulePages
public AmetysObjectIterable<Page> getModulePages(Project project, String moduleId, String language)
Retrieves the page of the module for all available languages- Parameters:
project
- The projectmoduleId
- The project module idlanguage
- the sitemap language ornull
for all sitemap languages.- Returns:
- the page or null if not found
-
getProjectPages
public AmetysObjectIterable<Page> getProjectPages(Project project, String tagName, String language)
Get a page in the site of a given project with a specific tag- Parameters:
project
- The projecttagName
- The name of the taglanguage
- the sitemap language ornull
for all sitemap languages.- Returns:
- The module's pages
-
getProjectDashboardPage
public AmetysObjectIterable<Page> getProjectDashboardPage(Project project, String language)
Get the dashboard page in the site of a given project- Parameters:
project
- The projectlanguage
- the sitemap language ornull
for all sitemap languages.- Returns:
- The module's dashboard pages
-
activateModules
public void activateModules(Project project, Set<String> moduleIds)
Activate the list of module of the project- Parameters:
project
- The projectmoduleIds
- The list of modules. Can be null to activate all modules
-
initializeModulesSitemap
public void initializeModulesSitemap(Project project, Sitemap sitemap)
Initialize the sitemap with the active module of the project- Parameters:
project
- The projectsitemap
- The sitemap
-
isModuleActivated
public boolean isModuleActivated(Project project, String moduleId)
Determines if a module is activated- Parameters:
project
- The projectmoduleId
- The id of module- Returns:
- true if the module the currently activated
-
deactivateModules
public void 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 deactivated- Parameters:
project
- The projectmoduleIds
- The id of module to activate
-
getProjectProfiles
public Map<String,Object> getProjectProfiles()
Get the list of profiles configured for the workspaces' projects- Returns:
- The list of profiles as JSON
-
getTags
public Set<String> getTags(List<String> projectIds)
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
public boolean isTagValid(String tagName)
Test if a tag is valid- Parameters:
tagName
- The tag name- Returns:
- True if the tag is valid
-
getCatalogSiteName
public String getCatalogSiteName()
Get the site name holding the catalog of projects- Returns:
- the catalog's site name
-
getUsersDirectorySiteName
public String getUsersDirectorySiteName()
Get the site name holding the users directory- Returns:
- the users directory's site name
-
-