Merging from EC-MC: Initial work to move interceptors and correct bean names

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5743 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley 2007-05-22 05:02:18 +00:00
parent e34312ea05
commit 2d461f5dd9
7 changed files with 109 additions and 66 deletions

View File

@ -323,7 +323,7 @@
<bean id="admLuceneIndexerAndSearcherFactory" <bean id="admLuceneIndexerAndSearcherFactory"
class="org.alfresco.repo.search.impl.lucene.ADMLuceneIndexerAndSearcherFactory"> class="org.alfresco.repo.search.impl.lucene.ADMLuceneIndexerAndSearcherFactory">
<property name="nodeService"> <property name="nodeService">
<ref bean="mlAwareNodeService" /> <ref bean="nodeService" />
</property> </property>
<property name="dictionaryService"> <property name="dictionaryService">
<ref bean="dictionaryService" /> <ref bean="dictionaryService" />
@ -835,7 +835,7 @@
<ref bean="nodeService" /> <ref bean="nodeService" />
</property> </property>
<property name="multilingualContentService"> <property name="multilingualContentService">
<ref bean="MultilingualContentService" /> <ref bean="multilingualContentService" />
</property> </property>
</bean> </bean>
@ -858,7 +858,7 @@
<ref bean="nodeService" /> <ref bean="nodeService" />
</property> </property>
<property name="multilingualContentService"> <property name="multilingualContentService">
<ref bean="MultilingualContentService" /> <ref bean="multilingualContentService" />
</property> </property>
</bean> </bean>

View File

@ -6,7 +6,7 @@
<bean id="mlPropertyInterceptor" class="org.alfresco.repo.node.MLPropertyInterceptor"> <bean id="mlPropertyInterceptor" class="org.alfresco.repo.node.MLPropertyInterceptor">
<property name="directNodeService"> <property name="directNodeService">
<ref bean="mlAwareNodeService"></ref> <ref bean="nodeService"></ref>
</property> </property>
<property name="dictionaryService"> <property name="dictionaryService">
<ref bean="dictionaryService" /> <ref bean="dictionaryService" />
@ -14,7 +14,7 @@
</bean> </bean>
<bean id="mlTranslationInterceptor" class="org.alfresco.repo.node.MLTranslationInterceptor"> <bean id="mlTranslationInterceptor" class="org.alfresco.repo.node.MLTranslationInterceptor">
<property name="nodeService"> <property name="directNodeService">
<ref bean="nodeService"/> <ref bean="nodeService"/>
</property> </property>
<property name="multilingualContentService"> <property name="multilingualContentService">
@ -22,25 +22,7 @@
</property> </property>
</bean> </bean>
<bean id="nodeService" class="org.alfresco.repo.service.StoreRedirectorProxyFactory">
<bean id="nodeService" class="org.springframework.aop.framework.ProxyFactoryBean" >
<property name="targetName">
<value>mlAwareNodeService</value>
</property>
<property name="proxyInterfaces">
<list>
<value>org.alfresco.service.cmr.repository.NodeService</value>
</list>
</property>
<property name="interceptorNames">
<list>
<value>mlTranslationInterceptor</value>
<value>mlPropertyInterceptor</value>
</list>
</property>
</bean>
<bean id="mlAwareNodeService" class="org.alfresco.repo.service.StoreRedirectorProxyFactory">
<property name="proxyInterface"> <property name="proxyInterface">
<value>org.alfresco.service.cmr.repository.NodeService</value> <value>org.alfresco.service.cmr.repository.NodeService</value>
</property> </property>

View File

@ -67,9 +67,10 @@
<list> <list>
<idref local="NodeService_transaction"/> <idref local="NodeService_transaction"/>
<idref local="AuditMethodInterceptor"/> <idref local="AuditMethodInterceptor"/>
<idref local="mlTranslationInterceptor"/>
<idref local="exceptionTranslator"/> <idref local="exceptionTranslator"/>
<idref bean="NodeService_security"/> <idref bean="NodeService_security"/>
<idref bean="mlTranslationInterceptor"/>
<idref bean="mlPropertyInterceptor"/>
</list> </list>
</property> </property>
</bean> </bean>

View File

@ -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<QName, Serializable> 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));
}
}

View File

