Class AemAITranslationMergeServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- org.apache.sling.api.servlets.SlingSafeMethodsServlet
-
- org.apache.sling.api.servlets.SlingAllMethodsServlet
-
- com.composum.ai.aem.core.impl.AemAITranslationMergeServlet
-
- All Implemented Interfaces:
Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
public class AemAITranslationMergeServlet extends org.apache.sling.api.servlets.SlingAllMethodsServlet
Servlet with functionality for the AI Translation Merge tool. The operations are distinguished by parameter 'operation'. There are:- save: save a translation
- check: check if a resource has unmerged translations
- merge: merge translations
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static com.google.gson.Gson
gson
-
Constructor Summary
Constructors Constructor Description AemAITranslationMergeServlet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doPost(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response)
Handles POST requests to the servlet.protected void
handleAcceptTranslation(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response)
Handles the "approve" operation of the servlet.protected void
handleChangeInheritance(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response, AutoTranslateMergeService.CancelOrReenable kind)
Handles the "cancelInheritance" operation of the servlet.protected void
handleCheck(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response)
Handles the 'check' operation to verify if a resource has unmerged translations.protected void
handleMerge(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response)
Handles the 'merge' operation to merge translations.protected void
handleSave(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response)
Handles the 'save' operation to save a translation.-
Methods inherited from class org.apache.sling.api.servlets.SlingAllMethodsServlet
doDelete, doPut, getAllowedRequestMethods, isMethodValid, mayService
-
Methods inherited from class org.apache.sling.api.servlets.SlingSafeMethodsServlet
doGeneric, doGet, doHead, doOptions, doTrace, getServletInfo, handleMethodNotImplemented, service, service
-
-
-
-
Method Detail
-
doPost
protected void doPost(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response) throws javax.servlet.ServletException, IOException
Handles POST requests to the servlet.- Overrides:
doPost
in classorg.apache.sling.api.servlets.SlingAllMethodsServlet
- Parameters:
request
- the Sling HTTP servlet requestresponse
- the Sling HTTP servlet response- Throws:
IOException
- if an I/O error occursjavax.servlet.ServletException
- See Also:
handleSave(SlingHttpServletRequest, SlingHttpServletResponse)
,handleCheck(SlingHttpServletRequest, SlingHttpServletResponse)
,handleMerge(SlingHttpServletRequest, SlingHttpServletResponse)
-
handleCheck
protected void handleCheck(@Nonnull org.apache.sling.api.SlingHttpServletRequest request, @Nonnull org.apache.sling.api.SlingHttpServletResponse response) throws IOException
Handles the 'check' operation to verify if a resource has unmerged translations.Request parameters: - `path`: the path of the resource to check for unmerged translations (required).
- Parameters:
request
- the Sling HTTP servlet requestresponse
- the Sling HTTP servlet response- Throws:
IOException
- if an I/O error occurs
-
handleSave
protected void handleSave(@Nonnull org.apache.sling.api.SlingHttpServletRequest request, @Nonnull org.apache.sling.api.SlingHttpServletResponse response) throws IOException, javax.servlet.ServletException
Handles the 'save' operation to save a translation.Request parameters: - `path`: the path of the resource to save the translation to (required). - `propertyName`: the name of the property to save the translation to (required). - `body`: the translation text to save (required).
- Parameters:
request
- the Sling HTTP servlet requestresponse
- the Sling HTTP servlet response- Throws:
IOException
- if an I/O error occursjavax.servlet.ServletException
-
handleMerge
protected void handleMerge(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response) throws IOException
Handles the 'merge' operation to merge translations.Request parameters: - `path`: the path of the resource to merge the translation for (required). - `propertyName`: the name of the property to merge the translation for (required). - `originalSource`: the original source text (required). - `newSource`: the new source text (required). - `newTranslation`: the new translation text (required). - `currentText`: the current text of the component (required). - `language`: the language of the translation (optional).
- Parameters:
request
- the Sling HTTP servlet requestresponse
- the Sling HTTP servlet response- Throws:
IOException
- if an I/O error occurs
-
handleAcceptTranslation
protected void handleAcceptTranslation(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response) throws IOException
Handles the "approve" operation of the servlet.Request parameters: - `path`: the path of the resource to approve the translation for (required). - `propertyName`: the name of the property to approve the translation for (required).
- Parameters:
request
- the Sling HTTP servlet requestresponse
- the Sling HTTP servlet response- Throws:
IOException
- if an I/O error occurs
-
handleChangeInheritance
protected void handleChangeInheritance(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response, AutoTranslateMergeService.CancelOrReenable kind) throws IOException
Handles the "cancelInheritance" operation of the servlet.Request parameters: - `path`: the path of the resource to cancel inheritance for (required). - `propertyName`: the name of the property to cancel inheritance for - optional, if not provided, inheritance is cancelled for the whole component. That's the normal case - normally only page properties are cancelled individually.
- Parameters:
request
- the Sling HTTP servlet requestresponse
- the Sling HTTP servlet responsekind
- whether to cancel or re-enable inheritance- Throws:
IOException
- if an I/O error occurs
-
-