Fix leaked 'MLPropertyInterceptor.setMLAware' in data load API implementation (ACE-4552)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@116895 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2015-11-10 10:39:07 +00:00
parent 5bcbdef83c
commit bcf40c1b72

View File

@@ -279,36 +279,42 @@ public class FileFolderLoader
{
// Add the cm:description additional properties
boolean wasMLAware = MLPropertyInterceptor.setMLAware(true);
MLText descriptions = new MLText();
String[] languages = Locale.getISOLanguages();
String defaultLanguage = Locale.getDefault().getLanguage();
// Create cm:description translations
for (int descriptionNum = -1; descriptionNum < (descriptionCount-1); descriptionNum++)
try
{
String language = null;
// Use the default language for the first description
if (descriptionNum == -1)
MLText descriptions = new MLText();
String[] languages = Locale.getISOLanguages();
String defaultLanguage = Locale.getDefault().getLanguage();
// Create cm:description translations
for (int descriptionNum = -1; descriptionNum < (descriptionCount-1); descriptionNum++)
{
language = defaultLanguage;
String language = null;
// Use the default language for the first description
if (descriptionNum == -1)
{
language = defaultLanguage;
}
else if (languages[descriptionNum].equals(defaultLanguage))
{
// Skip the default language, if we hit it
continue;
}
else
{
language = languages[descriptionNum];
}
Locale languageLocale = new Locale(language);
// For the cm:description, create new reader with a seed that changes each time
String descriptionUrl = SpoofedTextContentReader.createContentUrl(locale, seed + descriptionNum, descriptionSize);
SpoofedTextContentReader readerDescription = new SpoofedTextContentReader(descriptionUrl);
String description = readerDescription.getContentString();
descriptions.put(languageLocale, description);
}
else if (languages[descriptionNum].equals(defaultLanguage))
{
// Skip the default language, if we hit it
continue;
}
else
{
language = languages[descriptionNum];
}
Locale languageLocale = new Locale(language);
// For the cm:description, create new reader with a seed that changes each time
String descriptionUrl = SpoofedTextContentReader.createContentUrl(locale, seed + descriptionNum, descriptionSize);
SpoofedTextContentReader readerDescription = new SpoofedTextContentReader(descriptionUrl);
String description = readerDescription.getContentString();
descriptions.put(languageLocale, description);
nodeService.setProperty(fileNodeRef, ContentModel.PROP_DESCRIPTION, descriptions);
}
finally
{
MLPropertyInterceptor.setMLAware(wasMLAware);
}
nodeService.setProperty(fileNodeRef, ContentModel.PROP_DESCRIPTION, descriptions);
MLPropertyInterceptor.setMLAware(wasMLAware);
}
// Success
count.incrementAndGet();