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. * {@inheritDoc}
*
* Return Message to user to say what happened.
*/ */
@Override @Override
public String loadLicense() 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>() String result = AuthenticationUtil.runAs(new RunAsWork<String>()
{ {
public String doWork() throws Exception public String doWork() throws Exception
{ {
RetryingTransactionHelper helper = transactionService.getRetryingTransactionHelper(); return txnHelper.doInTransaction(loadCallback, false, true);
helper.setForceWritable(true);
return helper.doInTransaction(new RetryingTransactionCallback<String>()
{
public String execute()
{
return licenseService.loadLicense();
}
});
} }
}, AuthenticationUtil.getSystemUserName()); }, AuthenticationUtil.getSystemUserName());

View File

@@ -20,13 +20,14 @@ package org.alfresco.repo.descriptor;
import org.alfresco.repo.importer.ImporterBootstrap; import org.alfresco.repo.importer.ImporterBootstrap;
import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.transaction.TransactionServiceImpl;
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.descriptor.Descriptor; import org.alfresco.service.descriptor.Descriptor;
import org.alfresco.service.descriptor.DescriptorService; import org.alfresco.service.descriptor.DescriptorService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.BaseSpringTest; import org.alfresco.util.BaseSpringTest;
import org.alfresco.util.debug.NodeStoreInspector;
public class DescriptorServiceTest extends BaseSpringTest public class DescriptorServiceTest extends BaseSpringTest
{ {
@@ -49,8 +50,6 @@ public class DescriptorServiceTest extends BaseSpringTest
this.authenticationComponent = (AuthenticationComponent)this.applicationContext.getBean("authenticationComponent"); this.authenticationComponent = (AuthenticationComponent)this.applicationContext.getBean("authenticationComponent");
this.authenticationComponent.setSystemUserAsCurrentUser(); this.authenticationComponent.setSystemUserAsCurrentUser();
System.out.println(NodeStoreInspector.dumpNodeStore(nodeService, storeRef));
} }
@Override @Override
@@ -214,4 +213,26 @@ public class DescriptorServiceTest extends BaseSpringTest
return builder.toString(); 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);
}
}
} }

View File

@@ -110,7 +110,7 @@ public interface DescriptorService
/** /**
* Attempts to load the license. * Attempts to load the license.
* @return * @return Returns a message telling the user what happened
*/ */
public String loadLicense(); public String loadLicense();
} }