Package org.alfresco.service.cmr.ml
Interface MultilingualContentService
- All Known Implementing Classes:
MultilingualContentServiceImpl
public interface MultilingualContentService
The API to manage multilingual content and related structures.
- Author:
- Derek Hulley, Philippe Dubois
-
Method Summary
Modifier and TypeMethodDescriptionaddEmptyTranslation(NodeRef translationOfNodeRef, String name, Locale locale) Make a empty translation out of an existing pivot translation.voidaddTranslation(NodeRef newTranslationNodeRef, NodeRef translationOfNodeRef, Locale locale) Make a translation out of an existing document.copyTranslationContainer(NodeRef mlContainerNodeRef, NodeRef newParentRef, String prefixName) Copies the given cm:mlContainer.voiddeleteTranslationContainer(NodeRef mlContainerNodeRef) Delete the given mlContainer and its translations.getMissingTranslations(NodeRef localizedNodeRef, boolean addThisNodeLocale) Given a cm:mlDocument or cm:mlContainer this node returns each locale for which there isn't a translation.getPivotTranslation(NodeRef nodeRef) Given any node, this returns the pivot translation.getTranslationContainer(NodeRef translationNodeRef) Convenience method for super user.getTranslationForLocale(NodeRef translationNodeRef, Locale locale) Given a cm:mlDocument, this method attempts to find the best translation for the given locale.getTranslations(NodeRef translationOfNodeRef) Gets the set of sibling translations associated with the given cm:mlDocument or cm:mlContainer.booleanisTranslation(NodeRef contentNodeRef) Checks whether an existing document is part of a translation group.voidmakeTranslation(NodeRef contentNodeRef, Locale locale) Make an existing document into a translation by adding the cm:mlDocument aspect and creating a cm:mlContainer parent.voidmoveTranslationContainer(NodeRef mlContainerNodeRef, NodeRef newParentRef) Moves the location of the given cm:mlContainer.voidunmakeTranslation(NodeRef translationNodeRef) Removes the node from any associated translations.
-
Method Details
-
isTranslation
Checks whether an existing document is part of a translation group.- Parameters:
contentNodeRef- An existing cm:content- Returns:
- Returns true if the document has a cm:mlContainer parent
-
makeTranslation
@Auditable(parameters={"contentNodeRef","locale"}) void makeTranslation(NodeRef contentNodeRef, 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.- Parameters:
contentNodeRef- An existing cm:content- See Also:
-
unmakeTranslation
Removes the node from any associated translations. If the translation is the pivot translation, then the entire set of translations will be unhooked.- Parameters:
translationNodeRef- an existing cm:mlDocument
-
addTranslation
@Auditable(parameters={"newTranslationNodeRef","translationOfNodeRef","locale"}) void addTranslation(NodeRef newTranslationNodeRef, NodeRef translationOfNodeRef, Locale locale) Make a translation out of an existing document. The necessary translation structures will be created as necessary.- Parameters:
newTranslationNodeRef- An existing cm:contenttranslationOfNodeRef- An existing cm:mlDocument
-
getTranslationContainer
@Auditable(parameters="translationNodeRef") NodeRef getTranslationContainer(NodeRef translationNodeRef) Convenience method for super user.- Parameters:
translationNodeRef- An existing cm:mlDocument- Returns:
- Returns the cm:mlContainer translation parent
-
getTranslations
@Auditable(parameters="translationOfNodeRef") Map<Locale,NodeRef> getTranslations(NodeRef translationOfNodeRef) Gets the set of sibling translations associated with the given cm:mlDocument or cm:mlContainer.- Parameters:
translationOfNodeRef- An existing cm:mlDocument or cm:mlContainer- Returns:
- Returns a map of translation nodes keyed by locale
-
getTranslationForLocale
@Auditable(parameters={"translationNodeRef","locale"}) NodeRef getTranslationForLocale(NodeRef translationNodeRef, 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.- Parameters:
translationNodeRef- the cm:mlDocumentlocale- the target locale- Returns:
- Returns the best match for the locale (never null)
- See Also:
-
getTranslations(NodeRef)I18NUtil.getNearestLocale(Locale, Set)
-
getMissingTranslations
@Auditable(parameters={"localizedNodeRef","addThisNodeLocale"}) List<Locale> getMissingTranslations(NodeRef localizedNodeRef, boolean addThisNodeLocale) Given a cm:mlDocument or cm:mlContainer this node returns each locale for which there isn't a translation.- 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
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.- 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
@Auditable(parameters={"translationOfNodeRef","name","locale"}) NodeRef addEmptyTranslation(NodeRef translationOfNodeRef, String name, 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.txt
The necessary translation structures will be created as necessary.- 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
@Auditable(parameters={"mlContainerNodeRef","newParentRef"}) NodeRef copyTranslationContainer(NodeRef mlContainerNodeRef, NodeRef newParentRef, String prefixName) throws FileExistsException, FileNotFoundException, Exception Copies the given cm:mlContainer.This involves the copy of the cm:mlContainer node and the copy of its cm:mlDocument.
- 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:
FileNotFoundExceptionFileExistsExceptionException
-
moveTranslationContainer
@Auditable(parameters={"mlContainerNodeRef","newParentRef"}) void moveTranslationContainer(NodeRef mlContainerNodeRef, NodeRef newParentRef) throws FileExistsException, FileNotFoundException Moves the location of the given cm:mlContainer.This not involves changing the cm:mlContainer node but moves its cm:mlDocument.
- Parameters:
mlContainerNodeRef- The nodeRef> to movenewParentRef- The new parent of the moved cm:mlDocument- Throws:
FileExistsExceptionFileNotFoundException
-
deleteTranslationContainer
@Auditable(parameters="mlContainerNodeRef") void deleteTranslationContainer(NodeRef mlContainerNodeRef) Delete 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.- Parameters:
mlContainerNodeRef- The cm:mlContainer to remove
-