@ -52,7 +52,7 @@ public class MLTranslationInterceptor implements MethodInterceptor
private static Log logger = LogFactory private static Log logger = LogFactory
.getLog(MLTranslationInterceptor.class); .getLog(MLTranslationInterceptor.class);
private NodeService nodeService; private NodeService directNodeService;
private MultilingualContentService multilingualContentService; private MultilingualContentService multilingualContentService;
@ -76,7 +76,7 @@ public class MLTranslationInterceptor implements MethodInterceptor
Locale filterLocale = I18NUtil.getContentLocaleOrNull(); Locale filterLocale = I18NUtil.getContentLocaleOrNull();
if(filterLocale != null if(filterLocale != null
&& nodeService.getType(parent).equals(ContentModel.TYPE_FOLDER) && directNodeService.getType(parent).equals(ContentModel.TYPE_FOLDER)
&& ret != null && ret != null
&& !allChildAssoc.isEmpty() && !allChildAssoc.isEmpty()
) )
@ -92,10 +92,10 @@ public class MLTranslationInterceptor implements MethodInterceptor
{ {
NodeRef child = assoc.getChildRef(); NodeRef child = assoc.getChildRef();
QName type = nodeService.getType(child); QName type = directNodeService.getType(child);
if(type.equals(ContentModel.TYPE_CONTENT) && 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); NodeRef container = multilingualContentService.getTranslationContainer(child);
@ -159,24 +159,14 @@ public class MLTranslationInterceptor implements MethodInterceptor
return ret; return ret;
} }
public MultilingualContentService getMultilingualContentService()
{
return multilingualContentService;
}
public void setMultilingualContentService( public void setMultilingualContentService(
MultilingualContentService multilingualContentService) MultilingualContentService multilingualContentService)
{ {
this.multilingualContentService = multilingualContentService; this.multilingualContentService = multilingualContentService;
} }
public NodeService getNodeService() public void setDirectNodeService(NodeService nodeService)
{ {
return nodeService; this.directNodeService = nodeService;
}
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
} }
} }

View File

@ -691,14 +691,15 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
public void deleteNode(NodeRef nodeRef) public void deleteNode(NodeRef nodeRef)
{ {
// First get the node to ensure that it exists
Node node = getNodeNotNull(nodeRef);
boolean isArchivedNode = false; boolean isArchivedNode = false;
boolean requiresDelete = false; boolean requiresDelete = false;
// Invoke policy behaviours // Invoke policy behaviours
invokeBeforeDeleteNode(nodeRef); invokeBeforeDeleteNode(nodeRef);
// get the node
Node node = getNodeNotNull(nodeRef);
// get the primary parent-child relationship before it is gone // get the primary parent-child relationship before it is gone
ChildAssociationRef childAssocRef = getPrimaryParent(nodeRef); ChildAssociationRef childAssocRef = getPrimaryParent(nodeRef);
// get type and aspect QNames as they will be unavailable after the delete // get type and aspect QNames as they will be unavailable after the delete

View File

@ -63,11 +63,10 @@ public class DbNodeServiceImplTest extends BaseNodeServiceTest
private TransactionService txnService; private TransactionService txnService;
private NodeDaoService nodeDaoService; private NodeDaoService nodeDaoService;
private DictionaryService dictionaryService; private DictionaryService dictionaryService;
private NodeService mlAwareNodeService;
protected NodeService getNodeService() protected NodeService getNodeService()
{ {
return (NodeService) applicationContext.getBean("NodeService"); return (NodeService) applicationContext.getBean("nodeService");
} }
@Override @Override
@ -77,7 +76,6 @@ public class DbNodeServiceImplTest extends BaseNodeServiceTest
txnService = (TransactionService) applicationContext.getBean("transactionComponent"); txnService = (TransactionService) applicationContext.getBean("transactionComponent");
nodeDaoService = (NodeDaoService) applicationContext.getBean("nodeDaoService"); nodeDaoService = (NodeDaoService) applicationContext.getBean("nodeDaoService");
dictionaryService = (DictionaryService) applicationContext.getBean("dictionaryService"); 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, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE,
mlTextProperty); mlTextProperty);
// Check filterered property retrieval // Check unfiltered property retrieval
Serializable textValueFiltered = nodeService.getProperty( Serializable textValueDirect = 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<QName, Serializable> 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(
rootNodeRef, rootNodeRef,
BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE); BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE);
assertEquals( assertEquals(
@ -348,8 +330,8 @@ public class DbNodeServiceImplTest extends BaseNodeServiceTest
mlTextProperty, mlTextProperty,
textValueDirect); textValueDirect);
// Check filtered mass property retrieval // Check unfiltered mass property retrieval
Map<QName, Serializable> propertiesDirect = mlAwareNodeService.getProperties(rootNodeRef); Map<QName, Serializable> propertiesDirect = nodeService.getProperties(rootNodeRef);
assertEquals( assertEquals(
"MLText type not returned direct in Map", "MLText type not returned direct in Map",
mlTextProperty, mlTextProperty,