You can add JavaScript scripts to run at various points during the Content Engine import process (for an overview, see About import scripts). FileNet® Deployment Manager includes sample scripts that you can use as templates to develop your own custom scripts. See the following for a description of the sample JavaScript functions.
The sample scripts are part of the set of sample files that you generate with FileNet Deployment Manager. The scripts are placed in the Samples folder of the deployment tree. See Create sample files.
To customize the import process, the sample scripts start the Java™ API (Java Platform, Standard Edition) and the Content Engine Java API. The scripts include the following import statements:
importClass(Packages.java.lang.System);
importClass(Packages.java.util.HashMap);
importPackage(Packages.com.filenet.api.core);
importPackage(Packages.com.filenet.api.collection);
importPackage(Packages.com.filenet.api.exception);
Other package or class imports might be required depending upon your use cases. For information about the Content Engine Java API, see the Java and .NET Developer's Guide.
Each script run type is passed a HashMap object (java.util.HashMap), with which you can pass script execution state information between scripts. For example:
// Created a marking set. Store the ID so other scripts know about it.
var markingId = markingSet.get_Id();
var markingName = markingSet.get_DisplayName();
map.put(markingId, "MarkingSet Name: " + markingName);
For more information about the HashMap class, see the Java SDK documentation.
The following tables describe the sample JavaScript functions:
| JavaScript function | Description |
|---|---|
| Run-type | preImport |
| File | samplePreImport.js |
| Purpose | Access domain-level objects, object stores, or both before the import operation processes the converted deploy data set. |
| Syntax | function preImport(domain, map) |
| Parameters | domain - A FileNet P8
domain interface (com.filenet.api.core.Domain) map - A HashMap object (java.util.HashMap) that maps a String to a String: HashMap<String, String> |
| Dependencies | None |
| JavaScript function | Description |
|---|---|
| Run-type | preSave |
| File | samplePreSave.js |
| Purpose | Access the object that is processed from the converted deploy data set before the attempt to save it to the object store. |
| Syntax | function preSave(object, map) |
| Parameters | object - A Content Engine IndependentObject
interface (com.filenet.api.core.IndependentObject) map - A HashMap object (java.util.HashMap) that maps a String to a String: HashMap<String,String> |
| Dependencies | None |
| JavaScript function | Description |
|---|---|
| Run-type | postSave |
| File | samplePostSave.js |
| Purpose | Access the object that is processed from the converted deploy data set after it is saved to the object store. |
| Syntax | function postSave(object, map) |
| Parameters | object - A Content Engine IndependentObject
interface (com.filenet.api.core.IndependentObject) map - A HashMap object (java.util.HashMap) that maps a String to a String: HashMap<String,String> |
| Dependencies | None |
| JavaScript function | Description |
|---|---|
| Run-type | postImport |
| File | samplePostImport.js |
| Purpose | Access domain-level objects, object stores, or both after the import operation processes the converted deploy data set. If any objects fail to import, the post-import scripts do not run. |
| Syntax | function postImport(domain, map) |
| Parameters | domain - A FileNet P8
domain interface (com.filenet.api.core.Domain) map - A HashMap object (java.util.HashMap) that maps a String to a String: HashMap<String,String> |
| Dependencies | None |