
com.adobe.aemds.guide.model.ValidationOptions Maven / Gradle / Ivy
/*
*
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2017 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
*/
package com.adobe.aemds.guide.model;
import org.apache.sling.api.resource.Resource;
/**
* ValidationOptions describes the basic options required to validate an adaptive form
* on server side.
*
* Use {@link ValidationOptionsBuilder} , it's static helper class to define the validation options.
* @since 6.3
*/
public class ValidationOptions {
private String data;
private Resource formContainerResource;
private String serverUrl;
private String locale;
private String contextPath;
private String captchaData;
private String fileAttachmentMap;
private ValidationOptions(Resource formContainerResource, String data, String captchaData, String serverUrl, String contextPath, String locale, String fileAttachmentMap) {
this.formContainerResource = formContainerResource;
this.data = data;
this.captchaData = captchaData;
this.serverUrl = serverUrl;
this.contextPath = contextPath;
this.locale = locale;
this.fileAttachmentMap = fileAttachmentMap;
}
/**
* Returns the adaptive form container resource.
* @return Adaptive Form container resource.
*/
public Resource getFormContainerResource() {
return formContainerResource;
}
/**
* Returns the submitted adaptive form data
* @return string representing the adaptive form data
*/
public String getData() {
return data;
}
/**
* Returns the data associated with the captcha component present in the adaptive form
* @return string representing the captcha data
*/
public String getCaptchaData() {
return captchaData;
}
/**
* Returns the adaptive form server URL configured. This server URL is used to convert relative URL to
* absolute URL during server side validation
* @return string representing the adaptive form server url
*/
public String getServerUrl() {
return serverUrl;
}
/**
* Returns the context path set
* @return string representing the context path
*/
public String getContextPath() {
return contextPath;
}
/**
* Returns the locale set
* @return string representing the locale
*/
public String getLocale() {
return locale;
}
/**
* Returns the file attachment map
* @return string representing the file attachment map
*/
public String getFileAttachmentMap() {
return fileAttachmentMap;
}
/**
* Static helper class to build validation options. These validation options defines the basic
* options required to perform server side validation of an adaptive form
* @since 6.3
*/
public static class ValidationOptionsBuilder {
private Resource formContainerResource;
private String data;
private String captchaData;
private String serverUrl;
private String contextPath;
private String locale;
private String fileAttachmentMap;
/**
* Sets the adaptive form container resource against which server side validation is to be performed
* @param formContainerResource adaptive form container resource against which validation would be performed.
* @return {@link ValidationOptionsBuilder} validation options builder
*/
public ValidationOptionsBuilder setFormContainerResource(Resource formContainerResource) {
this.formContainerResource = formContainerResource;
return this;
}
/**
* Sets the submitted data of the adaptive form.
* @param data String representing data of Adaptive form.
* @return {@link ValidationOptionsBuilder} validation options builder
*/
public ValidationOptionsBuilder setData(String data) {
this.data = data;
return this;
}
/**
* Sets the captcha data to validate the captcha. This is optional and would depend on the existence of
* captcha component in an adaptive form.
* @param captchaData Captcha data coming from request to validate captcha, which resides in the form.
* @return {@link ValidationOptionsBuilder} validation options builder
*/
public ValidationOptionsBuilder setCaptchaData(String captchaData) {
this.captchaData = captchaData;
return this;
}
/**
* Sets the server name to be used for conversion of relative to absolute URL
* @param serverUrl host name/ip to be used for conversion of relative URL to absolute URL during server side validation.
* @return {@link ValidationOptionsBuilder} validation options builder
*/
public ValidationOptionsBuilder setServerUrl(String serverUrl) {
this.serverUrl = serverUrl;
return this;
}
/**
* Sets the context path of the application
* @param contextPath Context path for the application.
* @return {@link ValidationOptionsBuilder} validation options builder
*/
public ValidationOptionsBuilder setContextPath(String contextPath) {
this.contextPath = contextPath;
return this;
}
/**
* Sets the locale to be used during validation of data on server side
* @param locale locale
* @return {@link ValidationOptionsBuilder} validation options builder
*/
public ValidationOptionsBuilder setLocale(String locale) {
this.locale = locale;
return this;
}
/**
* Sets the file attachment map to be used during validation of data on server side
* @param fileAttachmentMap file attachment map
* @return {@link ValidationOptionsBuilder} validation options builder
*/
public ValidationOptionsBuilder setFileAttachmentMap(String fileAttachmentMap) {
this.fileAttachmentMap = fileAttachmentMap;
return this;
}
/**
* This will build the {@link ValidationOptions} object using the options provided in the setters.
* @return {@link ValidationOptions} validation options
*/
public ValidationOptions build() {
return new ValidationOptions(formContainerResource, data, captchaData, serverUrl, contextPath, locale, fileAttachmentMap);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy