1 Introduction to Developing Scripts with Oracle WebCenter Enterprise Capture

This chapter provides an introduction to developing scripts for Oracle WebCenter Enterprise Capture.

A script is a custom piece of code consumed by the Capture client or a batch processor (Import or Recognition) that allows you to customize functionality beyond existing configuration settings. For example, you might incorporate a script to change the first letter of a name to uppercase or to use a proprietary calculation to validate an account number used in a transaction.

For scripting, Capture uses the JavaScript script engine included with the Java Runtime Environment. Refer to the Oracle Java documentation for more information.

Controlling Java Class Access from Server-Side Scripts

For security, Capture limits the Java classes and packages that server-side scripts can access. This restriction applies to Recognition, Import, Document Conversion, and Commit Processor scripts. The ScriptEngineAllowedPackages setting does not control client scripts.

Capture provides access to the supported Capture script APIs and their required Java classes. Use the supported Capture classes documented in Common Capture Classes and in the processor-specific chapters: Recognition Processor Scripts, Import Processor Scripts, Document Conversion Processor Scripts, and Commit Processor Scripts.

If a custom server-side script requires another Java class, a Capture administrator can configure ScriptEngineAllowedPackages. For configuration syntax, security restrictions, and troubleshooting guidance, see Configuring Capture MBeans in Administering Oracle WebCenter Enterprise Capture.

During development, you can update a server-side script and rerun the processor job without restarting the Capture server. Similarly, changes to ScriptEngineAllowedPackages take effect immediately on the server where they are made and do not require a server restart. Use this rapid update cycle to add only the exact classes required by a script rather than allowing an entire Java package.

Resolving Java Class Access Errors

Configure ScriptEngineAllowedPackages with a comma-separated list of fully qualified Java class names or package roots. A package root can be specified as the root name, with a trailing period, or with .*; however, use an exact class name whenever possible.

When Capture blocks a class, it reports Capture script cannot access Java class: <fully-qualified-class-name>. For example, an error naming java.io.BufferedReader requires that exact entry; adding java.io.FileOutputStream does not allow java.io.BufferedReader.

Each importClass statement is evaluated when the script is loaded. Review every importClass statement and fully qualified Java class reference. For example, java.lang.Runtime.getRuntime() requires java.lang.Runtime even without an importClass(java.lang.Runtime) statement. Preserve the existing MBean value and append only the required exact entries; do not enable a broad package such as java.io to resolve one import.

For an Import Processor preImportFile script that converts PDF email attachments to TIFF files by using Ghostscript, the required additional access is:

java.io.BufferedReader,java.io.InputStreamReader,javax.script.ScriptException,java.lang.System,java.lang.Runtime,java.lang.Runnable,java.lang.Thread

java.io.File and java.util.ArrayList are available by default. java.io.FileOutputStream is not required unless the script uses it. java.lang.System, java.lang.Runtime, and java.lang.Thread are denied by default and require exact class entries; internal JDK (sun.*) and WebLogic (weblogic.*) packages cannot be enabled. Because this example starts an external process, restrict who can modify the script and configure only an approved Ghostscript executable path.

Scripts can be incorporated in the following Capture components:

Developing Scripts with WebCenter Enterprise Capture

The following are the main steps for developing and incorporating scripts in Capture components:

  1. For each Capture component, write the JavaScript using the events and classes. For more information, refer to the following component’s chapter:

  2. On the Advanced tab of a selected workspace in the WebCenter Enterprise Capture Workspace Console, a workspace manager adds the script by identifying its component type and loading the script file.

    For more information, see Managing Oracle WebCenter Enterprise Capture.

  3. In a client profile or an import or Recognition Processor job, the workspace manager then selects the script for use.

    Note that workspace managers can incorporate multiple client scripts in a client profile and specify the order in which they are executed. For more information, see Managing Oracle WebCenter Enterprise Capture.