001    package de.deepamehta.plugins.accesscontrol.migrations;
002    
003    import de.deepamehta.plugins.accesscontrol.service.AccessControlService;
004    import de.deepamehta.plugins.workspaces.service.WorkspacesService;
005    
006    import de.deepamehta.core.Topic;
007    import de.deepamehta.core.service.Inject;
008    import de.deepamehta.core.service.Migration;
009    
010    
011    
012    /**
013     * Creates the "System" workspace.
014     * Runs ALWAYS.
015     * <p>
016     * Part of DM 4.5
017     */
018    public class Migration3 extends Migration {
019    
020        // ---------------------------------------------------------------------------------------------- Instance Variables
021    
022        @Inject
023        private AccessControlService acService;
024    
025        @Inject
026        private WorkspacesService wsService;
027    
028        // -------------------------------------------------------------------------------------------------- Public Methods
029    
030        @Override
031        public void run() {
032            Topic systemWorkspace = wsService.createWorkspace(
033                AccessControlService.SYSTEM_WORKSPACE_NAME,
034                AccessControlService.SYSTEM_WORKSPACE_URI,
035                AccessControlService.SYSTEM_WORKSPACE_SHARING_MODE
036            );
037            // Note: at migration running time our plugin listeners are not yet registered
038            // (furthermore there is no user logged in). So we set the owner manually here.
039            acService.setWorkspaceOwner(systemWorkspace, AccessControlService.ADMIN_USERNAME);
040            // Note: we don't set a particular creator/modifier here as we don't want suggest that the System workspace has
041            // been created by the "admin" user. Instead the creator/modifier of the System workspace remain undefined as
042            // the System workspace is actually created by the system itself.
043        }
044    }