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
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.extensions.webscripts.AbstractWebScript
org.springframework.extensions.webscripts.AbstractWebScript.ScriptDetails -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringConstantDEEPL_API_URL="https://api.deepl.com/v2/translate"private static final StringConstantDEEPL_AUTH_KEY="auth_key"private static final StringConstantDEEPL_SOURCE_LANG="source_lang"private static final StringConstantDEEPL_TARGET_LANG="target_lang"private static final StringConstantDEEPL_TEXT="text"private Stringprivate EntityFormatServiceprivate static final StringConstantGOOGLE_KEY="key"private static final StringConstantGOOGLE_QUERY="q"private static final StringConstantGOOGLE_SOURCE="source"private static final StringConstantGOOGLE_TRANSLATE_API_URL="https://www.googleapis.com/language/tra"{trunked}private Stringprivate static final StringConstantJSON_DATA="data"private static final StringConstantJSON_TEXT="text"private static final StringConstantJSON_TRANSLATED_TEXT="translatedText"private static final StringConstantJSON_TRANSLATIONS="translations"private static final org.apache.commons.logging.LogConstantloggerprivate static final StringConstantNO_API_KEY_MSG="No google translate API key provided"private static final StringConstantNO_SUGGESTION_MSG="No suggestion available"private static final StringConstantPARAM_COPY="copy"private static final StringConstantPARAM_DEST_FIELD="destField"private static final StringConstantPARAM_DIFF_FIELD="diffField"private static final StringConstantPARAM_FIELD="field"private static final StringConstantPARAM_NODEREF="nodeRef"private static final StringConstantPARAM_SUGGEST="suggest"private static final StringConstantPARAM_TARGET="target"private org.alfresco.service.ServiceRegistry -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res) private org.alfresco.service.cmr.repository.MLTextextractMLTextFromVersion(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.private StringgetTranslatedText(org.alfresco.service.cmr.repository.MLText mlText, String target) getTranslatedText.voidsetDeepLAPIKey(String deepLAPIKey) Setter for the fielddeepLAPIKey.voidsetEntityFormatService(EntityFormatService entityFormatService) Setter for the fieldentityFormatService.voidsetGoogleApiKey(String googleApiKey) Setter for the fieldgoogleApiKey.voidsetServiceRegistry(org.alfresco.service.ServiceRegistry serviceRegistry) Setter for the fieldserviceRegistry.Methods inherited from class org.springframework.extensions.webscripts.AbstractWebScript
addModuleBundleToCache, checkModuleBundleCache, createArgs, createArgsM, createHeaders, createHeadersM, createScriptParameters, createStatusException, createTemplateParameters, executeScript, getContainer, getDescription, getExecuteScript, getResources, getStatusTemplate, init, renderString, renderString, renderTemplate, sendStatus, setURLModelFactory, toString
-
Field Details
-
logger
private static final org.apache.commons.logging.Log loggerConstantlogger -
PARAM_NODEREF
ConstantPARAM_NODEREF="nodeRef"- See Also:
-
PARAM_FIELD
ConstantPARAM_FIELD="field"- See Also:
-
PARAM_DIFF_FIELD
ConstantPARAM_DIFF_FIELD="diffField"- See Also:
-
PARAM_SUGGEST
ConstantPARAM_SUGGEST="suggest"- See Also:
-
PARAM_TARGET
ConstantPARAM_TARGET="target"- See Also:
-
PARAM_COPY
ConstantPARAM_COPY="copy"- See Also:
-
PARAM_DEST_FIELD
ConstantPARAM_DEST_FIELD="destField"- See Also:
-
DEEPL_API_URL
ConstantDEEPL_API_URL="https://api.deepl.com/v2/translate"- See Also:
-
GOOGLE_TRANSLATE_API_URL
ConstantGOOGLE_TRANSLATE_API_URL="https://www.googleapis.com/language/tra"{trunked}- See Also:
-
DEEPL_AUTH_KEY
ConstantDEEPL_AUTH_KEY="auth_key"- See Also:
-
DEEPL_TEXT
ConstantDEEPL_TEXT="text"- See Also:
-
DEEPL_SOURCE_LANG
ConstantDEEPL_SOURCE_LANG="source_lang"- See Also:
-
DEEPL_TARGET_LANG
ConstantDEEPL_TARGET_LANG="target_lang"- See Also:
-
GOOGLE_KEY
ConstantGOOGLE_KEY="key"- See Also:
-
GOOGLE_SOURCE
ConstantGOOGLE_SOURCE="source"- See Also:
-
GOOGLE_QUERY
ConstantGOOGLE_QUERY="q"- See Also:
-
JSON_DATA
ConstantJSON_DATA="data"- See Also:
-
JSON_TRANSLATIONS
ConstantJSON_TRANSLATIONS="translations"- See Also:
-
JSON_TEXT
ConstantJSON_TEXT="text"- See Also:
-
JSON_TRANSLATED_TEXT
ConstantJSON_TRANSLATED_TEXT="translatedText"- See Also:
-
NO_SUGGESTION_MSG
ConstantNO_SUGGESTION_MSG="No suggestion available"- See Also:
-
NO_API_KEY_MSG
ConstantNO_API_KEY_MSG="No google translate API key provided"- See Also:
-
googleApiKey
-
deepLAPIKey
-
serviceRegistry
private org.alfresco.service.ServiceRegistry serviceRegistry -
entityFormatService
-
-
Constructor Details
-
MultilingualFieldWebScript
public MultilingualFieldWebScript()
-
-
Method Details
-
setServiceRegistry
public void setServiceRegistry(org.alfresco.service.ServiceRegistry serviceRegistry) Setter for the field
serviceRegistry.- Parameters:
serviceRegistry- aServiceRegistryobject.
-
setEntityFormatService
Setter for the field
entityFormatService.- Parameters:
entityFormatService- aEntityFormatServiceobject.
-
setGoogleApiKey
Setter for the field
googleApiKey.- Parameters:
googleApiKey- aStringobject.
-
setDeepLAPIKey
Setter for the field
deepLAPIKey.- Parameters:
deepLAPIKey- aStringobject
-
execute
public void execute(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res) throws IOException - Throws:
IOException
-
getTranslatedText
getTranslatedText.
-
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 referenceitemType- the item type from versioned nodeRefitemId- the item ID from versioned nodeRefpropertyQName- the property QName to extractdefaultLocale- the default locale to use if MLText is not found- Returns:
- the extracted MLText or empty MLText if not found
-