mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V3.2 to HEAD
17363: Fix to DbNodeServiceImple to allow restored nodes. 17384: Minor comments 17451: Fix ETHREEOH-2751 / ETWOONE-340 - specialising a node through an action doesn't set default values from model 17459: ETHREEOH-2391 - Invite pending task now has lots of properties 17465: Repo side fix for ETHREEOH-3010: Inbound and outbound Mltext multiple property are not converted correctly 17478: Fix ETHREEOH-3340 - WCM - Revert to snapshot failure (fix AVM getListing -> AVNSync compare -> WCM revertSnapshot) 17483: (record only) Merged V3.1 to V3.2 (record-only) 17482: (record-only) due to earlier back-merge 17493: Fix for ETHREEOH-3342: index.recovery.mode example is incorrect 17494: Fix for ETHREEOH-3027: missingFullTextReindexTrigger (from index-recovery-context.xml) job does not work. 17510: Fix for ETHREEOH-1147: Indexing large indices can lead to Java Heap space. 17511: Fix for ETHREEOH-1271: It is possible to add one category more than one time to the same content or space 17513: ETHREEOH_3366: Altered DictionaryDAOImpl so that passing a null QName into getType and getAspect does not result in an NPE 17531: ETHREEOH-1186: Corrected rssfeed.get.js so a user can configure a RSS Feed dashlet that has been placed on their own dashboard 17550: ETHREEOH-2317: Rule not fired when document has no content 17556: Fixed ETHREEOH-1229: Can't delete space that contains "translation without content" 17558: Fix for ETHREEOH-3356: Forms fail to persist if property or association name has an _ (underscore) in it 17572: Changed caching of person NodeRefs so that duplicates are detected better 17573: Fixed UTF-8 for file with encoded chars 17576: LockAcquisitionException message specific to failed release of taken-over lock ___________________________________________________________________ Modified: svn:mergeinfo Merged /alfresco/BRANCHES/V3.2:r17363,17384,17451,17459,17465,17478,17483,17493-17494,17510-17511,17513,17531,17550,17556,17558,17572-17573,17576 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18140 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -25,11 +25,15 @@
|
||||
package org.alfresco.repo.node;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
import org.alfresco.model.ContentModel;
|
||||
@@ -352,6 +356,22 @@ public class MLPropertyInterceptor implements MethodInterceptor
|
||||
MLText mlText = (MLText) outboundValue;
|
||||
ret = mlText.getClosestValue(contentLocale);
|
||||
}
|
||||
else if(isCollectionOfMLText(outboundValue))
|
||||
{
|
||||
Collection<?> col = (Collection<?>)outboundValue;
|
||||
ArrayList<String> answer = new ArrayList<String>(col.size());
|
||||
Locale closestLocale = getClosestLocale(col, contentLocale);
|
||||
for(Object o : col)
|
||||
{
|
||||
MLText mlText = (MLText) o;
|
||||
String value = mlText.get(closestLocale);
|
||||
if(value != null)
|
||||
{
|
||||
answer.add(value);
|
||||
}
|
||||
}
|
||||
ret = answer;
|
||||
}
|
||||
else if (pivotNodeRef != null) // It is an empty translation
|
||||
{
|
||||
if (propertyQName.equals(ContentModel.PROP_MODIFIED))
|
||||
@@ -397,6 +417,58 @@ public class MLPropertyInterceptor implements MethodInterceptor
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Locale getClosestLocale(Collection<?> collection, Locale locale)
|
||||
{
|
||||
if (collection.size() == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// Use the available keys as options
|
||||
HashSet<Locale> locales = new HashSet<Locale>();
|
||||
for(Object o : collection)
|
||||
{
|
||||
MLText mlText = (MLText)o;
|
||||
locales.addAll(mlText.keySet());
|
||||
}
|
||||
// Get a match
|
||||
Locale match = I18NUtil.getNearestLocale(locale, locales);
|
||||
if (match == null)
|
||||
{
|
||||
// No close matches for the locale - go for the default locale
|
||||
locale = I18NUtil.getLocale();
|
||||
match = I18NUtil.getNearestLocale(locale, locales);
|
||||
if (match == null)
|
||||
{
|
||||
// just get any locale
|
||||
match = I18NUtil.getNearestLocale(null, locales);
|
||||
}
|
||||
}
|
||||
return match;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param outboundValue
|
||||
* @return
|
||||
*/
|
||||
private boolean isCollectionOfMLText(Serializable outboundValue)
|
||||
{
|
||||
if(outboundValue instanceof Collection)
|
||||
{
|
||||
for(Object o : (Collection<?>)outboundValue)
|
||||
{
|
||||
if(!(o instanceof MLText))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private Map<QName, Serializable> convertInboundProperties(
|
||||
Map<QName, Serializable> currentProperties,
|
||||
Map<QName, Serializable> newProperties,
|
||||
@@ -443,10 +515,83 @@ public class MLPropertyInterceptor implements MethodInterceptor
|
||||
else if (propertyDef.getDataType().getName().equals(DataTypeDefinition.MLTEXT))
|
||||
{
|
||||
// Don't mess with multivalued properties or instances already of type MLText
|
||||
if (propertyDef.isMultiValued() || (inboundValue instanceof MLText) )
|
||||
if (inboundValue instanceof MLText)
|
||||
{
|
||||
ret = inboundValue;
|
||||
}
|
||||
else if(propertyDef.isMultiValued())
|
||||
{
|
||||
// leave collectios of ML text alone
|
||||
if(isCollectionOfMLText(inboundValue))
|
||||
{
|
||||
ret = inboundValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Anything else we assume is localised
|
||||
if (currentValue == null && nodeRef != null)
|
||||
{
|
||||
currentValue = nodeService.getProperty(nodeRef, propertyQName);
|
||||
}
|
||||
ArrayList<MLText> returnMLList = new ArrayList<MLText>();
|
||||
if (currentValue != null)
|
||||
{
|
||||
Collection<MLText> currentCollection = DefaultTypeConverter.INSTANCE.getCollection(MLText.class, currentValue);
|
||||
returnMLList.addAll(currentCollection);
|
||||
}
|
||||
Collection<String> inboundCollection = DefaultTypeConverter.INSTANCE.getCollection(String.class, inboundValue);
|
||||
int count = 0;
|
||||
for(String current : inboundCollection)
|
||||
{
|
||||
MLText newMLValue;
|
||||
if(count < returnMLList.size())
|
||||
{
|
||||
MLText currentMLValue = returnMLList.get(count);
|
||||
newMLValue = new MLText();
|
||||
if (currentMLValue != null)
|
||||
{
|
||||
newMLValue.putAll(currentMLValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newMLValue = new MLText();
|
||||
}
|
||||
newMLValue.addValue(contentLocale, current);
|
||||
if(count < returnMLList.size())
|
||||
{
|
||||
returnMLList.set(count, newMLValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
returnMLList.add(newMLValue);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
// remove locale settings for anything after
|
||||
for(int i = count; i < returnMLList.size(); i++)
|
||||
{
|
||||
MLText currentMLValue = returnMLList.get(i);
|
||||
MLText newMLValue = new MLText();
|
||||
if (currentMLValue != null)
|
||||
{
|
||||
newMLValue.putAll(currentMLValue);
|
||||
}
|
||||
newMLValue.remove(contentLocale);
|
||||
returnMLList.set(i, newMLValue);
|
||||
}
|
||||
// tidy up empty locales
|
||||
ArrayList<MLText> tidy = new ArrayList<MLText>();
|
||||
for(MLText mlText : returnMLList)
|
||||
{
|
||||
if(mlText.keySet().size() > 0)
|
||||
{
|
||||
tidy.add(mlText);
|
||||
}
|
||||
}
|
||||
ret = tidy;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is a multilingual single-valued property
|
||||
|
Reference in New Issue
Block a user