Commit 75e0aa58 authored by Jörg Richter's avatar Jörg Richter

Consolidate Acces Control migrations

parent 760095c9
Pipeline #6606 passed with stages
in 3 minutes and 27 seconds
......@@ -10,10 +10,13 @@ import systems.dmx.core.service.Migration;
/**
* Creates the "System" workspace.
* Create the "System" and "Administration" workspaces.
* <p>
* Part of DMX 5.0
* Runs ALWAYS
* <p>
* Note: the "admin" user account is created in migration 6. At this moment both must exist, the "Login enabled"
* config topic type (created in migration 5), and the "Administration" workspace (created here).
*/
public class Migration2 extends Migration {
......@@ -29,16 +32,26 @@ public class Migration2 extends Migration {
@Override
public void run() {
// "System"
Topic systemWorkspace = wsService.createWorkspace(
AccessControlService.SYSTEM_WORKSPACE_NAME,
AccessControlService.SYSTEM_WORKSPACE_URI,
AccessControlService.SYSTEM_WORKSPACE_SHARING_MODE
);
// Note: at migration running time our plugin listeners are not yet registered
// (furthermore there is no user logged in). So we set the owner manually here.
acService.setWorkspaceOwner(systemWorkspace, AccessControlService.ADMIN_USERNAME);
// Note: we don't set a particular creator/modifier here as we don't want suggest that the System workspace has
// been created by the "admin" user. Instead the creator/modifier of the System workspace remain undefined as
// the System workspace is actually created by the system itself.
//
// "Administration"
Topic adminWorkspace = wsService.createWorkspace(
AccessControlService.ADMINISTRATION_WORKSPACE_NAME,
AccessControlService.ADMINISTRATION_WORKSPACE_URI,
AccessControlService.ADMINISTRATION_WORKSPACE_SHARING_MODE
);
acService.setWorkspaceOwner(adminWorkspace, AccessControlService.ADMIN_USERNAME);
//
// Note 1: at migration running time our plugin listeners are not yet registered (furthermore there is no user
// logged in). So we set the workspace owner manually here.
// Note 2: we don't set a particular creator/modifier here as we don't want suggest the workspaces have been
// created by the "admin" user. Instead the creator/modifier of the workspaces remain undefined as the
// workspaces are actually created by the system itself.
}
}
package systems.dmx.accesscontrol.migrations;
import systems.dmx.accesscontrol.AccessControlService;
import systems.dmx.workspaces.WorkspacesService;
import systems.dmx.core.Topic;
import systems.dmx.core.service.Inject;
import systems.dmx.core.service.Migration;
/**
* Creates the "Administration" workspace.
* <p>
* Part of DMX 5.0
* Runs ALWAYS
*
* Note: the "admin" user account is created in migration 7. At this moment both must exist, the "Login enabled"
* config topic type (created in migration 6), and the "Administration" workspace (created here).
*/
public class Migration3 extends Migration {
// ---------------------------------------------------------------------------------------------- Instance Variables
@Inject
private AccessControlService acService;
@Inject
private WorkspacesService wsService;
// -------------------------------------------------------------------------------------------------- Public Methods
@Override
public void run() {
Topic systemWorkspace = wsService.createWorkspace(
AccessControlService.ADMINISTRATION_WORKSPACE_NAME,
AccessControlService.ADMINISTRATION_WORKSPACE_URI,
AccessControlService.ADMINISTRATION_WORKSPACE_SHARING_MODE
);
// Note: at migration running time our plugin listeners are not yet registered
// (furthermore there is no user logged in). So we set the owner manually here.
acService.setWorkspaceOwner(systemWorkspace, AccessControlService.ADMIN_USERNAME);
// Note: we don't set a particular creator/modifier here as we don't want suggest that the Administration
// workspace has been created by the "admin" user. Instead the creator/modifier of the Administration
// workspace remain undefined as the Administration workspace is actually created by the system itself.
}
}
......@@ -9,12 +9,12 @@ import systems.dmx.core.service.Migration;
/**
* Sets "admin" as the owner of the "DMX" workspace.
* Set "admin" as the owner of the "DMX" workspace.
* <p>
* Part of DMX 5.0
* Runs ALWAYS
*/
public class Migration5 extends Migration {
public class Migration4 extends Migration {
// ---------------------------------------------------------------------------------------------- Instance Variables
......
......@@ -9,15 +9,15 @@ import systems.dmx.core.service.accesscontrol.Credentials;
/**
* Creates the "admin" user account.
* Create "admin" user account.
* <p>
* Part of DMX 5.0
* Runs ALWAYS
* <p>
* Note: both must exist already, the "Login enabled" config topic type (created in migration 6), and the
* "Administration" workspace (created in migration 3).
* Note: both must exist already, the "Login enabled" config topic type (created in migration 5), and the
* "Administration" workspace (created in migration 2).
*/
public class Migration7 extends Migration {
public class Migration6 extends Migration {
// ---------------------------------------------------------------------------------------------- Instance Variables
......
dmx.plugin.model_version = 7
dmx.plugin.model_version = 6
dmx.plugin.activate_after = systems.dmx.webclient
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment