AEM 6.4 has reached the end of extended support and this documentation is no longer updated. For further details, see our technical support periods. Find the supported versions here.
AEM Forms portal drafts and submissions component allows users to save their forms as drafts and submit later from any device. Also, users can view their submitted forms on portal. To enable this functionality, AEM Forms provides data and metadata services to store the data filled in by a user in the form and the form metadata associated with drafts and submitted forms. This data is stored in the CRX repository, by default. However, as users interact with forms through AEM publish instance, which is generally outside the enterprise firewall, organizations may want to customize data storage for it to be more secure and reliable.
The sample, discussed in this document, is a reference implementation of customized data and metadata services to integrate drafts and submissions component with a database. The database used in the sample implementation is MySQL 5.6.24. However, you can integrate the drafts and submissions component with any database of your choice.
Perform the following steps, on all the author and publish instances, to install and configure the sample :
Download the following aem-fp-db-integration-sample-pkg-6.1.2.zip package to your file system.
Sample package for database integration
Go to AEM package manager at https://[host]:[port]/crx/packmgr/.
Click Upload Package.
Browse to select the aem-fp-db-integration-sample-pkg-6.1.2.zip package and click OK.
Click Install to next to the package to install the package.
Go to AEM Web Console Configuration
page at https://[host]:[port]/system/console/configMgr.
Click to open Forms Portal Draft and Submission Configuration in edit mode.
Specify the values for properties as described in the following table:
Property | Description | Value |
---|---|---|
Forms Portal Draft Data Service | Identifier for draft data service | formsportal.sampledataservice |
Forms Portal Draft Metadata Service | Identifier for draft metadata service | formsportal.samplemetadataservice |
Forms Portal Submit Data Service | Identifier for submit data service | formsportal.sampledataservice |
Forms Portal Submit Metadata Service | Identifier for submit metadata service | formsportal.samplemetadataservice |
Forms Portal Pending Sign Data Service | Identifier for Pending Sign data service | formsportal.sampledataservice |
Forms Portal Pending Sign Metadata Service | Identifier for Pending Sign metadata service | formsportal.samplemetadataservice |
The services are resolved by their names mentioned as value for the aem.formsportal.impl.prop
key as follows:
@Service(value = {SubmitDataService.class, DraftDataService.class})
@Property(name = "aem.formsportal.impl.prop", value = "formsportal.sampledataservice")
@Service(value = { SubmitMetadataService.class, DraftMetadataService.class })
@Property(name = "aem.formsportal.impl.prop", value = "formsportal.samplemetadataservice")
You can change names of the data and metadata tables.
To provide a different name for the metadata table:
To provide a different name for the data table:
If you change the table names, provide them in the Form Portal configuration.
Leave other configurations as is and click Save.
The database connection can be done via Apache Sling Connection Pooled Data Source.
For Apache Sling connection, find and click to open Apache Sling Connection Pooled DataSource in edit mode in the Web Console Configuration. Specify the values for properties as described in the following table:
Property | Value |
Datasource name | A datasource name for filtering drivers from the data source pool Note: The sample implementation uses FormsPortal as the datasource name. |
JDBC driver class | com.mysql.jdbc.Driver |
JDBC connection URI |
jdbc:mysql://[host]:[port]/[schema_name] |
Username | A username to authenticate and perform actions on database tables |
Password | Password associated with the username |
Transaction Isolation | READ_COMMITTED |
Max Active Connections | 1000 |
Max Idle Connections | 100 |
Min Idle Connections | 10 |
Initial Size | 10 |
Max Wait | 100000 |
Test on Borrow | Checked |
Test while Idle | Checked |
Validation Query | Example values are SELECT 1(mysql), select 1 from dual(oracle), SELECT 1(MS Sql Server) (validationQuery) |
Validation Query timeout | 10000 |
Leave other configurations as is and click Save.
If you already have a table in the database schema, skip to the next step.
Otherwise, if you do not already have a table in the database schema, execute the following SQL statements to create separate tables for data, metadata, and additional metadata in the database schema:
You do not require different databases for author and publish instances. Use same database on all the author and publish instances.
SQL statement for data table
CREATE TABLE `data` (
`owner` varchar(255) DEFAULT NULL,
`data` longblob,
`metadataId` varchar(45) DEFAULT NULL,
`id` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
SQL statement for metadata table
CREATE TABLE `metadata` (
`formPath` varchar(1000) DEFAULT NULL,
`formType` varchar(100) DEFAULT NULL,
`description` text,
`formName` varchar(255) DEFAULT NULL,
`owner` varchar(255) DEFAULT NULL,
`enableAnonymousSave` varchar(45) DEFAULT NULL,
`renderPath` varchar(1000) DEFAULT NULL,
`nodeType` varchar(45) DEFAULT NULL,
`charset` varchar(45) DEFAULT NULL,
`userdataID` varchar(45) DEFAULT NULL,
`status` varchar(45) DEFAULT NULL,
`formmodel` varchar(45) DEFAULT NULL,
`markedForDeletion` varchar(45) DEFAULT NULL,
`showDorClass` varchar(255) DEFAULT NULL,
`sling:resourceType` varchar(1000) DEFAULT NULL,
`attachmentList` longtext,
`draftID` varchar(45) DEFAULT NULL,
`submitID` varchar(45) DEFAULT NULL,
`id` varchar(60) NOT NULL,
`profile` varchar(255) DEFAULT NULL,
`submitUrl` varchar(1000) DEFAULT NULL,
`xdpRef` varchar(1000) DEFAULT NULL,
`agreementId` varchar(255) DEFAULT NULL,
`nextSigners` varchar(255) DEFAULT NULL,
`eSignStatus` varchar(45) DEFAULT NULL,
`pendingSignID` varchar(45) DEFAULT NULL,
`agreementDataId` varchar(255) DEFAULT NULL,
`enablePortalSubmit` varchar(45) DEFAULT NULL,
`submitType` varchar(45) DEFAULT NULL,
`dataType` varchar(45) DEFAULT NULL,
`jcr:lastModified` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `ID_UNIQUE` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
SQL statement for additionalmetadatatable
CREATE TABLE `additionalmetadatatable` (
`value` text,
`key` varchar(255) NOT NULL,
`id` varchar(60) NOT NULL,
PRIMARY KEY (`id`,`key`),
CONSTRAINT ‘additionalmetadatatable_fk’ FOREIGN KEY (`id`) REFERENCES `metadata` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
SQL statement for comment table
CREATE TABLE `commenttable` (
`commentId` varchar(255) DEFAULT NULL,
`comment` text DEFAULT NULL,
`ID` varchar(255) DEFAULT NULL,
`commentowner` varchar(255) DEFAULT NULL,
`time` varchar(255) DEFAULT NULL);
If you already have the tables (data, metadata, and additionalmetadatatable) in the database schema, execute the following alter table queries:
SQL statement for altering the data table
ALTER TABLE `data` CHANGE `owner` `owner` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;
SQL statement for altering the metadata table
ALTER TABLE metadata add markedForDeletion varchar(45) DEFAULT NULL
The ALTER TABLE metadata add query fails if you have already run it and the markedforDeletion column is present in the table.
ALTER TABLE metadata add agreementId varchar(255) DEFAULT NULL,
add nextSigners varchar(255) DEFAULT NULL,
add eSignStatus varchar(45) DEFAULT NULL,
add pendingSignID varchar(45) DEFAULT NULL,
add agreementDataId varchar(255) DEFAULT NULL,
add enablePortalSubmit varchar(45) DEFAULT NULL,
add submitType varchar(45) DEFAULT NULL,
add dataType varchar(45) DEFAULT NULL;
ALTER TABLE `metadata` CHANGE `formPath` `formPath` VARCHAR(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
CHANGE `formType` `formType` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
CHANGE `description` `description` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
CHANGE `formName` `formName` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
CHANGE `owner` `owner` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
CHANGE `renderPath` `renderPath` VARCHAR(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
CHANGE `showDorClass` `showDorClass` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
CHANGE `sling:resourceType` `sling:resourceType` VARCHAR(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
CHANGE `profile` `profile` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
CHANGE `submitUrl` `submitUrl` VARCHAR(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
CHANGE `xdpRef` `xdpRef` VARCHAR(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;
SQL statement for altering the additionalmetadatatable table
ALTER TABLE `additionalmetadatatable` CHANGE `value` `value` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, CHANGE `key` `key` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
The sample implementation is now configured, which you can use to list your drafts and submissions while storing all data and metadata in a database. Let’s now see how data and metadata services are configured in the sample.
Perform the following steps,on all the author and publish instances, to install the mysql-connector-java-5.1.39-bin.jar file:
Navigate to https://[server]:[port]/system/console/depfinder
and search for com.mysql.jdbc package.
In the Exported by column, check if the package is exported by any bundle.
Proceed if the package is not exported by any bundle.
Navigate to https://[server]:[port]/system/console/bundles
and click Install/Update.
Click Choose File and browse to select the mysql-connector-java-5.1.39-bin.jar file. Also, select Start Bundle and Refresh Packages checkboxes.
Click Install or Update. Once complete, restart the server.
(Windows only) Turn off the system firewall for your operating system.
The following zip contains FormsPortalSampleDataServiceImpl
and FormsPortalSampleMetadataServiceImpl
(implementation classes) for data and metadata service interfaces. Additionally, it contains all the classes required for compilation of above mentioned implementation classes.
Database implementation of Forms Portal uses additional metadata table. The table has a composite primary key based on Key and id columns of the table. MySQL allows primary keys up to the length of 255 characters. You can use the following client-side validation script to verify the length of filename attached to the file widget. The validation is run when a file is attached. The script provided in the following procedure displays a message, when the filename is larger than 150 (including extension). You can modify the script to check it for a different number of characters.
Perform the following steps to create a client library and use the script:
Log in to CRXDE and navigate to /etc/clientlibs/
Create a node of type cq:ClientLibraryFolder and provide name of the node. For example, validation
.
Click Save All.
Right-click the node, click create new file, and create a file with extension .txt. For example, js.txt
Add the following code to the newly created .txt file and click Save All.
#base=util
util.js
In the above code, util
is the name of the folder and util.js
name of the file in the util
folder. The util
folder and util.js
file are created in suceeeding steps.
Right-click the cq:ClientLibraryFolder
node created in step 2, select Create > Create Folder. Create a folder named util
. Click Save All. Right-click the util
folder, select Create > Create File. Create a file named util.js
. Click Save All.
Add the following code to util.js file and click Save All. The code validate length of the file name.
/*
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2016 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 may be covered by U.S. and Foreign Patents,
* patents in process, 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.
*
*/
(function () {
var connectWithGuideBridge = function (gb) {
gb.connect(function () {
//For first time load
window.guideBridge.on("elementValueChanged" , function(event, payload) {
var component = payload.target; // Field whose value has changed
if(component.name == 'fileAttachment' && component.parent) {
var fileItems = $('#'+payload.target.parent.id).find(".guide-fu-fileItem");
for (i = 0;i<fileItems.length;i++) {
var filename = $(fileItems[i]).find(".guide-fu-fileName").text();
//check whether it is previously attached file or a newly attached one
if(filename.length > 150 && filename.indexOf("fp.attach.jsp") < 0) {
window.alert("filename is larger than 150 : "+filename);
$(fileItems[i]).find(".guide-fu-fileClose.close").click();
}
}
}
});
});
};
if (window.guideBridge) {
connectWithGuideBridge(window.guideBridge);
} else {
window.addEventListener("bridgeInitializeStart", function (event) {
connectWithGuideBridge(event.detail.guideBridge);
});
}
})();
The script is for out of the box (OOTB) attachment widget component. If you have customized the OOTB attachment widget then change the above script to incorporate respective changes.
Add the following property to the folder created in step 2 and click Save All.
Name: categories
Type: String
Value: fp.validation
multi option: Enabled
Navigate to /libs/fd/af/runtime/clientlibs/guideRuntime
and append the fp.validation
value to the embed property.
Navigate to /libs/fd/af/runtime/clientlibs/guideRuntimeWithXFA and append the fp.validation
value to embed property.
If you are using custom client libraries instead of of the guideRuntime and guideRuntimeWithXfa client libraries, use the category name to embed the client library created in this procedure to your custom libraries loaded at runtime.
Click Save All. Now, when the filename is larger than 150 (including extension) characters a message is displayed.