Ephesoft Linux Installation guide

Prerequisites

Following configuration is required for installing Ephesoft on Linux machine using command line installer:

  1. Ubuntu 13.10 (Installer is specifically built and tested on Ubuntu v 13.10).
  2. Internet connection is required as some software need to be updated or installed from Ubuntu’s repository while Ephesoft’s installation.
  3. Executeble permission must be given to all files present in installer folder by executing following command.
  4. Navigate to installer directory by executing cd /path to installer
  5. sudo chmod –R 755 *
  6. Installation script must be run as super user otherwise user will get an error message and script will exit.
  7. Ephesoft license must be installed on the machines on which Ephesoft has been installed.
  8. Installer is specifically built for Ephesoft v3.1 and currently supports MySQL database as MSSQL database can not be installed on Linux.
  9. SharedFolders must be configured on network using Samba server file sharing. Scripts doesn’t handles this automatically.
  10. SharedFolders path must be same on all the servers in multiserver cluster beacuse Linux doesn’t understand netowk paths in manner that windows does. Hence in order to use SharedFolders on network user will have to create a Samba share of installed SharedFolders on one of the machine e.g. user has SharedFolders locally on /opt/SharedFolders on the first machine in cluster. User will have to share this folder using Samba share. In order to configure same shared folders on other Linux machines in multicluster environment an empty folder will be created on machine being configured at same location i.e. /opt/SharedFolders by the installer (shared folders path must be same on all machines in multiserver cluster) and this empty folder will act as mount point for the Samba Share network path.

Installation Steps

In this guide we will deploy Ephesoft on two servers. Database and SharedFolders will be installed on server-1 and server-2 will use the database and SharedFolders installed on server-1.First install Ephesoft on Server-1. Please follow the step by step installation of Ephesoft on Ubuntu 13.10 operating system through command line installer:

  • Copy the Ephesoft_3.1.0.0.tar.gz and installation scripts to some path using WINSCP or any other tool. As shown in the below example all the required files are copied to /home/turbo/Linux directory.

3.1.0.0 Linux Multi 10001.jpg

  • In order to execute the scripts, give appropriate permission for executing the scripts using the command “sudo chmod 755 * “.

3.1.0.0 Linux Multi 10002.jpg

  • Now, proceed with the fresh installation of Ephesoft on Linux operating system. Run the installation script using command “sudo ./install”. The script must be run as a super user hence we have put sudo before the script. Installation will be interrupted if script is not run with super user permission.

3.1.0.0 Linux Multi 10003.jpg

  • Ephesoft installation will start and first installer will check for the internet connection availability. Installation will be interrupted if no internet connection is available as some of the software requires update or installation from Ubuntu’s repository during Ephesoft’s installation.

3.1.0.0 Linux Multi 10004.jpg

  • First, it will update the package lists from repositories. This process will take some time. As soon as package lists update completes, installer will ask for the path where user wants to install the Ephesoft application.

3.1.0.0 Linux Multi 10005.jpg

  • By default installer will install the Ephesoft application inside “opt” directory. User has an option to change the path manually. Installation path can be changed for Ephesoft application as shown in the below snapshot:

3.1.0.0 Linux Multi 10006.jpg

  • Now, installation script will extract the Ephesoft_3.1.0.0.tar.gz file inside the directory defined and tar file extraction progress bar will be shown as shown in the below screenshot:

3.1.0.0 Linux Multi 10007.jpg

  • Once the tar file extraction completes, Ephesoft application is copied to the desired directory. Now, installer will ask whether user wants to use existing SharedFolders or new SharedFolders. Since it’s a fresh installation on single server environment hence choose the “n” option. By default “n” option will be displayed on terminal as shown in the below snapshot:

3.1.0.0 Linux Multi 10008.jpg

  • SharedFolders will be installed inside Ephesoft directory by default (For example in this case SharedFolders will be installed inside /home/turbo/Linux/Ephesoft/SharedFolders). User has an option to change the SharedFolders path in case if one wants to install SharedFolders at some other location.

3.1.0.0 Linux Multi 10009.jpg

  • Selecting “y” option will install the SharedFolders at user defined path. For example in this case SharedFolders will be installed inside /home/turbo/Linux/unc-share directory as shown in the below snapshot:

3.1.0.0 Linux Multi 10010.jpg

  • After successful installation of SharedFolders, installer will ask for the port number on which tomcat server is to be run. By default tomcat will be run on 8080 port number. User can manually change the port number as desired.

3.1.0.0 Linux Multi 10011.jpg

  • Now, installer will ask for MySQL installation whether user wants to use existing MySQL instance or install a new MySQL instance.

3.1.0.0 Linux Multi 10012.jpg

  • We are taking here the example for installing fresh MySQL database instance assuming that MySQL is not installed on the system. It will then ask for database configuration details required. Enter the database port number (3306 is the default database port).

3.1.0.0 Linux Multi 10013.jpg

  • Enter the root user password and again re-enter the password. Please make sure password enter is correct. Enter the Ephesoft application database name (ehpesoft is default application DB name).

3.1.0.0 Linux Multi 10014.jpg

  • Enter the report database name (report is default report DB name).

3.1.0.0 Linux Multi 10015.jpg

  • Confirm that database configuration details entered is correct. If you want to change press “y” and press “n” for continuing the installation process.

3.1.0.0 Linux Multi 10016.jpg

  • Installer will now install the MySQL database. This installation may take some time. Please wait for some time.

3.1.0.0 Linux Multi 10017.jpg

  • As soon as MySQL is installed successfully, installer will install Imagemagick on system.

3.1.0.0 Linux Multi 10018.jpg

  • Imagemagcik installation will take some time as it will compile and build the libraries as per the operating system.

3.1.0.0 Linux Multi 10019.jpg

3.1.0.0 Linux Multi 10020.jpg

  • As soon as Imagmagick is installed successfully, Installer will now start installing dependencies for Ephesoft.

3.1.0.0 Linux Multi 10021.jpg

  • Installer will install the dependencies like ghostscript, libreoffice, libtool, libjpeg, libpng etc.

3.1.0.0 Linux Multi 10022.jpg

  • Now, it will install the Leptonica 1.69 required for installing Tesseract on Linux operating system.

3.1.0.0 Linux Multi 10023.jpg

  • Leptonica installation will take some time as it will compile and build the libraries as per the operating system.

3.1.0.0 Linux Multi 10024.jpg

  • Now, it will install Tesseract 3.0.1. Tesseract installation will take some time as it will compile and build the libraries as per the operating system.

3.1.0.0 Linux Multi 10025.jpg

  • Once Tesseract is installed successfully, Installer will install the Nuance on the system.

3.1.0.0 Linux Multi 10026.jpg

  • Now, it will install Nuance 18.6.5 on the system. Nuance installation will take some time as it will compile and build the libraries as per the operating system.

3.1.0.0 Linux Multi 10027.jpg

  • After successful installation of Nuance. It will install POCO 1.4.6 on the system. POCO installation will take some time as it will compile and build the libraries as per the operating system.

3.1.0.0 Linux Multi 10028.jpg

  • Once POCO is installed successfully, Ephesoft is successfully installed on the machine.

3.1.0.0 Linux Multi 10029.jpg

  • Now install license on this system. Go to the licensing directory inside Dependencies folder and run the full file using sudo user permission.

3.1.0.0 Linux Multi 10030.jpg

  • details.properties file is created in the present working directory as shown below:

3.1.0.0 Linux Multi 10031.jpg

  • Now, put the Ephesoft license file (ephesoft.lic) inside <Ephesoft Installation Directory>/Ephesoft/Dependencies/license-util/ephesoft-license-installer.

3.1.0.0 Linux Multi 10032.jpg

  • Run the install-license.sh file using sudo user permission and your license is successfully installed on the machine.

3.1.0.0 Linux Multi 10033.jpg

  • Now, start the Ephesoft server. For this go inside the bin directory of JavaAppServer placed inside Ephesoft directory.

3.1.0.0 Linux Multi 10034.jpg

  • Now, start the server by running the command “sudo sh startup.sh”. It will start the server. This will take some time as data is being populated in the database.

Note*: Make sure to start Ephesoft using sudo /super user permissions as Ephesoft has been installed with sudo/ super user permissions.

3.1.0.0 Linux Multi 10035.jpg

  • Now, open browser and hit the application using the following URL:

http://<server name>:<port number>/dcma/home.html

  • Following screen will open when server comes to RUNNING state:

3.1.0.0 Linux Multi 10036.jpg

  • Installing the Ephesoft application on server-2. Please note that Ephesoft application on server-2 will use the SharedFolder deployed on server-1 and will point to the database installed on server-1. Repeat from steps 1 to 7 and copy the Ephesoft application to some user configurable path.

3.1.0.0 Linux Multi 10037.jpg

  • Choose option “y” for installing the SharedFolders since we have to use existing SharedFolders.

3.1.0.0 Linux Multi 10038.jpg

  • Now, please enter the mounted SharedFolders path. Please note that mounted shared folder path should be exactly same as that of server-1.

3.1.0.0 Linux Multi 10039.jpg

  • After successful installation of SharedFolders, installer will ask for the port number on which tomcat server is to be run. By default tomcat will be run on 8080 port number. User can manually change the port number as desired.

3.1.0.0 Linux Multi 10040.jpg

  • Now user has to enter the database configuration details. We have to point to the same database which server-1 is using. First, it will ask for the system IP on which MySQL is installed.

3.1.0.0 Linux Multi 10041.jpg

  • Enter the database user name, database password, application database name, report database name etc. details. Please make sure that database details entered are correct.

3.1.0.0 Linux Multi 10042.jpg

  • Enter the database port number and confirm that database configuration details entered is correct. If you want to change press “y” and press “n” for continuing the installation process.

3.1.0.0 Linux Multi 10043.jpg

  • Repeat the steps from 19 to 32. Now Ephesoft is successfully installed on the server-2. Now mount the SharedFolders on server-2 using samba server manually. Once mount is successful start the server as shown in steps 33, 34, 35.
  • Now, open browser and hit the application using the following URL:

http://<server name>:<port number>/dcma/home.html

  • Following screen will open when server comes to RUNNING state:

3.1.0.0 Linux Multi 10044.jpg

  • For shutting down the Ephesoft server, go inside the bin directory of JavaAppServer placed inside Ephesoft directory and run the following command as shown below:

3.1.0.0 Linux Multi 10045.jpg

Ephesoft Linux Uninstallation guide

Prerequisites

  • Before proceeding for Ephesoft uninstallation please make sure that Ephesoft must be installed on the system.

Installation Steps

Please follow the step by step uninstallation of Ephesoft on Linux operating system through command line installer:

  • Run the uninstallation script using command “sudo ./uninstall”. The script must be run as a super user hence we have put sudo before the script name. Uninstallation will be interrupted if script is not run as super user.

3.1.0.0 Linux Uninstall 10001.jpg

  • Uninstallation script will identify whether the Ephesoft server is already running or not. User has an option to forcefully stop the server. It is always recommended to stop the server before proceeding with the uninstallation.

3.1.0.0 Linux Uninstall 10002.jpg

  • Selecting “y” option will forcefully stop the Ephesoft server. After that script will remove the Ephesoft application installed on the system.

3.1.0.0 Linux Uninstall 10003.jpg

  • Once Ephesoft application is uninstalled successfully it will ask for uninstalling the SharedFolders. User has an option “y” or “n” for uninstalling SharedFolders.

3.1.0.0 Linux Uninstall 10004.jpg

  • Selecting “y” option will uninstall the SharedFolders completely from the system. Now, uninstallation script will start uninstalling the dependent software’s which were being installed at the time of installation. First, it will ask for the uninstallation for Imagemagick as shown in the below screen shot:

3.1.0.0 Linux Uninstall 10005.jpg

  • Selecting “y” option will uninstall the Imagemagick from the system. Uninstallation script will then ask for uninstallation of GhostScript as shown in the below screenshot:

3.1.0.0 Linux Uninstall 10006.jpg

  • Selecting “y” option will uninstall the GhostScript from the system. Uninstallation script will then ask for uninstalling the MySQL database installed on the system as shown in the below screen shot:

3.1.0.0 Linux Uninstall 10007.jpg

  • Selecting “y” option will uninstall the MySQL database installed on the system as shown in the below screen shot:

3.1.0.0 Linux Uninstall 10008.jpg

  • After successful uninstallation of MySQL database, uninstallation script will ask for the uninstallation of Libreoffice from the system as shown in the below screen shot:

3.1.0.0 Linux Uninstall 10009.jpg

  • Selecting “y” option will remove the Libreoffice from the system. Uninstallation script will then ask for the uninstallation of Tesseract from the system as shown in the below screenshot:

3.1.0.0 Linux Uninstall 10010.jpg

  • While uninstalling Tesseract, first Leptonica will be uninstalled as shown in the below screen shot:

3.1.0.0 Linux Uninstall 10011.jpg

  • Once Leptonica is uninstalled successfully, script will then uninstall the Tesseract. Uninstallation script will then ask for the uninstallation of Nuance from the system as shown in the below screenshot:

