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

Helper component for managing project workspaces
  • Field Details

  • Constructor Details

  • Method Details

    • contextualize

      public void contextualize(Context context) throws ContextException
      Specified by:
      contextualize in interface Contextualizable
      Throws:
      ContextException
    • service

      public void service(ServiceManager manager) throws ServiceException
      Specified by:
      service in interface Serviceable
      Throws:
      ServiceException
    • initialize

      public void initialize() throws Exception
      Specified by:
      initialize in interface Initializable
      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 interface PluginAware
      Parameters:
      pluginName - Unique identifier for the plugin hosting the extension
      featureName - Unique feature identifier (unique for a given pluginName)
      id - Unique identifier of this component
    • getProjects

      Retrieves all projects
      Returns:
      the projects
    • getProjects

      public AmetysObjectIterable<Project> getProjects(boolean onlyWorking)
      Retrieves all projects
      Parameters:
      onlyWorking - true to retrieve only working projects with non null sites
      Returns:
      the projects
    • getProjects

      public List<Project> getProjects(Set<String> filteredCategories)
      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 pattern
      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, 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 pattern
      anyMatch - true to get projects matching categories OR keywords OR pattern
      excludePrivate - 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

      public Project getProject(String projectName)
      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

      Get the user's projects filtered by categories
      Parameters:
      user - the user
      filteredCategories - 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 user
      filteredCategories - the filtered categories. Can be empty to no filter by categories
      filteredKeywords - 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 user
      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 pattern
      anyMatch - 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 user
      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 pattern
      anyMatch - true to get projects matching categories OR keywords OR pattern
      excludePrivate - 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

      public List<Project> getManagedProjects(UserIdentity user, Set<String> filteredCategories)
      Get the projects managed by the user
      Parameters:
      user - the user
      filteredCategories - the filtered categories. Can be empty to no filter by categories.
      Returns:
      the projects for which the user is a manager
    • 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.
    • getManagers

      Get all managers
      Returns:
      the managers
    • isManager

      public boolean isManager()
      Determines if the current user is a manager of at least one project
      Returns:
      true if the user is a manager
    • isManager

      public boolean isManager(UserIdentity user)
      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

      public boolean isManager(String projectName, UserIdentity user)
      Determines if the user is a manager of the project
      Parameters:
      projectName - the project name
      user - the user
      Returns:
      true if the user is a manager
    • isManager

      public boolean isManager(Project project, UserIdentity user)
      Determines if the user is a manager of the project
      Parameters:
      project - the project
      user - the user
      Returns:
      true if the user is a manager
    • canAccessBO

      public boolean canAccessBO(Project project)
      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
    • canLeaveProject

      public boolean canLeaveProject(Project project)
      Can the current user leave the project
      Parameters:
      project - The non null project to analyse
      Returns:
      true if the user can leave the project
    • 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 name
      limit - limit of request
      criteria - the criteria of the search
      previousSearchData - 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

      protected Map<String,Object> _project2json(Project project)
      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

      public String getProjectUrl(Project project, String defaultValue)
      Get the project URL.
      Parameters:
      project - The project
      defaultValue - 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 name
      title - The project title
      description - The project description
      emailList - Project mailing list
      inscriptionStatus - The inscription status of the project
      defaultProfile - 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 name
      title - The project title
      additionalValues - A list of optional additional values. Accepted values are : description, mailingList, inscriptionStatus, defaultProfile, tags, categoryTags, keywords and language
      modulesIds - The list of modules to activate. Can be null to activate all modules
      errors - 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 identifier
      title - The title to set
      description - The description to set
      mailingList - Project mailing list
      inscriptionStatus - The inscription status of the project
      defaultProfile - 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 project
      title - The title to set
      description - The description to set
      mailingList - Project mailing list
      inscriptionStatus - The inscription status of the project
      defaultProfile - 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

      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).
    • 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

      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

      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 created
      errors - 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

      public List<String> getTags()
      Get the project's tags
      Returns:
      The project's tags
    • setTags

      public void setTags(List<String> tags)
      Set the tags
      Parameters:
      tags - The tags to set
    • addTags

      public void addTags(Collection<String> newTags)
      Add project's tags
      Parameters:
      newTags - The new tags to add
    • getPlaces

      public List<String> getPlaces()
      Get the project's places
      Returns:
      The project's places
    • 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

      Get the list of activated modules for a project
      Parameters:
      project - The project
      Returns:
      The list of activated modules
    • getModulePages

      public Set<Page> getModulePages(Project project, String moduleId)
      Retrieves the page of the module for all available languages
      Parameters:
      project - The project
      moduleId - 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 change
      moduleRoot - 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 change
      moduleRoot - The workspace module that use this page
    • getModulePages

      public Set<Page> getModulePages(Project project, WorkspaceModule workspaceModule)
      Get a page in the site of a given project with a specific tag
      Parameters:
      project - The project
      workspaceModule - 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 project
      moduleIds - The list of modules. Can be null to activate all modules
      additionalValues - A list of optional additional values. Accepted values are : description, mailingList, inscriptionStatus, defaultProfile, tags, categoryTags, keywords and language
    • initializeModulesSitemap

      public void initializeModulesSitemap(Project project, Sitemap sitemap)
      Initialize the sitemap with the active module of the project
      Parameters:
      project - The project
      sitemap - The sitemap
    • isModuleActivated

      public boolean isModuleActivated(Project project, String moduleId)
      Determines if a module is activated
      Parameters:
      project - The project
      moduleId - 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 project
      moduleIds - 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

      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 ids
      tagNames - the tag names
      contextualParameters - 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 ids
      tagNames - the tag names
      mode - 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

      Get the site name holding the catalog of projects
      Returns:
      the catalog's site name
      Throws:
      ProjectManager.UnknownCatalogSiteException - when the config is invalid
    • getUsersDirectorySiteName

      Get the site name holding the users directory
      Returns:
      the users directory's site name
      Throws:
      ProjectManager.UnknownUserDirectorySiteException - when the config is invalid
    • supports

      public boolean supports(Event event)
      Description copied from interface: Observer
      Checks if the event is supported. If true, the observe(Event) method will be called.
      Specified by:
      supports in interface Observer
      Parameters:
      event - the event.
      Returns:
      true for observing this event, false otherwise.
    • getPriority

      public int getPriority(Event event)
      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 interface Observer
      Parameters:
      event - the event.
      Returns:
      the priority where 0 the max priority and Integer.MAX_VALUE the min priority.
    • observe

      public void observe(Event event, Map<String,Object> transientVars) throws Exception
      Description copied from interface: Observer
      Observes an event.
      Specified by:
      observe in interface Observer
      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

      public void setProjectSiteTitle(Site site, String title)
      Prefix project title
      Parameters:
      site - the site
      title - the title
    • checkRightsForProjectCreation

      public void checkRightsForProjectCreation(Project.InscriptionStatus inscriptionStatus, SitemapElement catalogPage)
      Check rights to create project
      Parameters:
      inscriptionStatus - the inscription status
      catalogPage - 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 project
      inscriptionStatus - the inscription status
      catalogPage - the catalog page where projects are created
    • clearCaches

      public void clearCaches()
      Clear the site cache
    • _createCaches

      protected void _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

      public boolean isUserInProjectPopulations(Project project, UserIdentity user)
      Check if the user is in one of the populations of project
      Parameters:
      project - the project
      user - the user
      Returns:
      true if the user is in one of the populations of project