Media handlers are services that are usually used in combination with workflows.
CQ5 has the following default workflows to process assets:
DAM Asset Sync and Metadata Extractor
DAM Delete Asset
DAM Delete Dam Asset under /content/dam
DAM Sub Asset Processor
DAM Update Asset
Existing workflows can be extended and new ones can be created to process assets according to specific requirements.
By default, when a PDF document is uploaded into the
/var/dam/geometrixx/documents folder, the default DAM
Asset Sync and Metadata Extractor process:
copies the document into the
/content/dam/geometrixx/documentsfolderasks the AssetStore for a handler that is able to process pdf
Then, the pdf handler:
extracts the metadata
generates a thumbnail
creates sub-assets: each page of the document becomes a sub-asset
The following example shows how to disable the sub-asset creation
for PDF documents by extending the workflow: the Process
Subassets step will be replaced by an OR-split that checks the
asset filename:
if it ends with
.pdf, the asset reaches theEndstep.if it does not end with
.pdf, the asset goes through aProcess Subassetsstep that generates sub-assets.
The workflow will look as follows:

Proceed as follows:
Create a service (for example
com.day.cq5.myprocess.DoNothingProcess) that does not affect the asset and install it in CQ5. This service will be used to bypass the sub-asset creation step.![[Tip]](../resources/tip.png)
Tip You can refer to the section called “Example: create a specific Text Handler” to see how to create a service and install it in CQ5.
In your browser, open the
Workflow Console(for example:http://localhost:4502/libs/workflow/content/console.html).Select the
Modelstab and edit theDAM Asset Sync and Metadata Extractorworkflow.Drag and drop an
OR Splitbetween theThumbnail Creationstep and theProcess Subassetsstep.Click the configuration button of the left step of the OR Split and set the following properties in the right panel:
Type: select
ProcessDescription:
This process creates subassets if handler is able to extract subassetsHandler Advance:
trueImplementation: select
com.day.cq.dam.core.process.CreateSubAssetsProcessProcess Arguments:
/etc/workflow/models/dam/sub_asset_processorTimeout:
OffTimeout Handler:
Title:
Process Subassets
Click the configuration button of the right step of the OR Split and set the following properties in the right panel:
Type: select
ProcessDescription:
This process does not affect the asset and leads to the next stepHandler Advance:
trueImplementation: type the name of the service here (the service created in step 1; for example:
com.day.cq5.myprocess.DoNothingProcess)Process Arguments:
Timeout:
OffTimeout Handler:
Title:
Do Nothing
Delete the
Process Subassetsstep that comes after the end of theOR Split.Create an ecma-script function that is set to true if the filename ends with
.pdf, to false otherwise:In CQDE, create a file under
/etc/workflow/scriptsand call itmyPdfCheck.ecma.Copy-paste the following code into it:
function check() { if (workflowData.getPayloadType() == "JCR_PATH") { var path = workflowData.getPayload().toString(); var node = jcrSession.getItem(path); if (node.getPath().indexOf(".pdf") >= 0) { return true; } else { return false; } } else { return false; } }Save the file.
Create an ecma-script function that is set to true if the filename does not end with
.pdf, to false otherwise:In CQDE, create a file under
/etc/workflow/scriptsand call itmyNotPdfCheck.ecma.Copy-paste the following code into it:
function check() { if (workflowData.getPayloadType() == "JCR_PATH") { var path = workflowData.getPayload().toString(); var node = jcrSession.getItem(path); if (node.getPath().indexOf(".pdf") >= 0) { return false; } else { return true; } } else { return true; } }Save the file.
In your browser, set the rule of the
Process Subassetsstep of the OR Split: type/etc/workflow/scripts/myPdfCheck.ecmaas value of the Rule.Set the rule of the
Do Nothingstep of the OR Split: type/etc/workflow/scripts/myNotPdfCheck.ecmaas value of the Rule.Save the workflow.
From now on, whenever a pdf file is uploaded into the
/var/dam/geometrixx/documents folder, the file is
copied into /content/dam/geometrixx/documents, its
metadata are extracted and thumbnails are generated. Subassets are not
created anymore.