public class GuideSubmitUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
REQ_ATTR_FORWARD_OPTIONS |
static String |
REQ_ATTR_FORWARD_PATH |
static String |
REQ_ATTR_GUIDE_SUBMIT_OPTIONS |
static String |
REQUEST_ATTR_PDF_NAME |
static String |
REQUEST_ATTR_REDIRECT_PARAMETER_MAP |
Constructor and Description |
---|
GuideSubmitUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
addContextPath(String url,
String contextPath)
This method will prepend context path to the URL if it starts with a /,
provided url and context path is not blank.
|
static String |
addContextPathWithServerUrl(String url,
String contextPath,
String serverUrl)
A wrapper function for prepending context path and server url in case given url is not absolute already
|
static Map<String,String> |
getAFSuccessPayload(org.apache.sling.api.SlingHttpServletRequest request,
org.apache.sling.api.resource.ValueMap formContainerResourceProperties,
String redirectUrl)
When aemFormResource is null.
|
static GuideValidationResult |
getDefaultGuideValidationResult()
This method will return default guideValidation object
|
static GuideValidationResult |
getGuideValidationResultFromString(String errorMessage,
String status)
This method will check error in Map corresponding to key "FormSubmissioneError"
If this key is present and value is Object of @link GuideValidationResult, error will be sent in response
|
static Map<String,String> |
getGuideValueMap(FormSubmitInfo formSubmitInfo)
This API returns guideValueMap, that is, Map of all the fields and their values, and portal submit link and submit id
|
static Map<String,String> |
getGuideValueMap(FormSubmitInfo formSubmitInfo,
boolean retainBoundDataHierarchy)
This API returns guideValueMap, that is, Map of all the fields and their values, and portal submit link and submit id
|
static String |
getLocale(javax.servlet.http.HttpServletRequest request) |
static Map<String,String> |
getMappedFieldParameters(String[] fieldParameterMapping)
Provides map of field name and parameter name pairs.
|
static Map<String,String> |
getRedirectParameters(javax.servlet.http.HttpServletRequest request)
This API returns redirect parameters set in the current request.
|
static String |
getReqAttrPdfName(org.apache.sling.api.SlingHttpServletRequest request)
Returns the name of the PDF set in the request
|
static String |
getUserID(org.apache.sling.api.SlingHttpServletRequest request)
Returns the current user ID from the request
|
static void |
handleValidationError(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
Map<String,Object> submitResult)
This method will check error in Map corresponding to key "FormSubmissioneError"
If this key is present and value is Object of @link GuideValidationResult, error will be sent in response
|
static String |
prepareRedirectUrl(org.apache.sling.api.SlingHttpServletRequest request,
String redirectUrl) |
static void |
setForwardPath(org.apache.sling.api.SlingHttpServletRequest req,
String path,
String selector,
String suffix)
This API should be used to set the path to forward the current request
|
static void |
setRedirectParameters(javax.servlet.http.HttpServletRequest request,
Map<String,String> value)
Sets redirect parameters to the current request
|
static void |
setRedirectUrl(org.apache.sling.api.SlingHttpServletRequest req,
String redirectUrl)
This API should be used to set the redirect url
|
public static final String REQUEST_ATTR_PDF_NAME
public static final String REQUEST_ATTR_REDIRECT_PARAMETER_MAP
public static final String REQ_ATTR_FORWARD_PATH
public static final String REQ_ATTR_FORWARD_OPTIONS
public static final String REQ_ATTR_GUIDE_SUBMIT_OPTIONS
public static void setForwardPath(org.apache.sling.api.SlingHttpServletRequest req, String path, String selector, String suffix)
req
- Sling http servlet requestpath
- Path to forward the current requestselector
- Sling selector to use while forwarding the request to the path. Null if no selector to be usedsuffix
- Suffix to use while forwarding the request to the path. Null if no selector to be usedSlingHttpServletRequest
public static void setRedirectUrl(org.apache.sling.api.SlingHttpServletRequest req, String redirectUrl)
req
- Sling http servlet requestredirectUrl
- redirect url to set in the current request objectSlingHttpServletRequest
public static String getUserID(org.apache.sling.api.SlingHttpServletRequest request)
request
- SlingHttpServletRequest
sling http servlet requestpublic static Map<String,String> getRedirectParameters(javax.servlet.http.HttpServletRequest request)
getRedirectParameters(HttpServletRequest)
(org.apache.sling.api.SlingHttpServletRequest, java.util.Map)}request
- Sling http servlet requestSlingHttpServletRequest
public static Map<String,String> getGuideValueMap(FormSubmitInfo formSubmitInfo) throws org.apache.sling.commons.json.JSONException
formSubmitInfo
- FormSubmitInfo
object containing the basic information required during form submissionorg.apache.sling.commons.json.JSONException
FormSubmitInfo
public static Map<String,String> getGuideValueMap(FormSubmitInfo formSubmitInfo, boolean retainBoundDataHierarchy) throws org.apache.sling.commons.json.JSONException
formSubmitInfo
- FormSubmitInfo
object containing the basic information required during form submissionretainBoundDataHierarchy
- boolean indicates if map should contain absolute path of data elements as key in case of bound dataorg.apache.sling.commons.json.JSONException
FormSubmitInfo
public static Map<String,String> getMappedFieldParameters(String[] fieldParameterMapping)
fieldParameterMapping
- array of field mappings in the form of public static void setRedirectParameters(javax.servlet.http.HttpServletRequest request, Map<String,String> value)
request
- Sling http servlet requestvalue
- Map represent the redirect paramters to be setSlingHttpServletRequest
public static String getReqAttrPdfName(org.apache.sling.api.SlingHttpServletRequest request)
request
- Sling http servlet requestpublic static String addContextPath(String url, String contextPath)
url
- Thank You page URLcontextPath
- Context path for the application.public static String addContextPathWithServerUrl(String url, String contextPath, String serverUrl)
url
- URL that user will be redirected tocontextPath
- Context path for the applicationserverUrl
- Server url (e.g localhost:4502)public static void handleValidationError(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Map<String,Object> submitResult)
request
- request objectresponse
- response objectsubmitResult
- return value for submit() functionpublic static GuideValidationResult getDefaultGuideValidationResult()
public static GuideValidationResult getGuideValidationResultFromString(String errorMessage, String status)
errorMessage
- strings to be parsed to get GuideValidationResult or else set as originMessagestatus
- response originCode that needs to be set in case parsing of errorMessage to GuideValidationResult failspublic static String getLocale(javax.servlet.http.HttpServletRequest request)
public static String prepareRedirectUrl(org.apache.sling.api.SlingHttpServletRequest request, String redirectUrl) throws UnsupportedEncodingException
UnsupportedEncodingException
public static Map<String,String> getAFSuccessPayload(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.resource.ValueMap formContainerResourceProperties, String redirectUrl) throws UnsupportedEncodingException
request
- Sling http servlet requestformContainerResourceProperties
- Form container resource propertiesredirectUrl
- Url to be redirected to on async submission (can be null)UnsupportedEncodingException
Copyright © 1982–2023 Adobe Systems Incorporated. All rights reserved.