Class MultilingualContentServiceImpl

  • All Implemented Interfaces:
    MultilingualContentService

    public class MultilingualContentServiceImpl
    extends 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 Detail

      • MultilingualContentServiceImpl

        public MultilingualContentServiceImpl()
    • Method Detail

      • isTranslation

        public boolean isTranslation​(NodeRef contentNodeRef)
        Checks whether an existing document is part of a translation group.
        Specified by:
        isTranslation in interface MultilingualContentService
        Parameters:
        contentNodeRef - An existing cm:content
        Returns:
        Returns true if the document has a cm:mlContainer parent
      • deleteTranslationContainer

        public void deleteTranslationContainer​(NodeRef mlContainerNodeRef)
        Description copied from interface: MultilingualContentService
        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.
        Specified by:
        deleteTranslationContainer in interface MultilingualContentService
        Parameters:
        mlContainerNodeRef - The cm:mlContainer to remove
      • unmakeTranslation

        public void unmakeTranslation​(NodeRef translationNodeRef)
        Description copied from interface: MultilingualContentService
        Removes the node from any associated translations. If the translation is the pivot translation, then the entire set of translations will be unhooked.
        Specified by:
        unmakeTranslation in interface MultilingualContentService
        Parameters:
        translationNodeRef - an existing cm:mlDocument
      • addTranslation

        public 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.
        Specified by:
        addTranslation in interface MultilingualContentService
        Parameters:
        newTranslationNodeRef - An existing cm:content
        translationOfNodeRef - An existing cm:mlDocument
      • getTranslationContainer

        public NodeRef getTranslationContainer​(NodeRef translationNodeRef)
        Convenience method for super user.
        Specified by:
        getTranslationContainer in interface MultilingualContentService
        Parameters:
        translationNodeRef - An existing cm:mlDocument
        Returns:
        Returns the cm:mlContainer translation parent
      • getTranslations

        public Map<Locale,​NodeRef> getTranslations​(NodeRef translationOfNodeRef)
        Gets the set of sibling translations associated with the given cm:mlDocument or cm:mlContainer.
        Specified by:
        getTranslations in interface MultilingualContentService
        Parameters:
        translationOfNodeRef - An existing cm:mlDocument or cm:mlContainer
        Returns:
        Returns a map of translation nodes keyed by locale
      • getMissingTranslations

        public 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.
        Specified by:
        getMissingTranslations in interface MultilingualContentService
        Parameters:
        localizedNodeRef - the cm:mlDocument or cm:mlContainer
        addThisNodeLocale - if true, add the locale of the given cm:mlDocument in the list.
        Returns:
        Returns a list of missng locales
      • getPivotTranslation

        public NodeRef getPivotTranslation​(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:
        getPivotTranslation in interface MultilingualContentService
        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 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.

        Specified by:
        addEmptyTranslation in interface MultilingualContentService
        Parameters:
        translationOfNodeRef - An existing cm:mlDocument
        name - The name of the file to create, or null to use the default naming convention.
        Returns:
        Returns the new created cm:mlEmptyTranslation
      • setNodeService

        public void setNodeService​(NodeService nodeService)
      • setPermissionService

        public void setPermissionService​(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)