3.1.0.0 Linux Uninstall 10012.jpg

  • While uninstalling Nuance, first POCO will be uninstalled as shown in the below screen shot:

3.1.0.0 Linux Uninstall 10013.jpg

  • Once POCO is uninstalled successfully, script will then uninstall the Nuance from the system as shown in the below screen shot:

3.1.0.0 Linux Uninstall 10014.jpg

  • After successful uninstallation of Nuance from the system, Uninstallation script will now disable the firewall setting for tomcat port number and database port number as shown in the below screen shot:

3.1.0.0 Linux Uninstall 10015.jpg

  • Once firewall settings are disabled successfully, Ephesoft is successfully uninstalled on the machine as shown in the below screen shot:

3.1.0.0 Linux Uninstall 10016.jpg

Samba Share Configuration for Ephesoft on multiserver

Samba is a file sharing service which is based on SMB/CIFS network file sharing protocols. SMB, stands for Server Message Block, is a protocol for sharing files, printers, serial ports, and communications abstractions such as named pipes and mail slots between computers.

Samba primarily consists of two key programs plus few utilities. The two key programs are SMBD (Server Message Block Demon) and NMBD (NetBIOS Message Block Daemon). Main purpose of these two services is as follows:

  1. File & print services
  2. Authentication and Authorization
  3. Name resolution
  4. Service announcement (browsing)

Ephesoft’s SharedFolders are network shared folders which can be accessed from different Ephesoft nodes in Multi-Cluster. Hence on Linux Ephesoft uses Samba Share to make SharedFolders accessible over network as a file share.

This document describes steps to install and configure Samba Share such that Ephesoft’s SharedFolders can be accessible from different nodes in multi-server cluster.

Samba Installation

Most of Linux systems already have a samba service installed on the system. But just in case if Samba service is not installed on the system it can be installed by following simple steps:

Samba Installation on Ubuntu

  1. Make sure internet is available on the system.
  2. Make sure that user has proper permission to install software on the system.

To install software on Ubuntu a user needs to have Super user permission thus in order to install Samba user must use sudo to install it.

   sudo apt-get update

sudo apt-get install samba

Figure: Samba installation on ubuntu

  • Add a user to samba and assign password to that user. Next step demonstrates method to add user to samba and assign samba password for that user. This process needs sudo permissions.

sudo smbpasswd -a turbo

(-a is for adding user to samba and turbo is username to be added to samba)

Figure: Adding user to samba and assigning samba password for the user.

smbpasswd adds a user to samba and assigns samba password for the user. User will see error message if user does not exists on the Linux system.

Figure: Error adding user to samba as user does not exists on Linux machine.

  • Testing samba demons smbd and nmbd. This requires sudo permission.

sudo service smbd restart

sudo service nmbd restart

Figure: Restarting smbd and nmbd

Samba Configuration

Adding a folder to network share

Samba shares can be configured through /etc/samba/smb.conf file which holds configuration details for samba server.

  • Open smb.conf present inside /etc/samba/smb.conf using VI editor. Open file with sudo permissions as user may need to edit file.

sudo vi /etc/samba/smb.conf

  • E.g. User wants to make SharedFolders present at /home/turbo/Ephesoft/SharedFolders as shareable on samba share. User can do this by adding/appending following line to the end of smb.conf file. But before this user will need to give read, write, execute permission to everyone on the sharedfolders by executing following command (by default Ephesoft installer assigns rwx permission to everyone on SharedFolders):

sudo chmod -R 777 /home/turbo/Ephesoft/SharedFolders

Append following lines to end of smb.conf.

[ephesoft]

  comment=ephesoft
  path=/home/turbo/Ephesoft/SharedFolders
  browseable=yes
  writable=yes
  create mode=0777
  directory mode=0777
  share mode=yes
  guest ok=yes
  valid users=turbo

Figure: Share created with name ephesoft which point to /home/turbo/Ephesoft/SharedFolders on machine.

Details of parameters added to smb.conf

  1. Comment: comment for the shared folder.
  2. path : specifies the path of shared folder.
  3. browseable : allows to browse the files from file system.
  4. writeable : makes the shared folder writeable
  5. create mode : create files with group=rw permissions.
  6. directory mode : create dirs. with group=rw permissions.
  7. guest ok: allows guest access
  8. valid users : specifies list of valid users who can access the shared folder (users must be part of user-group assigned to the shared folder).
  9. Assign multiple users to list of valid users as one credential can be used by single machine at a time.

User will need to create the share with write, creation, readable and browseable permissions etc. The statements mentioned above make sure of the same.

  1. Save smb.conf file and restart smbd and nmbd demons by executing following commands.

sudo service smbd restart

sudo service nmbd restart

Figure: restarting samba smbd/nmbd demons

Now user can access this shared folder.

Figure: sharedfolders accessible on network

Accessing SharedFolders on different Ephesoft nodes in multi-cluster setup

In order to setup SharedFolders on different Ephesoft nodes in multi-cluster setup user will need to mount the network share on a folder on every Ephesoft Linux node as Linux doesn’t unserstand network paths as windows does i.e. on windows network share can be directly access using \\ip –addr but on Linux it can be done using samba protocol which works in different manner.

Note: Installer will create a empty folder on same location on every Ephesoft node other than the node on which actual shared folder lies i.e. path of empty folder will be same as path of actual shared folder on machine where actual shared folders lies e.g. In above configuration where SharedFolder has been added to samba share the actual folder lies at /home/turbo/Ephesoft/SharedFolders so empty folder will be created at same path on each machine using Ephesoft installer.

Now user will have to mount the network sharedfolders on each empty folders created by installer on each Ephesoft node.

Mounting network share on empty folders created by installer

User can mount the samba share over an empty folder by executing following command.

sudo mount -t cifs -o user=turbo,password=Passw0rd //192.168.108.21/ephesoft /home/turbo/Ephesoft/SharedFolders

Here password is the password of smbuser for which smbpasswd was set.

Figure: mounting share on empty folder /home/turbo/Ephesoft/SharedFolders

Figure: network shared folder mounted on empty folder on another Ephesoft node.

User will be able to access the mounted shared folder locally by accessing /home/turbo/Ephesoft/SharedFolders as this folder is acting as mount point for network share. User will be able to create/modify files/folders locally on this path and changes will be reflected on the network share and on all the machines where this network share has been mounted.

Figure: User able to access the SharedFolder locally on mounted folder.

Figure: User creating folder on the mounted folder and these changes will be reflected on all the mount points and network share.

Figure: Changes of folder creation reflected on the network share.

Note: Ephesoft META-INF properties file will contain the path of locally mounted folders and not the network path as Linux doesn’t understand the network share like windows do. Linux makes use of smb protocol to access the share folder. Hence user will have to mount network shared folders locally on their system such that Ephesoft is able to see data on same path on every system.

Nuance OCR Plugin

Overview

The Nuance HOCR plugin is the part of page processing module of Ephesoft Linux application by default. This plugin uses Nuance OCR tool for generating HOCR XML files. It reads the image files listed in the batch xml of a batch instance and generates HOCR XML file for each one of them.

** Nuance Plugin does not support barcode recognition.

Description

  1. Nuance OCR Plugin is executed in the page processing phase of the application when all the import processing on the batch has been done.
  2. This plugin extracts the contents of the image using Nuance tool. This tool performs OCR’ing on tiff files.
  3. This plugin uses SETTING.STS file present inside “{SharedFolder-intall-dir}\BC??\*” directory. In case if no setting file is present in the mentioned folder then the plugin uses its default settings for OCR’ing process and generates the SETTING.STS file inside “{SharedFolder-intall-dir}\BC*” directory.

Configuration

Configurable Properties

Following is the list of configurable properties for the plugin:

3.1.0.0 Linux Nuance 10001.jpg

Configurable property Type of value Value options Description
Nuance Auto Rotate/Deskew switch

 

List of values
  • ON
  • OFF
This property is used to auto rotate and de-skew the input images on the basis of orientation and skew angle computed by Nuance.
Nuance Switch List of values
  • ON
  • OFF
This switch is used to turn this plugin ON/OFF.
Nuance Valid Extensions

 

List of values
  • Tif

 

Following are the valid image types that can be OCR’ed using Nuance.

Dependency

This plugin requires an image as an input (with TIFF format). The thumbnails and display images are created using the TIFF processed by Nuance. Hence the plugins ‘Create Display Image Plugin’/ ‘Create Thumbnails Plugin’ must be placed after this plugin.

3.1.0.0 Linux Nuance 10001.jpg

Dependency on Shared Folders

The batch class folder inside the main shared folder contains a file by the name SETTING.STS. This file is used by the Nuance OCR engine for configuring some of its properties. If the file does not exist in the folder then Nuance uses its default settings for recognizing the image’s data and creates the setting file inside the Batch Class folder with default settings.

Ephesoft Web Service

Overview

This document gives detailed explanation of web services exposed by Ephesoft application.

Authenticated client calls code sample

Here is the code for making authenticated client calls via Ephesoft Web Services:-

Credentials defaultcreds = new UsernamePasswordCredentials(“username”, “password”);

client.getState().setCredentials(new AuthScope(“serverName”, 8080), defaultcreds);

client.getParams().setAuthenticationPreemptive(true);

List of API’s exposed in Ephesoft Product

Image Processing Web Service

createSearchablePDF

This API will generate the searchable pdf. It takes the input tif/tiff files and rsp file for processing. Input parameters will used to specify the output pdf is searchable or color.

Web Service urlhttp://{serverName}:{port}/dcma/rest/createSearchablePDF

Input Parameter Values Descriptions
isColorImage Either “true”/”false” Generates the color pdf if input image is color and value is “true”.
isSearchableImage Either “true”/”false” Generates the searchable pdf if value is “true”.
outputPDFFileName String value should ends with .pdf extension Output pdf file name generated using API.
projectFile String value should ends with .rsp extension RSP file used as recostar processing.
ocrEngine Nuance/Recostar Ocr engine to be used for generating the pdf.

Checklist:

  1. Input only tiff, tif files for generating searchable pdf.
  2. RSP file is only mandatory for generating the searchable pdf if Recostar is specified as the OCR engine. In case Nuance is selected no RSP file needs to be specified.

Sample Input Used:

ephesoft-web-services\create-searchable-pdf.zip

””Sample client code using apache commons http client:-

private static void createSearchablePDF() {

HttpClient client = new HttpClient();

// URL for webservice of create searchable pdf

String url = “http://localhost:8080/dcma/rest/createSearchablePDF“;

PostMethod mPost = new PostMethod(url);

// adding file for sending

// Adding tif images for processing

File file1 = new File(“C:\\sample\\sample1.tif”);

File file2 = new File(“C:\\sample\\sample2.tif”);

File file3 = new File(“C:\\sample\\sample3.tif”);

File file4 = new File(“C:\\sample\\sample4.tif”);

// Adding rsp file for recostar for processing

File file5 = new File(“C:\\sample\\Fpr.rsp”);

Part[] parts = new Part[9];

try {

parts[0] = new FilePart(file1.getName(), file1);

parts[1] = new FilePart(file2.getName(), file2);

parts[2] = new FilePart(file3.getName(), file3);

parts[3] = new FilePart(file4.getName(), file4);

parts[4] = new FilePart(file5.getName(), file5);

// adding parameter for color switch

parts[5] = new StringPart(“isColorImage”, “false”);

// adding parameter for searchable switch

parts[6] = new StringPart(“isSearchableImage”, “true”);

// adding parameter for outputPDFFileName

parts[7] = new StringPart(“outputPDFFileName”, “OutputPDF.pdf”);

// adding parameter for projectFile

parts[8] = new StringPart(“projectFile”, “Fpr.rsp”);

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

mPost.setRequestEntity(entity);

int statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

InputStream inputStream = mPost.getResponseBodyAsStream();

// output file path for saving result

String outputFilePath = “C:\\sample\\serverOutput.zip”;

// retrieving the searchable pdf file

File file = new File(outputFilePath);

FileOutputStream fileOutputStream = new FileOutputStream(file);

try {

byte[] buf = new byte[1024];

int len = inputStream.read(buf);

while (len > 0) {

fileOutputStream.write(buf, 0, len);

len = inputStream.read(buf);

}

finally {

if (fileOutputStream != null) {

fileOutputStream.close();

}

}

System.out.println(“Web service executed successfully.”);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(mPost.getResponseBodyAsString());

}

catch (FileNotFoundException e) {

System.err.println(“File not found for processing.”);

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

} } }

convertTiffToPdf

This API generates the pdf for the input tiffs. If 5 input tiff files are provided then 5 pdf files will be returned using this api. This API will have following parameter for configuration.

