Document management
Document lifecycle
Each time an order is created, or a signature added, files are uploaded from the user or downloaded from Signing Service. For each file, a database entry is created that keeps track of the file location and status, i.e. wether it is assigned to an order or not.
File locations
File uploads end up in the directory temp
. Files should never grow old in this directory: any file that is older than a few minutes is with high probability the product of a failed order creation, and can be removed.
When an upload is complete, the file is moved to the designated file storage location on disk. This location is configured using two global config parameters:
-
fileDirectory
: the directory where all files are stored -
documentLocationId
: an integer that identifies a particular storage location, and must be changed every time the fileDirectory changes. IffileDirectory
is changed without a new, uniquedocumentLocationId
, the system will refuse to create new orders.
If the designated file storage location is changed, it will not have any retroactive effects on existing orders. It is thus possible to change file store without moving existing files.
Order actions
Order creation:
- The file is uploaded to the directory
temp
- A document entry is created in the database, containing designated disk location and status (not assigned).
- The file is moved to the designated disk location
- When the order entry has been created in the database, the document status is updated (assigned to order)
Document signing:
- The signed file is downloaded from the Signing Service to the directory
temp
- A document entry is created in the database, containing designated disk location and status (not assigned).
- The file is moved to the designated disk location
- The document currently assigned to the order is un-assigned and the new document takes its place
Document retention
Functionality
The documents stored in the file area can automatically be removed by activating the document retention function. As documents are permanently deleted from the file area it is very important to have a backup scheme in place for recovery and rollback.
Activating
The function can be activated by setting the configuration parameter "documentRetention.enabled" to true and restarting the application.
Note that if the file area contains many documents the initial time for a full clean up can take some time. Activation is best done outside office hours and the file area and log files should be monitored for any problems.
Scheduling
The clean up job is executed every minute (53sec) and checks for expired documents according to the configuration parameters. At the most 100 documents are deleted every cycle.
Retention age policy
The document age policy can be configured for two types of document states.
Configuration parameters:
"inactiveDocumentAge": All documents that are in an intermediate state or the corresponding order is in state Rejected, Canceled or Expired.
"completedDocumentAge": All documents for orders that are in state Accepted/Completed.
Note that ongoing (Pending) documents are never deleted by this function.
Recovery and rollback
In the case of file area, database corruption or change in retention age policy to retrieve old documents, the documents can be rolled back by the following procedure:
- Stop the application
- Restore the files from backup to the file area.
- Optionally change or disable document retention while investigating root causes.
- Run SQL command: UPDATE documents SET file_state = 0
- Start the application
When the periodic schedule is activated again the documents will be deleted according to (new) settings.
PDF/A-1a validation
The service offers the possibility to validate the format of uploaded files, issuing a warning to the user if the file does not comply with the format PDF/A-1a. This feature is disabled by default, and can be turned on and off with the configuration parameter signingOrders.usePdfA1Validation.