MT - fixes

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8515 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2008-03-11 16:28:43 +00:00
parent 6a541a840e
commit 7f09e22794
2 changed files with 39 additions and 42 deletions

View File

@@ -242,10 +242,10 @@ public class MultiTAdminServiceImpl extends AbstractLifecycleBean implements Ten
register(tenantFileContentStore); register(tenantFileContentStore);
UserTransaction userTransaction = transactionService.getUserTransaction(); UserTransaction userTransaction = transactionService.getUserTransaction();
authenticationComponent.setSystemUserAsCurrentUser();
try try
{ {
authenticationComponent.setSystemUserAsCurrentUser();
userTransaction.begin(); userTransaction.begin();
// bootstrap Tenant Service internal cache // bootstrap Tenant Service internal cache
@@ -284,9 +284,12 @@ public class MultiTAdminServiceImpl extends AbstractLifecycleBean implements Ten
{ {
// rollback the transaction // rollback the transaction
try { if (userTransaction != null) {userTransaction.rollback();} } catch (Exception ex) {} try { if (userTransaction != null) {userTransaction.rollback();} } catch (Exception ex) {}
try {authenticationComponent.clearCurrentSecurityContext(); } catch (Exception ex) {}
throw new AlfrescoRuntimeException("Failed to bootstrap tenants", e); throw new AlfrescoRuntimeException("Failed to bootstrap tenants", e);
} }
finally
{
authenticationComponent.clearCurrentSecurityContext();
}
} }
@Override @Override
@@ -907,14 +910,13 @@ public class MultiTAdminServiceImpl extends AbstractLifecycleBean implements Ten
{ {
// rollback the transaction // rollback the transaction
try { if (userTransaction != null) {userTransaction.rollback();} } catch (Exception ex) {} try { if (userTransaction != null) {userTransaction.rollback();} } catch (Exception ex) {}
try {authenticationComponent.clearCurrentSecurityContext(); } catch (Exception ex) {}
throw new AlfrescoRuntimeException("Failed to get tenants", e); throw new AlfrescoRuntimeException("Failed to get tenants", e);
} }
finally
String currentUser = AuthenticationUtil.getCurrentUserName();
try
{ {
authenticationComponent.clearCurrentSecurityContext();
}
for (Tenant tenant : tenants) for (Tenant tenant : tenants)
{ {
if (tenant.isEnabled()) if (tenant.isEnabled())
@@ -947,11 +949,6 @@ public class MultiTAdminServiceImpl extends AbstractLifecycleBean implements Ten
} }
} }
} }
finally
{
if (currentUser != null) { AuthenticationUtil.setCurrentUser(currentUser); }
}
}
} }
public void undeployTenants(final TenantDeployer deployer, Log logger) public void undeployTenants(final TenantDeployer deployer, Log logger)

View File

@@ -536,7 +536,7 @@ public class MultiTServiceImpl implements TenantService
protected void checkTenantEnabled(String tenantDomain) protected void checkTenantEnabled(String tenantDomain)
{ {
// note: System user can access disabled tenants // note: System user can access disabled tenants
if (! getBaseNameUser(AuthenticationUtil.getCurrentUserName()).equals(AuthenticationUtil.getSystemUserName())) if (! (AuthenticationUtil.getSystemUserName().equals(getBaseNameUser(AuthenticationUtil.getCurrentUserName()))))
{ {
if (getTenant(tenantDomain).isEnabled() == false) if (getTenant(tenantDomain).isEnabled() == false)
{ {