Web Service URL: [ http://{serverName}:{port}/dcma/rest/convertTiffToPdf]

Input Parameter Values Descriptions
inputParams This value can be empty. Reference for image magick parameter. http://www.imagemagick.org/script/command-line-options.php

 

This are the image magick input parameters used for processing the input and output file.
outputParams This value can be empty. Reference for image magick parameter. http://www.imagemagick.org/script/command-line-options.php

 

This are the image magick output parameters used for optimizing the output file.

 

 

 

pdfGeneratorEngine Either “IMAGE_MAGICK”/”ITEXT” This will used for pdf generator engine.

Checklist:

  1. Input only tiff, tif files for generating pdf.
  2. If pdfGeneratorEngine is “IMAGE_MAGICK”, than only input params and output params are works.
  3. If Input tiff is multipage tiff than single multipage pdf is generated as output.

Sample Input Used:

ephesoft-web-services\convert-tiff-to-pdf.zip

Sample client code using apache commons http client:-

private static void convertTiffToPdf() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/convertTiffToPdf“;

PostMethod mPost = new PostMethod(url);

// adding image file for processing.

File file1 = new File(“C:\\sample\\sample1.tif”);

File file2 = new File(“C:\\sample\\sample2.tif”);

Part[] parts = new Part[5];

try{

parts[0] = new FilePart(file1.getName(), file1);

parts[1] = new FilePart(file2.getName(), file2);

// adding parameter for input params

parts[2] = new StringPart(“inputParams”, “”);

// adding parameter for output params

parts[3] = new StringPart(“outputParams”, “”);

// adding parameter for pdfGeneratorEngine

parts[4] = new StringPart(“pdfGeneratorEngine”, “IMAGE_MAGICK”);

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

mPost.setRequestEntity(entity);

int statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

System.out.println(“Web service executed successfully..”);

InputStream in = mPost.getResponseBodyAsStream();

// output file path for saving results.

String outputFilePath = “C:\\sample\\serverOutput.zip”;

// retrieving the searchable pdf file

File f = new File(outputFilePath);

FileOutputStream fos = new FileOutputStream(f);

try {

byte[] buf = new byte[1024];

int len = in.read(buf);

while (len > 0) {

fos.write(buf, 0, len);

len = in.read(buf);

}

finally {

if (fos != null) {

fos.close();

}

else if (statusCode == 403) {

System.out.println(“Invalid username/password..”);

else {

System.out.println(mPost.getResponseBodyAsString());

}

catch (FileNotFoundException e) {

System.err.println(“File not found for processing.”);

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

}

}

}

splitMultipageFile

This API will break the pdf and multipage tiff into single page tiff. This will used the image magick and ghost script for splitting the input file. This API will have following parameter for configuration.

Web Service URL: [ http://{serverName}:{port}/dcma/rest/splitMultipageFile]

Input Parameter Values Descriptions
inputParams For Image Magick:

This value can be empty. Reference for image magick parameter. http://www.imagemagick.org/script/command-line-options.php

For Ghost Script:

This value should not be empty. Reference for ghost script input parameter :

http://ghostscript.com/doc/8.54/Use.htm#Output_device

This parameter will used for both image magick and ghost script.
outputParams For Image Magick:

This value can be empty. Reference for image magick parameter. http://www.imagemagick.org/script/command-line-options.php

This are the image magick output parameters used for optimizing the output file.
isGhostscript Either “true”/”false” This parameter is used to specified the weather ghost script is using for breaking the pdf/multipage tiff into single page tiff.

Checklist:

  1. Input only tiff and pdf file only.
  2. If “isGhostscript” is “true”, then only input params will work and PDF files will be broken.
  3. If “isGhostscript” is “false”, then input params and output params will work.

Sample Input Used:

ephesoft-web-services\split-multipage-file.zip

Sample client code using apache commons http client:-

private static void splitMultiPageFile() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/splitMultipageFile“;

PostMethod mPost = new PostMethod(url);

File file1 = new File(“C:\\sample\\sample.pdf”);

File file2 = new File(“C:\\sample\\sample.tif”);

Part[] parts = new Part[5];

try {

parts[0] = new FilePart(file1.getName(), file1);

parts[1] = new FilePart(file2.getName(), file2);

parts[2] = new StringPart(“inputParams”, “gswin32c.exe -dNOPAUSE -r300 -sDEVICE=tiff12nc -dBATCH”);

parts[3] = new StringPart(“isGhostscript”, “true”);

parts[4] = new StringPart(“outputParams”, “”);

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

mPost.setRequestEntity(entity);

int statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

InputStream in = mPost.getResponseBodyAsStream();

File file = new File(“C:\\sample\\serverOutput.zip”);

FileOutputStream fos = new FileOutputStream(file);

try {

byte[] buf = new byte[1024];

int len = in.read(buf);

while (len > 0) {

fos.write(buf, 0, len);

len = in.read(buf);

}

finally {

if (fos != null) {

fos.close();

}

}

System.out.println(“Web service executed successfully..”);

else if (statusCode == 403) {

System.out.println(“Invalid username/password..”);

else {

System.out.println(mPost.getResponseBodyAsString());

}

catch (FileNotFoundException e) {

System.err.println(“File not found for processing..”);

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

} }

}

createMultipageFile

This API will create the multipage tif/pdf using “Image MagicK”, “IText” and “GhostScript”. This API works only for tif/tiff files and provided XML file for input parameters. This API will have following parameter for configuration.

Web Service URL:

http://{serverName}:{port}/dcma/rest/createMultiPageFile]

Input Parameter Values Descriptions
imageProcessingAPI Either “IMAGE_MAGICK” /”GHOSTSCRIPT”/”ITEXT” This parameter is used for generating pdf using image_magick , itext and ghost script.
pdfOptimizationParams This value should not be empty. Reference for ghost script input parameter :

http://ghostscript.com/doc/8.54/Use.htm#Output_device

This are the ghost script output parameters used for optimizing the output file.
multipageTifSwitch Either “ON”/”OFF” This parameter is used for generating multipage tif along with multipage pdf.
pdfOptimizationSwitch Either “ON”/”OFF” This switch is used for generated optimized pdf.
ghostscriptPdfParameters This value should not be empty. Reference for ghost script input parameter :

http://ghostscript.com/doc/8.54/Use.htm#Output_device

This are the ghost script parameter used for creating multipage pdf.

Checklist:

  1. Input only tiff file for processing and xml file for inputs.
  2. If “imageProcessingAPI” is “GHOSTSCRIPT”, than only ghostscriptPdfParameters will works.
  3. If “pdfOptimizationSwitch” is “ON”, than pdfOptimizationParams will works.

Sample Input Used:

ephesoft-web-services\ create-multipage-file.zip

Format for XML:

<WebServiceParams>

<Params>

<Param>

<Name>imageProcessingAPI</Name>

<Value>GHOSTSCRIPT</Value>

</Param>

<Param>

<Name>pdfOptimizationSwitch</Name>

<Value>on</Value>

</Param>

<Param>

<Name>pdfOptimizationParams</Name>

<Value>-q -dNODISPLAY -P- -dSAFER -dDELAYSAFER — pdfopt.ps</Value>

</Param>

<Param>

<Name>multipageTifSwitch</Name>

<Value>on</Value>

</Param>

<Param>

<Name>ghostscriptPdfParameters</Name>

<Value>-dQUIET -dNOPAUSE -r300 -sDEVICE=pdfwrite -dBATCH</Value>

</Param>

</Params>

</WebServiceParams>

Sample client code using apache commons http client:-

private static void createMultiPage() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/createMultiPageFile“;

PostMethod mPost = new PostMethod(url);

// Adding XML file for parameters

File file1 = new File(“C:\\sample\\WebServiceParams.xml”);

// Adding tif file for processing

File file2 = new File(“C:\\sample\\sample1.tif”);

File file3 = new File(“C:\\sample\\sample2.tif”);

Part[] parts = new Part[3];

try {

parts[0] = new FilePart(file1.getName(), file1);

parts[1] = new FilePart(file2.getName(), file2);

parts[2] = new FilePart(file3.getName(), file3);

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

mPost.setRequestEntity(entity);

int statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

InputStream inputStream = mPost.getResponseBodyAsStream();

// Retrieving file from result

File file = new File(“C:\\sample\\serverOutput.zip”);

FileOutputStream fos = new FileOutputStream(file);

try {

byte[] buf = new byte[1024];

int len = inputStream.read(buf);

while (len > 0) {

fos.write(buf, 0, len);

len = inputStream.read(buf);

} } finally {

if (fos != null) {

fos.close();

}

}

System.out.println(“Web service executed successfully..”);

else if (statusCode == 403) {

System.out.println(“Invalid username/password..”);

else {

System.out.println(statusCode + ” *** ” + mPost.getResponseBodyAsString());

}

catch (FileNotFoundException e) {

System.err.println(“File not found for processing..”);

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

} }

}

Classification Web Service

classifyImage

This API classifies the input image as per batch class identifier provided. This API will depend on the three plugin for completion “CREATE_THUMBNAILS_PLUGIN”, “CLASSIFY_IMAGES_PLUGIN” and “DOCUMENT_ASSEMBLER_PLUGIN”. If any batch class doesn’t have those plugin than classify image api will not work.

Web Service URL: [ http://{serverName}:{port}/dcma/rest/classifyImage ]

Input Parameter Values Descriptions
batchClassId This value should not be empty and it should be batch class identifier as like BC1. This parameter is used for providing batch class identifier on which classify image will perform.

Sample Input Used:

ephesoft-web-services\classify-image.zip

Checklist:

  1. Input file should be single page tif/tiff file only.
  2. batchClassId should be valid batch class identifier and must have the “CREATE_THUMBNAILS_PLUGIN”, “CLASSIFY_IMAGES_PLUGIN” and “DOCUMENT_ASSEMBLER_PLUGIN”.

Sample client code using apache commons http client:-

private static void classifyImage() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/classifyImage“;

PostMethod mPost = new PostMethod(url);

// Adding tif file for processing

File file1 = new File(“C:\\sample\\US-Invoice.tif”);

Part[] parts = new Part[2];

try {

parts[0] = new FilePart(file1.getName(), file1);

// Adding parameter for batchClassId

parts[1] = new StringPart(“batchClassId”, “BC1”);

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

mPost.setRequestEntity(entity);

int statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

System.out.println(“Web service executed successfully..”);

String responseBody = mPost.getResponseBodyAsString();

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password..”);

else {

System.out.println(mPost.getResponseBodyAsString());

}

catch (FileNotFoundException e) {

System.err.println(“File not found for processing..”);

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if(mPost != null) {

mPost.releaseConnection();

}

} }

classifyHOCR

This API will classify the input HOCR as per batch class identifier provided. This API will depend on the following plugins “SEARCH_CLASSIFICATION_PLUGIN”, “DOCUMENT_ASSEMBLER_PLUGIN” and the learning done on the batch class. If any batch class doesn’t have those plugins than classify hocr will not work.

Web Service URL: [ http://{serverName}:{port}/dcma/rest/classifyHOCR]

Input Parameter Values Descriptions
batchClassId This value should not be empty and it should be batch class identifier as like BC1. This parameter is used for providing batch class identifier on which classify HOCR will perform.

Checklist:

  1. Input file should be html file only.
  2. batchClassId should be valid batch class identifier and must have the “SEARCH_CLASSIFICATION_PLUGIN” and “DOCUMENT_ASSEMBLER_PLUGIN”.

””Sample Input Used:

ephesoft-web-services\classify-hocr.zip

Sample client code using apache commons http client:-

private static void classifyHocr() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/classifyHocr“;

PostMethod mPost = new PostMethod(url);

// Adding HTML file for processing

File file1 = new File(“C:\\sample\\US-Invoice.html”);

Part[] parts = new Part[2];

try {

parts[0] = new FilePart(file1.getName(), file1);

// Adding parameter for batchClassId

parts[1] = new StringPart(“batchClassId”, “BC1”);

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

mPost.setRequestEntity(entity);

int statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

System.out.println(“Web service executed successfully..”);

String responseBody = mPost.getResponseBodyAsString();

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password..”);

else {

System.out.println(mPost.getResponseBodyAsString());

}

catch (FileNotFoundException e) {

System.err.println(“File not found for processing..”);

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

}

}

}

classifyMultiPageHOCR

This API will classify the input HOCR as per batch class identifier provided. This API will depend on the following plugins “SEARCH_CLASSIFICATION_PLUGIN”, “DOCUMENT_ASSEMBLER_PLUGIN” and the learning done on the batch class. If any batch class doesn’t have those plugins than classify hocr will not work.

Web Service URL: [ http://{serverName}:{port}/dcma/rest/classifyHOCR]

Input Parameter Values Descriptions
batchClassId This value should not be empty and it should be batch class identifier as like BC1. This parameter is used for providing batch class identifier on which classify HOCR will perform.

Checklist:

  1. Input file should be zip file containing HTML’s in it.
  2. batchClassId should be valid batch class identifier and must have the “SEARCH_CLASSIFICATION_PLUGIN” and “DOCUMENT_ASSEMBLER_PLUGIN”.

Sample client code using apache commons http client:-

private static void classifyMultiPageHocr() {

           HttpClient client = new HttpClient();

           String url = “http://localhost:8080/dcma/rest/classifyMultiPageHocr“;

           PostMethod mPost = new PostMethod(url);

           // Adding ZIP file for processing

           File file1 = new File(“D:\\sample\\New folder.zip”);

           Part[] parts = new Part[2];

           try {

                parts[0] = new FilePart(file1.getName(), file1);

                // Adding parameter for batchClassId

                parts[1] = new StringPart(“batchClassId”, “BC1”);

                MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

                mPost.setRequestEntity(entity);

                int statusCode = client.executeMethod(mPost);

                String responseBody = mPost.getResponseBodyAsString();

                System.out.println(statusCode + “***” + responseBody);

                mPost.releaseConnection();

           } catch (FileNotFoundException e) {

                e.printStackTrace();

           } catch (HttpException e) {

                e.printStackTrace();

           } catch (IOException e) {

                e.printStackTrace();

           }

     }

classifyBarcodeImage

This API is used to classify the input image as per specified batch class. Image file should have barcode and barcode value should be document type which is present in the batch class.

Web Service URL: [ http://{serverName}:{port}/dcma/rest/classifyBarcodeImage]

Input Parameter Values Descriptions
batchClassId This value should not be empty and it should be batch class identifier as like BC1. This parameter is used for providing batch class identifier on which classify HOCR will perform.

Checklist:

  1. Input file should be tif/tiff file only.
  2. batchClassId should be valid batch class identifier and must have the “BARCODE_READER_PLUGIN” .

Sample client code using apache commons http client:-

private static void classifyBarcodeImage(){

HttpClient client = new HttpClient();

String url = “http://locahost:8080/dcma/rest/classifyBarcodeImage“;

PostMethod mPost = new PostMethod(url);

// Adding image file for processing the barcode classification

File file1 = new File(“C:\\sample\\US-Invoice.tif”);

Part[] parts = new Part[2];

try {

parts[0] = new FilePart(file1.getName(), file1);

// Adding batchClassId for which barcode classification to be perform.

parts[1] = new StringPart(“batchClassId”, “BC1”);

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

mPost.setRequestEntity(entity);

int statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

System.out.println(“Web service executed successfully..”);

String responseBody = mPost.getResponseBodyAsString();

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password..”);

else {

System.out.println(mPost.getResponseBodyAsString());

} } catch (FileNotFoundException e) {

System.err.println(“File not found for processing..”);

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

}

}

}

Extraction Web Service

extractKV

This API will extract the document level fields for the corresponding Key Value pattern provided using input XML. This API will take the HOCR file as input. If the Key Value pattern is not found in the HOCR file than it will create the empty document level fields.

Web Service URL: [ http://{serverName}:{port}/dcma/rest/extractKV]

Batch Class List >>Recostar Mail Room [BC1] >>Application-Checklist >>Invoice Date >>New KV Extraction

[[image:|511x197px]]

Input Parameter Values Descriptions
AdvancedKV Either “true”/”false” This parameter is used to specifying the KeyValue extraction is perform by advanced key value or not.
LocationType This value should be one of the following:

TOPRIGHTLEFTBOTTOMTOP_RIGHTTOP_LEFTBOTTOM_LEFT,BOTTOM_RIGHT

 

This parameter will fetch the Value pattern of the particular key pattern on the location provided.
NoOfWords Should be Integer This parameter is used for specify in case of AdvancedKV is false. This parameter is used for adding number word of RIGHT location in the result of the value pattern found in the HOCR.
KeyPattern This value should not be empty.

This value should be valid regex expression.

 

This is used for verify the Key pattern present in given HOCR.
ValuePattern This value should not be empty.

This value should be valid regex expression.

 

This is used for verify the Value pattern present in given HOCR for that particular Key Pattern.
KVFetchValue This value should be one of the following:

ALLFIRSTLAST

This parameter is used to specify the whether we need fetch all, first or last value pattern found.

 

 

Multiplier This value should be float and should be in between 0 to 1 This value is used to multiply with confidence for updating the confidence of the fields extracted using advanced KV.
Length This value should be integer For getting length value use Ephesoft Admin Screen as display screen shot above
Width This value should be integer For getting width value use Ephesoft Admin Screen as display screen shot above
Xoffset This value should be integer For getting xoffset value use Ephesoft Admin Screen as display screen shot above
Yoffset This value should be integer For getting yoffset value use Ephesoft Admin Screen as display screen shot above
hocrFileName This value should be string This value should be having HOCR file name passing for processing in XML file format.

CheckList:

  1. For using Advance KV user should have admin access to fetch the accurate value of Length, Width, Xoffset and Yoffset. Before using AdvancedKV, please test the image with Ephesoft Admin Screen and note the values of Length, Width, Xoffset, Yoffset and LocationType for the particular KeyValue pattern.
  2. If AdvancedKV is true than NoOfWords is not use and all other parameters is used.
  3. If AdvancedKV is false than NoOfWords, KeyPattern, ValuePattern and LocationType will work.

Sample Input Used:

ephesoft-web-services\extractkv.zip

Format for XML:

<ExtractKVParams>

<Params>

<AdvancedKV>true</AdvancedKV>

<LocationType>BOTTOM_LEFT</LocationType>

<NoOfWords>0</NoOfWords>

<KeyPattern>APPLICATION</KeyPattern>

<ValuePattern>[a-zA-Z]{10,15}</ValuePattern>

<KVFetchValue>ALL</KVFetchValue>

<Multiplier>1</Multiplier>

<Length>384</Length>

<Width>251</Width>

<Xoffset>284</Xoffset>

<Yoffset>105</Yoffset>

</Params>

</ExtractKVParams>

Sample client code using apache commons http client:-

private static void extractKV() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/extractKV“;

PostMethod mPost = new PostMethod(url);

// Adding XML for the input.

File f1 = new File(“C:\\sample\\extractKV.xml”);

// Adding HOCR for processing.

File f2 = new File(“C:\\sample\\Application-Checklist.xml “);

Part[] parts = new Part[3];

try {

parts[0] = new FilePart(f1.getName(), f1);

parts[1] = new FilePart(f2.getName(), f2);

parts[2] = new StringPart(“hocrFileName”, f2.getName());

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

mPost.setRequestEntity(entity);

int statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

String responseBody = mPost.getResponseBodyAsString();

// Generating result as responseBody.

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(mPost.getResponseBodyAsString());

}

catch (FileNotFoundException e) {

System.err.println(“File not found for processing.”);

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

}

}

}

extractFixedForm

This API extracts the document level fields from the given RSP file and the image provided. This image should be tif/png.

Web Service URL:

http://{serverName}:{port}/dcma/rest/extractFixedForm]

Input Parameter Values Descriptions
colorSwitch Either “ON”/”OFF” This parameter is used for extracting the data from color image or black and white image.
projectFile This value should not be empty and should have valid recostar project file name. This is used for HOCRing the image file using project file associated.

Format for project file:

<_Project MajorRevision=”6″ MinorRevision=”0″ Timeout=”180000″>

<_Collection Name=”Libraries”>

<_Library Type=”Dll” BaseName=”ImageProcess”/>

<_Library Type=”Dll” BaseName=”ImageProcess2″/>

<_Library Type=”Dll” BaseName=”FormIdent”/>

<_Library Type=”Dll” BaseName=”Recognition”/>

</_Collection>

<FormOperator Name=”Operator” SetupImageFileName=”” ProjectID=”0″ DefaultFormType=”Voting_Pharmacy” ExternalFormType=”” Country=”USA” FormRegistration=”Off” FormReading=”true” FormGeometry=”0 0 0 0 0 0″ ResultCoordinates=”OriginalImage” ResultImage=”Off” ResultGraphicalObjects=”false” PassThroughID=”Ignore” DiagnosticsMode=”OnError” DiagnosticsFileName=””>

<ImageSequence2Operator Name=”ImageProcessing” SetupImageFileName=”” RegisterImage=”false” DiagnosticsMode=”OnError” DiagnosticsFileName=”” ConfigurationFileName=”” Geometry=”0 0 1488 0 0 1019″>

<LoadImageOperator Name=”ImageSourceOperator” FileName=”” FileFormat=”Unknown” Resolution=”ReadFromFile” UnifyResolution=”false” RepairResolution=”false” AutoRotate=”false” IgnorePalette=”true” ScaleToGray=”0″/>

<ExtractGrayFromRgbOperator Name=”ColorFilterOperator” LumaRed=”0.299″ LumaGreen=”0.587″ LumaBlue=”0.114″/>

<BinarizeEdgeAdaptiveOperator Name=”BinarizeOperator” EdgeThreshold=”80″ DoubleResolution=”false”/>

<_Collection Name=”BinaryImageSequence”>

<DetectPaperAreaOperator Name=”DetectPaperArea” KeepBlackFrame=”false” SafetyClass=”Medium” DetectTextSkew=”false”/>

</_Collection>

</ImageSequence2Operator>

<_Collection Name=”Forms”>

<FormRecoOperator Name=”Voting_Pharmacy” SetupImageFileName=”” SetupImageWidth=”125.98″ SetupImageHeight=”86.27″>

<_Collection Name=”RecoOperators”>

<IcrField Name=”Field1″ Zone=”440 1151 11269 796 0 1″ ReaderSelection=”Voter” Orientation=”Normal” SyntaxMode=”Alphanumerical” Font=”Unknown” NumberOfLines=”1″ HandprintHeight=”5.50″ HandprintPitch=”5.00″ HandprintMinConfidence=”100″ MachinetypeHeight=”Unknown” MachinetypePitch=”Unknown” MachinetypeMinConfidence=”100″ LogicalContext=”On” TrigramMode=”On” DictionaryFileName=”” DictionaryMode=”Incomplete” DictionaryCandidates=”Words” CharacterSet=”” Pattern=”^[$%*+,\-.0-9:;<=>?A-Z\\a-z]*$” LeftBoundaryHandling=”On” TopBoundaryHandling=”On” RightBoundaryHandling=”On” BottomBoundaryHandling=”On” Classifiers=”” PassThroughID=”None”>

<_Collection Name=”IgnoreAreas”/>

</IcrField>

<IcrField Name=”Field2″ Zone=”593 1930 11803 796 0 1″ ReaderSelection=”Voter” Orientation=”Normal” SyntaxMode=”Numerical” Font=”Unknown” NumberOfLines=”1″ HandprintHeight=”5.50″ HandprintPitch=”5.00″ HandprintMinConfidence=”100″ MachinetypeHeight=”Unknown” MachinetypePitch=”Unknown” MachinetypeMinConfidence=”100″ LogicalContext=”On” TrigramMode=”On” DictionaryFileName=”” DictionaryMode=”Incomplete” DictionaryCandidates=”Words” CharacterSet=”” Pattern=”^[$*+,\-.0-9\\]*$” LeftBoundaryHandling=”On” TopBoundaryHandling=”On” RightBoundaryHandling=”On” BottomBoundaryHandling=”On” Classifiers=”” PassThroughID=”None”>

<_Collection Name=”IgnoreAreas”/>

</IcrField>

</_Collection>

</FormRecoOperator>

</_Collection>

<FormGenerator Name=”Generator”/>

</FormOperator>

</_Project>

Sample for XML:

<WebServiceParams>

<Params>

<Param>

<Name>colorSwitch</Name>

<Value>off</Value>

</Param>

<Param>

<Name>projectFile</Name>

<Value>Fpr.rsp</Value>

</Param>

</Params>

</WebServiceParams>

CheckList:

  1. projectFile should have fields like we have marked yellow in above.
  2. If colorSwitch is ON than image should be png.
  3. If colorSwitch is OFF than image should be tif/tiff.

Sample Input Used:

ephesoft-web-services\extract-fixed-form.zip

Sample client code using apache commons http client:-

private static void extractFixedForm() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/extractFixedForm“;

PostMethod mPost = new PostMethod(url);

// adding file for sending

File file1 = new File(“C:\\sample\\WebServiceParams.xml”);

File file2 = new File(“C:\\sample\\Voting_Pharmacy.rsp”);

Part[] parts = new Part[2];

try {

parts[0] = new FilePart(file1.getName(), file1);

parts[1] = new FilePart(file2.getName(), file2);

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

mPost.setRequestEntity(entity);

int statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

String responseBody = mPost.getResponseBodyAsString();

// Generating result as responseBody.

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(mPost.getResponseBodyAsString());

}

catch (FileNotFoundException e) {

System.err.println(“File not found for processing.”);

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

}

}

}

extractFieldFromHocr

This API will extract the KV pattern for the given word in the given HOCR.

Web Service URL:

http://{serverName}:{port}/dcma/rest/extractFieldFromHocr]

Input Parameter Values Descriptions
fieldValue This should not be empty. This parameter is used for extracting the Key Value pattern for the word provided.

CheckList:

  1. fieldValue is provided for the word on which Key Value pattern would be found.

Sample Input Used:

ephesoft-web-services\extract-field-from-hocr.zip

Sample client code using apache commons http client:-

private static void extractFieldFromHocr() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/extractFieldFromHocr“; PostMethod mPost = new PostMethod(url);

// Adding HTML for extracting field

File file1 = new File(“C:\\sample\\Application-Checklist.html”);

Part[] parts = new Part[2];

try {

parts[0] = new FilePart(file1.getName(), file1);

// Adding field value for extracting Key Value Pattern.

parts[1] = new StringPart(“fieldValue”, “APPLICATION”);

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

mPost.setRequestEntity(entity);

int statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

String responseBody = mPost.getResponseBodyAsString();

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(mPost.getResponseBodyAsString());

}

catch (FileNotFoundException e) {

System.err.println(“File not found for processing.”);

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

}

}

}

