diff --git a/config/alfresco/core-services-context.xml b/config/alfresco/core-services-context.xml index 917f6f0656..c73d02bf66 100644 --- a/config/alfresco/core-services-context.xml +++ b/config/alfresco/core-services-context.xml @@ -323,7 +323,7 @@ - + @@ -835,7 +835,7 @@ - + @@ -858,7 +858,7 @@ - + diff --git a/config/alfresco/node-services-context.xml b/config/alfresco/node-services-context.xml index c711715a10..943d5ef240 100644 --- a/config/alfresco/node-services-context.xml +++ b/config/alfresco/node-services-context.xml @@ -6,7 +6,7 @@ - + @@ -14,7 +14,7 @@ - + @@ -22,25 +22,7 @@ - - - - mlAwareNodeService - - - - org.alfresco.service.cmr.repository.NodeService - - - - - mlTranslationInterceptor - mlPropertyInterceptor - - - - - + org.alfresco.service.cmr.repository.NodeService diff --git a/config/alfresco/public-services-context.xml b/config/alfresco/public-services-context.xml index e478ea6c91..eb46238ddf 100644 --- a/config/alfresco/public-services-context.xml +++ b/config/alfresco/public-services-context.xml @@ -67,9 +67,10 @@ - + + diff --git a/source/java/org/alfresco/repo/node/FullNodeServiceTest.java b/source/java/org/alfresco/repo/node/FullNodeServiceTest.java new file mode 100644 index 0000000000..f085516514 --- /dev/null +++ b/source/java/org/alfresco/repo/node/FullNodeServiceTest.java @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.repo.node; + +import java.io.Serializable; +import java.util.Locale; +import java.util.Map; + +import org.alfresco.service.cmr.repository.MLText; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; + +/** + * Tests the fully-intercepted version of the NodeService + * + * @see NodeService + * + * @author Derek Hulley + */ +@SuppressWarnings("unused") +public class FullNodeServiceTest extends BaseNodeServiceTest +{ + protected NodeService getNodeService() + { + return (NodeService) applicationContext.getBean("NodeService"); + } + + @Override + protected void onSetUpInTransaction() throws Exception + { + super.onSetUpInTransaction(); + } + + public void testMLTextValues() throws Exception + { + // Set the server default locale + Locale.setDefault(Locale.ENGLISH); + + MLText mlTextProperty = new MLText(); + mlTextProperty.addValue(Locale.ENGLISH, "Very good!"); + mlTextProperty.addValue(Locale.FRENCH, "Très bon!"); + mlTextProperty.addValue(Locale.GERMAN, "Sehr gut!"); + + nodeService.setProperty( + rootNodeRef, + BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, + mlTextProperty); + + // Check filterered property retrieval + Serializable textValueFiltered = nodeService.getProperty( + rootNodeRef, + BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE); + assertEquals( + "Default locale value not taken for ML text", + mlTextProperty.getValue(Locale.ENGLISH), + textValueFiltered); + + // Check filtered mass property retrieval + Map propertiesFiltered = nodeService.getProperties(rootNodeRef); + assertEquals( + "Default locale value not taken for ML text in Map", + mlTextProperty.getValue(Locale.ENGLISH), + propertiesFiltered.get(BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE)); + } +} diff --git a/source/java/org/alfresco/repo/node/MLTranslationInterceptor.java b/source/java/org/alfresco/repo/node/MLTranslationInterceptor.java index 2c2dd2fdf9..40ef961d79 100644 --- a/source/java/org/alfresco/repo/node/MLTranslationInterceptor.java +++ b/source/java/org/alfresco/repo/node/MLTranslationInterceptor.java @@ -52,7 +52,7 @@ public class MLTranslationInterceptor implements MethodInterceptor private static Log logger = LogFactory .getLog(MLTranslationInterceptor.class); - private NodeService nodeService; + private NodeService directNodeService; private MultilingualContentService multilingualContentService; @@ -76,7 +76,7 @@ public class MLTranslationInterceptor implements MethodInterceptor Locale filterLocale = I18NUtil.getContentLocaleOrNull(); if(filterLocale != null - && nodeService.getType(parent).equals(ContentModel.TYPE_FOLDER) + && directNodeService.getType(parent).equals(ContentModel.TYPE_FOLDER) && ret != null && !allChildAssoc.isEmpty() ) @@ -92,10 +92,10 @@ public class MLTranslationInterceptor implements MethodInterceptor { NodeRef child = assoc.getChildRef(); - QName type = nodeService.getType(child); + QName type = directNodeService.getType(child); if(type.equals(ContentModel.TYPE_CONTENT) && - nodeService.hasAspect(child, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT)) + directNodeService.hasAspect(child, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT)) { NodeRef container = multilingualContentService.getTranslationContainer(child); @@ -159,24 +159,14 @@ public class MLTranslationInterceptor implements MethodInterceptor return ret; } - public MultilingualContentService getMultilingualContentService() - { - return multilingualContentService; - } - public void setMultilingualContentService( MultilingualContentService multilingualContentService) { this.multilingualContentService = multilingualContentService; } - public NodeService getNodeService() + public void setDirectNodeService(NodeService nodeService) { - return nodeService; - } - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; + this.directNodeService = nodeService; } } \ No newline at end of file diff --git a/source/java/org/alfresco/repo/node/db/DbNodeServiceImpl.java b/source/java/org/alfresco/repo/node/db/DbNodeServiceImpl.java index e70e9d3842..e4e3f3698a 100644 --- a/source/java/org/alfresco/repo/node/db/DbNodeServiceImpl.java +++ b/source/java/org/alfresco/repo/node/db/DbNodeServiceImpl.java @@ -691,14 +691,15 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl public void deleteNode(NodeRef nodeRef) { + // First get the node to ensure that it exists + Node node = getNodeNotNull(nodeRef); + boolean isArchivedNode = false; boolean requiresDelete = false; // Invoke policy behaviours invokeBeforeDeleteNode(nodeRef); - // get the node - Node node = getNodeNotNull(nodeRef); // get the primary parent-child relationship before it is gone ChildAssociationRef childAssocRef = getPrimaryParent(nodeRef); // get type and aspect QNames as they will be unavailable after the delete diff --git a/source/java/org/alfresco/repo/node/db/DbNodeServiceImplTest.java b/source/java/org/alfresco/repo/node/db/DbNodeServiceImplTest.java index bccee2bac1..2d93aa10e0 100644 --- a/source/java/org/alfresco/repo/node/db/DbNodeServiceImplTest.java +++ b/source/java/org/alfresco/repo/node/db/DbNodeServiceImplTest.java @@ -63,11 +63,10 @@ public class DbNodeServiceImplTest extends BaseNodeServiceTest private TransactionService txnService; private NodeDaoService nodeDaoService; private DictionaryService dictionaryService; - private NodeService mlAwareNodeService; protected NodeService getNodeService() { - return (NodeService) applicationContext.getBean("NodeService"); + return (NodeService) applicationContext.getBean("nodeService"); } @Override @@ -77,7 +76,6 @@ public class DbNodeServiceImplTest extends BaseNodeServiceTest txnService = (TransactionService) applicationContext.getBean("transactionComponent"); nodeDaoService = (NodeDaoService) applicationContext.getBean("nodeDaoService"); dictionaryService = (DictionaryService) applicationContext.getBean("dictionaryService"); - mlAwareNodeService = (NodeService) applicationContext.getBean("mlAwareNodeService"); } /** @@ -323,24 +321,8 @@ public class DbNodeServiceImplTest extends BaseNodeServiceTest BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, mlTextProperty); - // Check filterered property retrieval - Serializable textValueFiltered = nodeService.getProperty( - rootNodeRef, - BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE); - assertEquals( - "Default locale value not taken for ML text", - mlTextProperty.getValue(Locale.ENGLISH), - textValueFiltered); - - // Check filtered mass property retrieval - Map propertiesFiltered = nodeService.getProperties(rootNodeRef); - assertEquals( - "Default locale value not taken for ML text in Map", - mlTextProperty.getValue(Locale.ENGLISH), - propertiesFiltered.get(BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE)); - - // Check direct property retrieval - Serializable textValueDirect = mlAwareNodeService.getProperty( + // Check unfiltered property retrieval + Serializable textValueDirect = nodeService.getProperty( rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE); assertEquals( @@ -348,8 +330,8 @@ public class DbNodeServiceImplTest extends BaseNodeServiceTest mlTextProperty, textValueDirect); - // Check filtered mass property retrieval - Map propertiesDirect = mlAwareNodeService.getProperties(rootNodeRef); + // Check unfiltered mass property retrieval + Map propertiesDirect = nodeService.getProperties(rootNodeRef); assertEquals( "MLText type not returned direct in Map", mlTextProperty,