×

Please give details of the problem

Skip to content

FileWriter Adapter

The FileWriter adapter is used to write to files on a local system from RunMyProcess DigitalSuite.

Prerequisites

The following prerequisites must be fulfilled to install and run the FileWriter adapter:

  • You must install the adapter on a local system in your environment. This can either be the system where you have installed the DigitalSuite EnterpriseConnect Agent, or a different one which is able to connect to the Agent's host.

  • You can install the adapter several times in your environment, for example, to write to files on different systems. The identifier of the adapter (protocol setting in the handler.config configuration file) must be unique for each of the installations.

  • The file system where the files are to be written must be on the same system or directly accessible from the system where the adapter is installed.

Installing the Adapter

To install the adapter:

  1. Download the following ZIP file: unified-adapter-[version].zip

    [version] is the current version number

    The ZIP file contains executables, licences, configuration files, and reference files for several adapters.

  2. Extract the ZIP file to a local folder. The following path is recommended:

    [parent-folder]\adapters\fileWriter

    [parent-folder] is a folder of your choice. If the EnterpriseConnect Agent is installed on the same machine, use its installation folder as the [parent-folder], for example, C:\ProgramFiles (x86)\dsec-agent.

  3. Copy the configuration files for the FileWriter adapter, fileWriter.config and handler.config, from the configFiles\fileWriter.reference subfolder to the configFiles folder, for example:

    copy configFiles\fileWriter.reference\*.config configFiles
    

    Overwrite existing files in the configFiles folder.

  4. If desired, delete obsolete files. Only the following folders and files are required in the fileWriter folder to use the adapter:

    fileWriter
    ├── configFiles
    │   ├── handler.config
    │   └── fileWriter.config
    ├── lib
    │   └── unified-adapter-[version].jar
    └── log.properties
    

    In addition, we recommend you keep the following:

    • runAdapter.bat batch file for starting the adapter on Microsoft Windows
    • fileWriter.reference subfolder in the configFiles folder for reference purposes

Configuring the Adapter

Configuration settings for the FileWriter adapter are required in the following configuration files:

Edit the files with a plain text editor.

handler.config

The handler.config file contains general configuration settings for connecting the adapter to the EnterpriseConnect Agent:

#Generic Protocol Configuration
protocol = fileWriter
protocolClass = org.runmyprocess.sec2.FileWriter
agentHost = 127.0.0.1:8080
pingFrequency = 1000
adapterConnectionInterval = 1000
offlineLogsMaxSize = 100
maxNumberOfLogsInBatch = 100
clusterEnabled = false
clusterAgentsHttpAddressList = localhost:8071,localhost:8072,localhost:8073

The settings have the following meaning:

  • protocol: The identifier of the adapter. If you install the adapter several times in your environment, the identifier must be unique for each of the installations, for example, fileWriter1 and fileWriter2.
  • protocolClass: The adapter's Java class.
  • agentHost: The IP address and port of the EnterpriseConnect Agent.
  • pingFrequency: The frequency in milliseconds in which the adapter pings the EnterpriseConnect Agent.
  • adapterConnectionInterval: The frequency in milliseconds in which the adapter tries to connect to the EnterpriseConnect Agent.
  • offlineLogsMaxSize: The maximum number of log entries that the adapter collects locally and sends to the EnterpriseConnect Agent when it re-connects to it after it was disconnected.
  • maxNumberOfLogsInBatch: The maximum number of log entries the adapter sends to the EnterpriseConnect Agent at a time. A value of 0 means that the number of log entries sent at a time is unlimited.
  • clusterEnabled: true if the EnterpriseConnect Agent is configured and running as a cluster, false otherwise.
  • clusterAgentsHttpAddressList: The IP addresses and ports of the EnterpriseConnect Agent cluster, if clusterEnabled is set to true.

fileWriter.config

The fileWriter.config file contains specific settings for the adapter:

#fileWriter Configuration   
basePath=

The setting has the following meaning:

  • basePath: The absolute path starting from which the files written by the adapter are stored. This path will be prepended to any file paths and names received from RunMyProcess DigitalSuite. For example: basePath=/projects/myproject/

Note: Make sure to use proper escape characters for navigating through folders on Microsoft Windows, for example: basePath=C:\\Users\\RMP\\Desktop\\

Starting the Adapter

The adapter needs to be running to be able to write to local files.

Before you start the adapter, make sure that the DigitalSuite EnterpriseConnect Agent is running.

To start the adapter:

  1. Change to the fileWriter installation folder.

  2. Execute the following command, depending on the operating system:

    • On Microsoft Windows: Execute the runAdapter.bat batch file.

    • On Linux: Execute the following command directly, or create and execute a corresponding shell script to do so:

      java -XX:+UseG1GC -XX:+ExitOnOutOfMemoryError -Djava.util.logging.config.file=./log.properties -cp lib/*: org.runmyprocess.sec2.AdapterHandler
      

Using the Adapter

If everything is configured and running correctly, you can place requests from RunMyProcess DigitalSuite to write to files in the local environment.

Request: POST on http://[agent-host]:[port]/, where [agent-host] and [port] are the IP address and port of the EnterpriseConnect Agent.

Content Type: application/json

Accept: application/json

Content (example):

{
"protocol":"fileWriter",
"data":{
        "path":"output.json",
        "data":"sampleData"
    } 
}

The content specified in data is appended to the end of the file given in path.

You can find a sample request like the one above in the fileWriter.reference\InputJSONExample.txt file in the fileWriter installation folder.

Return Object:

The expected return is a JSON object that looks as follows:

{
"SECStatus":200,
"file":{
    "bytesWritten":10,
    "fileName":"output.json"
    }
}

file contains the return information. file.bytesWritten provides the number of bytes written to the file.