001package systems.dmx.accesscontrol.migrations; 002 003import systems.dmx.accesscontrol.AccessControlService; 004import systems.dmx.workspaces.WorkspacesService; 005 006import systems.dmx.core.Topic; 007import systems.dmx.core.service.Inject; 008import systems.dmx.core.service.Migration; 009 010 011 012/** 013 * Creates the "Administration" workspace. 014 * Runs only in CLEAN_INSTALL mode. 015 * <p> 016 * Part of DM 4.8 017 * <p> 018 * Note: when UPDATEing to 4.8 the "Administration" workspace is created in migration 12. 019 * 020 * ---------- 021 * 022 * Originally this migration created the "admin" user account (part of DM 4.5). 023 * Run mode was CLEAN_INSTALL as well. 024 * <p> 025 * Now the "admin" user account is created in migration 10. At this moment both must exist, the "Login enabled" 026 * config topic type (created in migration 9 as of DM 4.7), and the "Administration" workspace (created here). 027 * <p> 028 * Note: when UPDATEing to 4.5 the "admin" user account already exists. 029 * It was created via postInstall() hook (which is obsolete in 4.5) 030 */ 031public class Migration4 extends Migration { 032 033 // ---------------------------------------------------------------------------------------------- Instance Variables 034 035 @Inject 036 private AccessControlService acService; 037 038 @Inject 039 private WorkspacesService wsService; 040 041 // -------------------------------------------------------------------------------------------------- Public Methods 042 043 @Override 044 public void run() { 045 // Note: there is a copy in migration 12 046 Topic systemWorkspace = wsService.createWorkspace( 047 AccessControlService.ADMINISTRATION_WORKSPACE_NAME, 048 AccessControlService.ADMINISTRATION_WORKSPACE_URI, 049 AccessControlService.ADMINISTRATION_WORKSPACE_SHARING_MODE 050 ); 051 // Note: at migration running time our plugin listeners are not yet registered 052 // (furthermore there is no user logged in). So we set the owner manually here. 053 acService.setWorkspaceOwner(systemWorkspace, AccessControlService.ADMIN_USERNAME); 054 // Note: we don't set a particular creator/modifier here as we don't want suggest that the Administration 055 // workspace has been created by the "admin" user. Instead the creator/modifier of the Administration 056 // workspace remain undefined as the Administration workspace is actually created by the system itself. 057 } 058}