Setting Dummy PDF Files in Columns

Overview

This guide describes how to set a dummy PDF file in a database column.

The objective is to mask sensitive binary data by replacing it with a predefined dummy file. Although this guide uses a PDF file as an example, the same approach can be used for other binary file types, such as JPG, PNG, ZIP, or similar formats.

The process consists of:

  • creating a dummy file

  • converting the file to Base64

  • storing the Base64 content in an XDM file

  • using a Groovy Modification Method to decode and write the file content

  • applying the Modification Method through a Modification Set

This approach ensures data masking while maintaining database integrity.

Prerequisites

  • A target database column that can store binary data, for example BLOB or byte[].

Steps

Step 1: Create a Dummy File

Create a local file that should replace the sensitive data in the target database column.

Example:

dummy.pdf

This file will later be converted to Base64 and stored as an XDM file.

Step 2: Convert the File to Base64

Convert the dummy file into a Base64 representation.

This allows the binary file content to be embedded and read as text.

This can be done with:

Step 3: Create an XDM File

Create a new XDM file under XDM configuration → Files.

Use the following settings:

  • Type: Text

  • Content: Base64 representation of the dummy file

Upload or paste the Base64 content into the XDM file.

Step 4: Create the Modification Method

Create a Groovy Modification Method that reads the Base64 content from the XDM file, decodes it, and writes the binary content to the target column.

Add the following parameter to the Modification Method:

Name

fileName

Display Name

File Name

Type

STRING

Use the following code in the init() and apply() methods:

import org.apache.commons.codec.binary.Base64
import javax.sql.rowset.serial.SerialBlob
import de.ubs.xdm3.script.evaluator.ScriptValidationException

fileContentBinary = null

/*
 * This function is called once before the processing starts.
 */
void init() {
    // Retrieve the Base64 content of the dummy file
    file = api.files.find { modificationMethod.fileName.equals(it.displayName) }

    if (file == null) {
        throw new ScriptValidationException("File " + modificationMethod.fileName + " could not be found.")
    } else {
        // Decode the Base64 content to binary
        fileContentBase64 = file.content
        fileContentBinary = Base64.decodeBase64(fileContentBase64)
    }
}

/*
 * This function modifies each row of the table.
 */
def apply() {
    // Convert to Blob for binary storage in the database
    data[columnIndex] = new SerialBlob(fileContentBinary)
    return true
}

The SerialBlob class converts the decoded byte array into a Blob object. This is necessary if the database column is represented as BLOB during processing.

If the column is represented as byte[], the conversion to SerialBlob may not be required. For details, see Data Types Mappings.

Step 5: Create a Modification Set

Create a new Modification Set.

Add a Modification Rule for the database column where the dummy file should be applied.

Configure the parameter:

Parameter

Value

File Name

Name of the XDM file containing the Base64 encoded dummy file

Example:

dummy.pdf

Step 6: Use the Modification Set in a Task

Assign the Modification Set to the task that processes the target table.

Ensure that:

  • the correct table is selected,

  • the Modification Rule is applied to the correct binary column,

  • the XDM file name matches the value of the File Name parameter.

Execute the task and verify that the target column contains the dummy file content.

Benefits

This approach provides the following benefits:

  • Data masking: Sensitive binary data is replaced with controlled dummy content.

  • Reusability: The same Modification Method can be reused for different files and columns.

  • Flexibility: The approach supports different binary file types, such as PDF, JPG, PNG, or ZIP.

  • Consistency: The same dummy file can be applied consistently across multiple rows.

Conclusion

This guide shows how to mask binary database columns by replacing their content with a predefined dummy file.

By storing the dummy file as Base64 content in an XDM file and decoding it in a Modification Method, the process becomes reusable and easy to integrate into XDM tasks.

This approach helps protect sensitive binary data while keeping the target database structure intact.