Fixed ALF-10110: Error loading New Enterprise license onto a Team install where I'd exceeded my user limit

- load operation is now in a new, write-forced transaction regardless of the current thread's state


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30205 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2011-09-02 16:14:15 +00:00
parent e74b786fd2
commit c2f32afaaa
3 changed files with 40 additions and 17 deletions

View File

@@ -145,27 +145,29 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean
}
/**
* Load license management method.
*
* Return Message to user to say what happened.
* {@inheritDoc}
*/
@Override
public String loadLicense()
{
// Ensure that we force a writable txn for this operation
final RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
txnHelper.setForceWritable(true);
final RetryingTransactionCallback<String> loadCallback = new RetryingTransactionCallback<String>()
{
@Override
public String execute() throws Throwable
{
return licenseService.loadLicense();
}
};
// ... and we have to be 'system' for this, too
String result = AuthenticationUtil.runAs(new RunAsWork<String>()
{
public String doWork() throws Exception
{
RetryingTransactionHelper helper = transactionService.getRetryingTransactionHelper();
helper.setForceWritable(true);
return helper.doInTransaction(new RetryingTransactionCallback<String>()
{
public String execute()
{
return licenseService.loadLicense();
}
});
return txnHelper.doInTransaction(loadCallback, false, true);
}
}, AuthenticationUtil.getSystemUserName());

View File

@@ -20,13 +20,14 @@ package org.alfresco.repo.descriptor;
import org.alfresco.repo.importer.ImporterBootstrap;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.transaction.TransactionServiceImpl;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.descriptor.Descriptor;
import org.alfresco.service.descriptor.DescriptorService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.BaseSpringTest;
import org.alfresco.util.debug.NodeStoreInspector;
public class DescriptorServiceTest extends BaseSpringTest
{
@@ -49,8 +50,6 @@ public class DescriptorServiceTest extends BaseSpringTest
this.authenticationComponent = (AuthenticationComponent)this.applicationContext.getBean("authenticationComponent");
this.authenticationComponent.setSystemUserAsCurrentUser();
System.out.println(NodeStoreInspector.dumpNodeStore(nodeService, storeRef));
}
@Override
@@ -214,4 +213,26 @@ public class DescriptorServiceTest extends BaseSpringTest
return builder.toString();
}
public void testReadOnlyLicenseLoad_ALF10110() throws Exception
{
setComplete();
endTransaction();
QName vetoName = QName.createQName("{test}veto");
TransactionServiceImpl txnService = (TransactionServiceImpl) applicationContext.getBean("TransactionService");
ServiceRegistry registry = (ServiceRegistry)applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
DescriptorService descriptorService = registry.getDescriptorService();
// Veto writes
try
{
txnService.setAllowWrite(false, vetoName);
// Now reload the license
descriptorService.loadLicense();
}
finally
{
txnService.setAllowWrite(true, vetoName);
}
}
}