diff --git a/config/alfresco/bootstrap-context.xml b/config/alfresco/bootstrap-context.xml
index 9f9dcfdf64..b5017e9377 100644
--- a/config/alfresco/bootstrap-context.xml
+++ b/config/alfresco/bootstrap-context.xml
@@ -94,7 +94,7 @@
-
+
@@ -117,7 +117,7 @@
-
+
@@ -132,7 +132,7 @@
-
+
@@ -143,7 +143,7 @@
-
+
@@ -154,11 +154,11 @@
-
+
-
+
diff --git a/config/alfresco/extension/mt/mt-admin-context.xml.sample b/config/alfresco/extension/mt/mt-admin-context.xml.sample
index c31ff643fc..318d3bee71 100644
--- a/config/alfresco/extension/mt/mt-admin-context.xml.sample
+++ b/config/alfresco/extension/mt/mt-admin-context.xml.sample
@@ -23,8 +23,8 @@
-
-
+
+
diff --git a/config/alfresco/module-context.xml b/config/alfresco/module-context.xml
index e9832be446..910bfdd2a2 100644
--- a/config/alfresco/module-context.xml
+++ b/config/alfresco/module-context.xml
@@ -11,14 +11,16 @@
-
+
+
-
+
+
diff --git a/source/java/org/alfresco/repo/admin/registry/RegistryServiceImpl.java b/source/java/org/alfresco/repo/admin/registry/RegistryServiceImpl.java
index 0e0c3c44fe..c510e2417e 100644
--- a/source/java/org/alfresco/repo/admin/registry/RegistryServiceImpl.java
+++ b/source/java/org/alfresco/repo/admin/registry/RegistryServiceImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
+ * Copyright (C) 2005-2008 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -131,7 +131,7 @@ public class RegistryServiceImpl implements RegistryService
{
NodeRef registryRootNodeRef = null;
// Ensure that the registry root node is present
- ResultSet rs = searchService.query(registryStoreRef, SearchService.LANGUAGE_XPATH, registryRootPath);
+ ResultSet rs = searchService.query(registryStoreRef, SearchService.LANGUAGE_LUCENE, "PATH:\"" + registryRootPath + "\"");
if (rs.length() == 0)
{
throw new AlfrescoRuntimeException(
diff --git a/source/java/org/alfresco/repo/module/AbstractModuleComponent.java b/source/java/org/alfresco/repo/module/AbstractModuleComponent.java
index 18636ed5ee..1cc6f6c65a 100644
--- a/source/java/org/alfresco/repo/module/AbstractModuleComponent.java
+++ b/source/java/org/alfresco/repo/module/AbstractModuleComponent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
+ * Copyright (C) 2005-2008 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -25,11 +25,14 @@
package org.alfresco.repo.module;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.i18n.I18NUtil;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
+import org.alfresco.repo.tenant.TenantDeployerService;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.module.ModuleService;
import org.alfresco.util.EqualsHelper;
@@ -56,6 +59,7 @@ public abstract class AbstractModuleComponent implements ModuleComponent, BeanNa
protected ServiceRegistry serviceRegistry;
protected AuthenticationComponent authenticationComponent;
protected ModuleService moduleService;
+ private TenantDeployerService tenantDeployerService;
private String moduleId;
private String name;
@@ -66,7 +70,7 @@ public abstract class AbstractModuleComponent implements ModuleComponent, BeanNa
private List dependsOn;
/** Defaults to true */
private boolean executeOnceOnly;
- private boolean executed;
+ private Map executed;
public AbstractModuleComponent()
{
@@ -75,7 +79,7 @@ public abstract class AbstractModuleComponent implements ModuleComponent, BeanNa
appliesToVersion = VersionNumber.VERSION_BIG;
dependsOn = new ArrayList(0);
executeOnceOnly = true;
- executed = false;
+ executed = new HashMap(1);
}
/**
@@ -153,6 +157,11 @@ public abstract class AbstractModuleComponent implements ModuleComponent, BeanNa
{
this.serviceRegistry = serviceRegistry;
}
+
+ public void setTenantDeployerService(TenantDeployerService tenantDeployerService)
+ {
+ this.tenantDeployerService = tenantDeployerService;
+ }
/**
* {@inheritDoc}
@@ -332,7 +341,13 @@ public abstract class AbstractModuleComponent implements ModuleComponent, BeanNa
public final synchronized void execute()
{
// ensure that this has not been executed already
- if (executed)
+ String tenantDomain = tenantDeployerService.getCurrentUserDomain();
+ if (! executed.containsKey(tenantDomain))
+ {
+ executed.put(tenantDomain, false);
+ }
+
+ if (executed.get(tenantDomain))
{
throw AlfrescoRuntimeException.create(ERR_ALREADY_EXECUTED, moduleId, name);
}
@@ -350,7 +365,7 @@ public abstract class AbstractModuleComponent implements ModuleComponent, BeanNa
finally
{
// There are no second chances
- executed = true;
+ executed.put(tenantDomain, true);
}
}
}
diff --git a/source/java/org/alfresco/repo/module/ModuleComponentHelper.java b/source/java/org/alfresco/repo/module/ModuleComponentHelper.java
index a70b76dda9..29ee3d6cbd 100644
--- a/source/java/org/alfresco/repo/module/ModuleComponentHelper.java
+++ b/source/java/org/alfresco/repo/module/ModuleComponentHelper.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
+ * Copyright (C) 2005-2008 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -33,13 +33,16 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import net.sf.acegisecurity.Authentication;
-
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.i18n.I18NUtil;
import org.alfresco.repo.admin.registry.RegistryKey;
import org.alfresco.repo.admin.registry.RegistryService;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
+import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
+import org.alfresco.repo.tenant.Tenant;
+import org.alfresco.repo.tenant.TenantDeployerService;
+import org.alfresco.repo.tenant.TenantService;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.module.ModuleDependency;
@@ -89,6 +92,7 @@ public class ModuleComponentHelper
private AuthenticationComponent authenticationComponent;
private RegistryService registryService;
private ModuleService moduleService;
+ private TenantDeployerService tenantDeployerService;
private Map> componentsByNameByModule;
/** Default constructor */
@@ -136,6 +140,11 @@ public class ModuleComponentHelper
{
this.moduleService = moduleService;
}
+
+ public void setTenantDeployerService(TenantDeployerService tenantDeployerService)
+ {
+ this.tenantDeployerService = tenantDeployerService;
+ }
/**
* Add a managed module component to the registry of components. These will be controlled
@@ -197,47 +206,123 @@ public class ModuleComponentHelper
PropertyCheck.mandatory(this, "authenticationComponent", authenticationComponent);
PropertyCheck.mandatory(this, "registryService", registryService);
PropertyCheck.mandatory(this, "moduleService", moduleService);
+ PropertyCheck.mandatory(this, "tenantDeployerService", tenantDeployerService);
/*
* Ensure transactionality and the correct authentication
*/
- // Get the current authentication
- Authentication authentication = authenticationComponent.getCurrentAuthentication();
- try
+
+ // Note: for system bootstrap this will be the default domain, else tenant domain for tenant create/import
+ final String tenantDomainCtx = tenantDeployerService.getCurrentUserDomain();
+
+ AuthenticationUtil.runAs(new RunAsWork