Class ProjectManager

    • Method Detail

      • 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

        public List<ProjectgetProjects​(List<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<ProjectgetProjects​(List<String> filteredCategories,
                                         List<String> filteredKeywords,
                                         boolean matchesAny)
        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.
        matchesAny - true to get projects matching categories OR keywords
        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

        public Map<Project,​JCRProjectMember.MemberTypegetUserProjects​(UserIdentity user,
                                                                              List<String> filteredCategories,
                                                                              List<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
      • getManagedProjects

        public List<ProjectgetManagedProjects​(UserIdentity user,
                                                List<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.
      • 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
      • getUserProjectsData

        public List<Map<String,​Object>> 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,​ObjectsearchUserByProject​(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

        public List<Map<String,​Object>> 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
      • getProjectProperties

        public Map<String,​ObjectgetProjectProperties​(String projectId)
        Retrieves the standard information of a project
        Parameters:
        projectId - Identifier of the project
        Returns:
        The map of information
      • getProjectUrls

        public Set<StringgetProjectUrls​(Project project)
        Get the availables project URLs.
        Parameters:
        project - The project
        Returns:
        The availables project URLs, can be empty.
      • getProjectNames

        public Set<StringgetProjectNames​(Project project)
        Get the availables project names.
        Parameters:
        project - The project
        Returns:
        The availables project names, can be empty.
      • createProject

        public Map<String,​ObjectcreateProject​(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

        public Map<String,​ObjectdeleteProjectsByIds​(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).
      • 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<StringgetProjectsForSite​(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<ProjectgetProjectsForSite​(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 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<StringgetTags()
        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<StringgetPlaces()
        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

        public List<WorkspaceModulegetModules​(Project project)
        Get the list of activated modules for a project
        Parameters:
        project - The project
        Returns:
        The list of activated modules
      • getModulePages

        public Set<PagegetModulePages​(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
      • tagProjectPage

        public void tagProjectPage​(ModifiablePage page,
                                   ModifiableResourceCollection moduleRoot)
        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

        public void untagProjectPage​(ModifiablePage page,
                                     ModifiableResourceCollection moduleRoot)
        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<PagegetModulePages​(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

        public Map<String,​ObjectgetProjectProfiles()
        Get the list of profiles configured for the workspaces' projects
        Returns:
        The list of profiles as JSON
      • getTags

        public Set<StringgetTags​(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,​Objecttag​(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,​Objecttag​(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

        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
      • 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
      • clearCaches

        public void clearCaches()
        Clear the site cache
      • _createCaches

        protected void _createCaches()
        Creates the caches