Class MultilingualContentServiceImpl
- java.lang.Object
-
- org.alfresco.repo.model.ml.MultilingualContentServiceImpl
-
- All Implemented Interfaces:
MultilingualContentService
public class MultilingualContentServiceImpl extends java.lang.Object implements MultilingualContentService
Multilingual support implementation.The basic structure supported is that of a hidden container of type cm:mlContainer containing one or more secondary children of type cm:mlDocument. One of these will have a matching locale and is referred to as the pivot translation. It is also possible to have several transient cm:emptyTranslation instances that live and die with the container until they get their own content.
It is not possible to guarantee that there is always a pivot translation available in the set of sibling translations. The strategy is to hide all translations when there isn't a pivot translation available. A background task should be cleaning up the empty or invalid cm:mlContainer instances.
- Author:
- Derek Hulley, Philippe Dubois, Yannick Pignot
-
-
Constructor Summary
Constructors Constructor Description MultilingualContentServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.alfresco.service.cmr.repository.NodeRefaddEmptyTranslation(org.alfresco.service.cmr.repository.NodeRef translationOfNodeRef, java.lang.String name, java.util.Locale locale)Make a empty translation out of an existing pivot translation.voidaddTranslation(org.alfresco.service.cmr.repository.NodeRef newTranslationNodeRef, org.alfresco.service.cmr.repository.NodeRef translationOfNodeRef, java.util.Locale locale)Make a translation out of an existing document.org.alfresco.service.cmr.repository.NodeRefcopyTranslationContainer(org.alfresco.service.cmr.repository.NodeRef mlContainerNodeRef, org.alfresco.service.cmr.repository.NodeRef newParentRef, java.lang.String prefixName)Copies the given cm:mlContainer.voiddeleteTranslationContainer(org.alfresco.service.cmr.repository.NodeRef mlContainerNodeRef)Delete the given mlContainer and its translations.java.util.List<java.util.Locale>getMissingTranslations(org.alfresco.service.cmr.repository.NodeRef localizedNodeRef, boolean addThisNodeLocale)Given a cm:mlDocument or cm:mlContainer this node returns each locale for which there isn't a translation.org.alfresco.service.cmr.repository.NodeRefgetPivotTranslation(org.alfresco.service.cmr.repository.NodeRef nodeRef)Given any node, this returns the pivot translation.org.alfresco.service.cmr.repository.NodeRefgetTranslationContainer(org.alfresco.service.cmr.repository.NodeRef translationNodeRef)Convenience method for super user.org.alfresco.service.cmr.repository.NodeRefgetTranslationForLocale(org.alfresco.service.cmr.repository.NodeRef translationNodeRef, java.util.Locale locale)Given a cm:mlDocument, this method attempts to find the best translation for the given locale.java.util.Map<java.util.Locale,org.alfresco.service.cmr.repository.NodeRef>getTranslations(org.alfresco.service.cmr.repository.NodeRef translationOfNodeRef)Gets the set of sibling translations associated with the given cm:mlDocument or cm:mlContainer.booleanisTranslation(org.alfresco.service.cmr.repository.NodeRef contentNodeRef)Checks whether an existing document is part of a translation group.voidmakeTranslation(org.alfresco.service.cmr.repository.NodeRef contentNodeRef, java.util.Locale locale)Make an existing document into a translation by adding the cm:mlDocument aspect and creating a cm:mlContainer parent.voidmoveTranslationContainer(org.alfresco.service.cmr.repository.NodeRef mlContainerNodeRef, org.alfresco.service.cmr.repository.NodeRef newParentRef)Moves the location of the given cm:mlContainer.voidsetContentFilterLanguagesService(ContentFilterLanguagesService contentFilterLanguagesService)voidsetFileFolderService(FileFolderService fileFolderService)voidsetNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)voidsetPermissionService(org.alfresco.service.cmr.security.PermissionService permissionService)voidsetPolicyBehaviourFilter(BehaviourFilter policyBehaviourFilter)voidsetVersionService(VersionService versionService)voidunmakeTranslation(org.alfresco.service.cmr.repository.NodeRef translationNodeRef)Removes the node from any associated translations.
-
-
-
Method Detail
-
isTranslation
public boolean isTranslation(org.alfresco.service.cmr.repository.NodeRef contentNodeRef)
Checks whether an existing document is part of a translation group.- Specified by:
isTranslationin interfaceMultilingualContentService- Parameters:
contentNodeRef- An existing cm:content- Returns:
- Returns true if the document has a cm:mlContainer parent
-
makeTranslation
public void makeTranslation(org.alfresco.service.cmr.repository.NodeRef contentNodeRef, java.util.Locale locale)Make an existing document into a translation by adding the cm:mlDocument aspect and creating a cm:mlContainer parent. If it is already a translation, then nothing is done.- Specified by:
makeTranslationin interfaceMultilingualContentService- Parameters:
contentNodeRef- An existing cm:content- See Also:
ContentModel.ASPECT_MULTILINGUAL_DOCUMENT
-
deleteTranslationContainer
public void deleteTranslationContainer(org.alfresco.service.cmr.repository.NodeRef mlContainerNodeRef)
Description copied from interface:MultilingualContentServiceDelete the given mlContainer and its translations. The translations will lost their cm:mlDocument aspect and will be archved. The empty translations will be permanently deleted.- Specified by:
deleteTranslationContainerin interfaceMultilingualContentService- Parameters:
mlContainerNodeRef- The cm:mlContainer to remove
-
unmakeTranslation
public void unmakeTranslation(org.alfresco.service.cmr.repository.NodeRef translationNodeRef)
Description copied from interface:MultilingualContentServiceRemoves the node from any associated translations. If the translation is the pivot translation, then the entire set of translations will be unhooked.- Specified by:
unmakeTranslationin interfaceMultilingualContentService- Parameters:
translationNodeRef- an existing cm:mlDocument
-
addTranslation
public void addTranslation(org.alfresco.service.cmr.repository.NodeRef newTranslationNodeRef, org.alfresco.service.cmr.repository.NodeRef translationOfNodeRef, java.util.Locale locale)Make a translation out of an existing document. The necessary translation structures will be created as necessary.- Specified by:
addTranslationin interfaceMultilingualContentService- Parameters:
newTranslationNodeRef- An existing cm:contenttranslationOfNodeRef- An existing cm:mlDocument
-
getTranslationContainer
public org.alfresco.service.cmr.repository.NodeRef getTranslationContainer(org.alfresco.service.cmr.repository.NodeRef translationNodeRef)
Convenience method for super user.- Specified by:
getTranslationContainerin interfaceMultilingualContentService- Parameters:
translationNodeRef- An existing cm:mlDocument- Returns:
- Returns the cm:mlContainer translation parent
-
getTranslations
public java.util.Map<java.util.Locale,org.alfresco.service.cmr.repository.NodeRef> getTranslations(org.alfresco.service.cmr.repository.NodeRef translationOfNodeRef)
Gets the set of sibling translations associated with the given cm:mlDocument or cm:mlContainer.- Specified by:
getTranslationsin interfaceMultilingualContentService- Parameters:
translationOfNodeRef- An existing cm:mlDocument or cm:mlContainer- Returns:
- Returns a map of translation nodes keyed by locale
-
getTranslationForLocale
public org.alfresco.service.cmr.repository.NodeRef getTranslationForLocale(org.alfresco.service.cmr.repository.NodeRef translationNodeRef, java.util.Locale locale)Given a cm:mlDocument, this method attempts to find the best translation for the given locale. If there is not even apartial match, then thepivot translationis used. If that also gives no results then the translation itself is returned.- Specified by:
getTranslationForLocalein interfaceMultilingualContentService- Parameters:
translationNodeRef- the cm:mlDocumentlocale- the target locale- Returns:
- Returns the best match for the locale (never null)
- See Also:
MultilingualContentService.getTranslations(NodeRef),I18NUtil.getNearestLocale(Locale, Set)
-
getMissingTranslations
public java.util.List<java.util.Locale> getMissingTranslations(org.alfresco.service.cmr.repository.NodeRef localizedNodeRef, boolean addThisNodeLocale)Given a cm:mlDocument or cm:mlContainer this node returns each locale for which there isn't a translation.- Specified by:
getMissingTranslationsin interfaceMultilingualContentService- Parameters:
localizedNodeRef- the cm:mlDocument or cm:mlContaineraddThisNodeLocale- if true, add the locale of the given cm:mlDocument in the list.- Returns:
- Returns a list of missng locales
-
getPivotTranslation
public org.alfresco.service.cmr.repository.NodeRef getPivotTranslation(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Given any node, this returns the pivot translation. All multilingual documents belong to a group linked by a hidden parent node of type cm:mlContainer. The pivot language for the translations is stored on the parent, and the child that has the same locale is the pivot translation.- Specified by:
getPivotTranslationin interfaceMultilingualContentService- Parameters:
nodeRef- a cm:mlDocument translation or cm:mlContainer translation container- Returns:
- Returns a corresponding cm:mlDocument that matches the locale of of the cm:mlContainer. null is returned if there is no pivot translation.
-
addEmptyTranslation
public org.alfresco.service.cmr.repository.NodeRef addEmptyTranslation(org.alfresco.service.cmr.repository.NodeRef translationOfNodeRef, java.lang.String name, java.util.Locale locale)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.txtThe necessary translation structures will be created as necessary.- Specified by:
addEmptyTranslationin interfaceMultilingualContentService- Parameters:
translationOfNodeRef- An existing cm:mlDocumentname- The name of the file to create, or null to use the default naming convention.- Returns:
- Returns the new created cm:mlEmptyTranslation
-
copyTranslationContainer
public org.alfresco.service.cmr.repository.NodeRef copyTranslationContainer(org.alfresco.service.cmr.repository.NodeRef mlContainerNodeRef, org.alfresco.service.cmr.repository.NodeRef newParentRef, java.lang.String prefixName) throws java.lang.ExceptionDescription copied from interface:MultilingualContentServiceCopies the given cm:mlContainer.This involves the copy of the cm:mlContainer node and the copy of its cm:mlDocument.
- Specified by:
copyTranslationContainerin interfaceMultilingualContentService- Parameters:
mlContainerNodeRef- The nodeRef to copynewParentRef- The new parent of the copied cm:mlDocumentprefixName- The prefix of the name of the copied translations. Can be null.- Returns:
- The copied cm:mlContainer
- Throws:
FileNotFoundExceptionFileExistsExceptionjava.lang.Exception
-
moveTranslationContainer
public void moveTranslationContainer(org.alfresco.service.cmr.repository.NodeRef mlContainerNodeRef, org.alfresco.service.cmr.repository.NodeRef newParentRef) throws FileExistsException, FileNotFoundExceptionDescription copied from interface:MultilingualContentServiceMoves the location of the given cm:mlContainer.This not involves changing the cm:mlContainer node but moves its cm:mlDocument.
- Specified by:
moveTranslationContainerin interfaceMultilingualContentService- Parameters:
mlContainerNodeRef- The nodeRef> to movenewParentRef- The new parent of the moved cm:mlDocument- Throws:
FileExistsExceptionFileNotFoundException
-
setNodeService
public void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
-
setPermissionService
public void setPermissionService(org.alfresco.service.cmr.security.PermissionService permissionService)
-
setContentFilterLanguagesService
public void setContentFilterLanguagesService(ContentFilterLanguagesService contentFilterLanguagesService)
-
setFileFolderService
public void setFileFolderService(FileFolderService fileFolderService)
-
setVersionService
public void setVersionService(VersionService versionService)
-
setPolicyBehaviourFilter
public void setPolicyBehaviourFilter(BehaviourFilter policyBehaviourFilter)
-
-