mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
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:
@@ -242,10 +242,10 @@ public class MultiTAdminServiceImpl extends AbstractLifecycleBean implements Ten
|
||||
register(tenantFileContentStore);
|
||||
|
||||
UserTransaction userTransaction = transactionService.getUserTransaction();
|
||||
authenticationComponent.setSystemUserAsCurrentUser();
|
||||
|
||||
try
|
||||
{
|
||||
authenticationComponent.setSystemUserAsCurrentUser();
|
||||
userTransaction.begin();
|
||||
|
||||
// bootstrap Tenant Service internal cache
|
||||
@@ -284,9 +284,12 @@ public class MultiTAdminServiceImpl extends AbstractLifecycleBean implements Ten
|
||||
{
|
||||
// rollback the transaction
|
||||
try { if (userTransaction != null) {userTransaction.rollback();} } catch (Exception ex) {}
|
||||
try {authenticationComponent.clearCurrentSecurityContext(); } catch (Exception ex) {}
|
||||
throw new AlfrescoRuntimeException("Failed to bootstrap tenants", e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
authenticationComponent.clearCurrentSecurityContext();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -907,49 +910,43 @@ public class MultiTAdminServiceImpl extends AbstractLifecycleBean implements Ten
|
||||
{
|
||||
// rollback the transaction
|
||||
try { if (userTransaction != null) {userTransaction.rollback();} } catch (Exception ex) {}
|
||||
try {authenticationComponent.clearCurrentSecurityContext(); } catch (Exception ex) {}
|
||||
throw new AlfrescoRuntimeException("Failed to get tenants", e);
|
||||
}
|
||||
|
||||
String currentUser = AuthenticationUtil.getCurrentUserName();
|
||||
|
||||
try
|
||||
{
|
||||
for (Tenant tenant : tenants)
|
||||
{
|
||||
if (tenant.isEnabled())
|
||||
{
|
||||
try
|
||||
{
|
||||
// switch to admin in order to deploy within context of tenant domain
|
||||
// assumes each tenant has default "admin" user
|
||||
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
||||
{
|
||||
public Object doWork()
|
||||
{
|
||||
// init the service within tenant context
|
||||
deployer.init();
|
||||
return null;
|
||||
}
|
||||
}, getSystemUser(tenant.getTenantDomain()));
|
||||
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
logger.error("Deployment failed" + e);
|
||||
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
e.printStackTrace(new PrintWriter(stringWriter));
|
||||
logger.error(stringWriter.toString());
|
||||
|
||||
// tenant deploy failure should not necessarily affect other tenants
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (currentUser != null) { AuthenticationUtil.setCurrentUser(currentUser); }
|
||||
authenticationComponent.clearCurrentSecurityContext();
|
||||
}
|
||||
|
||||
for (Tenant tenant : tenants)
|
||||
{
|
||||
if (tenant.isEnabled())
|
||||
{
|
||||
try
|
||||
{
|
||||
// switch to admin in order to deploy within context of tenant domain
|
||||
// assumes each tenant has default "admin" user
|
||||
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
||||
{
|
||||
public Object doWork()
|
||||
{
|
||||
// init the service within tenant context
|
||||
deployer.init();
|
||||
return null;
|
||||
}
|
||||
}, getSystemUser(tenant.getTenantDomain()));
|
||||
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
logger.error("Deployment failed" + e);
|
||||
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
e.printStackTrace(new PrintWriter(stringWriter));
|
||||
logger.error(stringWriter.toString());
|
||||
|
||||
// tenant deploy failure should not necessarily affect other tenants
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -536,7 +536,7 @@ public class MultiTServiceImpl implements TenantService
|
||||
protected void checkTenantEnabled(String tenantDomain)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user