×

Please give details of the problem

Docs

Find

SEC-File Reader Adapter

The "File Reader Adapter" is used to retrieve files from a local server. It requires the "Connector agent" and the "Protocol Manager" to be installed and running. Please follow the SEC - Installation Guide.

For this guide the following is assumed :

  • The SEC manager is running on the server and a tunnel is open and configured. You can find instructions on how to install and configure the SEC here.
  • The server has Java installed.
  • The ping port on the manager is 4444 (this can be configured in the adapter and the manager).
  • The manager is running on the same server as the adapter (127.0.0.1).

Install and Configure the Adapter

  • Download and unzip the SEC File Reader zip file on your local server.
  • You must navigate to [install-path]/configFiles and modify the Handler.config and the fileAdapter.config files.

NOTE: It is recommended that the Adapter be installed in a "Adapters" folder inside the SEC installation path.

The Handler.config file should look like this :

1
2
3
4
5
6
7
8
#Generic Protocol Configuration
protocol = fileReader
protocolClass = com.runmyprocess.sec.FileReader
handlerHost = 127.0.0.1
connectionPort = 5832
managerHost = 127.0.0.1
managerPort = 4444
pingFrequency = 300

Where :

  • protocol is the name to identify our Adapter.
  • protocolClass is the class of the Adapter.
  • handlerHost is where the Adapter is running.
  • connectionPort is the port of the adapter where data will be received and returned.
  • managerHost is where the SEC is running.
  • managerPort is the port where the SEC is listening for ping registrations.
  • pingFrequency is the frequency in which the manager will be pinged (at least three times shorter than what's configured in the manager).

The fileReader.config file should look like this :

1
2
#fileReader Configuration
basePath=C:\\/Users\\/RMP\\/Desktop\\/

Where :

  • basePath is the path from where the received path will look for the file.

Note: Make sure you use the correct base path and use the escape characters to navigate through folders on Windows machines.

Running and Testing the Adapter

You can now run the Adapter by executing the FileReaderAdapter.jar in the installed path :

1
java -jar FileReader.jar

Note: Make sure that you have launched the [Protocol Manager] (/Integration_Guide/SEC/Installation_Guide) and it is running on port 8080.

If everything is configured correctly, you can now place a request from RunMyProcess to retrieve a file:

POST on http://127.0.0.1:8080/

Content-Type: application/json

Accept: application/json

Content (example):

1
2
3
4
5
6
{
"protocol":"fileReader",
"data":{
        "path":"a.log"
    } 
}

The expected return is a JSON object that should look like this :

1
2
3
4
5
6
7
{
"SECStatus":200,
"file":{
    "file":"SEVMTE8h",
    "fileName":"a.log"
    }
}

Where "file" contains the return information and "file.file" is the file content base64 encoded.

Note: if you are having problems, make sure that:

  • the Protocol Manager and the File Reader have the same ping port configuration (4444 by default).
  • the Protocol Manager is running on the port you are posting to (8080 by default) with no errors on the console.
  • navigating to http://127.0.0.1:8080/ on your browser returns a success message and the fileReader adapter.

Automatic launching.

In order to access adapter resources from RunMyProcess, the Connector Agent, Protocol Manager and the required adapters must be running. You can create a script (shell script or bat file) to launch all resources. For example, in windows, you can create a bat file that looks like this:

1
2
3
4
5
6
7
@echo off
cd %SECPATH%\data-connector-agent\bin
call start "Tunnel" runagent.bat
cd %SECPATH%\jetty7.6.11
start "Manager" java -jar start.jar
cd %SECPATH%\Adapters\file_reader
start "FileReaderAdapter" java -jar FileReaderAdapter.jar

Note: in the example above note that the %SECPATH% environment variable is pointing to the installation path of the SEC. Also note that the Adapter is inside an "Adapters" folder in the SEC installation folder. We recommend you follow this best practice.