Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,13 @@ private FormConstants() {
/** The resource type for date time input field v1 */
public static final String RT_FD_FORM_DATETIME_V1 = RT_FD_FORM_PREFIX + "datetime/v1/datetime";

/** The resource type for signature step v1 */
public static final String RT_FD_FORM_SIGNATURE_STEP_V1 = RT_FD_FORM_PREFIX + "signaturestep/v1/signaturestep";

/** The resource type for summary step v1 */
public static final String RT_FD_FORM_SUMMARY_STEP_V1 = RT_FD_FORM_PREFIX + "summarystep/v1/summarystep";

/** The resource type for Adobe Sign block v1 */
public static final String RT_FD_FORM_ADOBE_SIGN_BLOCK_V1 = RT_FD_FORM_PREFIX + "adobesignblock/v1/adobesignblock";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2024 Adobe
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
package com.adobe.cq.forms.core.components.internal.models.v1.form;

import java.util.Map;

import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Default;
import org.apache.sling.models.annotations.Exporter;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy;
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import com.adobe.cq.export.json.ComponentExporter;
import com.adobe.cq.export.json.ExporterConstants;
import com.adobe.cq.forms.core.components.internal.form.FormConstants;
import com.adobe.cq.forms.core.components.models.form.FieldType;
import com.adobe.cq.forms.core.components.models.form.SignatureStep;
import com.adobe.cq.forms.core.components.util.AbstractBaseImpl;

@Model(
adaptables = { SlingHttpServletRequest.class, Resource.class },
adapters = { SignatureStep.class, ComponentExporter.class },
resourceType = { FormConstants.RT_FD_FORM_SIGNATURE_STEP_V1 })
@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)
public class SignatureStepImpl extends AbstractBaseImpl implements SignatureStep {

static final String PROP_SIGNING_SERVICE = "signingService";
static final String PROP_CLOUD_SERVICE_CONFIG = "cq:cloudserviceconfigs";
static final String PROP_DISPLAY_MSG = "displayMsg";
static final String PROP_TARGET_VERSION = "fd:targetVersion";

static final String DEFAULT_SIGNING_SERVICE = "echosign";
static final String DEFAULT_DISPLAY_MSG = "";
static final String DEFAULT_TARGET_VERSION = "";

static final String VIEW_TYPE_SIGNATURE_STEP = "signature-step";

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = PROP_SIGNING_SERVICE)
@Default(values = DEFAULT_SIGNING_SERVICE)
private String signingService;

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = PROP_CLOUD_SERVICE_CONFIG)
@Nullable
private String cloudServiceConfig;

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = PROP_DISPLAY_MSG)
@Nullable
private String displayMsg;

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = PROP_TARGET_VERSION)
@Nullable
private String targetVersion;

@Override
public String getSigningService() {
return signingService;
}

@Override
public String getCloudServiceConfig() {
return cloudServiceConfig != null ? cloudServiceConfig : "";
}

@Override
public String getDisplayMsg() {
return displayMsg;
}

@Override
public String getTargetVersion() {
return targetVersion;
}

@Override
public String getFieldType() {
return super.getFieldType(FieldType.PLAIN_TEXT);
}

@Override
public @NotNull Map<String, Object> getProperties() {
Map<String, Object> properties = super.getProperties();
properties.put("fd:signingService", getSigningService());
if (!getCloudServiceConfig().isEmpty()) {
properties.put("fd:cloudServiceConfig", getCloudServiceConfig());
}
if (getDisplayMsg() != null) {
properties.put("fd:displayMsg", getDisplayMsg());
}
if (getTargetVersion() != null && !getTargetVersion().isEmpty()) {
properties.put("fd:targetVersion", getTargetVersion());
}
return properties;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2024 Adobe
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
package com.adobe.cq.forms.core.components.internal.models.v1.form;

import java.util.Map;

import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Default;
import org.apache.sling.models.annotations.Exporter;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy;
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import com.adobe.cq.export.json.ComponentExporter;
import com.adobe.cq.export.json.ExporterConstants;
import com.adobe.cq.forms.core.components.internal.form.FormConstants;
import com.adobe.cq.forms.core.components.models.form.FieldType;
import com.adobe.cq.forms.core.components.models.form.SummaryStep;
import com.adobe.cq.forms.core.components.util.AbstractBaseImpl;

@Model(
adaptables = { SlingHttpServletRequest.class, Resource.class },
adapters = { SummaryStep.class, ComponentExporter.class },
resourceType = { FormConstants.RT_FD_FORM_SUMMARY_STEP_V1 })
@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)
public class SummaryStepImpl extends AbstractBaseImpl implements SummaryStep {

static final String PROP_DISPLAY_MSG = "displayMsg";
static final String PROP_AUTO_SUBMIT = "autoSubmit";

static final String VIEW_TYPE_SUMMARY_STEP = "summary-step";

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = PROP_DISPLAY_MSG)
@Nullable
private String displayMsg;

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = PROP_AUTO_SUBMIT)
@Default(booleanValues = true)
private boolean autoSubmit;

@Override
public String getDisplayMsg() {
return displayMsg;
}

@Override
public boolean isAutoSubmit() {
return autoSubmit;
}

@Override
public String getFieldType() {
return super.getFieldType(FieldType.PLAIN_TEXT);
}

@Override
public @NotNull Map<String, Object> getProperties() {
Map<String, Object> properties = super.getProperties();
if (getDisplayMsg() != null) {
properties.put("fd:displayMsg", getDisplayMsg());
}
properties.put("fd:autoSubmit", isAutoSubmit());
return properties;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
package com.adobe.cq.forms.core.components.internal.models.v1.form;

import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Default;
Expand All @@ -37,20 +38,31 @@
adaptables = { SlingHttpServletRequest.class, Resource.class },
adapters = { Text.class,
ComponentExporter.class },
resourceType = { FormConstants.RT_FD_FORM_TEXT_DRAW_V1 })
resourceType = {
FormConstants.RT_FD_FORM_TEXT_DRAW_V1,
FormConstants.RT_FD_FORM_ADOBE_SIGN_BLOCK_V1 })
@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)
public class TextImpl extends AbstractFormComponentImpl implements Text {

private static final String PN_LEGACY_VALUE = "_value";

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = ReservedProperties.PN_TEXT_IS_RICH)
@Default(booleanValues = false)
private boolean textIsRich;

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = PN_LEGACY_VALUE)
private String legacyValue;

@SlingObject
private Resource resource;

@Override
public String getValue() {
return translate("value", value);
String resolvedValue = translate("value", value);
if (StringUtils.isBlank(resolvedValue) && StringUtils.isNotBlank(legacyValue)) {
return legacyValue;
}
return resolvedValue;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
package com.adobe.cq.forms.core.components.internal.models.v2.form;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
Expand Down Expand Up @@ -88,6 +89,30 @@ public class FormContainerImpl extends AbstractContainerImpl implements FormCont
private static final String FD_DATA_URL = "fd:dataUrl";
private static final String FD_VIEW_PRINT_PATH = "fd:view/print";
private static final String EXCLUDE_FROM_DOR_IF_HIDDEN = "excludeFromDoRIfHidden";
private static final String PN_USE_SIGNED_PDF = "_useSignedPdf";
private static final String PN_SIGNER_INFO = "signerInfo";
private static final String PN_FIRST_SIGNER_FORM_FILLER = "firstSignerFormFiller";
private static final String PN_SIGN_CONFIG_PATH = "signConfigPath";
private static final String PN_WORKFLOW_TYPE = "workflowType";
private static final String PN_DAYS_UNTIL_SIGNING_DEADLINE = "daysUntilSigningDeadline";
private static final String PN_SIGNERS = "signers";
private static final String PN_SIGNER_TITLE = "signerTitle";
private static final String PN_IS_FORM_FILLER = "isFormFiller";
private static final String PN_SIGNER_EMAIL_TYPE = "signerEmailType";
private static final String PN_SIGNER_EMAIL_REF = "signerEmailRef";
private static final String PN_SIGNER_EMAIL = "signerEmail";
private static final String PN_AUTHENTICATION_METHOD = "authenticationMethod";
private static final String PN_COUNTRY_CODE_SOURCE = "countryCodeSource";
private static final String PN_COUNTRY_CODE = "countryCode";
private static final String PN_PHONE_SOURCE = "phoneSource";
private static final String PN_PHONE = "phone";
private static final String PN_SIGNATURE_TYPE = "signatureType";
private static final String FD_USE_SIGNED_PDF = "fd:useSignedPdf";
private static final String FD_IS_FORM_FILLER_FIRST_SIGNER = "fd:isFormFillerFirstSigner";
private static final String FD_SIGNING_CLOUD_SERVICE = "fd:signingCloudService";
private static final String FD_WORKFLOW_TYPE = "fd:workflowType";
private static final String FD_DAYS_UNTIL_SIGNING_DEADLINE = "fd:daysUntilSigningDeadline";
private static final String FD_SIGNERS = "fd:signers";

/** Constant representing email submit action type */
private static final String SS_EMAIL = "email";
Expand Down Expand Up @@ -159,6 +184,16 @@ public class FormContainerImpl extends AbstractContainerImpl implements FormCont
@Self(injectionStrategy = InjectionStrategy.OPTIONAL)
private AutoSaveConfiguration autoSaveConfig;

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = PN_USE_SIGNED_PDF)
@Default(booleanValues = false)
private boolean useSignedPdf;

