×

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.

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).
  • The Unified Adapters zip file has been extracted to your local server as described here.

1 Configure the Adapter

The Adapter is configured by modifying the handler.config and by creating a fileAdapter.config file in the [SEC-PATH]\configFiles folder. A reference configuration file can be found in the \configFiles\fileReader.reference folder.

NB: 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.

2 Running and Testing the Adapter

You can now run the Adapter as follows:

On Windows:

1
runAdapter.bat

On Unix:

1
java -jar unified-adapter_${version}.jar

or (recommended):

1
java -server -Xmx512m -Xss256m -Djava.util.logging.config.file=./log.properties -jar unified-adapter_${version}.jar

Note: Make sure that you have launched the Protocol Manager 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.

3 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%\sec-agent-manzanillo\bin
call start "Tunnel" runagent.bat
cd %SECPATH%\jetty7.6.11
start "Manager" java -jar start.jar
cd %SECPATH%\Adapters\fileReader
start "FileReaderAdapter" java -jar unified-adapter_${version}.jar

Where version is the current unified adapter version installed on your server.

Note: For the above example, note that the %SECPATH% environment variable points 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.