ACE-3310: It is impossible to delete tenant, when a site has been created in it

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@89210 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Matt Ward
2014-10-27 13:19:11 +00:00
parent befc704431
commit 2c4b80f1e4
2 changed files with 24 additions and 8 deletions

View File

@@ -30,7 +30,7 @@
<property name="moduleService" ref="moduleService"/>
<property name="baseAdminUsername" value="${alfresco_user_store.adminusername}"/>
<property name="thumbnailRegistry" ref="thumbnailRegistry"/>
<property name="behaviourFilter" ref="policyBehaviourFilter" />
<!-- note: if set then tenant are not co-mingled and all content roots will appear below this container (in <tenantdomain> sub-folder) -->
<property name="contentRootContainerPath" value="${dir.contentstore.tenants}"/>

View File

@@ -32,6 +32,7 @@ import javax.transaction.UserTransaction;
import net.sf.acegisecurity.providers.encoding.PasswordEncoder;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.admin.RepoModelDefinition;
import org.alfresco.repo.content.ContentStore;
import org.alfresco.repo.content.ContentStoreCaps;
@@ -41,6 +42,7 @@ import org.alfresco.repo.domain.tenant.TenantEntity;
import org.alfresco.repo.domain.tenant.TenantUpdateEntity;
import org.alfresco.repo.importer.ImporterBootstrap;
import org.alfresco.repo.node.db.DbNodeServiceImpl;
import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.repo.security.authentication.AuthenticationContext;
import org.alfresco.repo.security.authentication.AuthenticationException;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
@@ -84,6 +86,7 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
private RepoAdminService repoAdminService;
private AuthenticationContext authenticationContext;
private MultiTServiceImpl tenantService;
private BehaviourFilter behaviourFilter;
protected TransactionService transactionService;
protected DictionaryComponent dictionaryComponent;
@@ -164,7 +167,12 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
{
this.tenantService = tenantService;
}
public void setBehaviourFilter(BehaviourFilter behaviourFilter)
{
this.behaviourFilter = behaviourFilter;
}
public void setTenantAdminDAO(TenantAdminDAO tenantAdminDAO)
{
this.tenantAdminDAO = tenantAdminDAO;
@@ -801,12 +809,20 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
}, tenantDomain);
// delete tenant-specific stores
nodeService.deleteStore(tenantService.getName(new StoreRef(PROTOCOL_STORE_WORKSPACE, STORE_BASE_ID_SPACES), tenantDomain, false));
nodeService.deleteStore(tenantService.getName(new StoreRef(PROTOCOL_STORE_ARCHIVE, STORE_BASE_ID_SPACES), tenantDomain, false));
nodeService.deleteStore(tenantService.getName(new StoreRef(PROTOCOL_STORE_WORKSPACE, STORE_BASE_ID_VERSION1), tenantDomain, false));
nodeService.deleteStore(tenantService.getName(new StoreRef(PROTOCOL_STORE_WORKSPACE, STORE_BASE_ID_VERSION2), tenantDomain, false));
nodeService.deleteStore(tenantService.getName(new StoreRef(PROTOCOL_STORE_SYSTEM, STORE_BASE_ID_SYSTEM), tenantDomain, false));
nodeService.deleteStore(tenantService.getName(new StoreRef(PROTOCOL_STORE_USER, STORE_BASE_ID_USER), tenantDomain, false));
behaviourFilter.disableBehaviour(ContentModel.ASPECT_UNDELETABLE);
try
{
nodeService.deleteStore(tenantService.getName(new StoreRef(PROTOCOL_STORE_WORKSPACE, STORE_BASE_ID_SPACES), tenantDomain, false));
nodeService.deleteStore(tenantService.getName(new StoreRef(PROTOCOL_STORE_ARCHIVE, STORE_BASE_ID_SPACES), tenantDomain, false));
nodeService.deleteStore(tenantService.getName(new StoreRef(PROTOCOL_STORE_WORKSPACE, STORE_BASE_ID_VERSION1), tenantDomain, false));
nodeService.deleteStore(tenantService.getName(new StoreRef(PROTOCOL_STORE_WORKSPACE, STORE_BASE_ID_VERSION2), tenantDomain, false));
nodeService.deleteStore(tenantService.getName(new StoreRef(PROTOCOL_STORE_SYSTEM, STORE_BASE_ID_SYSTEM), tenantDomain, false));
nodeService.deleteStore(tenantService.getName(new StoreRef(PROTOCOL_STORE_USER, STORE_BASE_ID_USER), tenantDomain, false));
}
finally
{
behaviourFilter.enableBehaviour(ContentModel.ASPECT_UNDELETABLE);
}
TenantUtil.runAsSystemTenant(new TenantRunAsWork<Object>()
{