mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fixes bugs uncovered by JDK 7 upgrade
- nodeService's interceptors depended on nodeService, resulting in some 'interesting' interceptor ordering in the chain (3 * the normal number in a random order). Now we use a lazy interceptor to break the cycle. - When the Content Language was en_GB and an MLText property contained {en_US, en_GB} it would return the en_US one, not taking country codes into account when available git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@41904 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -32,6 +32,22 @@
|
|||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="nodeService" class="org.springframework.aop.framework.ProxyFactoryBean" >
|
<bean id="nodeService" class="org.springframework.aop.framework.ProxyFactoryBean" >
|
||||||
|
<!-- Lazy init to avoid circular dependencies -->
|
||||||
|
<property name="targetSource">
|
||||||
|
<bean class="org.alfresco.config.NonBlockingLazyInitTargetSource">
|
||||||
|
<property name="targetBeanName">
|
||||||
|
<idref bean="_nodeService" />
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
</property>
|
||||||
|
<property name="proxyInterfaces">
|
||||||
|
<list>
|
||||||
|
<value>org.alfresco.service.cmr.repository.NodeService</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="_nodeService" class="org.springframework.aop.framework.ProxyFactoryBean" >
|
||||||
<property name="targetName">
|
<property name="targetName">
|
||||||
<value>mlAwareNodeService</value>
|
<value>mlAwareNodeService</value>
|
||||||
</property>
|
</property>
|
||||||
|
@@ -66,14 +66,9 @@
|
|||||||
<value>org.alfresco.service.cmr.repository.NodeService</value>
|
<value>org.alfresco.service.cmr.repository.NodeService</value>
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
<!-- Lazy init to avoid circular dependencies -->
|
<property name="target">
|
||||||
<property name="targetSource">
|
<ref bean="nodeService"/>
|
||||||
<bean class="org.alfresco.config.NonBlockingLazyInitTargetSource">
|
</property>
|
||||||
<property name="targetBeanName">
|
|
||||||
<idref bean="nodeService" />
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
</property>
|
|
||||||
<property name="interceptorNames">
|
<property name="interceptorNames">
|
||||||
<list>
|
<list>
|
||||||
<idref local="NodeService_transaction"/>
|
<idref local="NodeService_transaction"/>
|
||||||
|
@@ -28,6 +28,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
@@ -163,7 +164,7 @@ public class MLPropertyInterceptor implements MethodInterceptor
|
|||||||
|
|
||||||
// What locale must be used for filtering - ALF-3756 fix, ignore the country and variant
|
// What locale must be used for filtering - ALF-3756 fix, ignore the country and variant
|
||||||
Serializable value = (Serializable) invocation.proceed();
|
Serializable value = (Serializable) invocation.proceed();
|
||||||
ret = convertOutboundProperty(contentLangLocale, nodeRef, pivotNodeRef, propertyQName, value);
|
ret = convertOutboundProperty(nodeRef, pivotNodeRef, propertyQName, value);
|
||||||
}
|
}
|
||||||
else if (methodName.equals("getProperties"))
|
else if (methodName.equals("getProperties"))
|
||||||
{
|
{
|
||||||
@@ -179,7 +180,7 @@ public class MLPropertyInterceptor implements MethodInterceptor
|
|||||||
{
|
{
|
||||||
QName propertyQName = entry.getKey();
|
QName propertyQName = entry.getKey();
|
||||||
Serializable value = entry.getValue();
|
Serializable value = entry.getValue();
|
||||||
Serializable convertedValue = convertOutboundProperty(contentLangLocale, nodeRef, pivotNodeRef, propertyQName, value);
|
Serializable convertedValue = convertOutboundProperty(nodeRef, pivotNodeRef, propertyQName, value);
|
||||||
// Add it to the return map
|
// Add it to the return map
|
||||||
convertedProperties.put(propertyQName, convertedValue);
|
convertedProperties.put(propertyQName, convertedValue);
|
||||||
}
|
}
|
||||||
@@ -334,7 +335,6 @@ public class MLPropertyInterceptor implements MethodInterceptor
|
|||||||
* Ensure that content is spoofed for empty translations.
|
* Ensure that content is spoofed for empty translations.
|
||||||
*/
|
*/
|
||||||
private Serializable convertOutboundProperty(
|
private Serializable convertOutboundProperty(
|
||||||
Locale contentLocale,
|
|
||||||
NodeRef nodeRef,
|
NodeRef nodeRef,
|
||||||
NodeRef pivotNodeRef,
|
NodeRef pivotNodeRef,
|
||||||
QName propertyQName,
|
QName propertyQName,
|
||||||
@@ -349,13 +349,13 @@ public class MLPropertyInterceptor implements MethodInterceptor
|
|||||||
{
|
{
|
||||||
// It is MLText
|
// It is MLText
|
||||||
MLText mlText = (MLText) outboundValue;
|
MLText mlText = (MLText) outboundValue;
|
||||||
ret = mlText.getClosestValue(contentLocale);
|
ret = getClosestValue(mlText);
|
||||||
}
|
}
|
||||||
else if(isCollectionOfMLText(outboundValue))
|
else if(isCollectionOfMLText(outboundValue))
|
||||||
{
|
{
|
||||||
Collection<?> col = (Collection<?>)outboundValue;
|
Collection<?> col = (Collection<?>)outboundValue;
|
||||||
ArrayList<String> answer = new ArrayList<String>(col.size());
|
ArrayList<String> answer = new ArrayList<String>(col.size());
|
||||||
Locale closestLocale = getClosestLocale(col, contentLocale);
|
Locale closestLocale = getClosestLocale(col);
|
||||||
for(Object o : col)
|
for(Object o : col)
|
||||||
{
|
{
|
||||||
MLText mlText = (MLText) o;
|
MLText mlText = (MLText) o;
|
||||||
@@ -412,7 +412,32 @@ public class MLPropertyInterceptor implements MethodInterceptor
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Locale getClosestLocale(Collection<?> collection, Locale locale)
|
private Serializable getClosestValue(MLText mlText)
|
||||||
|
{
|
||||||
|
Set<Locale> locales = mlText.getLocales();
|
||||||
|
Locale contentLocale = I18NUtil.getContentLocale();
|
||||||
|
Locale locale = I18NUtil.getNearestLocale(contentLocale, locales);
|
||||||
|
if (locale != null)
|
||||||
|
{
|
||||||
|
return mlText.getValue(locale);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the content locale is too specific, try relaxing it to just language
|
||||||
|
Locale contentLocaleLang = I18NUtil.getContentLocaleLang();
|
||||||
|
if (!contentLocaleLang.equals(locale))
|
||||||
|
{
|
||||||
|
locale = I18NUtil.getNearestLocale(contentLocaleLang, locales);
|
||||||
|
if (locale != null)
|
||||||
|
{
|
||||||
|
return mlText.getValue(locale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Just return the default translation
|
||||||
|
return mlText.getDefaultValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Locale getClosestLocale(Collection<?> collection)
|
||||||
{
|
{
|
||||||
if (collection.size() == 0)
|
if (collection.size() == 0)
|
||||||
{
|
{
|
||||||
@@ -425,17 +450,24 @@ public class MLPropertyInterceptor implements MethodInterceptor
|
|||||||
MLText mlText = (MLText)o;
|
MLText mlText = (MLText)o;
|
||||||
locales.addAll(mlText.keySet());
|
locales.addAll(mlText.keySet());
|
||||||
}
|
}
|
||||||
// Get a match
|
// Try the content locale
|
||||||
|
Locale locale = I18NUtil.getContentLocale();
|
||||||
Locale match = I18NUtil.getNearestLocale(locale, locales);
|
Locale match = I18NUtil.getNearestLocale(locale, locales);
|
||||||
if (match == null)
|
if (match == null)
|
||||||
{
|
{
|
||||||
// No close matches for the locale - go for the default locale
|
// Try just the content locale language
|
||||||
locale = I18NUtil.getLocale();
|
locale = I18NUtil.getContentLocaleLang();
|
||||||
match = I18NUtil.getNearestLocale(locale, locales);
|
match = I18NUtil.getNearestLocale(locale, locales);
|
||||||
if (match == null)
|
if (match == null)
|
||||||
{
|
{
|
||||||
// just get any locale
|
// No close matches for the locale - go for the default locale
|
||||||
match = I18NUtil.getNearestLocale(null, locales);
|
locale = I18NUtil.getLocale();
|
||||||
|
match = I18NUtil.getNearestLocale(locale, locales);
|
||||||
|
if (match == null)
|
||||||
|
{
|
||||||
|
// just get any locale
|
||||||
|
match = I18NUtil.getNearestLocale(null, locales);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return match;
|
return match;
|
||||||
|
Reference in New Issue
Block a user