diff --git a/config/alfresco/model-specific-services-context.xml b/config/alfresco/model-specific-services-context.xml index 6b3d8bbdd2..6fc8977884 100644 --- a/config/alfresco/model-specific-services-context.xml +++ b/config/alfresco/model-specific-services-context.xml @@ -12,7 +12,6 @@ - @@ -35,6 +34,9 @@ + + + diff --git a/config/alfresco/node-services-context.xml b/config/alfresco/node-services-context.xml index 8ca3f4e320..a3072e86c7 100644 --- a/config/alfresco/node-services-context.xml +++ b/config/alfresco/node-services-context.xml @@ -13,15 +13,6 @@ - - - - - - - - - mlAwareNodeService diff --git a/source/java/org/alfresco/repo/model/filefolder/FileFolderServiceImpl.java b/source/java/org/alfresco/repo/model/filefolder/FileFolderServiceImpl.java index 90d1fbe834..756aa74523 100644 --- a/source/java/org/alfresco/repo/model/filefolder/FileFolderServiceImpl.java +++ b/source/java/org/alfresco/repo/model/filefolder/FileFolderServiceImpl.java @@ -30,7 +30,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; -import java.util.Locale; import java.util.Map; import org.alfresco.error.AlfrescoRuntimeException; @@ -123,7 +122,6 @@ public class FileFolderServiceImpl implements FileFolderService private CopyService copyService; private SearchService searchService; private ContentService contentService; - private MultilingualContentService multilingualContentService; private MimetypeService mimetypeService; // TODO: Replace this with a more formal means of identifying "system" folders (i.e. aspect or UUID) @@ -167,11 +165,6 @@ public class FileFolderServiceImpl implements FileFolderService this.contentService = contentService; } - public void setMultilingualContentService(MultilingualContentService multilingualContentService) - { - this.multilingualContentService = multilingualContentService; - } - public void setMimetypeService(MimetypeService mimetypeService) { this.mimetypeService = mimetypeService; @@ -217,40 +210,15 @@ public class FileFolderServiceImpl implements FileFolderService */ private FileInfo toFileInfo(NodeRef nodeRef, boolean addTranslations) throws InvalidTypeException { - // get the file attributes + // Get the file attributes Map properties = nodeService.getProperties(nodeRef); - // is it a folder + // Is it a folder QName typeQName = nodeService.getType(nodeRef); boolean isFolder = isFolder(typeQName); - Map translations = null; - if (!isFolder && addTranslations) - { - // Get any translations - translations = new HashMap(13); - // Check for the ML aspect - if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT)) - { - // Get all the translations - Map translationsToConvert = multilingualContentService.getTranslations(nodeRef); - for (Map.Entry entry : translationsToConvert.entrySet()) - { - Locale locale = entry.getKey(); - NodeRef nodeRefToConvert = entry.getValue(); - FileInfo convertedFileInfo = toFileInfo(nodeRefToConvert, false); - // Add to map - translations.put(locale, convertedFileInfo); - } - } - } - else - { - translations = Collections.emptyMap(); - } - - // construct the file info and add to the results - FileInfo fileInfo = new FileInfoImpl(nodeRef, isFolder, properties, translations); - // done + // Construct the file info and add to the results + FileInfo fileInfo = new FileInfoImpl(nodeRef, isFolder, properties); + // Done return fileInfo; } diff --git a/source/java/org/alfresco/repo/model/filefolder/FileInfoImpl.java b/source/java/org/alfresco/repo/model/filefolder/FileInfoImpl.java index ce870f4215..8b130e3643 100644 --- a/source/java/org/alfresco/repo/model/filefolder/FileInfoImpl.java +++ b/source/java/org/alfresco/repo/model/filefolder/FileInfoImpl.java @@ -25,9 +25,7 @@ package org.alfresco.repo.model.filefolder; import java.io.Serializable; -import java.util.Collections; import java.util.Date; -import java.util.Locale; import java.util.Map; import org.alfresco.model.ContentModel; @@ -46,7 +44,6 @@ public class FileInfoImpl implements FileInfo { private NodeRef nodeRef; private NodeRef linkNodeRef; - private Map translations; private boolean isFolder; private boolean isLink; private Map properties; @@ -54,33 +51,14 @@ public class FileInfoImpl implements FileInfo /** * Package-level constructor */ - /* package */ FileInfoImpl(NodeRef nodeRef, boolean isFolder, Map properties) - { - this(nodeRef, isFolder, properties, Collections.emptyMap()); - } - - /** - * Package-level constructor - * - * @param translations a map of translations including this instance. It may be null. - */ /* package */ FileInfoImpl( NodeRef nodeRef, boolean isFolder, - Map properties, - Map translations) + Map properties) { this.nodeRef = nodeRef; this.isFolder = isFolder; this.properties = properties; - if (translations == null || isFolder) - { - this.translations = Collections.emptyMap(); - } - else - { - this.translations = translations; - } // Check if this is a link node if ( properties.containsKey( ContentModel.PROP_LINK_DESTINATION)) @@ -97,7 +75,15 @@ public class FileInfoImpl implements FileInfo @Override public boolean equals(Object obj) { - if (obj == null || this.getClass().isInstance(obj)) + if (obj == null) + { + return false; + } + else if (this == obj) + { + return true; + } + else if (obj instanceof FileInfoImpl == false) { return false; } @@ -130,8 +116,6 @@ public class FileInfoImpl implements FileInfo sb.append(linkNodeRef); } - sb.append(", translations=").append(translations.size()); - sb.append("]"); return sb.toString(); } @@ -156,11 +140,6 @@ public class FileInfoImpl implements FileInfo return linkNodeRef; } - public Map getTranslations() - { - return translations; - } - public String getName() { return (String) properties.get(ContentModel.PROP_NAME); diff --git a/source/java/org/alfresco/repo/model/filefolder/MLTranslationInterceptor.java b/source/java/org/alfresco/repo/model/filefolder/MLTranslationInterceptor.java index 082ed697d1..9e195545ff 100644 --- a/source/java/org/alfresco/repo/model/filefolder/MLTranslationInterceptor.java +++ b/source/java/org/alfresco/repo/model/filefolder/MLTranslationInterceptor.java @@ -97,6 +97,7 @@ public class MLTranslationInterceptor implements MethodInterceptor private NodeService nodeService; private MultilingualContentService multilingualContentService; + private FileFolderService fileFolderService; /** * Constructor. @@ -115,6 +116,11 @@ public class MLTranslationInterceptor implements MethodInterceptor this.multilingualContentService = multilingualContentService; } + public void setFileFolderService(FileFolderService fileFolderService) + { + this.fileFolderService = fileFolderService; + } + /** * Converts the node referenice where an alternative translation should be used. * @@ -133,13 +139,14 @@ public class MLTranslationInterceptor implements MethodInterceptor { return nodeRef; } - // Find the translation - Map translations = multilingualContentService.getTranslations(nodeRef); Locale filterLocale = I18NUtil.getContentLocaleOrNull(); - Set possibleLocales = translations.keySet(); - Locale localeToUse = I18NUtil.getNearestLocale(filterLocale, possibleLocales); - // Select the node - NodeRef translatedNodeRef = translations.get(localeToUse); + if (filterLocale == null) + { + // We aren't doing any filtering + return nodeRef; + } + // Find the best translation. This won't return null. + NodeRef translatedNodeRef = multilingualContentService.getTranslationForLocale(nodeRef, filterLocale); // Done if (logger.isDebugEnabled()) { @@ -152,7 +159,7 @@ public class MLTranslationInterceptor implements MethodInterceptor logger.debug("NodeRef substitution: " + nodeRef + " (no change)"); } } - return nodeRef; + return translatedNodeRef; } /** @@ -160,8 +167,6 @@ public class MLTranslationInterceptor implements MethodInterceptor * * @param fileInfo the basic file or folder info * @return Returns a replacement if required - * - * @see FileInfo#getTranslations() */ private FileInfo getTranslatedFileInfo(FileInfo fileInfo) { @@ -175,28 +180,20 @@ public class MLTranslationInterceptor implements MethodInterceptor { return fileInfo; } - // Ignore files without translations - Map translations = fileInfo.getTranslations(); - if (translations.size() == 0) + NodeRef nodeRef = fileInfo.getNodeRef(); + // Get the best translation for the node + NodeRef translatedNodeRef = getTranslatedNodeRef(nodeRef); + // Convert to FileInfo, if required + FileInfo translatedFileInfo = null; + if (nodeRef.equals(translatedNodeRef)) { - return fileInfo; + // No need to do any more work + translatedFileInfo = fileInfo; } - // Get the locale to use - Set possibleLocales = translations.keySet(); - Locale filterLocale = I18NUtil.getContentLocaleOrNull(); - Locale localeToUse = I18NUtil.getNearestLocale(filterLocale, possibleLocales); - FileInfo translatedFileInfo = translations.get(localeToUse); - // Done - if (logger.isDebugEnabled()) + else { - if (fileInfo.equals(translatedFileInfo)) - { - logger.debug("FileInfo substitution: " + fileInfo + " --> " + translatedFileInfo); - } - else - { - logger.debug("FileInfo substitution: " + fileInfo + " (no change)"); - } + // Get the FileInfo + translatedFileInfo = fileFolderService.getFileInfo(translatedNodeRef); } return translatedFileInfo; } @@ -207,7 +204,12 @@ public class MLTranslationInterceptor implements MethodInterceptor Object ret = null; String methodName = invocation.getMethod().getName(); - if (METHOD_NAMES_LIST.contains(methodName)) + if (I18NUtil.getContentLocaleOrNull() == null) + { + // This can shortcut anything as there is no filtering going on + return invocation.proceed(); + } + else if (METHOD_NAMES_LIST.contains(methodName)) { List fileInfos = (List) invocation.proceed(); // Compile a set to ensure we don't get duplicates @@ -223,13 +225,14 @@ public class MLTranslationInterceptor implements MethodInterceptor Set alreadyPresent = new HashSet(fileInfos.size() * 2 + 1); for (FileInfo info : fileInfos) { - if (alreadyPresent.contains(info)) + FileInfo translatedFileInfo = translatedFileInfos.get(info); + if (alreadyPresent.contains(translatedFileInfo)) { // We've done this one continue; } - alreadyPresent.add(info); - orderedResults.add(translatedFileInfos.get(info)); + alreadyPresent.add(translatedFileInfo); + orderedResults.add(translatedFileInfo); } ret = orderedResults; } diff --git a/source/java/org/alfresco/repo/model/ml/MLContainerType.java b/source/java/org/alfresco/repo/model/ml/MLContainerType.java index da1a7db629..313a78664f 100644 --- a/source/java/org/alfresco/repo/model/ml/MLContainerType.java +++ b/source/java/org/alfresco/repo/model/ml/MLContainerType.java @@ -22,7 +22,6 @@ * the FLOSS exception, and it is also available here: * http://www.alfresco.com/legal/licensing" */ - package org.alfresco.repo.model.ml; import java.io.Serializable; @@ -51,17 +50,8 @@ import org.alfresco.service.namespace.QName; public class MLContainerType implements NodeServicePolicies.OnUpdatePropertiesPolicy { - /** - * set a property with this QName when the deletion process is running on the mlContainer. In this case - * the policies of the remove aspect of mlDocument don't delete one more time the mlContainer. - */ - /*package*/ static QName PROP_NAME_DELETION_RUNNING = QName.createQName("__MLContanier_", "Deletion_Running"); - - // Dependencies private PolicyComponent policyComponent; - private NodeService nodeService; - private MultilingualContentService multilingualContentService; /** diff --git a/source/java/org/alfresco/repo/model/ml/MLContentInterceptor.java b/source/java/org/alfresco/repo/model/ml/MLContentInterceptor.java index 3612116cd2..959a137a28 100644 --- a/source/java/org/alfresco/repo/model/ml/MLContentInterceptor.java +++ b/source/java/org/alfresco/repo/model/ml/MLContentInterceptor.java @@ -103,18 +103,26 @@ public class MLContentInterceptor implements MethodInterceptor } // Get the pivot translation NodeRef pivotNodeRef = multilingualContentService.getPivotTranslation(nodeRef); - // Get the reader from that - ContentReader pivotContentReader = contentService.getReader(pivotNodeRef, propertyQName); - // Done - if (logger.isDebugEnabled()) + if (pivotNodeRef == null) { - logger.debug( - "Converted reader for empty translation: \n" + - " Empty Translation: " + nodeRef + "\n" + - " Pivot Translation: " + pivotNodeRef + "\n" + - " Reader: " + pivotContentReader); + // This is technically possible + ret = invocation.proceed(); + } + else + { + // Get the reader from that + ContentReader pivotContentReader = contentService.getReader(pivotNodeRef, propertyQName); + // Done + if (logger.isDebugEnabled()) + { + logger.debug( + "Converted reader for empty translation: \n" + + " Empty Translation: " + nodeRef + "\n" + + " Pivot Translation: " + pivotNodeRef + "\n" + + " Reader: " + pivotContentReader); + } + ret = pivotContentReader; } - ret = pivotContentReader; } else { diff --git a/source/java/org/alfresco/repo/model/ml/MultilingualContentServiceImpl.java b/source/java/org/alfresco/repo/model/ml/MultilingualContentServiceImpl.java index 0ac46f8ecc..225d031544 100644 --- a/source/java/org/alfresco/repo/model/ml/MultilingualContentServiceImpl.java +++ b/source/java/org/alfresco/repo/model/ml/MultilingualContentServiceImpl.java @@ -561,6 +561,16 @@ public class MultilingualContentServiceImpl implements MultilingualContentServic Set locales = nodeRefsByLocale.keySet(); Locale nearestLocale = I18NUtil.getNearestLocale(locale, locales); NodeRef nearestNodeRef = nodeRefsByLocale.get(nearestLocale); + if (nearestNodeRef == null) + { + // There is no translation for the locale, so get the pivot translation + nearestNodeRef = getPivotTranslation(translationNodeRef); + if (nearestNodeRef == null) + { + // There is no pivot translation, so just use the given node + nearestNodeRef = translationNodeRef; + } + } // Done if (logger.isDebugEnabled()) { @@ -629,24 +639,34 @@ public class MultilingualContentServiceImpl implements MultilingualContentServic /** @inheritDoc */ public NodeRef getPivotTranslation(NodeRef nodeRef) { + Locale containerLocale = null; if(nodeService.hasAspect(nodeRef, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT)) { NodeRef container = getTranslationContainer(nodeRef); - Locale containerLocale = (Locale) nodeService.getProperty(container, ContentModel.PROP_LOCALE); - - return getTranslationForLocale(nodeRef, containerLocale); + containerLocale = (Locale) nodeService.getProperty(container, ContentModel.PROP_LOCALE); } else if(ContentModel.TYPE_MULTILINGUAL_CONTAINER.equals(nodeService.getType(nodeRef))) { - Locale containerLocale = (Locale) nodeService.getProperty(nodeRef, ContentModel.PROP_LOCALE); - return getTranslationForLocale(nodeRef, containerLocale); + containerLocale = (Locale) nodeService.getProperty(nodeRef, ContentModel.PROP_LOCALE); } else { logger.warn("The node is not multilingual " + nodeRef); - + } + // Get all the translations + Map nodeRefsByLocale = getTranslations(nodeRef); + // Get the closest matching locale + Set locales = nodeRefsByLocale.keySet(); + Locale nearestLocale = I18NUtil.getNearestLocale(containerLocale, locales); + if (nearestLocale == null) + { + // There is pivot translation return null; } + else + { + return nodeRefsByLocale.get(nearestLocale); + } } /** diff --git a/source/java/org/alfresco/repo/model/ml/tools/MultilingualContentServiceImplTest.java b/source/java/org/alfresco/repo/model/ml/tools/MultilingualContentServiceImplTest.java index 68153ee3ec..9ee555d63c 100644 --- a/source/java/org/alfresco/repo/model/ml/tools/MultilingualContentServiceImplTest.java +++ b/source/java/org/alfresco/repo/model/ml/tools/MultilingualContentServiceImplTest.java @@ -137,31 +137,51 @@ public class MultilingualContentServiceImplTest extends AbstractMultilingualTest assertFalse("Missing Translation List false. Locale " + loc2 + " or " + loc3 + " found", missing.contains(loc2.toString()) || missing.contains(loc3.toString())); } - @SuppressWarnings("unused") - public void testPivotTranslation() throws Exception + public void testGetTranslationForLocale() throws Exception { NodeRef chineseContentNodeRef = createContent(); + NodeRef mlContainerNodeRef = multilingualContentService.makeTranslation(chineseContentNodeRef, Locale.CHINESE); + NodeRef frenchContentNodeRef = createContent(); + multilingualContentService.addTranslation(frenchContentNodeRef, chineseContentNodeRef, Locale.FRENCH); + // Get the chinese translation + assertEquals("Chinese translation should be present", + chineseContentNodeRef, + multilingualContentService.getTranslationForLocale(mlContainerNodeRef, Locale.CHINESE)); + // Get the french translation + assertEquals("French translation should be present", + frenchContentNodeRef, + multilingualContentService.getTranslationForLocale(mlContainerNodeRef, Locale.FRENCH)); + // The Italian should return the pivot + assertEquals("French translation should be present", + chineseContentNodeRef, + multilingualContentService.getTranslationForLocale(mlContainerNodeRef, Locale.ITALIAN)); + } + + @SuppressWarnings("unused") + public void testGetPivotTranslation() throws Exception + { + NodeRef chineseContentNodeRef = createContent(); NodeRef mlContainerNodeRef = multilingualContentService.makeTranslation(chineseContentNodeRef, Locale.CHINESE); // make sure that the pivot language is set assertNotNull("Pivot language not set", nodeService.getProperty(mlContainerNodeRef, ContentModel.PROP_LOCALE)); // make sure that the pivot language is correctly set - assertTrue("Pivot language not correctly set", nodeService.getProperty(mlContainerNodeRef, ContentModel.PROP_LOCALE).equals(Locale.CHINESE)); + assertEquals("Pivot language not correctly set", Locale.CHINESE, nodeService.getProperty(mlContainerNodeRef, ContentModel.PROP_LOCALE)); NodeRef frenchContentNodeRef = createContent(); multilingualContentService.addTranslation(frenchContentNodeRef, chineseContentNodeRef, Locale.FRENCH); // make sure that the pivot noderef is correct - assertTrue("Pivot node ref not correct", multilingualContentService.getPivotTranslation(mlContainerNodeRef).equals(chineseContentNodeRef)); + assertEquals("Unable to get pivot from container", chineseContentNodeRef, multilingualContentService.getPivotTranslation(mlContainerNodeRef)); + assertEquals("Unable to get pivot from translation", chineseContentNodeRef, multilingualContentService.getPivotTranslation(frenchContentNodeRef)); // modify the pivot language nodeService.setProperty(mlContainerNodeRef, ContentModel.PROP_LOCALE, Locale.FRENCH); // make sure that the modified pivot noderef is correct - assertTrue("Pivot node ref not correct", multilingualContentService.getPivotTranslation(mlContainerNodeRef).equals(frenchContentNodeRef)); - + assertEquals("Pivot node ref not correct", frenchContentNodeRef, multilingualContentService.getPivotTranslation(mlContainerNodeRef)); } @SuppressWarnings("unused") diff --git a/source/java/org/alfresco/repo/node/MLTranslationInterceptor.java b/source/java/org/alfresco/repo/node/MLTranslationInterceptor.java deleted file mode 100644 index e26b900520..0000000000 --- a/source/java/org/alfresco/repo/node/MLTranslationInterceptor.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * 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.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.Set; - -import org.alfresco.i18n.I18NUtil; -import org.alfresco.model.ContentModel; -import org.alfresco.service.cmr.ml.MultilingualContentService; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.aopalliance.intercept.MethodInterceptor; -import org.aopalliance.intercept.MethodInvocation; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Interceptor to - * - filter the multilingual nodes to display the documents in the prefered language of teh user - * - * @author yanipig - */ -public class MLTranslationInterceptor implements MethodInterceptor -{ - private static Log logger = LogFactory.getLog(MLTranslationInterceptor.class); - - private NodeService directNodeService; - - private MultilingualContentService directMultilingualContentService; - - @SuppressWarnings("unchecked") - public Object invoke(MethodInvocation invocation) throws Throwable - { - Object ret = null; - String methodName = invocation.getMethod().getName(); - - // intercept the methods getChildAssocs and getChildByNames to apply filter. - if (methodName.equals("getChildAssocs") || methodName.equals("getChildByName")) - { - ret = invocation.proceed(); - - NodeRef parent = (NodeRef) invocation.getArguments()[0]; - - // all the association returned by the method - List allChildAssoc = (List) ret; - - // get the user content filter language - Locale filterLocale = I18NUtil.getContentLocaleOrNull(); - - if(filterLocale != null - && directNodeService.getType(parent).equals(ContentModel.TYPE_FOLDER) - && ret != null - && !allChildAssoc.isEmpty() - ) - { - - // the list of Association to return - List toReturn = new ArrayList(); - // the ml containers found in the folder - List mlContainers = new ArrayList(); - - // construct the list of ML Container - for (ChildAssociationRef assoc : allChildAssoc) - { - NodeRef child = assoc.getChildRef(); - - QName type = directNodeService.getType(child); - - if(type.equals(ContentModel.TYPE_CONTENT) && - directNodeService.hasAspect(child, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT)) - { - NodeRef container = directMultilingualContentService.getTranslationContainer(child); - - if (!mlContainers.contains(container)) - { - mlContainers.add(container); - } - } - else - { - // no specific treatment for folder and non-multilingual document - toReturn.add(assoc); - } - } - - // for each mlContainer found, choose the unique document to return - for(NodeRef container : mlContainers) - { - // get each translation language - Set locales = directMultilingualContentService.getTranslations(container).keySet(); - - if(locales != null && locales.size() > 0) - { - Locale matchedLocal = I18NUtil.getNearestLocale(filterLocale, locales); - - NodeRef matchedTranslation = null; - - // if the filter language is not found - if(matchedLocal == null) - { - // get the pivot translation - matchedTranslation = directMultilingualContentService.getPivotTranslation(container); - } - else - { - // get the matched translation - matchedTranslation = directMultilingualContentService.getTranslations(container).get(matchedLocal); - } - - toReturn.add(new ChildAssociationRef(null, null, null, matchedTranslation)); - } - } - - ret = toReturn; - - if (logger.isDebugEnabled()) - { - logger.debug("Filter has found " + - allChildAssoc.size() + " entries, " + - mlContainers.size() + " different ML Container " + - "and returns " + toReturn.size() + " nodes"); - } - } - - } - else - { - ret = invocation.proceed(); - } - - return ret; - } - - public void setDirectMultilingualContentService( - MultilingualContentService multilingualContentService) - { - this.directMultilingualContentService = multilingualContentService; - } - - public void setDirectNodeService(NodeService nodeService) - { - this.directNodeService = nodeService; - } -} \ No newline at end of file diff --git a/source/java/org/alfresco/service/cmr/ml/MultilingualContentService.java b/source/java/org/alfresco/service/cmr/ml/MultilingualContentService.java index 1e11ef8efb..86c1809a44 100644 --- a/source/java/org/alfresco/service/cmr/ml/MultilingualContentService.java +++ b/source/java/org/alfresco/service/cmr/ml/MultilingualContentService.java @@ -123,13 +123,13 @@ public interface MultilingualContentService /** * Given a cm:mlDocument, this method attempts to find the best translation for the given * locale. If there is not even a - * {@link org.alfresco.i18n.I18NUtil#getNearestLocale(Locale, Set) partial match}, then null - * is returned. + * {@link org.alfresco.i18n.I18NUtil#getNearestLocale(Locale, Set) partial match}, then the + * {@link #getPivotTranslation(NodeRef) pivot translation} is used. If that also gives no results + * then the translation itself is returned. * * @param translationNodeRef the cm:mlDocument * @param locale the target locale - * @return Returns Returns the best match for the locale, or null if there - * is no near match. + * @return Returns the best match for the locale (never null) * * @see #getTranslations(NodeRef) * @see org.alfresco.i18n.I18NUtil#getNearestLocale(Locale, Set) @@ -157,7 +157,8 @@ public interface MultilingualContentService * * @param nodeRef a cm:mlDocument * @return Returns a corresponding cm:mlDocument that matches the locale of - * of the cm:mlContainer. + * of the cm:mlContainer. null is returned if there is no + * pivot translation. */ @Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef"}) NodeRef getPivotTranslation(NodeRef nodeRef); diff --git a/source/java/org/alfresco/service/cmr/model/FileInfo.java b/source/java/org/alfresco/service/cmr/model/FileInfo.java index 3764a1f4dc..e8e418404f 100644 --- a/source/java/org/alfresco/service/cmr/model/FileInfo.java +++ b/source/java/org/alfresco/service/cmr/model/FileInfo.java @@ -62,15 +62,6 @@ public interface FileInfo */ public NodeRef getLinkNodeRef(); - /** - * Get all translated versions of the file info. The map will always be empty if this - * instance references {@link #isFolder() a folder}. The map may also be empty if the - * file represented is not multilingual. - * - * @return Returns a map of transalations keyed on locale - */ - public Map getTranslations(); - /** * @return Returns the name of the file or folder within the parent folder */