Class MultilingualFieldWebScript

java.lang.Object
org.springframework.extensions.webscripts.AbstractWebScript
fr.becpg.repo.web.scripts.multilingual.MultilingualFieldWebScript
All Implemented Interfaces:
org.springframework.extensions.webscripts.WebScript

public class MultilingualFieldWebScript extends org.springframework.extensions.webscripts.AbstractWebScript
Return or save MLText field
Version:
$Id: $Id
Author:
matthieu
  • Field Details

    • logger

      private static final org.apache.commons.logging.Log logger
      Constant logger
    • PARAM_NODEREF

      private static final String PARAM_NODEREF
      Constant PARAM_NODEREF="nodeRef"
      See Also:
    • PARAM_FIELD

      private static final String PARAM_FIELD
      Constant PARAM_FIELD="field"
      See Also:
    • PARAM_DIFF_FIELD

      private static final String PARAM_DIFF_FIELD
      Constant PARAM_DIFF_FIELD="diffField"
      See Also:
    • PARAM_SUGGEST

      private static final String PARAM_SUGGEST
      Constant PARAM_SUGGEST="suggest"
      See Also:
    • PARAM_TARGET

      private static final String PARAM_TARGET
      Constant PARAM_TARGET="target"
      See Also:
    • PARAM_COPY

      private static final String PARAM_COPY
      Constant PARAM_COPY="copy"
      See Also:
    • PARAM_DEST_FIELD

      private static final String PARAM_DEST_FIELD
      Constant PARAM_DEST_FIELD="destField"
      See Also:
    • DEEPL_API_URL

      private static final String DEEPL_API_URL
      Constant DEEPL_API_URL="https://api.deepl.com/v2/translate"
      See Also:
    • GOOGLE_TRANSLATE_API_URL

      private static final String GOOGLE_TRANSLATE_API_URL
      Constant GOOGLE_TRANSLATE_API_URL="https://www.googleapis.com/language/tra"{trunked}
      See Also:
    • DEEPL_AUTH_KEY

      private static final String DEEPL_AUTH_KEY
      Constant DEEPL_AUTH_KEY="auth_key"
      See Also:
    • DEEPL_TEXT

      private static final String DEEPL_TEXT
      Constant DEEPL_TEXT="text"
      See Also:
    • DEEPL_SOURCE_LANG

      private static final String DEEPL_SOURCE_LANG
      Constant DEEPL_SOURCE_LANG="source_lang"
      See Also:
    • DEEPL_TARGET_LANG

      private static final String DEEPL_TARGET_LANG
      Constant DEEPL_TARGET_LANG="target_lang"
      See Also:
    • GOOGLE_KEY

      private static final String GOOGLE_KEY
      Constant GOOGLE_KEY="key"
      See Also:
    • GOOGLE_SOURCE

      private static final String GOOGLE_SOURCE
      Constant GOOGLE_SOURCE="source"
      See Also:
    • GOOGLE_QUERY

      private static final String GOOGLE_QUERY
      Constant GOOGLE_QUERY="q"
      See Also:
    • JSON_DATA

      private static final String JSON_DATA
      Constant JSON_DATA="data"
      See Also:
    • JSON_TRANSLATIONS

      private static final String JSON_TRANSLATIONS
      Constant JSON_TRANSLATIONS="translations"
      See Also:
    • JSON_TEXT

      private static final String JSON_TEXT
      Constant JSON_TEXT="text"
      See Also:
    • JSON_TRANSLATED_TEXT

      private static final String JSON_TRANSLATED_TEXT
      Constant JSON_TRANSLATED_TEXT="translatedText"
      See Also:
    • NO_SUGGESTION_MSG

      private static final String NO_SUGGESTION_MSG
      Constant NO_SUGGESTION_MSG="No suggestion available"
      See Also:
    • NO_API_KEY_MSG

      private static final String NO_API_KEY_MSG
      Constant NO_API_KEY_MSG="No google translate API key provided"
      See Also:
    • googleApiKey

      private String googleApiKey
    • deepLAPIKey

      private String deepLAPIKey
    • serviceRegistry

      private org.alfresco.service.ServiceRegistry serviceRegistry
    • entityFormatService

      private EntityFormatService entityFormatService
  • Constructor Details

    • MultilingualFieldWebScript

      public MultilingualFieldWebScript()
  • Method Details

    • setServiceRegistry

      public void setServiceRegistry(org.alfresco.service.ServiceRegistry serviceRegistry)

      Setter for the field serviceRegistry.

      Parameters:
      serviceRegistry - a ServiceRegistry object.
    • setEntityFormatService

      public void setEntityFormatService(EntityFormatService entityFormatService)

      Setter for the field entityFormatService.

      Parameters:
      entityFormatService - a EntityFormatService object.
    • setGoogleApiKey

      public void setGoogleApiKey(String googleApiKey)

      Setter for the field googleApiKey.

      Parameters:
      googleApiKey - a String object.
    • setDeepLAPIKey

      public void setDeepLAPIKey(String deepLAPIKey)

      Setter for the field deepLAPIKey.

      Parameters:
      deepLAPIKey - a String object
    • execute

      public void execute(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res) throws IOException
      Throws:
      IOException
    • getTranslatedText

      private String getTranslatedText(org.alfresco.service.cmr.repository.MLText mlText, String target)

      getTranslatedText.

      Parameters:
      mlText - a MLText object
      target - a String object
      Returns:
      a String object
    • extractMLTextFromVersion

      private org.alfresco.service.cmr.repository.MLText extractMLTextFromVersion(org.alfresco.service.cmr.repository.NodeRef versionNodeRef, String itemType, String itemId, org.alfresco.service.namespace.QName propertyQName, Locale defaultLocale)
      Extract MLText property from version JSON data.
      Parameters:
      versionNodeRef - the version node reference
      itemType - the item type from versioned nodeRef
      itemId - the item ID from versioned nodeRef
      propertyQName - the property QName to extract
      defaultLocale - the default locale to use if MLText is not found
      Returns:
      the extracted MLText or empty MLText if not found