extractFuzzyDB

This API will create the document level fields for the document type for the specified batch class for HOCR file passing it.

Web Service URL:

http://{serverName}:{port}/dcma/rest/extractFuzzyDB]

Input Parameter Values Descriptions
documentType This should not be empty and valid document type for that batch class This parameter is used for generating document level fields for defined document type.
batchClassIdentifier This should not be empty and valid batch class identifier This parameter used for fetching the information of the document for defined document type
hocrFile This value should not and empty and should have same name as HOCR file attached for processing. This parameter is used for verifying the HOCR file name.

CheckList:-

  1. hocrFile should have same HOCR file name that are passed for processing.
  2. BatchClass having that batchClassIdentifier should have fuzzyDB plugin for processing.
  3. DocumentType should have document level fields for specified document type.

Sample Input Used:

ephesoft-web-services\extract-fuzzy-db.zip

Sample client code using apache commons http client:-

private static void extractFuzzyDB() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/extractFuzzyDB“;

PostMethod mPost = new PostMethod(url);

// Adding HOCR file for processing

File file = new File(“C:\\sample\\Application-Checklist_000.html”);

Part[] parts = new Part[4];

try {

parts[0] = new FilePart(file.getName(), file);

// Adding parameter for docuement type.

parts[1] = new StringPart(“documentType”, “Application-Checklist”);

// Adding parameter for batch class.

parts[2] = new StringPart(“batchClassIdentifier”, “BC1”);

parts[3] = new StringPart(“hocrFile”, “Application-Checklist.html”);

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

mPost.setRequestEntity(entity);

int statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

String responseBody = mPost.getResponseBodyAsString();

// Generating result as responseBody.

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(mPost.getResponseBodyAsString());

}

