Class WorkspaceManager


  • public final class WorkspaceManager
    extends java.lang.Object
    A manager for Workspace that provides utility methods.
    Author:
    Jean-Philippe Encausse
    • Field Detail

      • MAIL_PATTERN_INFO

        public static final java.lang.String MAIL_PATTERN_INFO
        An extraInfo that stores the Workspace Incoming Mail pattern if any.
        Since:
        jcms-9.0.0
        See Also:
        Constant Field Values
    • Method Detail

      • deepDuplicate

        @Deprecated
        public static WorkspaceWizardContext deepDuplicate​(Workspace model,
                                                           Member author,
                                                           java.lang.String prefix,
                                                           java.lang.String title)
        Deprecated.
        Deep duplicate the Workspace model using given configuration for duplication. Then returns the context with correctly filled binding maps.
        Parameters:
        model - the Workspace to duplicate
        author - the author of all duplication
        prefix - the prefix to use on all duplicated items
        title - the new workspace title
        Returns:
        WorkspaceWizardContext the filled context
      • deepDuplicate

        public static WorkspaceWizardContext deepDuplicate​(Workspace model,
                                                           Member author,
                                                           java.lang.String prefix,
                                                           java.lang.String title,
                                                           java.util.Map<java.lang.String,​java.lang.String> titleML)
        Deep duplicate the Workspace model using given configuration for duplication. Then returns the context with correctly filled binding maps.
        Parameters:
        model - the Workspace to duplicate
        author - the author of all duplication
        prefix - the prefix to use on all duplicated items
        title - the new workspace title
        titleML - the multilingual workspace titles
        Returns:
        WorkspaceWizardContext the filled context
        Since:
        jcms-9.0.0
      • deepDuplicate

        @Deprecated
        public static WorkspaceWizardContext deepDuplicate​(Workspace model,
                                                           Member author,
                                                           java.lang.String prefix,
                                                           java.lang.String title,
                                                           boolean collaborativeSpace)
        Deprecated.
        Deep duplicate the Workspace model using given configuration for duplication. Then returns the context with correctly filled binding maps.
        Parameters:
        model - the Workspace to duplicate
        author - the author of all duplication
        prefix - the prefix to use on all duplicated items
        title - the new workspace title
        collaborativeSpace - tell if the duplication is to create a collaborative space
        Returns:
        WorkspaceWizardContext the filled context
      • deepDuplicate

        @Deprecated
        public static WorkspaceWizardContext deepDuplicate​(Workspace model,
                                                           Member author,
                                                           java.lang.String prefix,
                                                           java.lang.String title,
                                                           java.lang.String wsemail,
                                                           java.util.List adminList,
                                                           java.util.Collection typeCollec,
                                                           java.util.Collection catCollec,
                                                           java.util.Collection groupCollec,
                                                           java.util.Collection portalCollec,
                                                           boolean collaborativeSpace)
        Deprecated.
        Deep duplicate the Workspace model using given configuration for duplication. Then returns the context with correctly filled binding maps.
        Parameters:
        model - the Workspace to duplicate
        author - the author of all duplication
        prefix - the prefix to use on all duplicated items
        title - the workspace title
        wsemail - the workspace email
        adminList - a List of workspace administrators
        typeCollec - a Set of classes to define WSTypeEntry to retrieve from model
        catCollec - Workspace root categories to duplicate
        groupCollec - to duplicate
        portalCollec - to duplicate
        collaborativeSpace - tell if the duplication is to create a collaborative space
        Returns:
        WorkspaceWizardContext the filled context
      • deepDuplicate

        public static WorkspaceWizardContext deepDuplicate​(Workspace model,
                                                           Member author,
                                                           java.lang.String prefix,
                                                           java.lang.String title,
                                                           java.util.Map<java.lang.String,​java.lang.String> titleML,
                                                           java.lang.String wsemail,
                                                           java.util.List adminList,
                                                           java.util.Collection typeCollec,
                                                           java.util.Collection catCollec,
                                                           java.util.Collection groupCollec,
                                                           java.util.Collection portalCollec,
                                                           boolean collaborativeSpace)
        Deep duplicate the Workspace model using given configuration for duplication. Then returns the context with correctly filled binding maps.
        Parameters:
        model - the Workspace to duplicate
        author - the author of all duplication
        prefix - the prefix to use on all duplicated items
        title - the workspace title
        titleML - the multilingual workspace titles
        wsemail - the workspace email
        adminList - a List of workspace administrators
        typeCollec - a Set of classes to define WSTypeEntry to retrieve from model
        catCollec - Workspace root categories to duplicate
        groupCollec - to duplicate
        portalCollec - to duplicate
        collaborativeSpace - tell if the duplication is to create a collaborative space
        Returns:
        WorkspaceWizardContext the filled context
        Since:
        jcms-9.0.0
      • deepDuplicate

        @Deprecated
        public static WorkspaceWizardContext deepDuplicate​(Workspace model,
                                                           Member author,
                                                           java.lang.String prefix,
                                                           java.lang.String title,
                                                           Workspace parent)
        Deprecated.
        Deep duplicate the Workspace model using given configuration for duplication. Then returns the context with correctly filled binding maps.
        Parameters:
        model - the Workspace to duplicate
        author - the author of all duplication
        prefix - the prefix to use on all duplicated items
        title - the new workspace title
        parent - the parent workspace
        Returns:
        WorkspaceWizardContext the filled context
      • deepDuplicate

        @Deprecated
        public static WorkspaceWizardContext deepDuplicate​(Workspace model,
                                                           Member author,
                                                           java.lang.String prefix,
                                                           java.lang.String title,
                                                           Workspace parent,
                                                           boolean collaborativeSpace)
        Deprecated.
        Deep duplicate the Workspace model using given configuration for duplication. Then returns the context with correctly filled binding maps.
        Parameters:
        model - the Workspace to duplicate
        author - the author of all duplication
        prefix - the prefix to use on all duplicated items
        title - the new workspace title
        parent - the parent workspace
        collaborativeSpace - tell if the duplication is to create a collaborative space
        Returns:
        WorkspaceWizardContext the filled context
      • deepDuplicate

        public static WorkspaceWizardContext deepDuplicate​(Workspace model,
                                                           Member author,
                                                           java.lang.String prefix,
                                                           java.lang.String title,
                                                           java.util.Map<java.lang.String,​java.lang.String> titleML,
                                                           Workspace parent,
                                                           boolean collaborativeSpace)
        Deep duplicate the Workspace model using given configuration for duplication. Then returns the context with correctly filled binding maps.
        Parameters:
        model - the Workspace to duplicate
        author - the author of all duplication
        prefix - the prefix to use on all duplicated items
        title - the new workspace title
        titleML - the multilingual workspace titles
        parent - the parent workspace
        collaborativeSpace - tell if the duplication is to create a collaborative space
        Returns:
        WorkspaceWizardContext the filled context
        Since:
        jcms-9.0.0
      • deepDuplicate

        @Deprecated
        public static WorkspaceWizardContext deepDuplicate​(Workspace model,
                                                           Member author,
                                                           java.lang.String prefix,
                                                           java.lang.String title,
                                                           java.lang.String wsemail,
                                                           java.util.List adminList,
                                                           java.util.Collection typeCollec,
                                                           java.util.Collection catCollec,
                                                           java.util.Collection groupCollec,
                                                           java.util.Collection portalCollec,
                                                           Workspace parent,
                                                           boolean collaborativeSpace)
        Deprecated.
        Deep duplicate the Workspace model using given configuration for duplication. Then returns the context with correctly filled binding maps.
        Parameters:
        model - the Workspace to duplicate
        author - the author of all duplication
        prefix - the prefix to use on all duplicated items
        title - the workspace title
        wsemail - the workspace email
        adminList - a List of workspace administrators
        typeCollec - a Set of classes to define WSTypeEntry to retrieve from model
        catCollec - Workspace root categories to duplicate
        groupCollec - to duplicate
        parent - the parent workspace
        portalCollec - to duplicate
        collaborativeSpace - tell if the duplication is to create a collaborative space
        Returns:
        WorkspaceWizardContext the filled context
      • deepDuplicate

        public static WorkspaceWizardContext deepDuplicate​(Workspace model,
                                                           Member author,
                                                           java.lang.String prefix,
                                                           java.lang.String title,
                                                           java.util.Map<java.lang.String,​java.lang.String> titleML,
                                                           java.lang.String wsemail,
                                                           java.util.List adminList,
                                                           java.util.Collection typeCollec,
                                                           java.util.Collection catCollec,
                                                           java.util.Collection groupCollec,
                                                           java.util.Collection portalCollec,
                                                           Workspace parent,
                                                           boolean collaborativeSpace)
        Deep duplicate the Workspace model using given configuration for duplication. Then returns the context with correctly filled binding maps.
        Parameters:
        model - the Workspace to duplicate
        author - the author of all duplication
        prefix - the prefix to use on all duplicated items
        title - the workspace title
        titleML - the multilingual workspace titles
        wsemail - the workspace email
        adminList - a List of workspace administrators
        typeCollec - a Set of classes to define WSTypeEntry to retrieve from model
        catCollec - Workspace root categories to duplicate
        groupCollec - to duplicate
        parent - the parent workspace
        portalCollec - to duplicate
        collaborativeSpace - tell if the duplication is to create a collaborative space
        Returns:
        WorkspaceWizardContext the filled context
        Since:
        jcms-9.0.0
      • deepDuplicate

        @Deprecated
        public static WorkspaceWizardContext deepDuplicate​(Workspace model,
                                                           Member author,
                                                           java.lang.String prefix,
                                                           java.lang.String title,
                                                           java.lang.String wsemail,
                                                           java.util.List adminList,
                                                           java.util.Collection typeCollec,
                                                           Category[] categories,
                                                           Group[] groups,
                                                           PortalInterface[] portals,
                                                           Workspace parent,
                                                           boolean collaborativeSpace)
        Deprecated.
        Deep duplicate the Workspace model using given configuration for duplication. Then returns the context with correctly filled binding maps.
        Parameters:
        model - the Workspace to duplicate
        author - the author of all duplication
        prefix - the prefix to use on all duplicated items
        title - the workspace title
        wsemail - the workspace email
        adminList - a List of workspace administrators
        typeCollec - a Set of classes to define WSTypeEntry to retrieve from model
        categories - Workspace root categories to duplicate
        groups - to duplicate
        portals - to duplicate
        parent - the parent workspace
        collaborativeSpace - tell if the duplication is to create a collaborative space
        Returns:
        WorkspaceWizardContext the filled context
      • deepDuplicate

        public static WorkspaceWizardContext deepDuplicate​(Workspace model,
                                                           Member author,
                                                           java.lang.String prefix,
                                                           java.lang.String title,
                                                           java.util.Map<java.lang.String,​java.lang.String> titleML,
                                                           java.lang.String wsemail,
                                                           java.util.List adminList,
                                                           java.util.Collection typeCollec,
                                                           Category[] categories,
                                                           Group[] groups,
                                                           PortalInterface[] portals,
                                                           Workspace parent,
                                                           boolean collaborativeSpace)
        Deep duplicate the Workspace model using given configuration for duplication. Then returns the context with correctly filled binding maps.
        Parameters:
        model - the Workspace to duplicate
        author - the author of all duplication
        prefix - the prefix to use on all duplicated items
        title - the workspace title
        titleML - the multilingual workspace titles
        wsemail - the workspace email
        adminList - a List of workspace administrators
        typeCollec - a Set of classes to define WSTypeEntry to retrieve from model
        categories - Workspace root categories to duplicate
        groups - to duplicate
        portals - to duplicate
        parent - the parent workspace
        collaborativeSpace - tell if the duplication is to create a collaborative space
        Returns:
        WorkspaceWizardContext the filled context
        Since:
        jcms-9.0.0
      • deepDuplicate

        public static WorkspaceWizardContext deepDuplicate​(WorkspaceWizardContext context)
        Deep duplicate the Workspace model referenced by given WorkspaceWizardContext using context configuration for duplication. Then returns the context with correctly filled binding maps.
         1.  Create Workspace (Check create) 
         2.1 Create Category (no checks)      => Map with previous categories
         2.2 Update Workspace with categories (1)
        
         3.1 Create Groups (no checks)        => Link with workspace (1) and Map with previous groups
         3.2 Update Groups (no checks)        => Link with parents group (3.1)
         3.3 Update Category (no checks)      => Link with groups (3.1) for rights
        
         4.1 Create PortalElement (no checks) => Map with previous portal element, workspace (1), groups (3.1), categories (1)
         4.2 Recursive duplicate (no checks)
        
         5.1 Create WSTypeEntry (no checks)   => Link with categories (2), groups (3.1)
         5.2 Create WKRole (not stored)       => Link with groups (3.1)
         5.3 Update Workspace (no checks)     => Link with (5.1) and (5.2)
         
        Parameters:
        context - the WorkspaceWizardContext
        Returns:
        WorkspaceWizardContext the filled context
      • createDuplicateCategories

        protected static void createDuplicateCategories​(WorkspaceWizardContext context)
        Duplicate all categories specified for the given WizardContext. Fills the WizardContext Category Map to retrieve binding old/new category
        Parameters:
        context - the WizardContext
      • createWorkspace

        protected static boolean createWorkspace​(WorkspaceWizardContext context)
        Creates the workspace instance from the given model
        Parameters:
        context - the WizardContext
        Returns:
        true when creation succeeds
      • createGroups

        protected static void createGroups​(WorkspaceWizardContext context)
        Duplicate all groups specified for the given WizardContext. Fills the WizardContext Group Map to retrieve binding old/new groups
        Parameters:
        context - the WizardContext
      • createPortals

        protected static void createPortals​(WorkspaceWizardContext context)
        Duplicate all portals specified for the given WizardContext. Fills the WizardContext Portal Map to retrieve binding old/new portals
        Parameters:
        context - the WizardContext
      • createOtherPortlets

        protected static void createOtherPortlets​(WorkspaceWizardContext context)
        Duplicate remaining portlets that have not yet been duplicated from portals, and which are specified for the given WizardContext. Fills the WizardContext PublicationMap to retrieve binding old/new portlets.
        Parameters:
        context - the WizardContext
        Since:
        jcms-10.0.3
      • updateWorkspace

        protected static void updateWorkspace​(WorkspaceWizardContext context)
        Update duplicated Workspace
        • Duplicate WSTypeEntry
        • Duplicate WKRoles
        • Instance Workflow Groups
        Parameters:
        context - the WizardContext
      • getNonCollaborativeWorkspaceCount

        public static int getNonCollaborativeWorkspaceCount()
        Returns the count of workspaces which are not used as CollaborativeSpace.
        Returns:
        the count of workspaces which are not used as CollaborativeSpace.
        Since:
        jcms-6.0.0
      • getCollaborativeSpaceCount

        public static int getCollaborativeSpaceCount()
        Returns the count of workspaces used as CollaborativeSpace.
        Returns:
        the count of workspaces used as CollaborativeSpace.
        Since:
        jcms-6.0.0
      • getAllIncomingMailLocalPart

        public static java.util.Collection<java.lang.String> getAllIncomingMailLocalPart()
        Returns:
        all existing Workspace's incoming mail local parts.
        Since:
        jcms-9.0.0
      • getIncomingMailLocalPartWorkspace

        public static Workspace getIncomingMailLocalPartWorkspace​(java.lang.String localPart)
        Parameters:
        localPart - the local part to retrieve the associated Workspace.
        Returns:
        the Workspace using the given local part, if any. Null otherwise.
        Since:
        jcms-9.0.0
      • getIncomingMailPattern

        public static java.lang.String getIncomingMailPattern​(Workspace ws)
        Computes the incoming mail pattern given the Workspace.

        Example:
        Given a Workspace which incoming mail local part is local-part and site incoming mail suffix is @jcms.company.com, the output will be: local-part\+.*@jcms.company.com

        Parameters:
        ws - the Workspace to compute its incoming mail pattern.
        Returns:
        an incoming mail pattern or null;
        Since:
        jcms-9.0.0
      • initIncomingMails

        public static void initIncomingMails()
        If site incoming mail is enabled, initializes Workspaces' incoming mail Patterns.
        Since:
        jcms-9.0.0
      • getSearchedWorkspaceSet

        public static java.util.Set<Workspace> getSearchedWorkspaceSet​(Member mbr,
                                                                       java.lang.String userLang,
                                                                       java.lang.String query,
                                                                       boolean withPortal,
                                                                       boolean showModel)
        Returns the set of workspace which :
        • Matches the query
        • Is a model the member can work on
        • Has a portal (If withPortal is set to true)
        • And the member can read the portal
        Parameters:
        mbr - the Member
        userLang - the user language
        query - workspace title to search for
        withPortal - if set to true, only workspaces with a portal will be added to the set
        showModel - if set to true, models the member can work on will be displayed. If false, models will be removed from set
        Returns:
        a Set of Workspace
        Since:
        jcms-10.0.0
      • getOtherWorkspaceSet

        public static java.util.Set<Workspace> getOtherWorkspaceSet​(Member member,
                                                                    java.lang.String userLang,
                                                                    java.util.Set<Workspace> workspaceToExcludeSet,
                                                                    boolean belongsToWorkspace,
                                                                    boolean isWorker,
                                                                    boolean withPortal)
        Parameters:
        member - the Member
        userLang - the user language
        workspaceToExcludeSet - the Set of Workspace to exclude from set
        belongsToWorkspace - weither to include only space attendees or not
        isWorker - weither to include only space workers or not
        withPortal - weither to include only space with an accessible Portal or not
        Returns:
        the set of workspace for given member without the set of excluded workspace
        Since:
        jcms-10.0.0
      • canReadWorkspace

        public static boolean canReadWorkspace​(Workspace workspace,
                                               Member member)