Class WorkspaceManager

java.lang.Object
com.jalios.jcms.workspace.WorkspaceManager

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

    • MAIL_PATTERN_INFO

      public static final String MAIL_PATTERN_INFO
      An extraInfo that stores the Workspace Incoming Mail pattern if any.
      Since:
      jcms-9.0.0
      See Also:
  • Method Details

    • deepDuplicate

      @Deprecated public static WorkspaceWizardContext deepDuplicate(Workspace model, Member author, String prefix, 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, String prefix, String title, Map<String,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, String prefix, 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, String prefix, String title, String wsemail, List adminList, Collection typeCollec, Collection catCollec, Collection groupCollec, 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, String prefix, String title, Map<String,String> titleML, String wsemail, List adminList, Collection typeCollec, Collection catCollec, Collection groupCollec, 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, String prefix, 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, String prefix, 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, String prefix, String title, Map<String,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, String prefix, String title, String wsemail, List adminList, Collection typeCollec, Collection catCollec, Collection groupCollec, 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
      portalCollec - 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, String prefix, String title, Map<String,String> titleML, String wsemail, List adminList, Collection typeCollec, Collection catCollec, Collection groupCollec, 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
      portalCollec - 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

      @Deprecated public static WorkspaceWizardContext deepDuplicate(Workspace model, Member author, String prefix, String title, String wsemail, List adminList, 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, String prefix, String title, Map<String,String> titleML, String wsemail, List adminList, 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 Collection<String> getAllIncomingMailLocalPart()
      Returns:
      all existing Workspace's incoming mail local parts.
      Since:
      jcms-9.0.0
    • getIncomingMailLocalPartWorkspace

      public static Workspace getIncomingMailLocalPartWorkspace(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 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
    • updateIncomingMailPattern

      public static void updateIncomingMailPattern(Workspace workspace, Workspace oldWorkspace)
      Updates given Workspace incoming Mail Pattern in IncomingMailListener.
      If oldWs is not null, checks if localPart changed.
      Parameters:
      workspace - the Workspace after update (must be null in delete case)
      oldWorkspace - the Workspace before update (may be null in create case)
      Since:
      jcms-9.0.0
      See Also:
    • getSearchedWorkspaceSet

      public static Set<Workspace> getSearchedWorkspaceSet(Member mbr, String userLang, 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 Set<Workspace> getOtherWorkspaceSet(Member member, String userLang, 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)