catch (FileNotFoundException e) {

System.err.println(“File not found for processing.”);

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

}

}

}

barcodeExtraction

This API will create the document level fields for the document type for the specified batch class for barcode in tiff files passing it.

Web Service URL:

http://{serverName}:{port}/dcma/rest/barcodeExtraction]

Input Parameter Values Descriptions
documentType This should not be empty and valid document type for that batch class This parameter is used for generating document level fields for defined document type.
batchClassIdentifier This should not be empty and valid batch class identifier This parameter used for fetching the information of the document for defined document type
imageName This value should not and empty. On this file extraction operation will be performed.

CheckList:-

  1. BatchClass having that batchClassIdentifier should have Barcode Extraction plugin for processing.
  2. DocumentType should have document level fields for specified document type.
  3. Image name should have valid extension i.e. TIF/TIFF.

Sample Input Used:

ephesoft-web-services\barcodeExtraction.zip

Sample client code using apache commons http client:-

private static void barcodeExtraction() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/barcodeExtraction“;

PostMethod mPost = new PostMethod(url);

File file1 = new File(“C:\\sample\\sample.tif”);

// adding xml file for taking input

File file2 = new File(“C:\\sample\\WebServiceParams-barcodeExtraction.xml”);

Part[] parts = new Part[2];

try {

parts[0] = new FilePart(file1.getName(), file1);

parts[1] = new FilePart(file2.getName(), file2);

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

mPost.setRequestEntity(entity);

int statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

System.out.println(mPost.getResponseBodyAsString());

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(mPost.getResponseBodyAsString());

}

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

}

}

}

regularRegexExtraction

This API will extract the document level fields for the document type for the specified batch class.

Web Service URL: [ http://{serverName}:{port}/dcma/rest/extractFieldsUsingRegex]

Input Parameter Values Descriptions
documentType This should not be empty and valid document type for that batch class This parameter is used for generating document level fields for defined document type.
batchClassIdentifier This should not be empty and valid batch class identifier This parameter used for fetching the information of the document for defined document type.
hocrFileName This value should not be empty. XML file name for which document level fields will be extracted.

CheckList:-

  1. This batch class specified should have Regular Regex plugin defined for it.
  2. DocumentType should have document level fields for specified document type.
  3. HOCR file name should have valid extension, i.e., XML.

Sample Input Used:

ephesoft-web-services/regularRegexExtraction.zip

Sample client code using apache commons http client:-

””private static void extractFieldsUsingRegex() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/extractFieldsUsingRegex“;

PostMethod mPost = new PostMethod(url);

File file1 = new File(“C:\\sample\\sample1.xml”);

// adding xml file for taking input

File file2 = new File(“C:\\sample\\WebServiceParams.xml”);

Part[] parts = new Part[3];

try {

parts[0] = new FilePart(file1.getName(), file1);

parts[1] = new FilePart(file2.getName(), file2);

parts[2] = new StringPart(“hocrFileName”, file1.getName());

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

mPost.setRequestEntity(entity);

int statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

System.out.println(mPost.getResponseBodyAsString());

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(mPost.getResponseBodyAsString());

}

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

}

}

}

commonAPIForExtraction

This API is required to set the Header in the client for which the extraction to be performed. Rest of the information for the individual api found above.

Input for Extraction Type:

Pass the name of extraction api that is to use in the client header as shown in following example: BARCODE_EXTARCTIONRECOSTAR_EXTARCTIONREGULAR_REGEX_EXTRACTIONKV_EXTRACTIONFUZZY_DB

Here’s the sample client code using Regular Regex Extraction:

private static void extractFields() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/extractFields“;

PostMethod mPost = new PostMethod(url);

File file1 = new File(“C:\\sample\\input\\sample1.html”);

// adding xml file for taking input

File file2 = new File(“C:\\sample\\input\\WebServiceParams.xml”);

Part[] parts = new Part[2];

try {

parts[0] = new FilePart(file1.getName(), file1);

parts[1] = new FilePart(file2.getName(), file2);

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

/* Pass the name of extraction api that is to used:

BARCODE_EXTARCTION

RECOSTAR_EXTARCTION

REGULAR_REGEX_EXTRACTION

KV_EXTRACTION

FUZZY_DB*/

Header header = new Header(“extractionAPI”, “REGULAR_REGEX_EXTRACTION”);

mPost.addRequestHeader(header);

mPost.setRequestEntity(entity);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

System.out.println(mPost.getResponseBodyAsString());

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(mPost.getResponseBodyAsString());

} } catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

}

}

}

OCR Web Service

createOCR

This API will generate the OCR result for the specified sample image file. This API works for tif and png file. If processing the color image we accept the png/tif file as input and for black and white image we processing tif file as input.

Web Service URL:

http://{serverName}:{port}/dcma/rest/createOCR]

Input Parameter Values Descriptions
ocrEngine Either “nuance”/”tesseract”/”recostar” This parameter is used for configuring the ocrEngine to be used
colorSwitch Either “ON”/”OFF” This parameter is used
tesseractVersion Currently we are supporting “tesseract_version_3” This parameter is used for tesseract version to be used.
cmdLanguage Either “tha”/”eng” This parameter is used for configure the language that has been learnt by tessearact
projectFile This can be empty in case of tesseract/nuance ocrEngine This parameter is validating the RSP used for OCRing in case of recostar.

CheckList:-

  1. In case of ocrEngine is recostar, than colorSwitch and projectFile is mandatory parameters.
  2. In case of ocrEngine is tesseract than colorSwitch, tesseractVersion and cmdLanguage is mandatory parameters.
  3. If colorSwitch is ON, input image can be tif/png.
  4. If colorSwitch is OFF than input image should be TIFF.

Sample Input Used:

ephesoft-web-services\create-ocr.zip

File format for XML file:

<WebServiceParams>

<Params>

<Param>

<Name>ocrEngine</Name>

<Value>recostar</Value>

</Param>

<Param>

<Name>colorSwitch</Name>

<Value>off</Value>

</Param>

<Param>

<Name>tesseractVersion</Name>

<Value>tesseract_version_3</Value>

</Param>

<Param>

<Name>cmdLanguage</Name>

<Value>eng</Value>

</Param>

<Param>

<Name>projectFile</Name>

<Value>Fpr.rsp</Value>

</Param>

</Params>

</WebServiceParams>

Format for RSP file:

<_Project MajorRevision=”1″ MinorRevision=”0″ Timeout=”180000″>

<_Collection Name=”Libraries”>

<_Library Type=”Dll” BaseName=”ImageProcess”/>

<_Library Type=”Dll” BaseName=”ImageProcess2″/>

<_Library Type=”Dll” BaseName=”Recognition”/>

</_Collection>

<FullPageOperator Name=”Operator” SetupImageFileName=”” Country=”USA” TextReading=”true” ResultCoordinates=”OriginalImage” ResultImage=”RecoImage” ResultGraphicalObjects=”false” DiagnosticsMode=”OnError” DiagnosticsFileName=””>

<ImageSequence2Operator Name=”ImageProcessing” SetupImageFileName=”” RegisterImage=”true” DiagnosticsMode=”OnError” DiagnosticsFileName=”” ConfigurationFileName=”” Geometry=”-1 0 1683 0 1 2190″>

<LoadImageOperator Name=”ImageSourceOperator” FileName=”” FileFormat=”Unknown” Resolution=”200″ UnifyResolution=”true” RepairResolution=”true” AutoRotate=”false” IgnorePalette=”false” ScaleToGray=”0″/>

<ExtractGrayFromRgbOperator Name=”ColorFilterOperator” LumaRed=”0.299″ LumaGreen=”0.587″ LumaBlue=”0.114″/>

<BinarizeEdgeAdaptiveOperator Name=”BinarizeOperator” EdgeThreshold=”80″ DoubleResolution=”false”/>

<_Collection Name=”BinaryImageSequence”>

<RemoveShadingOperator Name=”RemoveShading” MinRegionWidth=”10.00″ MinRegionHeight=”3.00″/>

<DetectPaperAreaOperator Name=”DetectPaperArea” KeepBlackFrame=”false” SafetyClass=”Medium” DetectTextSkew=”true”/>

<BinaryAutoRotateOperator Name=”AutoRotate” DocumentOrientation=”Unknown” InputOrientation=”MostlyCorrect”/>

<ProtectBarCodesOperator Name=”ProtectBarCodes” SafetyClass=”Medium” SearchRegion=””/>

<RemoveLineSystemOperator Name=”RemoveLineSystem” HorizontalLineLength=”10.00″ VerticalLineLength=”12.00″ DashedLineLength=”30.00″ MaxLineWidth=”1.50″ MaxGapWidth=”1.00″ BoxSeparatorHeight=”4.00″ InvertedRegionWidth=”12.00″ InvertedRegionHeight=”4.00″ LineQuality=”Medium”/>

</_Collection>

</ImageSequence2Operator>

<LayoutOperator Name=”LayoutOperator” FindTextBlocks=”true”/>

<FullPageField Name=”TextField” Zone=”0 0 0 0 0 1″ ReaderSelection=”Voter” Orientation=”Normal” SyntaxMode=”Alphanumerical” NumberOfLines=”TextLineSegments” MachinetypeHeight=”Unknown” MachinetypePitch=”Unknown” MachinetypeMinConfidence=”100″ LogicalContext=”On” TrigramMode=”On” DictionaryFileName=”” DictionaryMode=”Incomplete” DictionaryCandidates=”Words” CharacterSet=”” Pattern=”” PassThroughID=”None”/>

<FormGenerator Name=”Generator”/>

</FullPageOperator>

</_Project>

Sample client code using apache commons http client:-

private static void createOCR() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/createOCR“;

PostMethod mPost = new PostMethod(url);

// adding image file for processing

File file1 = new File(“C:\\sample\\sample1.tif”);

// adding xml file for taking input

File file2 = new File(“C:\\sample\\WebServiceParams.xml”);

// adding rsp file used for creating OCR in case of recostar

File file3 = new File(“C:\\sample\\Fpr.rsp”);

Part[] parts = new Part[3];

try {

parts[0] = new FilePart(file1.getName(), file1);

parts[1] = new FilePart(file2.getName(), file2);

parts[2] = new FilePart(file3.getName(), file3);

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

mPost.setRequestEntity(entity);

int statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

InputStream in = mPost.getResponseBodyAsStream();

// saving result generated.

File outputFile = new File(“C:\\sample\\serverOutput.zip”);

FileOutputStream fos = new FileOutputStream(outputFile);

try {

byte[] buf = new byte[1024];

int len = in.read(buf);

while (len > 0) {

fos.write(buf, 0, len);

len = in.read(buf);

}

finally {

if (fos != null) {

fos.close();

}

}

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(mPost.getResponseBodyAsString());

}

catch (FileNotFoundException e) {

System.err.println(“File not found for processing.”);

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

}

}

}

Users and Groups Web Service

