diff --git a/config/alfresco/action-services-context.xml b/config/alfresco/action-services-context.xml index f420d37375..73d4dda87c 100644 --- a/config/alfresco/action-services-context.xml +++ b/config/alfresco/action-services-context.xml @@ -429,6 +429,7 @@ + @@ -521,6 +522,7 @@ + @@ -565,7 +567,7 @@ - + @@ -581,7 +583,7 @@ - + @@ -594,7 +596,7 @@ - + @@ -604,7 +606,7 @@ - + @@ -614,7 +616,7 @@ - + @@ -624,7 +626,7 @@ - + @@ -634,7 +636,7 @@ - + @@ -647,7 +649,7 @@ - + @@ -719,7 +721,7 @@ - + diff --git a/source/java/org/alfresco/repo/i18n/MessageServiceImpl.java b/source/java/org/alfresco/repo/i18n/MessageServiceImpl.java index d3a7b732a4..65b651373b 100644 --- a/source/java/org/alfresco/repo/i18n/MessageServiceImpl.java +++ b/source/java/org/alfresco/repo/i18n/MessageServiceImpl.java @@ -27,9 +27,10 @@ import org.alfresco.repo.cache.SimpleCache; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.repo.tenant.TenantService; -import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.repository.ContentReader; +import org.alfresco.service.cmr.repository.ContentService; 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; @@ -56,8 +57,11 @@ public class MessageServiceImpl implements MessageService private Lock writeLock = lock.writeLock(); // dependencies - private ServiceRegistry serviceRegistry; private TenantService tenantService; + private SearchService searchService; + private ContentService contentService; + private NamespaceService namespaceService; + private NodeService nodeService; /** * List of registered bundles @@ -77,16 +81,29 @@ public class MessageServiceImpl implements MessageService private List messageDeployers = new ArrayList(); - - public void setServiceRegistry(ServiceRegistry serviceRegistry) + public void setNamespaceService(NamespaceService namespaceService) { - this.serviceRegistry = serviceRegistry; + this.namespaceService = namespaceService; } + public void setSearchService(SearchService searchService) { + this.searchService = searchService; + } + + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + public void setTenantService(TenantService tenantService) { this.tenantService = tenantService; } + + public void setContentService(ContentService contentService) + { + this.contentService = contentService; + } public void setResourceBundleBaseNamesCache(SimpleCache> resourceBundleBaseNamesCache) { @@ -537,19 +554,16 @@ public class MessageServiceImpl implements MessageService // TODO - need to replace basic strategy with a more complete // search & instantiation strategy similar to ResourceBundle.getBundle() // Consider search query with basename* and then apply strategy ... - - SearchService searchService = serviceRegistry.getSearchService(); - NamespaceService resolver = serviceRegistry.getNamespaceService(); - - NodeRef rootNode = serviceRegistry.getNodeService().getRootNode(storeRef); + + NodeRef rootNode = nodeService.getRootNode(storeRef); // first attempt - with locale - List nodeRefs = searchService.selectNodes(rootNode, path+"_"+locale+PROPERTIES_FILE_SUFFIX, null, resolver, false); + List nodeRefs = searchService.selectNodes(rootNode, path+"_"+locale+PROPERTIES_FILE_SUFFIX, null, namespaceService, false); if ((nodeRefs == null) || (nodeRefs.size() == 0)) { // second attempt - basename - nodeRefs = searchService.selectNodes(rootNode, path+PROPERTIES_FILE_SUFFIX, null, resolver, false); + nodeRefs = searchService.selectNodes(rootNode, path+PROPERTIES_FILE_SUFFIX, null, namespaceService, false); if ((nodeRefs == null) || (nodeRefs.size() == 0)) { @@ -566,7 +580,7 @@ public class MessageServiceImpl implements MessageService { NodeRef messageResourceNodeRef = nodeRefs.get(0); - ContentReader cr = serviceRegistry.getContentService().getReader(messageResourceNodeRef, ContentModel.PROP_CONTENT); + ContentReader cr = contentService.getReader(messageResourceNodeRef, ContentModel.PROP_CONTENT); resBundle = new MessagePropertyResourceBundle(new InputStreamReader(cr.getContentInputStream(), cr.getEncoding())); } diff --git a/source/java/org/alfresco/repo/jscript/ScriptAction.java b/source/java/org/alfresco/repo/jscript/ScriptAction.java index 5934a57dac..af39128a01 100644 --- a/source/java/org/alfresco/repo/jscript/ScriptAction.java +++ b/source/java/org/alfresco/repo/jscript/ScriptAction.java @@ -32,10 +32,13 @@ import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransacti import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.ActionDefinition; +import org.alfresco.service.cmr.action.ActionService; import org.alfresco.service.cmr.action.ParameterDefinition; import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; +import org.alfresco.service.transaction.TransactionService; import org.mozilla.javascript.Scriptable; import org.mozilla.javascript.Wrapper; @@ -54,12 +57,15 @@ public final class ScriptAction implements Serializable, Scopeable /** Converter with knowledge of action parameter values */ private ActionValueConverter converter; - private ServiceRegistry services; - /** Action state */ private Action action; private ActionDefinition actionDef; + + private ServiceRegistry services; + private ActionService actionService; + private NamespaceService namespaceService; + private TransactionService transactionService; private ScriptableParameterMap parameters = null; @@ -72,6 +78,10 @@ public final class ScriptAction implements Serializable, Scopeable public ScriptAction(ServiceRegistry services, Action action, ActionDefinition actionDef) { this.services = services; + this.actionService = services.getActionService(); + this.namespaceService = services.getNamespaceService(); + this.transactionService = services.getTransactionService(); + this.action = action; this.actionDef = actionDef; this.converter = new ActionValueConverter(); @@ -141,7 +151,7 @@ public final class ScriptAction implements Serializable, Scopeable actionParams.put(name, value); } } - services.getActionService().executeAction(action, node.getNodeRef()); + actionService.executeAction(action, node.getNodeRef()); // Parameters may have been updated by action execution, so reset cache this.parameters = null; @@ -180,11 +190,11 @@ public final class ScriptAction implements Serializable, Scopeable { public Object execute() throws Throwable { - services.getActionService().executeAction(action, node.getNodeRef()); + actionService.executeAction(action, node.getNodeRef()); return null; } }; - services.getTransactionService().getRetryingTransactionHelper().doInTransaction( + transactionService.getRetryingTransactionHelper().doInTransaction( executionActionCallback, readOnly, newTxn); @@ -218,7 +228,7 @@ public final class ScriptAction implements Serializable, Scopeable actionParams.put(name, value); } } - services.getActionService().executeAction(action, nodeRef); + actionService.executeAction(action, nodeRef); // Parameters may have been updated by action execution, so reset cache this.parameters = null; @@ -254,11 +264,11 @@ public final class ScriptAction implements Serializable, Scopeable { public Object execute() throws Throwable { - services.getActionService().executeAction(action, nodeRef); + actionService.executeAction(action, nodeRef); return null; } }; - services.getTransactionService().getRetryingTransactionHelper().doInTransaction( + transactionService.getRetryingTransactionHelper().doInTransaction( executionActionCallback, readOnly, newTxn); @@ -289,7 +299,7 @@ public final class ScriptAction implements Serializable, Scopeable ParameterDefinition paramDef = actionDef.getParameterDefintion(paramName); if (paramDef != null && paramDef.getType().equals(DataTypeDefinition.QNAME)) { - return ((QName) value).toPrefixString(services.getNamespaceService()); + return ((QName) value).toPrefixString(namespaceService); } else { @@ -331,7 +341,7 @@ public final class ScriptAction implements Serializable, Scopeable } else { - return QName.createQName(stringQName, services.getNamespaceService()); + return QName.createQName(stringQName, namespaceService); } } else