001package de.deepamehta.accesscontrol.migrations;
002
003import de.deepamehta.accesscontrol.AccessControlService;
004import de.deepamehta.workspaces.WorkspacesService;
005
006import de.deepamehta.core.Topic;
007import de.deepamehta.core.service.Inject;
008import 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 */
018public 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}