getBatchInstanceForRole

This API is used to fetch all batch instance list having accessed by the specified role. This API is GET api, works with web url and client code.

Web Service URL:

http://{serverName}:{port}/dcma/rest/getBatchInstanceForRole/{role}]

Input Parameter Values Descriptions
role This value should not be empty.

 

This parameter is used for specifying the role name for which batch instance list to be fetched.

Sample client code using apache commons http client:-

private static void getBatchInstanceForRole() {

HttpClient client = new HttpClient();

// URL path to be hit for getting the batch instance list having accessed by the role specified.

String url = “http://localhost:8080/dcma/rest/getBatchInstanceForRoles/admin“;

GetMethod getMethod = new GetMethod(url);

int statusCode;

try {

statusCode = client.executeMethod(getMethod);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

String responseBody = getMethod.getResponseBodyAsString();

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(getMethod.getResponseBodyAsString());

}

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (getMethod != null) {

getMethod.releaseConnection();

}

}

}

getBatchClassForRole

This API is used to fetch all batch class list having accessed by the specified role. This API is GET api, works with web url and client code.

Web Service URL:

http://{serverName}:{port}/dcma/rest/getBatchClassForRole/{role}]

Input Parameter Values Descriptions
role This value should not be empty.

 

This parameter is used for specifying the role name for which batch class list to be fetched.

Sample client code using apache commons http client:-

private static void getBatchClassForRole() {

HttpClient client = new HttpClient();

// URL path to be hit for getting the batch class list having accessed by the role specified.

String url = “http://localhost:8080/dcma/rest/getBatchClassForRole/admin“;

GetMethod getMethod = new GetMethod(url);

int statusCode;

try {

statusCode = client.executeMethod(getMethod);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

String responseBody = getMethod.getResponseBodyAsString();

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(getMethod.getResponseBodyAsString());

}

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (getMethod != null) {

getMethod.releaseConnection();

}

}

}

Reporting Web Service

runReporting

This API is used to run reporting on using web services. This web service takes server side installer path as an input and performs synchronizing the report database.

Web Service URL:

http://{serverName}:{port}/dcma/rest/runReporting]

Input Parameter Values Descriptions
installerPath This value should be valid path. This parameter is used for specifying path fie build.xml for reporting present on the server side.

Checklist :-

  1. This path should be valid file path and must be server path for the build.xml file.

Sample Input Used:

ephesoft-web-services\run-reporting.zip

Format for inputXML file :

<ReportingOptions>

<installerPath>C:\\testing</installerPath>

</ReportingOptions>

Sample client code using apache commons http client:-

private static void runReporting() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/runReporting“;

PostMethod mPost = new PostMethod(url);

File file1 = new File(“C:\\sample\\reporting.xml”);

Part[] parts = new Part[1];

try {

parts[0] = new FilePart(file1.getName(), file1);

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

mPost.setRequestEntity(entity);

int statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

String responseBody = mPost.getResponseBodyAsString();

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(mPost.getResponseBodyAsString());

}

catch (FileNotFoundException e) {

System.out.println(“File not found for processing.”);

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

}

}

}

Batch Instance Management Web Service

getBatchInstanceList

This api will return the batch instance list of the batch instance status accessed for the specific role using in the authentication. This API is GET api, works with client code and URL directly.

Web Service URL:

http://{serverName}:{port}/dcma/rest/getBatchInstanceList/{status}]

””Input Parameter Values Descriptions
status This values can be NEW, LOCKED,READY,ERROR, FINISHED,ASSIGNED, RUNNING, READY_FOR_REVIEW,

READY_FOR_VALIDATION, RESTARTED, DELETED, TRANSFERRED, RESTART_IN_PROGRESS

This parameter is used for specifying the batch instance status for which batch instance list to be fetched.

Checklist:-

  1. Status should have status provided above in the list.

Sample client code using apache commons http client:-

private static void getBatchInstanceList() {

HttpClient client = new HttpClient();

// URL path to be hit for getting the batch instance identifier list having status specified.

String url = “http://localhost:8080/dcma/rest/getBatchInstanceList/RUNNING“;

GetMethod getMethod = new GetMethod(url);

int statusCode;

try {

statusCode = client.executeMethod(getMethod);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

String responseBody = getMethod.getResponseBodyAsString();

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(getMethod.getResponseBodyAsString());

}

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (getMethod != null) {

getMethod.releaseConnection();

}

}

}

getAllModulesWorkflowNameByBatchClass

This API will return the module workflow names and the module names of the specified batch class identifier. This API is GET API, works with client code and web url.

Web Service URL:

http://{serverName}:{port}/dcma/rest/getAllModulesWorkflowNameByBatchClass/{batchClassIdentifier}]

Input Parameter Values Descriptions
batchClassIdentifier This value should not be empty. This parameter is used for specifying the batch class identifier for which module name to be fetched.

Sample client code using apache commons http client:-

private static void getAllModulesWorkflowNameByBatchClass() {

HttpClient client = new HttpClient();

// URL path to be hit for getting the mdoule workflow name of the specified batch class identifier

String url = “http://localhost:8080/dcma/rest/getAllModulesWorkflowNameByBatchClass/BC1“;

GetMethod getMethod = new GetMethod(url);

int statusCode;

try {

statusCode = client.executeMethod(getMethod);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

String responseBody = getMethod.getResponseBodyAsString();

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(getMethod.getResponseBodyAsString());

}

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (getMethod != null) {

getMethod.releaseConnection();

}

}

}

restartBatchInstance

This API is used to restart the batch instance from specified module. User can restart those batch instances those are accessible by their role. This API is GET api, works with client code and web url.

Web Service URL:

http://{serverName}:{port}/dcma/rest/restartBatchInstance/{batchInstanceIdentifier}/{restartAtModuleName}]

Input Parameter Values Descriptions
batchInstanceIdentifier This value should be valid batch instance identifier. This parameter is used to specifying the batch instance identifier for which batch instance to be restart.
restartAtModuleName This value should not be empty. This parameter is used specifying the module name from where batch to be restart.

Checklist:-

  1. Batch Instance identifier should be valid identifier and having access by the user which are authenticate the web service.
  2. restartAtModuleName this value should valid module name and it can be differ with batch class.

Sample client code using apache commons http client:-

private static void restartBatchInstance() {

HttpClient client = new HttpClient();

// URL path to be hit for restarting batch instance identifier from specified module.

// User can restart only those batch instance having status “ERROR”, “READY_FOR_REVIEW”, “READY_FOR_VALIDATION”, “RUNNING”

String url = “http://{serverName}:{port}/dcma/rest/restartBatchInstance/BI1/Folder_Import_Module“;

GetMethod getMethod = new GetMethod(url);

int statusCode;

try {

statusCode = client.executeMethod(getMethod);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

String responseBody = getMethod.getResponseBodyAsString();

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(getMethod.getResponseBodyAsString());

}

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (getMethod != null) {

getMethod.releaseConnection();

}

}

}

deleteBatchInstance

This API is used to delete the batch instance for specified batch instance identifier. This API will delete that batch instance having accessed by the authenticated user.

Web Service URL:

http://{serverName}:{port}/dcma/rest/deleteBatchInstance/{identifier}]

Input Parameter Values Descriptions
batchInstanceIdentifier This value should be valid batch instance identifier. This parameter is used to specifying the batch instance identifier to be deleted.

Sample client code using apache commons http client:-

private static void deleteBatchInstance() {

HttpClient client = new HttpClient();

// URL path to be hit for deleting the batch instance having access to the authenticated user.

// User can delete only those batch instance having status “ERROR”, “READY_FOR_REVIEW”, “READY_FOR_VALIDATION”, “RUNNING”

String url = “http://localhost:8080/dcma/rest/deleteBatchInstance/BI1“;

GetMethod getMethod = new GetMethod(url);

int statusCode;

try {

statusCode = client.executeMethod(getMethod);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

String responseBody = getMethod.getResponseBodyAsString();

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(getMethod.getResponseBodyAsString());

}

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (getMethod != null) {

getMethod.releaseConnection();

}

}

}

restartAllBatchInstance

This API is used to restart all the batch instance having status READY_FOR_REVIEW and READY_FOR_VALIDATION and having access by the authenticated user. This API is GET API, works with clinet code and web url.

Web Service URL: http://{serverName}:{port}/dcma/rest/restartAllBatchInstance]

Checklist:-

  1. Only those batches will restart whose status is READY_FOR_REVIEW and READY_FOR_VALIDATION and are accessible by authenticated user.

Sample client code using apache commons http client:-

””private static void restartAllBatchInstance() {

HttpClient client = new HttpClient();

// URL path to be hit for restarting the batch instance having access to the authenticated user.

// User can restart only those batch instance having status “READY_FOR_REVIEW”, “READY_FOR_VALIDATION”

String url = “http://localhost:8080/dcma/rest/restartAllBatchInstance“;

GetMethod getMethod = new GetMethod(url);

int statusCode;

try {

statusCode = client.executeMethod(getMethod);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

String responseBody = getMethod.getResponseBodyAsString();

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(getMethod.getResponseBodyAsString());

}

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (getMethod != null) {

getMethod.releaseConnection();

}

}

}

addUserRolesToBatchInstance

This API is used to adding roles to batch instance identifier. This API takes batch instance identifier and role name as an input and adding it to the database. This API is GET api, works with client code and web browser both.

Web Service URL:

http://{serverName}:{port}/dcma/rest/addUserRolesToBatchInstance/{batchInstanceIdentifier}/{userRole}]

Input Parameter Values Descriptions
batchInstanceIdentifier This value should be valid batch instance identifier. This parameter is used to specifying the batch instance identifier for which roles to be added.
userRole This value should not be empty. This parameter is used specifying the role to be added on the specified batch instance identifier.

Sample client code using apache commons http client:-

private static void addUserRolesToBatchInstance() {

HttpClient client = new HttpClient();

// URL path to be hit for adding user roles to batch instance identifier

String url = “http://localhost:8080/dcma/rest/addUserRolesToBatchInstance/BI45/admin“;

GetMethod getMethod = new GetMethod(url);

int statusCode;

try {

statusCode = client.executeMethod(getMethod);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

String responseBody = getMethod.getResponseBodyAsString();

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(getMethod.getResponseBodyAsString());

}

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (getMethod != null) {

getMethod.releaseConnection();

}

}

}

Batch Class Management Web Service

importBatchClass

This API is used for importing batch class to the ephesoft. This API takes XML for input parameters and exported batch class data as an input. Exported batch class is in zip format as exported by Ephesoft.

Web Service URL:

http://{serverName}:{port}/dcma/rest/importBatchClass]

Input Parameter Values Descriptions
RolesImported Either “true”/”false” This value is used for importing roles with batch class or not.
EmailAccounts Either “true”/”false” This value is used for importing email accounts with batch class or not.
UseSource Either “true”/”false” This value is used for saving the information of source batch class to be imported
Name This value should not be empty This value is used to configure the batch class name of the imported batch class.
Description This value should not be empty This value is used to configure the description of the imported batch class.
Priority This value should lie in between 1 to 100. This value indicates the priority of batch class.
UseExisting Either “true”/”false” This value is used for overwrite the existing batch class with new batch class.
UncFolder This value should not be empty and have any string value that specified directory path These values specify the UNC folder path for batch class to be imported along with batch class.
Script This tag is configured for ScriptFile to be imported This tag is configured for which Script file to be imported
Folder This tag is configured for Folder to be imported This tag is configured for which folder to be imported along with batch class

Checklist:-

  1. If UseExisting is “true”, existing batch class will be overwriting with the Folders and Script as well as others parameter.
  2. If UseExisting is “false”, new batch class will created and Folders and Scripts will be used as false.
  3. If UseSource is “true”, new batch class will have same Name, Description and Priority as source batch class.
  4. If UseSource is “false”, new batch class will have property like Name, Description and Priority configured.

SampleInputXML:

<ImportBatchClassOptions>

<RolesImported>false</RolesImported>

<EmailAccounts>true</EmailAccounts>

<UseSource>false</UseSource>

<Name>BatchClassName</Name>

<Description>Description</Description>

<Priority>10</Priority>

<UseExisting>true</UseExisting>

<UncFolder>C:\ephesoft-data\Test-UNC</UncFolder>

<BatchClassDefinition>

<Scripts>

<Script>

<FileName>ScriptDocumentAssembler.java</FileName>

<Selected>true</Selected>

</Script>

<Script>

<FileName>ScriptPageProcessing.java</FileName>

<Selected>true</Selected>

</Script>

</Scripts>

<Folders>

<Folder>

<FileName>image-classification-sample</FileName>

<Selected>false</Selected>

</Folder>

</Folders>

<BatchClassModules>

<BatchClassModule>

<ModuleName></ModuleName>

<PluginConfiguration>true</PluginConfiguration>

</BatchClassModule>

</BatchClassModules>

</BatchClassDefinition>

</ImportBatchClassOptions>

Sample client code using apache commons http client:-

private static void importBatchClass() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/importBatchClass“;

PostMethod mPost = new PostMethod(url);