private boolean formFillerFirstSigner = false;
private String signingCloudService = null;
private String workflowType = "SEQUENTIAL";
private int daysUntilSigningDeadline = 1;
private List<Map<String, Object>> signers = new ArrayList<>();

@Inject
private ResourceResolver resourceResolver;

Expand Down Expand Up @@ -199,6 +234,52 @@ private void initExcludeFromDoRIfHidden() {
}
}

@PostConstruct
private void initSignerInfo() {
Resource signerInfoResource = resource.getChild(PN_SIGNER_INFO);
if (signerInfoResource != null) {
ValueMap vm = signerInfoResource.getValueMap();
formFillerFirstSigner = vm.get(PN_FIRST_SIGNER_FORM_FILLER, false);
signingCloudService = vm.get(PN_SIGN_CONFIG_PATH, String.class);
workflowType = vm.get(PN_WORKFLOW_TYPE, "SEQUENTIAL");
daysUntilSigningDeadline = vm.get(PN_DAYS_UNTIL_SIGNING_DEADLINE, 1);
Resource signersResource = signerInfoResource.getChild(PN_SIGNERS);
if (signersResource != null) {
for (Resource signerItem : signersResource.getChildren()) {
ValueMap signerVm = signerItem.getValueMap();
Map<String, Object> signerMap = new LinkedHashMap<>();

String title = signerVm.get(PN_SIGNER_TITLE, String.class);
String isFormFillerVal = signerVm.get(PN_IS_FORM_FILLER, "true");
String emailType = signerVm.get(PN_SIGNER_EMAIL_TYPE, "fromForm");
String emailRef = signerVm.get(PN_SIGNER_EMAIL_REF, String.class);
String signerEmail = signerVm.get(PN_SIGNER_EMAIL, String.class);
String authMethod = signerVm.get(PN_AUTHENTICATION_METHOD, "NONE");
String countryCodeSource = signerVm.get(PN_COUNTRY_CODE_SOURCE, "form");
String countryCode = signerVm.get(PN_COUNTRY_CODE, String.class);
String phoneSource = signerVm.get(PN_PHONE_SOURCE, "form");
String phone = signerVm.get(PN_PHONE, String.class);
String sigType = signerVm.get(PN_SIGNATURE_TYPE, "ESIGN");

if (title != null) signerMap.put(PN_SIGNER_TITLE, title);
signerMap.put(PN_IS_FORM_FILLER, Boolean.parseBoolean(isFormFillerVal));
signerMap.put(PN_SIGNER_EMAIL_TYPE, emailType);
if (emailRef != null) signerMap.put(PN_SIGNER_EMAIL_REF, emailRef);
if (signerEmail != null) signerMap.put(PN_SIGNER_EMAIL, signerEmail);
signerMap.put(PN_AUTHENTICATION_METHOD, authMethod);
if ("PHONE".equals(authMethod)) {
signerMap.put(PN_COUNTRY_CODE_SOURCE, countryCodeSource);
if (countryCode != null) signerMap.put(PN_COUNTRY_CODE, countryCode);
signerMap.put(PN_PHONE_SOURCE, phoneSource);
if (phone != null) signerMap.put(PN_PHONE, phone);
}
signerMap.put(PN_SIGNATURE_TYPE, sigType);
signers.add(signerMap);
}
}
}
}

@Override
public void setContextPath(String contextPath) {
this.contextPath = contextPath;
Expand Down Expand Up @@ -420,6 +501,18 @@ public String getLanguageDirection() {
if (submitProperties != null && !submitProperties.isEmpty()) {
properties.put(ReservedProperties.FD_SUBMIT_PROPERTIES, submitProperties);
}
if (isAdobeSignEnabled()) {
properties.put(FD_USE_SIGNED_PDF, true);
properties.put(FD_IS_FORM_FILLER_FIRST_SIGNER, isFormFillerFirstSigner());
if (signingCloudService != null) {
properties.put(FD_SIGNING_CLOUD_SERVICE, signingCloudService);
}
properties.put(FD_WORKFLOW_TYPE, workflowType);
properties.put(FD_DAYS_UNTIL_SIGNING_DEADLINE, daysUntilSigningDeadline);
if (!signers.isEmpty()) {
properties.put(FD_SIGNERS, signers);
}
}
return properties;
}

Expand Down Expand Up @@ -488,6 +581,18 @@ public AutoSaveConfiguration getAutoSaveConfig() {
return autoSaveConfig;
}

@JsonIgnore
@Override
public boolean isAdobeSignEnabled() {
return useSignedPdf;
}

@JsonIgnore
@Override
public boolean isFormFillerFirstSigner() {
return formFillerFirstSigner;
}

private Map<String, Object> getSubmitProperties() {

Map<String, Object> submitProps = null;
Expand Down
Loading
Loading