diff --git a/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java b/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java index 0857e07fbc..4375b6e101 100644 --- a/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java +++ b/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java @@ -72,7 +72,7 @@ public abstract class AbstractPatch implements Patch /** support service */ protected SearchService searchService; /** support service */ - protected AuthenticationComponent authComponent; + protected AuthenticationComponent authenticationComponent; public AbstractPatch() { @@ -137,9 +137,12 @@ public abstract class AbstractPatch implements Patch this.searchService = searchService; } - public void setAuthenticationComponent(AuthenticationComponent authComponent) + /** + * Set a generally-used service + */ + public void setAuthenticationComponent(AuthenticationComponent authenticationComponent) { - this.authComponent = authComponent; + this.authenticationComponent = authenticationComponent; } /** @@ -295,7 +298,7 @@ public abstract class AbstractPatch implements Patch checkPropertyNotNull(namespaceService, "namespaceService"); checkPropertyNotNull(nodeService, "nodeService"); checkPropertyNotNull(searchService, "searchService"); - checkPropertyNotNull(authComponent, "authComponent"); + checkPropertyNotNull(authenticationComponent, "authenticationComponent"); if (fixesFromSchema == -1 || fixesToSchema == -1 || targetSchema == -1) { throw new AlfrescoRuntimeException( diff --git a/source/java/org/alfresco/repo/admin/patch/PatchTest.java b/source/java/org/alfresco/repo/admin/patch/PatchTest.java index cc5be82af8..f3de1cee3a 100644 --- a/source/java/org/alfresco/repo/admin/patch/PatchTest.java +++ b/source/java/org/alfresco/repo/admin/patch/PatchTest.java @@ -23,7 +23,12 @@ import junit.framework.TestCase; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.repo.domain.AppliedPatch; +import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.service.cmr.admin.PatchException; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.search.SearchService; +import org.alfresco.service.cmr.security.AuthorityService; +import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.ApplicationContextHelper; import org.springframework.context.ApplicationContext; @@ -40,6 +45,10 @@ public class PatchTest extends TestCase private static final ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); private TransactionService transactionService; + private NamespaceService namespaceService; + private NodeService nodeService; + private SearchService searchService; + private AuthenticationComponent authenticationComponent; private PatchService patchService; private PatchDaoService patchDaoComponent; @@ -51,6 +60,11 @@ public class PatchTest extends TestCase public void setUp() throws Exception { transactionService = (TransactionService) ctx.getBean("transactionComponent"); + namespaceService = (NamespaceService) ctx.getBean("namespaceService"); + nodeService = (NodeService) ctx.getBean("nodeService"); + searchService = (SearchService) ctx.getBean("searchService"); + authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent"); + patchService = (PatchService) ctx.getBean("PatchService"); patchDaoComponent = (PatchDaoService) ctx.getBean("patchDaoComponent"); @@ -66,9 +80,20 @@ public class PatchTest extends TestCase assertNotNull(patchDaoComponent); } + private SamplePatch constructSamplePatch(boolean mustFail) + { + SamplePatch patch = new SamplePatch(mustFail, transactionService); + patch.setNamespaceService(namespaceService); + patch.setNodeService(nodeService); + patch.setSearchService(searchService); + patch.setAuthenticationComponent(authenticationComponent); + // done + return patch; + } + public void testSimplePatchSuccess() throws Exception { - Patch patch = new SamplePatch(false, transactionService); + Patch patch = constructSamplePatch(false); String report = patch.apply(); // check that the report was generated assertEquals("Patch report incorrect", SamplePatch.MSG_SUCCESS, report); @@ -77,7 +102,7 @@ public class PatchTest extends TestCase public void testPatchReapplication() { // successfully apply a patch - Patch patch = new SamplePatch(false, transactionService); + Patch patch = constructSamplePatch(false); patch.apply(); // check that the patch cannot be reapplied try @@ -91,7 +116,7 @@ public class PatchTest extends TestCase } // apply an unsuccessful patch - patch = new SamplePatch(true, transactionService); + patch = constructSamplePatch(true); try { patch.apply(); diff --git a/source/java/org/alfresco/repo/admin/patch/impl/EmailTemplatesContentPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/EmailTemplatesContentPatch.java index 0a39e75785..f02e49509e 100644 --- a/source/java/org/alfresco/repo/admin/patch/impl/EmailTemplatesContentPatch.java +++ b/source/java/org/alfresco/repo/admin/patch/impl/EmailTemplatesContentPatch.java @@ -165,13 +165,13 @@ public class EmailTemplatesContentPatch extends AbstractPatch // import the content try { - authComponent.setCurrentUser(authComponent.getSystemUserName()); + authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName()); importContent(); } finally { - authComponent.clearCurrentSecurityContext(); + authenticationComponent.clearCurrentSecurityContext(); } // output a message to describe the result