diff --git a/config/alfresco/ml/content-filter-lang.xml b/config/alfresco/ml/content-filter-lang.xml
index e7ea15dc1e..7ae240bea9 100644
--- a/config/alfresco/ml/content-filter-lang.xml
+++ b/config/alfresco/ml/content-filter-lang.xml
@@ -9,7 +9,7 @@
@@ -19,216 +19,192 @@
The list is ordered by language code ascending.
-->
- Afar
- Abkhazian
- Avestan
- Afrikaans
- Akan
- Amharic
- Aragonese
- Arabic
- Assamese
- Avaric
- Aymara
- Azerbaijani
- Bashkir
- Belarusian
- Bulgarian
- Bihari
- Bislama
- Bambara
- Bengali
- Tibetan
- Breton
- Bosnian
- Catalan; Valencian
- Chechen
- Chamorro
- Corsican
- Cree
- Czech
-
- Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic
-
- Chuvash
- Welsh
- Danish
- German
-
- Divehi; Dhivehi; Maldivian
-
- Dzongkha
- Ewe
- Greek
- English
- Esperanto
- Spanish
- Estonian
- Basque
- Persian
- Fulah
- Finnish
- Fijian
- Faroese
- French
- Western Frisian
- Irish
-
- Gaelic; Scottish Gaelic
-
- Galician
- Guarani
- Gujarati
- Manx
- Hausa
- Hebrew
- Hindi
- Hiri Motu
- Croatian
-
- Haitian; Haitian Creole
-
- Hungarian
- Armenian
- Herero
-
- Interlingua (International Auxiliary Language Association)
-
- Indonesian
- Interlingue
- Igbo
- Sichuan Yi
- Inupiaq
- Ido
- Icelandic
- Italian
- Inuktitut
- Japanese
- Javanese
- Georgian
- Kongo
- Kikuyu; Gikuyu
- Kuanyama; Kwanyama
- Kazakh
-
- Kalaallisut; Greenlandic
-
- Khmer
- Kannada
- Korean
- Kanuri
- Kashmiri
- Kurdish
- Komi
- Cornish
- Kirghiz
- Latin
-
- Luxembourgish; Letzeburgesch
-
- Ganda
-
- Limburgan; Limburger; Limburgish
-
- Lingala
- Lao
- Lithuanian
- Luba-Katanga
- Latvian
- Malagasy
- Marshallese
- Maori
- Macedonian
- Malayalam
- Mongolian
- Moldavian
- Marathi
- Malay
- Maltese
- Burmese
- Nauru
- Norvégien Bokmål
-
- Ndebele, North; North Ndebele
-
- Nepali
- Ndonga
- Dutch
- Norwegian Nynorsk
- Norwegian
-
- Ndebele, South; South Ndebele
-
- Navajo; Navaho
-
- Chichewa; Chewa; Nyanja
-
-
- Occitan (post 1500); Provençal
-
- Ojibwa
- Oromo
- Oriya
- Ossetian; Ossetic
- Panjabi; Punjabi
- Pali
- Polish
- Pushto
- Portuguese
- Quechua
- Raeto-Romance
- Rundi
- Romanian
- Russian
- Kinyarwanda
- Sanskrit
- Sardinian
- Sindhi
- Northern Sami
- Sango
- Sinhala; Sinhalese
- Slovak
- Slovenian
- Samoan
- Shona
- Somali
- Albanian
- Serbian
- Swati
- Sotho, Southern
- Sundanese
- Swedish
- Swahili
- Tamil
- Telugu
- Tajik
- Thai
- Tigrinya
- Turkmen
- Tagalog
- Tswana
- Tonga (Tonga Islands)
- Turkish
- Turkish
- Tsonga
- Tatar
- Twi
- Tahitian
- Uighur; Uyghur
- Ukrainian
- Urdu
- Uzbek
- Venda
- Vietnamese
- Volapük
- Walloon
- Wolof
- Xhosa
- Yiddish
- Yoruba
- Zhuang; Chuang
- Chinese
- Zulu
+ Afar
+ Abkhazian
+ Avestan
+ Afrikaans
+ Akan
+ Amharic
+ Aragonese
+ Arabic
+ Assamese
+ Avaric
+ Aymara
+ Azerbaijani
+ Bashkir
+ Belarusian
+ Bulgarian
+ Bihari
+ Bislama
+ Bambara
+ Bengali
+ Tibetan
+ Breton
+ Bosnian
+ Catalan; Valencian
+ Chechen
+ Chamorro
+ Corsican
+ Cree
+ Czech
+ Slavic
+ Chuvash
+ Welsh
+ Danish
+ German
+ Maldivian
+ Dzongkha
+ Ewe
+ Greek
+ English
+ Esperanto
+ Spanish
+ Estonian
+ Basque
+ Persian
+ Fulah
+ Finnish
+ Fijian
+ Faroese
+ French
+ Western Frisian
+ Irish
+ Gaelic
+ Galician
+ Guarani
+ Gujarati
+ Manx
+ Hausa
+ Hebrew
+ Hindi
+ Hiri Motu
+ Croatian
+ Haitian
+ Hungarian
+ Armenian
+ Herero
+ Interlingua
+ Indonesian
+ Interlingue
+ Igbo
+ Sichuan Yi
+ Inupiaq
+ Ido
+ Icelandic
+ Italian
+ Inuktitut
+ Japanese
+ Javanese
+ Georgian
+ Kongo
+ Kikuyu; Gikuyu
+ Kuanyama; Kwanyama
+ Kazakh
+ Kalaallisut; Greenlandic
+ Khmer
+ Kannada
+ Korean
+ Kanuri
+ Kashmiri
+ Kurdish
+ Komi
+ Cornish
+ Kirghiz
+ Latin
+ Luxembourgish; Letzeburgesch
+ Ganda
+ Limburgan; Limburger; Limburgish
+ Lingala
+ Lao
+ Lithuanian
+ Luba-Katanga
+ Latvian
+ Malagasy
+ Marshallese
+ Maori
+ Macedonian
+ Malayalam
+ Mongolian
+ Moldavian
+ Marathi
+ Malay
+ Maltese
+ Burmese
+ Nauru
+ Norvégien Bokmål
+ North Ndebele
+ Nepali
+ Ndonga
+ Dutch
+ Norwegian Nynorsk
+ Norwegian
+ South Ndebele
+ Navajo; Navaho
+ Chichewa; Chewa; Nyanja
+ Occitan (post 1500); Provençal
+ Ojibwa
+ Oromo
+ Oriya
+ Ossetian; Ossetic
+ Panjabi; Punjabi
+ Pali
+ Polish
+ Pushto
+ Portuguese
+ Quechua
+ Raeto-Romance
+ Rundi
+ Romanian
+ Russian
+ Kinyarwanda
+ Sanskrit
+ Sardinian
+ Sindhi
+ Northern Sami
+ Sango
+ Sinhala; Sinhalese
+ Slovak
+ Slovenian
+ Samoan
+ Shona
+ Somali
+ Albanian
+ Serbian
+ Swati
+ Sotho, Southern
+ Sundanese
+ Swedish
+ Swahili
+ Tamil
+ Telugu
+ Tajik
+ Thai
+ Tigrinya
+ Turkmen
+ Tagalog
+ Tswana
+ Tonga (Tonga Islands)
+ Turkish
+ Turkish
+ Tsonga
+ Tatar
+ Twi
+ Tahitian
+ Uighur; Uyghur
+ Ukrainian
+ Urdu
+ Uzbek
+ Venda
+ Vietnamese
+ Volapük
+ Walloon
+ Wolof
+ Xhosa
+ Yiddish
+ Yoruba
+ Zhuang; Chuang
+ Chinese
+ Zulu
@@ -238,216 +214,192 @@
The list is ordered for the European Commission needs.
-->
- Bulgarian
- Czech
- Danish
- German
- Estonian
- Greek
- English
- Spanish
- French
- Irish
- Italian
- Latvian
- Lithuanian
- Hungarian
- Maltese
- Dutch
- Polish
- Portuguese
- Romanian
- Slovak
- Slovenian
- Finnish
- Swedish
- Croatian
- Turkish
- Afar
- Abkhazian
- Afrikaans
- Akan
- Albanian
- Amharic
- Arabic
- Aragonese
- Armenian
- Assamese
- Avaric
- Avestan
- Aymara
- Azerbaijani
- Bashkir
- Bambara
- Basque
- Belarusian
- Bengali
- Bihari
- Bislama
- Bosnian
- Breton
- Burmese
- Catalan; Valencian
- Chamorro
- Chechen
- Chinese
-
- Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic
-
- Chuvash
- Cornish
- Corsican
- Cree
-
- Divehi; Dhivehi; Maldivian
-
- Dzongkha
- Esperanto
- Ewe
- Faroese
- Fijian
- Western Frisian
- Fulah
- Georgian
-
- Gaelic; Scottish Gaelic
-
- Galician
- Manx
- Guarani
- Gujarati
-
- Haitian; Haitian Creole
-
- Hausa
- Hebrew
- Herero
- Hindi
- Hiri Motu
- Igbo
- Icelandic
- Ido
- Sichuan Yi
- Inuktitut
- Interlingue
-
- Interlingua (International Auxiliary Language Association)
-
- Indonesian
- Inupiaq
- Javanese
- Japanese
-
- Kalaallisut; Greenlandic
-
- Kannada
- Kashmiri
- Kanuri
- Kazakh
- Khmer
- Kikuyu; Gikuyu
- Kinyarwanda
- Kirghiz
- Komi
- Kongo
- Korean
- Kuanyama; Kwanyama
- Kurdish
- Lao
- Latin
-
- Limburgan; Limburger; Limburgish
-
- Lingala
-
- Luxembourgish; Letzeburgesch
-
- Luba-Katanga
- Ganda
- Macedonian
- Marshallese
- Malayalam
- Maori
- Marathi
- Malay
- Malagasy
- Moldavian
- Mongolian
- Nauru
- Navajo; Navaho
-
- Ndebele, South; South Ndebele
-
-
- Ndebele, North; North Ndebele
-
- Ndonga
- Nepali
- Norwegian Nynorsk
- Norvégien Bokmål
- Norwegian
-
- Chichewa; Chewa; Nyanja
-
-
- Occitan (post 1500); Provençal
-
- Ojibwa
- Oriya
- Oromo
- Ossetian; Ossetic
- Panjabi; Punjabi
- Persian
- Pali
- Pushto
- Quechua
- Raeto-Romance
- Rundi
- Russian
- Sango
- Sanskrit
- Serbian
- Sinhala; Sinhalese
- Northern Sami
- Samoan
- Shona
- Sindhi
- Somali
- Sotho, Southern
- Sardinian
- Swati
- Sundanese
- Swahili
- Tahitian
- Tamil
- Tatar
- Telugu
- Tajik
- Tagalog
- Thai
- Tibetan
- Tigrinya
- Tonga (Tonga Islands)
- Tswana
- Tsonga
- Turkmen
- Turkish
- Twi
- Uighur; Uyghur
- Ukrainian
- Urdu
- Uzbek
- Venda
- Vietnamese
- Volapük
- Welsh
- Walloon
- Wolof
- Xhosa
- Yiddish
- Yoruba
- Zhuang; Chuang
- Zulu
+ Bulgarian
+ Czech
+ Danish
+ German
+ Estonian
+ Greek
+ English
+ Spanish
+ French
+ Irish
+ Italian
+ Latvian
+ Lithuanian
+ Hungarian
+ Maltese
+ Dutch
+ Polish
+ Portuguese
+ Romanian
+ Slovak
+ Slovenian
+ Finnish
+ Swedish
+ Croatian
+ Turkish
+ Afar
+ Abkhazian
+ Afrikaans
+ Akan
+ Albanian
+ Amharic
+ Arabic
+ Aragonese
+ Armenian
+ Assamese
+ Avaric
+ Avestan
+ Aymara
+ Azerbaijani
+ Bashkir
+ Bambara
+ Basque
+ Belarusian
+ Bengali
+ Bihari
+ Bislama
+ Bosnian
+ Breton
+ Burmese
+ Catalan; Valencian
+ Chamorro
+ Chechen
+ Chinese
+ Slavic
+ Chuvash
+ Cornish
+ Corsican
+ Cree
+ Divehi; Dhivehi; Maldivian
+ Dzongkha
+ Esperanto
+ Ewe
+ Faroese
+ Fijian
+ Western Frisian
+ Fulah
+ Georgian
+ Gaelic
+ Galician
+ Manx
+ Guarani
+ Gujarati
+ Haitian
+ Hausa
+ Hebrew
+ Herero
+ Hindi
+ Hiri Motu
+ Igbo
+ Icelandic
+ Ido
+ Sichuan Yi
+ Inuktitut
+ Interlingue
+ Interlingua
+ Indonesian
+ Inupiaq
+ Javanese
+ Japanese
+ Kalaallisut; Greenlandic
+ Kannada
+ Kashmiri
+ Kanuri
+ Kazakh
+ Khmer
+ Kikuyu; Gikuyu
+ Kinyarwanda
+ Kirghiz
+ Komi
+ Kongo
+ Korean
+ Kuanyama; Kwanyama
+ Kurdish
+ Lao
+ Latin
+ Limburgan; Limburger; Limburgish
+ Lingala
+ Luxembourgish; Letzeburgesch
+ Luba-Katanga
+ Ganda
+ Macedonian
+ Marshallese
+ Malayalam
+ Maori
+ Marathi
+ Malay
+ Malagasy
+ Moldavian
+ Mongolian
+ Nauru
+ Navajo; Navaho
+ South Ndebele
+ North Ndebele
+ Ndonga
+ Nepali
+ Norwegian Nynorsk
+ Norvégien Bokmål
+ Norwegian
+ Chichewa; Chewa; Nyanja
+ Occitan (post 1500); Provençal
+ Ojibwa
+ Oriya
+ Oromo
+ Ossetian; Ossetic
+ Panjabi; Punjabi
+ Persian
+ Pali
+ Pushto
+ Quechua
+ Raeto-Romance
+ Rundi
+ Russian
+ Sango
+ Sanskrit
+ Serbian
+ Sinhala; Sinhalese
+ Northern Sami
+ Samoan
+ Shona
+ Sindhi
+ Somali
+ Sotho, Southern
+ Sardinian
+ Swati
+ Sundanese
+ Swahili
+ Tahitian
+ Tamil
+ Tatar
+ Telugu
+ Tajik
+ Tagalog
+ Thai
+ Tibetan
+ Tigrinya
+ Tonga (Tonga Islands)
+ Tswana
+ Tsonga
+ Turkmen
+ Turkish
+ Twi
+ Uighur; Uyghur
+ Ukrainian
+ Urdu
+ Uzbek
+ Venda
+ Vietnamese
+ Volapük
+ Welsh
+ Walloon
+ Wolof
+ Xhosa
+ Yiddish
+ Yoruba
+ Zhuang; Chuang
+ Zulu
diff --git a/source/java/org/alfresco/repo/model/filefolder/FileFolderServiceImpl.java b/source/java/org/alfresco/repo/model/filefolder/FileFolderServiceImpl.java
index 756aa74523..7b32145601 100644
--- a/source/java/org/alfresco/repo/model/filefolder/FileFolderServiceImpl.java
+++ b/source/java/org/alfresco/repo/model/filefolder/FileFolderServiceImpl.java
@@ -37,7 +37,6 @@ import org.alfresco.model.ContentModel;
import org.alfresco.repo.search.QueryParameterDefImpl;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService;
-import org.alfresco.service.cmr.ml.MultilingualContentService;
import org.alfresco.service.cmr.model.FileExistsException;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileInfo;
diff --git a/source/java/org/alfresco/repo/model/ml/ContentFilterLanguagesMap.java b/source/java/org/alfresco/repo/model/ml/ContentFilterLanguagesMap.java
index 6dad0b04b9..ead3ea0278 100644
--- a/source/java/org/alfresco/repo/model/ml/ContentFilterLanguagesMap.java
+++ b/source/java/org/alfresco/repo/model/ml/ContentFilterLanguagesMap.java
@@ -59,7 +59,6 @@ public class ContentFilterLanguagesMap implements ContentFilterLanguagesService
private static final String DEFAULT_LANGUAGE_LIST_STANDARD = "ISO 639-1";
private static final String ATTR_CODE = "code";
- private static final String ATTR_ORDER = "order";
private static final String ATTR_DEFAULT = "default";
private static final Log logger = LogFactory.getLog(ContentFilterLanguagesMap.class);
@@ -210,11 +209,10 @@ public class ContentFilterLanguagesMap implements ContentFilterLanguagesService
for (ConfigElement langElem : languages)
{
String code = convertToOldISOCode(langElem.getAttribute(ATTR_CODE));
- String order = langElem.getAttribute(ATTR_ORDER);
String value = langElem.getValue();
String def = langElem.getAttribute(ATTR_DEFAULT);
- orderedLangCodes.add(Integer.parseInt(order) - 1, code);
+ orderedLangCodes.add(code);
languagesByCode.put(code, value);
diff --git a/source/java/org/alfresco/repo/model/ml/MultilingualContentServiceImpl.java b/source/java/org/alfresco/repo/model/ml/MultilingualContentServiceImpl.java
index 225d031544..dbb1bae46b 100644
--- a/source/java/org/alfresco/repo/model/ml/MultilingualContentServiceImpl.java
+++ b/source/java/org/alfresco/repo/model/ml/MultilingualContentServiceImpl.java
@@ -39,6 +39,7 @@ import org.alfresco.repo.version.VersionModel;
import org.alfresco.service.cmr.ml.ContentFilterLanguagesService;
import org.alfresco.service.cmr.ml.MultilingualContentService;
import org.alfresco.service.cmr.model.FileFolderService;
+import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -674,56 +675,95 @@ public class MultilingualContentServiceImpl implements MultilingualContentServic
*/
public NodeRef addEmptyTranslation(NodeRef translationOfNodeRef, String name, Locale locale)
{
- // any node used as reference
- NodeRef anyTranslation;
- // the empty document to create
- NodeRef newTranslationNodeRef = null;
-
QName typeQName = nodeService.getType(translationOfNodeRef);
- if (typeQName.equals(ContentModel.TYPE_MULTILINGUAL_CONTAINER))
+ boolean hasMLAspect = nodeService.hasAspect(translationOfNodeRef, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
+ if (hasMLAspect || typeQName.equals(ContentModel.TYPE_MULTILINGUAL_CONTAINER))
{
- // Set the ml container ans get the pivot
- anyTranslation = getPivotTranslation(translationOfNodeRef);
- }
- else if(nodeService.hasAspect(translationOfNodeRef, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT))
- {
- anyTranslation = translationOfNodeRef;
+ // Get the pivot translation
+ NodeRef pivotTranslationNodeRef = getPivotTranslation(translationOfNodeRef);
+ if (pivotTranslationNodeRef != null)
+ {
+ // We found a pivot translation, so use it
+ translationOfNodeRef = pivotTranslationNodeRef;
+ }
+ else
+ {
+ // We use the given translation, provided it is an actual translation
+ if (!hasMLAspect)
+ {
+ throw new IllegalArgumentException(
+ "The node provided is not associated with a pivot translation " +
+ "and is not in itself a translation: \n" +
+ " Translation: " + translationOfNodeRef + "\n" +
+ " Locale: " + locale);
+ }
+ }
}
else
{
throw new IllegalArgumentException(
- "Node must have aspect " + ContentModel.ASPECT_MULTILINGUAL_DOCUMENT + " applied or be a " + ContentModel.TYPE_MULTILINGUAL_CONTAINER);
+ "Node must have aspect " + ContentModel.ASPECT_MULTILINGUAL_DOCUMENT +
+ " or be a " + ContentModel.TYPE_MULTILINGUAL_CONTAINER + ": \n" +
+ " Translation: " + translationOfNodeRef + "\n" +
+ " Locale: " + locale);
+ }
+
+ FileInfo translationOfFileInfo = fileFolderService.getFileInfo(translationOfNodeRef);
+ String translationOfName = translationOfFileInfo.getName();
+ // If name is null, supply one
+ if (name == null)
+ {
+ name = translationOfName;
+ }
+ // If there is a name clash, add the locale to the main portion of the filename
+ if (name.equals(translationOfName))
+ {
+ String localeStr = locale.toString();
+ if (localeStr.endsWith("_"))
+ {
+ localeStr = localeStr.substring(0, localeStr.length() - 1);
+ }
+ String rawName;
+ String extension;
+ int index = name.lastIndexOf('.');
+ if (index > 0)
+ {
+ rawName = name.substring(0, index);
+ extension = "." + name.substring(index + 1);
+ }
+ else
+ {
+ rawName = name;
+ extension = ""; // No extension
+ }
+ name = rawName + "_" + localeStr + extension;
}
// Create the document in the space of the node of reference
- NodeRef parentNodeRef = nodeService.getPrimaryParent(anyTranslation).getParentRef();
+ NodeRef parentNodeRef = nodeService.getPrimaryParent(translationOfNodeRef).getParentRef();
- newTranslationNodeRef = fileFolderService.create(
+ // Create the empty translation
+ NodeRef newTranslationNodeRef = fileFolderService.create(
parentNodeRef,
name,
ContentModel.TYPE_CONTENT).getNodeRef();
-
+
// add the translation to the container
addTranslation(newTranslationNodeRef, translationOfNodeRef, locale);
+ // Although the content is spoofed from the pivot translation, it isn't done for all services
+ // TODO: Fix http://issues.alfresco.com/browse/AR-1487
+ ContentData translationOfContentData = (ContentData) nodeService.getProperty(translationOfNodeRef, ContentModel.PROP_CONTENT);
+ if (translationOfContentData != null)
+ {
+ nodeService.setProperty(newTranslationNodeRef, ContentModel.PROP_CONTENT, translationOfContentData);
+ }
+
// set it empty
nodeService.addAspect(newTranslationNodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION, null);
// Initially, the file should be temporary. This will be changed as soon as some content is added.
nodeService.addAspect(newTranslationNodeRef, ContentModel.ASPECT_TEMPORARY, null);
- // get the extension and set the ContentData property with an null URL.
- // TODO: Mimetype must be correct, i.e. taken from the original
- String extension = "";
- int dotIdx;
- if((dotIdx = name.lastIndexOf(".")) > -1 )
- {
- extension = name.substring(dotIdx);
- }
-
- nodeService.setProperty(newTranslationNodeRef, ContentModel.PROP_CONTENT,
- new ContentData(null, extension, 0, "UTF-8", locale));
-
-
if (logger.isDebugEnabled())
{
logger.debug("Added an empty translation: \n" +
diff --git a/source/java/org/alfresco/repo/model/ml/tools/AbstractMultilingualTestCases.java b/source/java/org/alfresco/repo/model/ml/tools/AbstractMultilingualTestCases.java
index efda4f070c..13cf31c354 100644
--- a/source/java/org/alfresco/repo/model/ml/tools/AbstractMultilingualTestCases.java
+++ b/source/java/org/alfresco/repo/model/ml/tools/AbstractMultilingualTestCases.java
@@ -117,10 +117,16 @@ public abstract class AbstractMultilingualTestCases extends TestCase
}
protected NodeRef createContent()
+ {
+ String name = "" + System.currentTimeMillis();
+ return createContent(name);
+ }
+
+ protected NodeRef createContent(String name)
{
NodeRef contentNodeRef = fileFolderService.create(
folderNodeRef,
- "" + System.currentTimeMillis(),
+ name,
ContentModel.TYPE_CONTENT).getNodeRef();
// add some content
ContentWriter contentWriter = fileFolderService.getWriter(contentNodeRef);
@@ -128,7 +134,7 @@ public abstract class AbstractMultilingualTestCases extends TestCase
// done
return contentNodeRef;
}
-
+
public void testSetup() throws Exception
{
// Ensure that content can be created
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 9ee555d63c..7b6fa48960 100644
--- a/source/java/org/alfresco/repo/model/ml/tools/MultilingualContentServiceImplTest.java
+++ b/source/java/org/alfresco/repo/model/ml/tools/MultilingualContentServiceImplTest.java
@@ -30,10 +30,11 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
-
import org.alfresco.i18n.I18NUtil;
import org.alfresco.model.ContentModel;
+import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.alfresco.service.cmr.version.Version;
import org.alfresco.service.cmr.version.VersionHistory;
@@ -187,17 +188,57 @@ public class MultilingualContentServiceImplTest extends AbstractMultilingualTest
@SuppressWarnings("unused")
public void testCreateEmptyTranslation() throws Exception
{
- NodeRef chineseContentNodeRef = createContent();
+ NodeRef chineseContentNodeRef = createContent("Document.txt");
NodeRef mlContainerNodeRef = multilingualContentService.makeTranslation(chineseContentNodeRef, Locale.CHINESE);
- NodeRef empty = multilingualContentService.addEmptyTranslation(chineseContentNodeRef, "" + System.currentTimeMillis(), Locale.CANADA);
+ // This should use the pivot language
+ NodeRef emptyNodeRef = multilingualContentService.addEmptyTranslation(mlContainerNodeRef, "Document.txt", Locale.CANADA);
// Ensure that the empty translation is not null
- assertNotNull("The creation of the empty document failed ", empty);
+ assertNotNull("The creation of the empty document failed ", emptyNodeRef);
// Ensure that the empty translation has the mlDocument aspect
- assertTrue("The empty document must have the mlDocument aspect", nodeService.hasAspect(empty, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT));
+ assertTrue("The empty document must have the mlDocument aspect",
+ nodeService.hasAspect(emptyNodeRef, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT));
// Ensure that the empty translation has the mlEmptyTranslation aspect
- assertTrue("The empty document must have the mlEmptyTranslation aspect", nodeService.hasAspect(empty, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION));
+ assertTrue("The empty document must have the mlEmptyTranslation aspect",
+ nodeService.hasAspect(emptyNodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION));
+ // Check that the auto renaming worked
+ String emptyName = DefaultTypeConverter.INSTANCE.convert(String.class,
+ nodeService.getProperty(emptyNodeRef, ContentModel.PROP_NAME));
+ assertEquals("Empty auto-rename didn't work for same-named document", "Document_en_CA.txt", emptyName);
+
+ // Check that the content is identical
+ ContentData chineseContentData = fileFolderService.getReader(chineseContentNodeRef).getContentData();
+ ContentData emptyContentData = fileFolderService.getReader(emptyNodeRef).getContentData();
+ }
+
+ public void testCreateEmptyTranslationNames() throws Exception
+ {
+ NodeRef chineseContentNodeRef = createContent("Document.txt");
+ NodeRef mlContainerNodeRef = multilingualContentService.makeTranslation(chineseContentNodeRef, Locale.CHINESE);
+ NodeRef koreanContentNodeRef = createContent("Document_ko.txt");
+ multilingualContentService.addTranslation(koreanContentNodeRef, chineseContentNodeRef, Locale.KOREAN);
+ // Create with a null name, and off a non-pivot just to be sure
+ NodeRef nullNameNodeRef = multilingualContentService.addEmptyTranslation(
+ koreanContentNodeRef,
+ null,
+ Locale.CANADA);
+ String nullName = fileFolderService.getFileInfo(nullNameNodeRef).getName();
+ assertEquals("Empty translation name not generated correctly.", "Document_en_CA.txt", nullName);
+ // Create with the same name
+ NodeRef sameNameNodeRef = multilingualContentService.addEmptyTranslation(
+ mlContainerNodeRef,
+ "Document.txt",
+ Locale.CANADA_FRENCH);
+ String sameName = fileFolderService.getFileInfo(sameNameNodeRef).getName();
+ assertEquals("Empty translation name not generated correctly.", "Document_fr_CA.txt", sameName);
+ // Create with a different name
+ NodeRef differentNameNodeRef = multilingualContentService.addEmptyTranslation(
+ mlContainerNodeRef,
+ "Document2.txt",
+ Locale.JAPANESE);
+ String differentName = fileFolderService.getFileInfo(differentNameNodeRef).getName();
+ assertEquals("Empty translation name not generated correctly.", "Document2.txt", differentName);
}
@SuppressWarnings("unused")
diff --git a/source/java/org/alfresco/repo/node/archive/ArchiveAndRestoreTest.java b/source/java/org/alfresco/repo/node/archive/ArchiveAndRestoreTest.java
index 711d9ec1fe..5cc67c97d5 100644
--- a/source/java/org/alfresco/repo/node/archive/ArchiveAndRestoreTest.java
+++ b/source/java/org/alfresco/repo/node/archive/ArchiveAndRestoreTest.java
@@ -46,7 +46,6 @@ 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.cmr.repository.StoreRef;
-import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.OwnableService;
import org.alfresco.service.cmr.security.PermissionService;
diff --git a/source/java/org/alfresco/service/cmr/ml/MultilingualContentService.java b/source/java/org/alfresco/service/cmr/ml/MultilingualContentService.java
index 86c1809a44..8e9082188d 100644
--- a/source/java/org/alfresco/service/cmr/ml/MultilingualContentService.java
+++ b/source/java/org/alfresco/service/cmr/ml/MultilingualContentService.java
@@ -164,12 +164,20 @@ public interface MultilingualContentService
NodeRef getPivotTranslation(NodeRef nodeRef);
/**
- * Make a empty translation out of an existing document. The necessary translation structures will be created
- * as necessary.
+ * Make a empty translation out of an existing pivot translation. The given translation or
+ * container will be used to find the pivot translation. Failing this, the given translation
+ * will be used directly. If no name is provided or if the name is the same as the original's
+ * then the locale will be added to the main portion of the filename, i.e.
+ *
+ * Document.txt --> Document_fr.txt
+ *
+ *
+ * The necessary translation structures will be created as necessary.
*
* @param translationOfNodeRef An existing cm:mlDocument or cm:mlContainer
- * @param name The name of the translation to create
- * @return Returns the new created cm:mlEmptyTranslation
+ * @param name The name of the file to create, or null to use
+ * the default naming convention.
+ * @return Returns the new created cm:mlEmptyTranslation
*/
@Auditable(key = Auditable.Key.ARG_0, parameters = {"translationOfNodeRef", "name", "locale"})
NodeRef addEmptyTranslation(NodeRef translationOfNodeRef, String name, Locale locale);