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

View File

@ -6,7 +6,7 @@
<bean id="mlPropertyInterceptor" class="org.alfresco.repo.node.MLPropertyInterceptor">
<property name="directNodeService">
<ref bean="mlAwareNodeService"></ref>
<ref bean="nodeService"></ref>
</property>
<property name="dictionaryService">
<ref bean="dictionaryService" />
@ -14,7 +14,7 @@
</bean>
<bean id="mlTranslationInterceptor" class="org.alfresco.repo.node.MLTranslationInterceptor">
<property name="nodeService">
<property name="directNodeService">
<ref bean="nodeService"/>
</property>
<property name="multilingualContentService">
@ -22,25 +22,7 @@
</property>
</bean>
<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">
<bean id="nodeService" class="org.alfresco.repo.service.StoreRedirectorProxyFactory">
<property name="proxyInterface">
<value>org.alfresco.service.cmr.repository.NodeService</value>
</property>

View File

@ -67,9 +67,10 @@
<list>
<idref local="NodeService_transaction"/>
<idref local="AuditMethodInterceptor"/>
<idref local="mlTranslationInterceptor"/>
<idref local="exceptionTranslator"/>
<idref bean="NodeService_security"/>
<idref bean="mlTranslationInterceptor"/>
<idref bean="mlPropertyInterceptor"/>
</list>
</property>
</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
.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;
}
}

View File

@ -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

View File

@ -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<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(
// 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<QName, Serializable> propertiesDirect = mlAwareNodeService.getProperties(rootNodeRef);
// Check unfiltered mass property retrieval
Map<QName, Serializable> propertiesDirect = nodeService.getProperties(rootNodeRef);
assertEquals(
"MLText type not returned direct in Map",
mlTextProperty,