Loading a document

You use methods from the ODServer class to load documents to Content Manager OnDemand.

About this task

Loading documents by using ODWEK is not intended to replace the ARSLOAD program or the Add Report (ADDRPTOND) command on IBM i as the primary way to load data into Content Manager OnDemand. For example, ODWEK loading does not include an indexer to automatically parse and extract index values. As such, the indexes must be individually supplied. Additionally, ODWEK loading is not optimized to process very large input files. Performance degradation and potential load failure might result if attempted.

The example, which shows how you can load multiple documents in one load request, shows the following tasks:
  • Logging on to the specified server
  • Initialing the load environment
  • Gathering the document(s) and metadata to be loaded to the server by using ODServer.loadAddDoc, passing the number of pages, a Hashtable containing database field names (keys) with their corresponding indexes (values), and the document data.
  • Loading the documents(s) to the server by using ODServer.loadCommit, specifying the application group and application to send the load data and load request to the Content Manager OnDemand server.
The following example demonstrates the single method used to load one or more documents:
  • ODServer
The example demonstrates the following ODServer methods:
  • initialize
  • logon
  • loadInit
  • loadAddDoc
  • loadCommit
  • logoff
  • terminate
This example uses the following runtime parameters:
  • Server name
  • User Id
  • Password
Be aware of the following:
  • The steps must be called in the order shown in the example. Attempting to call them out of order will result in an exception. If you need to reset the process for any reason, call the ODServer.loadReset API and begin the entire process again. All documents loaded during the process must meet all of the requirements of the specified application group and application combination. For example, they must be the correct data type and format.
  • All dates must be standardized on the ISO date and/or datetime format.
    • The format for Date must be specified as %Y-%m-%d for example, '2014-11-17'
    • The format for Date/Time (with/without TZ) must be specified as %Y-%m-%d %H:%M:%S.%F for example, '2014-11-17 14:07:00.000000'
  • The number of pages that the ODServer.loadAddDoc API accepts is valid only if the application group has a field defined with the 'Page Count' attribute. If the application group does not have such a field defined, the number of pages parameter passed to ODServer.loadAddDoc will be ignored.
  • If the application to which the documents are being loaded is enabled for Large Object support, that attribute is not honored.
Steps must be taken to prepare the Content Manager OnDemand archive where the documents will be loaded prior to calling any of the ODWEK load APIs. The directories specified must exist. For example:
  • On Unix servers and z/OS servers, add two values to the instance's ARS.CFG file:
    ARS_DOWNLOAD_DIR=/arstmp
    ARS_DOWNLOAD_TMP_DIR=/arstmp
  • On Windows servers, by using the OnDemand Configurator, Configuration Parameters panel (select the Parameters button on the Instance tab to launch the Configuration Parameters panel), enter ARS_DOWNLOAD_DIR in the Name field and a valid directory for the Value field and select the Add button. Take similar steps to add an entry for the ARS_DOWNLOAD_TMP_DIR.
  • On IBM i servers, add two values to the /QIBM/UserData/OnDemand/<instance name>/ARS.CFG (where <instance name> is the name of your Content Manager OnDemand instance):
    ARS_DOWNLOAD_DIR=/arstmp
    ARS_DOWNLOAD_TMP_DIR=/arstmp
Important: If you extract and reload the same document, the system generates a new DocId for the document, and the old DocId does not reference the new document.
Example of loading three documents with a single ODWEK load request:
import java.io.File;
import java.util.*;
        
import com.ibm.edms.od.*;
        
public class TcLoadDocs
{
    public static void main ( String argv[] )
    {
        ODServer    odServer;
        ODConfig    odConfig;
        Hashtable<String,String> idxs;
        File        loadFile;
        
        if ( argv.length < 3 )
        {
            System.out.println( "usage: java TcLoadDocs <server> <userid> <password> " );
            return;
        }
        try
        {
            //----------
            // Set the stage
            //----------
            System.out.println( "This testcase should" );
            System.out.println( "  Demonstrate the ODWEK Load Process" );
            System.out.println( "" );
            System.out.println( "---------------------------------------------------" );
            System.out.println( "" );
            
            odConfig = new ODConfig
                (ODConstant.PLUGIN,
                      ODConstant.APPLET,
                      null,
                      200,
                      "/applets",
                      "ENU",
                      "c:/temp",
                      "c:/trace",
                      0);
            
            odServer = new ODServer(odConfig );
            odServer.initialize(  "TcLoadDocs.java" );
            System.out.println( "Logging on to " + argv[0] + "..." );
            odServer.logon( argv[0], argv[1], argv[2] );
            
            //----------
            // Step 1 in the ODWEK Load process
            //----------
            odServer.loadInit();
            
            //----------
            // Step 2 in the ODWEK Load process
            // Repeated for each document to be loaded
            //----------
            idxs = new Hashtable<String, String>();
                
            idxs.put("acct_name",    "Acme Art Company");
            idxs.put("acct_num",     "00112233445");
            idxs.put("purchase_date","2012-05-23");
            idxs.put("purchase_amt", "1172.18");
            loadFile = new File("c:\\invoices\\acme\\bluePaintingInvoice.afp");
            odServer.loadAddDoc(4, idxs, loadFile);
                
            idxs.clear();
            loadFile = null;
                
            idxs.put("acct_name",    "Acme Art Company");
            idxs.put("acct_num",     "00112233445");
            idxs.put("purchase_date","2012-05-30");
            idxs.put("purchase_amt", "879.39");
            loadFile = new File("c:\\invoices\\acme\\redPaintingInvoice.afp");
            odServer.loadAddDoc(3, idxs, loadFile);
                
            idxs.clear();
            loadFile = null;
               
            idxs.put("acct_name",    "Light and Dark Inc.");
            idxs.put("acct_num",     "99887766554");
            idxs.put("purchase_date","2012-05-15");
            idxs.put("purchase_amt", "8711.10");
            loadFile = new File("c:\\invoices\\light_dark\\blackWhiteCharcoalInvoice.afp");
            odServer.loadAddDoc(7, idxs, loadFile);            
                
            //----------
            // Step 3 in the ODWEK Load process
            // Done adding documents, now call the server to load
            //----------
            odServer.loadCommit("Invoices", "InvoicesWestCoast");
                
            //----------
            // Cleanup
            //----------
            odServer.logoff( );
            odServer.terminate( );
            System.out.println( "" );
            System.out.println( "---------------------------------------------------" );
            System.out.println( "" );
            System.out.println( "Testcase completed" );
            System.out.println( "" );
        }
        catch ( ODException e )
        {
            System.out.println( "ODException: " + e );
            System.out.println( "  id = " + e.getErrorId( ) );
            System.out.println( "  msg = " + e.getErrorMsg( ) );
            e.printStackTrace( );
        }
        catch ( Exception e2 )
        {
            System.out.println( "exception: " + e2 );
            e2.printStackTrace( );
        }
    }
}