Sunteți pe pagina 1din 5

DocuShare®

Batch Uploader Programmer's Guide


Publication date: June 2006
This document supports DocuShare Release 5/DocuShare CPX Release 5.

Prepared by:

Xerox Corporation
DocuShare Business Unit
3400 Hillview Avenue
Palo Alto, California 94304
USA

Copyright © 2006 Xerox Corporation. All Rights Reserved. Xerox ® and DocuShare® are trademarks of
Xerox Corporation. All other trademarks are the property of their respective companies and are hereby
acknowledged.
Contents
• Introduction
• Overview
• Examples
• Deployment

Introduction
The DocuShare Batch Uploader Programmer's Guide describes the Java API for the Batch
Uploader. Using this API, an Action Class can be tailored to upload files to DocuShare in a
specific way, in effect extending the functionality of the Batch Uploader.

This document assumes familiarity with object-oriented design and competence in the Java
programming language.

This programming interface supports Java applications, which run as standalone applications
and interact with the standalone applications that comprise the DocuShare services.

The Batch Uploader API is a set of Java interfaces and classes provided in a jar file.

Overview
DocuShare Batch Uploader (dsuploadgui) is a DocuShare Java API application, release with
documentation and samples for further customization. It uses a watcher mechanism and
monitors an input folder for a configurable time interval. The upload chunk can associated
with a comma separated value (CSV) metadata file, and define the meta properties, upload
destination, and permissions for the upload object. It can also upload a directory hierarchy
directly into DocuShare. Here are some of its features:

• Uploads files dumped to a watch folder.


• Customizable watchers via DocuShare Java APIs support a programmatic way of
customizing dsupload watcher behavior, such as uploading new version of an existing
document.
• Multiple job configurations.
• Allows mapping of metadata fields to DS properties. This provides flexibility in the
naming of the CVS columns.
• Schedule start time.
• Creates destination collection and intermediate collections (if required).
• Sets ACL (Access Control List).
• Allows job configuration to be persisted, i.e. saved and loaded, in XML.
• Can upload to multiple hosts by creating multiple jobs.
• Relative path support in meta path (4.0.2 and above).
• Multiple destination levels.

DocuShare® Batch Uploader Programmer’s Guide 1


Examples
The following are examples on how to customize the Default Upload Action used by the
Batch Uploader.

Note: When deploying the custom upload action class, there are two ways about it:
1. Specify the custom upload action class in the in the Job Detail GUI by providing
the value of the full class path.
2. Specify the custom upload action class in the script file by passing in a "-
Ddocushare.watcher.action=<full_class_path>" when starting the
dsuploadgui.bat/sh.

The action class specified with -D in the script file applied to the instance of the Batch
Uploader, i.e. to all the jobs created in this instance. The action class specified in the Job
Detail applies only to the job. When both are specified, the action class specified in the Job
Detail takes precedence.

CustomUploadActionCollectionClone.java

● This example demonstrates how to designate a different class (cloned from Collection
class) to be the parent object instead of the usual Collection container.

● This example code overrides the postUpload() method in the


DSDefaultUploadAction class.

CustomUploadActionDocumentClone.java

● This example demonstrates how to designate a different class (cloned from


Document class) to be the object holding the uploaded files instead of the usual
Document class.
● This example code override the preUpload() method in the DSDefaultUploadAction
class.

CustomUploadActionNewVersion.java

● This example demonstrates how to upload the file as the new version of an existing
Document object instead of a new Document object.
● This example code override the doUpload()and postUpload() method in the
DSDefaultUploadAction class.
● String customColumnName = "DocContainNewVer"; is defined in the source file. A
corresponding column with the name is also specified for each row, and the value is
a DocuShare document object handle. The name can be any name desired but it
must be identical between the Java source and the CSV metadata file. The example
code will first retrieve the document object handle value from the CSV file and
attempt to locate it from the DocuShare server, and then the uploaded file is
designated as a new version of this existing object.

DocuShare® Batch Uploader Programmer’s Guide 2


● The postUpload() method is overridden in this example to print some message, and
it also demonstrate how to determine whether the file just uploaded became a new
Document object or a new Version object of an existing document.

Deployment
1. Compile the source file with dscommon.jar, docushare3.jar, and log4j.jar

2. Copy the compiled CLASS file to DSHOME/bin or in directory of your choice.

3. Modify DSUploadGUI bat/sh script file to include the directory, you used in step 2
above, in the classpath. ...

@echo off

if "%ENV_SETUP%" == "YES" goto runServer

call setup_docushare.bat

:runServer
SET MY_HOLD=%MY_CLASSPATH%

SET MY_CLASSPATH=%LIB_JARS%\jcifs-1.2.7.jar;%MY_CLASSPATH%
SET MY_CLASSPATH=%LIB_JARS%\dsuploadgui.jar;%MY_CLASSPATH%
SET MY_CLASSPATH=%LIB_JARS%;%MY_CLASSPATH%

echo -------
echo Running dsuploadgui %*

java -cp %MY_CLASSPATH% -Dcom.xerox.docushare.install=%DOCUSHARE_HOME%


-Xms10m -Xmx100m com.xerox.docushare.toolsgp.upload.DSUpload %0 %*

SET MY_CLASSPATH=%MY_HOLD%

@echo on

4. Launch dsuploadgui.bat/sh.

5. Add a Job.

6. In the Job Configuration Detail section of the Job Detail window enter the action class in
in the Java Callback field.

7. Fill in the rest of the fields as necessary and click on the Accept button.

DocuShare® Batch Uploader Programmer’s Guide 3

S-ar putea să vă placă și