mPost.setDoAuthentication(true);

// Input XML for adding parameter.

File file1 = new File(“C:\\sample\\importbatchclass.xml”);

// Input zip file for importing batch class.

File file2 = new File(“C:\\sample\\BC1_050712_1714.zip”);

Part[] parts = new Part[2];

try {

parts[0] = new FilePart(file1.getName(), file1);

parts[1] = new FilePart(file2.getName(), file2);

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

mPost.setRequestEntity(entity);

int statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

System.out.println(“Batch class imported successfully”);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(mPost.getResponseBodyAsString());

}

catch (FileNotFoundException e) {

System.out.println(“File not found for processing.”);

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

}

}

}

exportBatchClass

This API is used for exporting existing batch class. This method will take the batch class identifier and learnt-sample to be exported with the batch class.

Web Service URL:

http://{serverName}:{port}/dcma/rest/exportBatchClass]

Input Parameter Values Descriptions
identifier This value should not be empty and valid batch class identifier. This parameter is used for identifying which batch class is to be exported.
lucene-search-classification-sample Either “true”/”false” This parameter is used to configure the lucene learnt sample is exported with batch class or not.
image-classification-sample Either “true”/”false” This parameter is used to configure the image classification sample is exported with batch class or not.

CheckList:-

  1. Identifier should be batch class identifier.

Sample client code using apache commons http client:-

private static void exportBatchClass() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/exportBatchClass“;

PostMethod mPost = new PostMethod(url);

mPost.addParameter(“identifier”, “BC1”);

mPost.addParameter(“lucene-search-classification-sample”, “true”);

mPost.addParameter(“image-classification-sample”, “false”);

int statusCode;

try {

statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

System.out.println(“Batch class exported successfully”);

InputStream in = mPost.getResponseBodyAsStream();

File f = new File(“C:\\sample\\serverOutput.zip”);

FileOutputStream fos = new FileOutputStream(f);

try {

byte[] buf = new byte[1024];

int len = in.read(buf);

while (len > 0) {

fos.write(buf, 0, len);

len = in.read(buf);

}

finally {

if (fos != null) {

fos.close();

}

}

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(mPost.getResponseBodyAsString());

}

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

}

}

}

getBatchClassList

This API returns all the batch class having accessible by the authenticated user. This API is GET API, works with the client code and web url.

Web Service URL:

http://{serverName}:{port}/dcma/rest/getBatchClassList]

Sample client code using apache commons http client:-

private static void getBatchClassList() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/getBatchClassList“;

GetMethod mGet = new GetMethod(url);

int statusCode;

try {

statusCode = client.executeMethod(mGet);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

String responseBody = mGet.getResponseBodyAsString();

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(mGet.getResponseBodyAsString());

}

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mGet != null) {

mGet.releaseConnection();

}

}

}

getRoles

This API is used to get the roles of the specified batch class. This API is GET API, works with the client code and web url.

Web Service URL:

http://{serverName}:{port}/dcma/rest/getRoles/{batchClassIdentifier}]

Input Parameter Values Descriptions
identifier This value should not be empty and valid batch class identifier. This parameter is used for identifying which batch class roles to be fetched.

CheckList:-

  1. Identifier should be batch class identifier.

Sample client code using apache commons http client:-

private static void getRoles () {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/getRoles/BC1“;

GetMethod mGet = new GetMethod(url);

int statusCode;

try {

statusCode = client.executeMethod(mGet);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

String responseBody = mGet.getResponseBodyAsString();

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(mGet.getResponseBodyAsString());

}

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mGet != null) {

mGet.releaseConnection();

}

}

}

Uploading a Batch through a Web Service

uploadBatch

This API is for uploading a new batch to a watch folder for a given batch class. It executes the new batch with supplied tif, tiff or pdf files. User need to be authorized to execute a batch for a particular batch class otherwise an error message would be generated. All the files would be copied to the unc folder of the requested batch class with the folder name supplied by the user as input.

Web Service URL:

http://{serverName}:{port}/dcma/rest/uploadBatch]/{batchClassIdentifier}/{batchInstanceName }

Input Parameter Descriptions
batchClassIdentifier The identifier of the batch class in which user wishes to upload its batch.
batchInstanceName This name with which user wishes to upload the batch.

CheckList:-

  1. The value for batchClassIdentifier is compulsory and should be valid with permissions to the user to run the batch on it.
  2. The value for batchInstanceName is compulsory and if left empty then it will send an error.

Sample client code using apache commons http client:-

private static void uploadBatch () {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/uploadBatch/{BatchClassIdentifier}/{BatchInstanceName} “;

PostMethod mPost = new PostMethod(url);

// adding image file for processing

File file1 = new File(“C:\\sample\\sample1.tif”);

Part[] parts = new Part[1];

try {

parts[0] = new FilePart(file1.getName(), file1);

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

mPost.setRequestEntity(entity);

int statusCode = client.executeMethod(mPost);

String responseBody = mPost.getResponseBodyAsString();

// Generating result as responseBody.

System.out.println(statusCode + “***” + responseBody);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(mPost.getResponseBodyAsString());

}

catch (FileNotFoundException e) {

System.err.println(“File not found for processing.”);

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

}

}

}

Copy Batch Class

This API will create the copy of an existing batch class whose identifier is provided as input/source. Other parameters required for the batch class creation are as follows:

Request Method POST

Web Service URL:

http://{serverName}:{port}/dcma/rest/batchClass/copyBatchClass

Input Parameter Values Descriptions
batchClassName The Name of batch class should not be empty or contains characters like space(“ “) or hyphen(“-“) and should not be more than 255 characters. The unique character is used for naming the new copied batch class.
batchClassDescription This should be a non-empty Value This parameter is the description of the new copied batch class.
batchClassPriority The batch class priority cannot be null or empty and should be between 1 and 100 inclusive of both. The priority of the batch class.
batchUNCFolder The UNC folder name for the batch class. This UNC folder name for the new copied batch class.
copyBatchClassIdentifier This value should be non-empty and a preexisting Batch Class Idenitifer The identifier of the Batch Class which is used as reference for copying.
gridWorkflow Can be true or false States the workflow, is the batch class deployed as grid workflow or normal workflow.

Sample Input XML:

<?xml version=“1.0” encoding=“UTF-8”?>

<WebServiceParams>

<Params>

<Param>

<Name>batchClassName</Name>

<Value>NEW_BATCH_CLASS_NAME</Value>

</Param>

<Param>

<Name>batchClassDescription</Name>

<Value>NEW_BATCH_CLASS_DESCIPTION</Value>

</Param>

<Param>

<Name>batchClassPriority</Name>

<Value>NEW_BATCH_CLASS_PRIORITY</Value>

</Param>

<Param>

<Name>batchUNCFolder</Name>

<Value>NEW_BATCH_CLASS_UNC_FOLDER_NAME</Value>

</Param>

<Param>

<Name> copyBatchClassIdentifier </Name>

<Value>EXISTING_BATCH_CLASS_ID</Value>

</Param>

</Params>

</WebServiceParams>

Note: Values highlighted in blue should be replaced with corresponding values while executing the Web service for copying an existing batch Class.

Sample client code using apache commons http client:-

private static void createDocumentType() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/batchClass/copybatchClass“;

PostMethod mPost = new PostMethod(url);

// Adding Input XML file for processing

File file = new File(“C:\\sample\\Input.xml”);

Part[] parts = new Part[1];

try {

parts[0] = new FilePart(file.getName(), file);

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

mPost.setRequestEntity(entity);

int statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

String responseBody = mPost.getResponseBodyAsString();

// Generating result as responseBody.

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(mPost.getResponseBodyAsString());

}

catch (FileNotFoundException e) {

System.err.println(“File not found for processing.”);

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

}

}

}

Learn File:

This API will learn all the files present in the batch class folders for the batch class whose identifier is provided as input.

Request Method POST

Web Service URL:

http://{serverName}:{port}/dcma/rest/batchClass/learnFile/{BatchClassIdentifier}]

Input Parameter Values Descriptions
BatchClassIdentifier This value should be nonempty and a pre-existing Batch Class’s identifier. The value is provided in the URL only. The identifier of the batch class for which learning has to be done.

Note: – Replace the parameter BatchClassIdentifier in the input URL for which learning should be performed.

Sample client code using apache commons http client:-

private static void fileLearningService() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/batchClass/learnFile/{BatchClassIdentifier}“;

PostMethod mPost = new PostMethod(url);

try {

int statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

String responseBody = mPost.getResponseBodyAsString();

// Generating result as responseBody.

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(mPost.getResponseBodyAsString());

}

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

}

}

}

Document Type Creator:

This API will create the new document type for the specified batch class supplied as an input.

Request Method POST

Web Service URL:

http://{serverName}:{port}/dcma/rest/batchClass/documentTypeCreator

Input Parameters:

Input Parameter Values Descriptions
BatchClassIdentifier This value should be nonempty and a pre-existing Batch Class’s identifier. The value is provided in the URL only. The identifier of the batch class for which learning has to be done.
Input Parameter Value Description
documentTypeName The document type name should be nonempty and should not contain ‘*’ symbol. This parameter is the unique name of the new document type to be create
documentTypeDescription This should be a non-empty Value This parameter is the description of the new document type created
minConfidenceThreshold The minimum confidence threshold cannot be null and should be between 0 and 100 inclusive of both. The minimum threshold value for the documents recognition
formProcessingProjectFile The name of the RSP file for recostar extraction This file would be used for KV extraction by Recostar engine
batchClassIdentifier This value should be nonempty and a pre-existing Batch Class Identifier The identity of the Batch Class Identifier under which document type is to be created
Hidden Can be true or false This parameter signifies whether new document type created should be hidden or not.

Check List:-

  1. documentTypeName should be unique and non-empty.
  2. minConfidenceThreshold should be a value between 0 and 100.
  3. formProcessingProjectFile should be a name of pre-existing RSP file.
  4. batchClassIdentifier should be an identity of pre-existing Batch Class.

Sample Input XML:

<?xml version=“1.0” encoding=“UTF-8”?>

<WebServiceParams>

<Params>

<Param>

<Name>documentTypeName</Name>

<Value>NEW_DOCUMENT_TYPE_NAME</Value>

</Param>

<Param>

<Name>documentTypeDescription</Name>

<Value>NEW_DOCUMENT_TYPE_DESCRIPTION</Value>

</Param>

<Param>

<Name>minConfidenceThreshold</Name>

<Value>CONFIDENCE_THRESHOLD</Value>

</Param>

<Param>

<Name>firstPageProjectFile</Name>

<Value>RSP_FILE_NAME</Value>

</Param>

<Param>

<Name>firstPageProjectFile</Name>

<Value>RSP_FILE_NAME</Value>

</Param>

<Param>

<Name>batchClassIdentifier</Name>

<Value>BATCH_CLASS_ID</Value>

</Param>

<Param>

<Name>hidden</Name>

<Value>TRUE/FALSE</Value>

</Param>

</Params>

</WebServiceParams>

Note: Values highlighted in blue should be replaced with corresponding values while executing the Web service for copying an existing batch Class.

Sample client code using apache commons http client:-

private static void createDocumentType() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/batchClass/documentTypeCreator“;

PostMethod mPost = new PostMethod(url);

// Adding Input XML file for processing

File file = new File(“C:\\sample\\Input.xml”);

Part[] parts = new Part[1];

try {

parts[0] = new FilePart(file.getName(), file);

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

mPost.setRequestEntity(entity);

int statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

String responseBody = mPost.getResponseBodyAsString();

// Generating result as responseBody.

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(mPost.getResponseBodyAsString());

}

catch (FileNotFoundException e) {

System.err.println(“File not found for processing.”);

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

}

}

}

Upload files for learning files :

This API will upload learning files for a particular batch class to Shared Folder\ [BatchClassID]\lucene-search-classification-sample folder

[Document-Type] _First_Page

[Document-Type] _Middle_Page

[Document-Type] _Last_Page

Or image-classification-sample folder [Application-Installed-Path]\Shared Folder\ [BatchClassID]\image-classification-sample folder

[Document-Type] _First_Page

[Document-Type] _Middle_Page

[Document-Type] _Last_Page

Or, both depending upon input supplied.

This Web Service API can upload files (tif, tiff or zip file containing tif/tiff files) for multiple document type of a batch class. Only files will be uploaded without performing any operation.

The upload instruction will be in the form of specific xml format.

Request Method POST

Web Service URL:

http://{serverName}:{port}/dcma/rest/batchClass/uploadLearningFile]

Input Parameters:

Input Parameter Values Descriptions
batch_class_id This value should be an existing batch class Id. This Parameter specifies the Batch Class Id for which learning files need to be uploaded.
doc_type_name This should be an existing document type. This parameter specifies the document for which files are getting uploaded. In a single XML file can have multiple doc type name, as we can upload document for more than one doc type at a time.
learning_type Its value can be ‘’lucene’’, ‘’Image’’ or ‘’both’’.
If learning type is selected as Lucene file will be uploaded under  Lucene-search-classification-sample folder  only, if learning type is image than file will be uploaded under image-classification-sample folder only. For learning_type value as ‘Both’, files will be uploaded under Lucene as well as Image folder.
file_name Valid FileName. File can be either of tif, tiff extension or zip extension. In case of zip file the files compressed must be of extension tif, tiff. This API accepts learning files in the form of tif, tiff files or an archive of tif, tiff files. To upload multiple files to a directory user can either use multiple file_name tag or create an archive of all files and upload that archive (.zip file). The structure ofr archive is fixed. It need to be upload.zip- upload -{file1, file 2, file 3}.

Other than above parameters specified in xml files, user need to upload a complete and accurate XML with other learning files(tif, tiff, zip files).

Sample XML file format:

<upload_learning_files>

<batch_class_id>BATCH_CLASS_ID</batch_class_id>

<doc_type>

<doc_type_name>DOCUMENT_TYPE_NAME_1</doc_type_name>

<learning_type>LEARNING_TYPE</learning_type>

<page_type_first>

<files_to_be_uploaded>

<file_name>FILE_NAME_1</file_name>

<file_name> FILE_NAME_2</file_name>

</files_to_be_uploaded>

</page_type_first>

<page_type_middle>

<files_to_be_uploaded>

<file_name>FILE_NAME_1</file_name>

<file_name> FILE_NAME_2</file_name>

</files_to_be_uploaded>

</page_type_middle>

<page_type_last>

<files_to_be_uploaded>

<file_name>FILE_NAME_1</file_name>

<file_name> FILE_NAME_2</file_name>

</files_to_be_uploaded>

</page_type_last>

</doc_type>

<doc_type>

</doc_type>

</upload_learning_files>

Note:

  • Values highlighted in blue should be replaced with corresponding values while executing the Web service for uploading Files for learning.
  • Parameters page_type_first, page_type_middle, page_type_last are not manadatory.

Check List:-

Before uploading following points need to ensured first:

  1. XML and other required learning files are attached with the request.
  2. Name of learning files mentioned in the XML must match with the file name uploaded with the request.
  3. XMl format must be same as it shown in Sample XML format. Don’t rearrange the xml elements.
  4. batch_class_id, doc_type_name, learning_type, are mandatory information and must need to be specified. User cannot omit these fields.
  5. If user don’t upload file for particular page type(first, middle and last). He can omit the whole block. (Starting from page_type_first, page_type_middle or page_type_last ).
  6. All the upload information need to be uploaded in single XML file. User cannot split information across different XML and then upload all of them. Only 1 xml will be allowed at a time.
  7. In a xml file there needs to be single batch_class_id, but there can be multiple <doc_type>. Inside a doc_type there can only one doc_type_name, learning_type , page_type_first, page_type_middle, page_type_last block.
  8. If learning files for a particular page folder(ex. First page) are getting uploaded in a single file zip. Zip folder need to follow a specific structure. {zipfileName.zip} – {zipFileName folder} -{file1, file 2, file3 and so on}. Zip file name and first folder name inside zip file needs to be same.

””Sample client code using apache commons http client:-

private static void learnFile() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/batchClass/uploadLearningFile“;

PostMethod mPost = new PostMethod(url);

// Adding Input XML file for processing

File file = new File(“C:\\sample\\Input.xml”);

File file1 = new File(“C:\\sample\\first.tif”);

File file2 = new File(“C:\\sample\\second.tif”);

……………………………………………..

Part[] parts = new Part[number of files need to be uploaded];

try {

parts[0] = new FilePart(file.getName(), file);

parts[1] = new FilePart(file1.getName(), file1);

parts[2] = new FilePart(file2.getName(), file2);

.

parts[n] = new FilePart(filen.getName(), filen);

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

mPost.setRequestEntity(entity);

// send post request to server

int statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

String responseBody = mPost.getResponseBodyAsString();

// Generating result as responseBody.

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(mPost.getResponseBodyAsString());

}

}catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

}

}

}

ExtractKVForDocumentType:

This Web Service API is used to perform Key Value Extraction for the Document type of the specified Batch Class, on the Basis of HOCR XML provided as an input.

Request Method POST

Web Service URL:

http://{serverName}:{port}/dcma/rest/batchClass/ExtractKVForDocumentType

Input Parameters:

Input Parameter Value Description
BATCH_CLASS_IDENTIFIER

 

This value should be an existing batch class Id. This Parameter specifies the Batch Class Id for key Value extraction needs to be performed.
DOCUMENT_TYPE

 

This should be an existing document type. This tag should contain name of document type of the Batch Class Identifier

for which KV extraction to be performed through Web service API.

HOCR_ZIP_FILE

 

HOCR XML/(s) zipped to a folder name should be specified ZIP file which is uploaded, containing HOCR XML’s on basis

of which extraction is performed. For example HOCR.zip. Please add .zip extension to file name.

Check List:-

  1. Batch_Class_Identifier should be existing and non-empty.
  2. DOCUMENT_TYPE should be existing and non-empty.
  3. HOCR_ZIP_FILE should contain file*_HOCR.xml zipped directly to a folder

Sample Input XML:

<KV_Extraction_DocType>

<Batch_Class>BATCH_CLASS_IDENTIFIER</Batch_Class> <Document_Type>DOCUMENT_TYPE</Document_Type>

<HOCR_File>HOCR_ZIP_FILE</HOCR_File>

</KV_Extraction_DocType>

Note: Values highlighted in blue should be replaced with corresponding values while executing the Web service for performing key value extraction.

Sample client code using apache commons http client:-

private static void performKeyValueExtraction() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/batchClass/ExtractKVForDocumentType“;

PostMethod mPost = new PostMethod(url);

// Adding Input XML file for processing

File file = new File(“C:\\sample\\Input.xml”);

File hocrZipFile = new File(“C:\\sample\\Input_HOCR.zip”);

Part[] parts = new Part[2];

try {

parts[0] = new FilePart(file.getName(), file);

parts[1] = new FilePart(hocrZipFile.getName(),hocrZipFile);

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

mPost.setRequestEntity(entity);

int statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

String responseBody = mPost.getResponseBodyAsString();

// Generating result as responseBody.

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(mPost.getResponseBodyAsString());

}

catch (FileNotFoundException e) {

System.err.println(“File not found for processing.”);

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

}

}

}

CopyDocumentType

This Web Service API is used to copy an Existing document type for a batch class to create new document type. It takes an XML as input containing information like Existing Document type Name, New Document type name its Description and confidence threshold and output of this API is new document type in line with existing document type.

””Request Method: POST

Web Service URL:

http://{serverName}:{port}/dcma/rest/batchClass/copyDocumentType]

Input Parameters for the Web Service a as follow:

Input Parameter Value Description
BATCH_CLASS_ID It should contain a value of an existing batch Class Identifier. The identifier of the Batch Class whose document type is copied.
EXISTING_DOC_TYPE_NAME This should be a non-empty Value containing existing document type name. This parameter should contain name of document type of the Batch Class Identifier

which is to be copied through Web service API.

NEW_DOC_TYPE_NAME This value should be unique name for new document type created. This parameter should unique name for new document type which is to be created.
NEW_DOC_TYPE_DESCRIPTION This value should contain description for new document type created. This parameter should description for new document type which is to be created.
CONFIDENCE_THRESHOLD Value should be between 0.0 to 100.0 inclusive of both values. This parameter should contain confidence threshold value, between 0 to 100 for new document type.

Sample Input XML :

<Copy_Document_Type>

<Batch_Class_Id>BATCH_CLASS_ID</Batch_Class_Id>

<Existing_Doc_Type_Name>EXISTING_DOC_TYPE_NAME</Existing_Doc_Type_Name>

<New_Document_Type>

<Name>NEW_DOC_TYPE_NAME</Name>

<Description>NEW_DOC_TYPE_DESCRIPTION</Description>

<Confidence_Threshold>CONFIDENCE_THRESHOLD</Confidence_Threshold>

</New_Document_Type>

</Copy_Document_Type>

Note: Values highlighted in blue should be replaced with corresponding values while executing the Web service for copying an existing document type for a batch Class.

Sample client code using apache commons http client:-

private static void copyDocumentType() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/batchClass/copyDocumentType“;

PostMethod mPost = new PostMethod(url);

// Adding Input XML file for processing

File file = new File(“C:\\sample\\Input.xml”);

Part[] parts = new Part[1];

try {

parts[0] = new FilePart(file.getName(), file);

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

mPost.setRequestEntity(entity);

int statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

String responseBody = mPost.getResponseBodyAsString();

// Generating result as responseBody.

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(mPost.getResponseBodyAsString());

}

catch (FileNotFoundException e) {

System.err.println(“File not found for processing.”);

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

}

}

}

Create_HOCR_XML_for Batch_Class

This Web Service API is used to create HOCR XML of Batch Class of single page tiff/tif passes as an input. This Web Service API requires two Inputs i.e. Input Sample and tif/tiff file to create HOCR_xml.

On the basis of Batch Class Identifier provided as an input,this API will Extract plugin configuration settings of RECOSTAR_HOCR/TESSERACT_HOCR plugin in Page Process module, if property named “Recostar Switch” value is turned ON then process of OCRing will be done from Recostar and its corresponding plugin configurations will be used else Tesseract will be used to perform process of OCRing.

Request Method POST

Web Service URL:

http://{serverName}:{port}/dcma/rest/batchClass/createHOCRforBatchClass]

Input parameters required for the batch class creation are as follows:

Input Parameter Values Descriptions
BATCH_CLASS_ID It should contain a value of an existing batch Class Identifier. The identifier of the Batch Class whose HOCR_XML needs to be created.
FILE_NAME This should be a non-empty Value containing file name with tif/tiff extension. This parameter value should contain name tif/tiff file for which HOCR XML need to be created with extension specified .For example Application-Checklist.tif

Check list:

  1. Batch Class Identifier should be an existing one.
  2. Only single page tif/tiff should be passed as an input.

Sample Input XML :

<WebServiceParams>

<Params>

<Param>

<Name>BATCH_CLASS_IDENTIFIER</Name>

<Value>BATCH_CLASS_ID</Value>

</Param>

<Param>

<Name>INPUT_FILE_NAME</Name>

<Value>FILE_NAME</Value>

</Param>

</Params>

</WebServiceParams>

Note: Values highlighted in blue should be replaced with corresponding values while executing the Web service for creating HOCR XML for Batch Class.

Sample client code using apache commons http client:-

private static void createHOCRXML() {

HttpClient client = new HttpClient();

String url = “http://localhost:8080/dcma/rest/batchClass/copybatchClass“;

PostMethod mPost = new PostMethod(url);

// Adding Input XML file for processing

File file = new File(“C:\\sample\\Input.xml”);

File imageFile = new File(“C:\\sample\\SampleImage.tif”);

Part[] parts = new Part[2];

try {

parts[0] = new FilePart(file.getName(), file);

parts[1] = new FilePart(imageFile.getName(),imageFile);

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

mPost.setRequestEntity(entity);

int statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

String responseBody = mPost.getResponseBodyAsString();

// Generating result as responseBody.

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(mPost.getResponseBodyAsString());

}

catch (FileNotFoundException e) {

System.err.println(“File not found for processing.”);

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

}

}

}

Run Batch Instance

This API is used to run the batch instance from READY_FOR_REVIEW or READY_FOR_VALIDATION module to next phase in workflow. User can restart those batch instances those are accessible by their role.

Request Method: GET

Web Service URL:

http://{serverName}:{port}/dcma/rest/runBatchInstance/{batchInstanceIdentifier]}

Input Parameters for the Web Service are as follows:

Input Parameter Value Description
batchInstanceIdentifier It should contain a value of an existing batch instance Identifier. The parameter value should contain of the Batch Class whose document type is copied.

Note: Value highlighted curly braces in input URL should be replaces with corresponding values.Module name should end with _module.

Sample client code using apache commons http client:-

private static void runBatchInstance() {

HttpClient client = new HttpClient();

String url = ” http://localhost:8080/dcma/rest/runBatchInstance/BI15

PostMethod mPost = new PostMethod(url);

// Adding Input XML file for processing

File file = new File(“C:\\sample\\Input.xml”);

Part[] parts = new Part[1];

try {

parts[0] = new FilePart(file.getName(), file);

MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());

mPost.setRequestEntity(entity);

int statusCode = client.executeMethod(mPost);

if (statusCode == 200) {

System.out.println(“Web service executed successfully.”);

String responseBody = mPost.getResponseBodyAsString();

// Generating result as responseBody.

System.out.println(statusCode + ” *** ” + responseBody);

else if (statusCode == 403) {

System.out.println(“Invalid username/password.”);

else {

System.out.println(mPost.getResponseBodyAsString());

}

catch (FileNotFoundException e) {

System.err.println(“File not found for processing.”);

catch (HttpException e) {

e.printStackTrace();

catch (IOException e) {

e.printStackTrace();

finally {

if (mPost != null) {

mPost.releaseConnection();

}

}

}




Was this article helpful to you?

J.D. Abbey

Comments are closed.