From c544223cd53aa94e002c0657a2bf0bd94c54f061 Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Tue, 11 Apr 2006 10:34:06 +0000 Subject: [PATCH] Fixed AR-525: basePatch bean has the following beans injected and held as protected fields transactionService namespaceService searchService nodeService authenticationComponent git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2643 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/admin/patch/AbstractPatch.java | 48 +++++++++++++- .../impl/EmailTemplatesContentPatch.java | 66 ++----------------- .../patch/impl/EmailTemplatesFolderPatch.java | 39 +---------- .../patch/impl/GenericBootstrapPatch.java | 24 ------- .../patch/impl/SavedSearchFolderPatch.java | 21 ------ 5 files changed, 53 insertions(+), 145 deletions(-) diff --git a/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java b/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java index 6cefc9dfc3..0674eb99ab 100644 --- a/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java +++ b/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java @@ -22,9 +22,13 @@ import java.util.Collections; import java.util.List; import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.TransactionUtil.TransactionWork; 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.namespace.NamespaceService; import org.alfresco.service.transaction.TransactionService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -59,7 +63,16 @@ public abstract class AbstractPatch implements Patch private boolean applied; /** the service to register ourselves with */ private PatchService patchService; - private TransactionService transactionService; + /** used to ensure a unique transaction per execution */ + protected TransactionService transactionService; + /** support service */ + protected NamespaceService namespaceService; + /** support service */ + protected NodeService nodeService; + /** support service */ + protected SearchService searchService; + /** support service */ + protected AuthenticationComponent authComponent; public AbstractPatch() { @@ -100,6 +113,35 @@ public abstract class AbstractPatch implements Patch this.transactionService = transactionService; } + /** + * Set a generally-used service + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * Set a generally-used service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * Set a generally-used service + */ + public void setSearchService(SearchService searchService) + { + this.searchService = searchService; + } + + public void setAuthenticationComponent(AuthenticationComponent authComponent) + { + this.authComponent = authComponent; + } + /** * This ensures that this bean gets registered with the appropriate {@link PatchService service}. */ @@ -250,6 +292,10 @@ public abstract class AbstractPatch implements Patch checkPropertyNotNull(id, "id"); checkPropertyNotNull(description, "description"); checkPropertyNotNull(transactionService, "transactionService"); + checkPropertyNotNull(namespaceService, "namespaceService"); + checkPropertyNotNull(nodeService, "nodeService"); + checkPropertyNotNull(searchService, "searchService"); + checkPropertyNotNull(authComponent, "authComponent"); if (fixesFromSchema == -1 || fixesToSchema == -1 || targetSchema == -1) { throw new AlfrescoRuntimeException( 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 a475ed692e..0a39e75785 100644 --- a/source/java/org/alfresco/repo/admin/patch/impl/EmailTemplatesContentPatch.java +++ b/source/java/org/alfresco/repo/admin/patch/impl/EmailTemplatesContentPatch.java @@ -17,28 +17,18 @@ package org.alfresco.repo.admin.patch.impl; import java.io.IOException; -import java.io.Serializable; -import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Properties; import org.alfresco.i18n.I18NUtil; -import org.alfresco.model.ContentModel; import org.alfresco.repo.admin.patch.AbstractPatch; import org.alfresco.repo.importer.ACPImportPackageHandler; import org.alfresco.repo.importer.ImporterBootstrap; -import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.service.cmr.admin.PatchException; -import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.cmr.view.ImporterService; import org.alfresco.service.cmr.view.Location; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; import org.springframework.context.MessageSource; import org.springframework.core.io.ClassPathResource; @@ -64,11 +54,7 @@ public class EmailTemplatesContentPatch extends AbstractPatch public static final String PROPERTY_EMAIL_TEMPLATES_CHILDNAME = "spaces.templates.email.childname"; private ImporterBootstrap importerBootstrap; - private NamespaceService namespaceService; - private SearchService searchService; private ImporterService importerService; - private AuthenticationComponent authComponent; - private NodeService nodeService; private MessageSource messageSource; protected Properties configuration; @@ -81,31 +67,11 @@ public class EmailTemplatesContentPatch extends AbstractPatch this.importerBootstrap = importerBootstrap; } - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - public void setSearchService(SearchService searchService) - { - this.searchService = searchService; - } - public void setImporterService(ImporterService importerService) { this.importerService = importerService; } - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - public void setAuthenticationComponent(AuthenticationComponent authComponent) - { - this.authComponent = authComponent; - } - public void setMessageSource(MessageSource messageSource) { this.messageSource = messageSource; @@ -124,34 +90,10 @@ public class EmailTemplatesContentPatch extends AbstractPatch */ protected void checkRequiredProperties() throws Exception { - if (importerBootstrap == null) - { - throw new PatchException("'importerBootstrap' property has not been set"); - } - if (namespaceService == null) - { - throw new PatchException("'namespaceService' property has not been set"); - } - if (searchService == null) - { - throw new PatchException("'searchService' property has not been set"); - } - if (nodeService == null) - { - throw new PatchException("'nodeService' property has not been set"); - } - if (importerService == null) - { - throw new PatchException("'importerService' property has not been set"); - } - if (messageSource == null) - { - throw new PatchException("'messageSource' property has not been set"); - } - if (templatesACP == null || templatesACP.length() == 0) - { - throw new PatchException("'templatesACP' property has not been set"); - } + checkPropertyNotNull(importerBootstrap, "importerBootstrap"); + checkPropertyNotNull(importerService, "importerService"); + checkPropertyNotNull(messageSource, "messageSource"); + checkPropertyNotNull(templatesACP, "templatesACP"); } /** diff --git a/source/java/org/alfresco/repo/admin/patch/impl/EmailTemplatesFolderPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/EmailTemplatesFolderPatch.java index 2c169a2eda..c071fde627 100644 --- a/source/java/org/alfresco/repo/admin/patch/impl/EmailTemplatesFolderPatch.java +++ b/source/java/org/alfresco/repo/admin/patch/impl/EmailTemplatesFolderPatch.java @@ -29,10 +29,7 @@ import org.alfresco.repo.importer.ImporterBootstrap; import org.alfresco.service.cmr.admin.PatchException; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.search.SearchService; -import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.springframework.context.MessageSource; @@ -62,9 +59,6 @@ public class EmailTemplatesFolderPatch extends AbstractPatch private static final String PROPERTY_ICON = "space-icon-default"; private ImporterBootstrap importerBootstrap; - private NamespaceService namespaceService; - private SearchService searchService; - private NodeService nodeService; private MessageSource messageSource; protected NodeRef dictionaryNodeRef; @@ -76,21 +70,6 @@ public class EmailTemplatesFolderPatch extends AbstractPatch this.importerBootstrap = importerBootstrap; } - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - public void setSearchService(SearchService searchService) - { - this.searchService = searchService; - } - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - public void setMessageSource(MessageSource messageSource) { this.messageSource = messageSource; @@ -101,22 +80,8 @@ public class EmailTemplatesFolderPatch extends AbstractPatch */ protected void checkCommonProperties() throws Exception { - if (importerBootstrap == null) - { - throw new PatchException("'importerBootstrap' property has not been set"); - } - else if (namespaceService == null) - { - throw new PatchException("'namespaceService' property has not been set"); - } - else if (searchService == null) - { - throw new PatchException("'searchService' property has not been set"); - } - else if (nodeService == null) - { - throw new PatchException("'nodeService' property has not been set"); - } + checkPropertyNotNull(importerBootstrap, "importerBootstrap"); + checkPropertyNotNull(messageSource, "messageSource"); } /** diff --git a/source/java/org/alfresco/repo/admin/patch/impl/GenericBootstrapPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/GenericBootstrapPatch.java index 89fcf541aa..93a10ff8b6 100644 --- a/source/java/org/alfresco/repo/admin/patch/impl/GenericBootstrapPatch.java +++ b/source/java/org/alfresco/repo/admin/patch/impl/GenericBootstrapPatch.java @@ -25,10 +25,7 @@ import org.alfresco.repo.admin.patch.AbstractPatch; import org.alfresco.repo.importer.ImporterBootstrap; import org.alfresco.service.cmr.admin.PatchException; import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.search.SearchService; -import org.alfresco.service.namespace.NamespaceService; /** * Generic patch that uses existing {@link org.alfresco.repo.importer.ImporterBootstrap importers} @@ -46,28 +43,10 @@ public class GenericBootstrapPatch extends AbstractPatch private static final String MSG_CREATED = "patch.genericBootstrap.result.created"; private static final String ERR_MULTIPLE_FOUND = "patch.genericBootstrap.err.multiple_found"; - private NamespaceService namespaceService; - private NodeService nodeService; - private SearchService searchService; private ImporterBootstrap importerBootstrap; private String checkPath; private Properties bootstrapView; - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - public void setSearchService(SearchService searchService) - { - this.searchService = searchService; - } - /** * @param importerBootstrap the bootstrap bean that performs the user store bootstrap */ @@ -100,9 +79,6 @@ public class GenericBootstrapPatch extends AbstractPatch @Override protected void checkProperties() { - checkPropertyNotNull(namespaceService, "blah"); - checkPropertyNotNull(nodeService, "nodeService"); - checkPropertyNotNull(searchService, "searchService"); checkPropertyNotNull(importerBootstrap, "importerBootstrap"); checkPropertyNotNull(checkPath, "checkPath"); checkPropertyNotNull(bootstrapView, "bootstrapView"); diff --git a/source/java/org/alfresco/repo/admin/patch/impl/SavedSearchFolderPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/SavedSearchFolderPatch.java index 93aefec0fc..69acc47578 100644 --- a/source/java/org/alfresco/repo/admin/patch/impl/SavedSearchFolderPatch.java +++ b/source/java/org/alfresco/repo/admin/patch/impl/SavedSearchFolderPatch.java @@ -29,10 +29,7 @@ import org.alfresco.repo.importer.ImporterBootstrap; import org.alfresco.service.cmr.admin.PatchException; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.search.SearchService; -import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.springframework.context.MessageSource; @@ -62,9 +59,6 @@ public class SavedSearchFolderPatch extends AbstractPatch private static final String PROPERTY_ICON = "space-icon-default"; private ImporterBootstrap importerBootstrap; - private NamespaceService namespaceService; - private SearchService searchService; - private NodeService nodeService; private MessageSource messageSource; protected NodeRef dictionaryNodeRef; @@ -76,21 +70,6 @@ public class SavedSearchFolderPatch extends AbstractPatch this.importerBootstrap = importerBootstrap; } - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - public void setSearchService(SearchService searchService) - { - this.searchService = searchService; - } - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - public void setMessageSource(MessageSource messageSource) { this.messageSource = messageSource;