Class AutoTranslateMergeServiceImpl

  • All Implemented Interfaces:
    AutoTranslateMergeService

    public class AutoTranslateMergeServiceImpl
    extends Object
    implements AutoTranslateMergeService
    Implementation of the AutoTranslateMergeService. Provides methods to retrieve properties for resources in the context of translations.
    • Field Detail

      • COMPONENT_TITLE_PROPERTIES

        protected static final String[] COMPONENT_TITLE_PROPERTIES
        Heuristic set of properties that might give a recognizable title to the component.
    • Constructor Detail

      • AutoTranslateMergeServiceImpl

        public AutoTranslateMergeServiceImpl()
    • Method Detail

      • saveTranslation

        public Map<String,​String> saveTranslation​(@Nonnull
                                                        org.apache.sling.api.resource.Resource resource,
                                                        @Nonnull
                                                        String propertyName,
                                                        @Nonnull
                                                        String content,
                                                        boolean markAsMerged)
                                                 throws com.day.cq.wcm.api.WCMException
        Description copied from interface: AutoTranslateMergeService
        Saves the new content to a property.
        Specified by:
        saveTranslation in interface AutoTranslateMergeService
        Parameters:
        resource - the resource to save the translation to.
        propertyName - the name of the property to save the translation to.
        content - the new content to save.
        markAsMerged - whether to mark the property as merged
        Returns:
        a map containing "saved" and the text saved in the resource, to verify that it went OK, otherwise empty.
        Throws:
        com.day.cq.wcm.api.WCMException
      • approveTranslation

        public void approveTranslation​(org.apache.sling.api.resource.Resource resource,
                                       String propertyName)
                                throws com.day.cq.wcm.api.WCMException
        Description copied from interface: AutoTranslateMergeService
        Approves a translation for the specified property of the given resource, marking it as accepted.
        Specified by:
        approveTranslation in interface AutoTranslateMergeService
        Parameters:
        resource - the resource containing the property to approve
        propertyName - the name of the property for which the translation is to be approved
        Throws:
        com.day.cq.wcm.api.WCMException
      • changeInheritance

        public void changeInheritance​(org.apache.sling.api.resource.Resource resource,
                                      String propertyName,
                                      AutoTranslateMergeService.CancelOrReenable kind)
                               throws com.day.cq.wcm.api.WCMException
        Description copied from interface: AutoTranslateMergeService
        Cancels a translation for the specified property of the given resource, marking it as cancelled.
        Specified by:
        changeInheritance in interface AutoTranslateMergeService
        Parameters:
        resource - the resource containing the property to cancel
        propertyName - the name of the property for which the translation is to be cancelled
        kind - whether to cancel or reenable the property
        Throws:
        com.day.cq.wcm.api.WCMException
      • descendantsStream

        protected Stream<org.apache.sling.api.resource.Resource> descendantsStream​(org.apache.sling.api.resource.Resource resource)
      • getComponentName

        protected String getComponentName​(org.apache.sling.api.resource.Resource resource)
        Determines the jcr:title of the current component, as found by sling:resourceType
      • getComponentTitle

        protected String getComponentTitle​(@Nonnull
                                           org.apache.sling.api.resource.Resource resource)
        Determines the jcr:title , title, text etc. of the component by searching upwards for such a property.