Virtual File System Service
Purpose
The Virtual File System Service provides file operations — read, write, copy, move, delete — against the Virtual File System from within a Javascript or Python Processor. It allows you to manage files programmatically in your script code, independent of any VFS Source or Sink.
The Virtual File System Service is a pure script-facing service. It has no input/output ports and cannot be used as a standalone processing step in a Workflow. It must be invoked from a Javascript Processor or a Python Processor.
Configuration
Name & Description
-
Virtual FS Service name: Name of the Asset. This is the name you will use in your script to reference this service (e.g.services.MyVfsService). Spaces are not allowed in the name. -
Virtual FS Service description: Enter a description.
The Asset Usage box shows how many times this Asset is used and which parts are referencing it.
Click to expand and then click to follow, if any.
Required Roles
In case you are deploying to a Cluster which is running (a) Reactive Engine Nodes which have (b) specific Roles configured, then you can restrict use of this Asset to those Nodes with matching roles.
If you want this restriction, then enter the names of the Required Roles here. Otherwise, leave empty to match all Nodes (no restriction).
Virtual FS Service Settings
Connection: Select the Virtual File System Connection asset to use. This connection defines the mount points and storage backends (local filesystem, SMB, OneDrive, SharePoint, etc.) accessible to this service. The service will only be able to operate within the paths defined by that connection's mount points.
Service Functions
The Virtual File System Service provides the following built-in functions:
| Function | Description |
|---|---|
CopyFile | Copy a file from one location to another in the virtual file system |
DeleteFile | Delete a file from the virtual file system |
FileExists | Check if a file exists within the virtual file system; returns a boolean |
MoveFile | Move a file from one location to another |
ReadFile | Read a file from the virtual file system and return its content |
WriteFile | Write a file into the virtual file system |
Example — Using Virtual File System from a Script
Step 1 — Create a Virtual File System Connection
Before using the Virtual File System Service, configure a Virtual File System Connection with the mount points you need to access. This connection defines which filesystem backends (local paths, SMB shares, OneDrive, SharePoint) are available.
Step 2 — Create the Virtual File System Service
Create a new Virtual File System Service Asset. In Virtual FS Service Settings, select your Virtual File System Connection.
Step 3 — Map the Service in a Script Processor
In your Javascript Processor or Python Processor, add a Service Mapping:
- Service: Select your Virtual File System Service
- Logical Service Name:
MyVfsService(or any name you will use in your script)
Step 4 — Use in Your Script
You can now call any of the service functions from your script. The functions are invoked identically to any other service.
- JavaScript
- Python
Copy a file:
export function onMessage() {
services.MyVfsService.CopyFile({
sourcePath: '/data/inbox/report.pdf',
targetPath: '/data/archive/report.pdf'
});
}
Check if a file exists:
export function onMessage() {
const exists = services.MyVfsService.FileExists({
path: '/data/inbox/report.pdf'
});
if (!exists.data) {
processor.logWarning('File not found, skipping');
return;
}
// Continue processing...
}
Read and process a file:
export function onMessage() {
const fileContent = services.MyVfsService.ReadFile({
path: '/data/inbox/data.json'
});
if (fileContent && fileContent.data) {
const records = JSON.parse(fileContent.data.content);
processor.logInfo('Loaded ' + records.length + ' records');
}
}
Write a file:
export function onMessage() {
services.MyVfsService.WriteFile({
path: '/data/outbox/result.json',
content: JSON.stringify(resultData)
});
}
Move a file:
export function onMessage() {
services.MyVfsService.MoveFile({
sourcePath: '/data/inbox/report.pdf',
targetPath: '/data/archive/report.pdf'
});
}
Delete a file:
export function onMessage() {
services.MyVfsService.DeleteFile({
path: '/data/inbox/report.pdf'
});
}
Copy a file:
def on_message():
services.MyVfsService.CopyFile({
'sourcePath': '/data/inbox/report.pdf',
'targetPath': '/data/archive/report.pdf'
})
Check if a file exists:
def on_message():
exists = services.MyVfsService.FileExists({
'path': '/data/inbox/report.pdf'
})
if not exists.data:
processor.log_warning('File not found, skipping')
return
# Continue processing...
Read and process a file:
def on_message():
file_content = services.MyVfsService.ReadFile({
'path': '/data/inbox/data.json'
})
if file_content and file_content.data:
records = json.loads(file_content.data.content)
processor.log_info('Loaded ' + str(len(records)) + ' records')
Write a file:
def on_message():
services.MyVfsService.WriteFile({
'path': '/data/outbox/result.json',
'content': json.dumps(result_data)
})
Move a file:
def on_message():
services.MyVfsService.MoveFile({
'sourcePath': '/data/inbox/report.pdf',
'targetPath': '/data/archive/report.pdf'
})
Delete a file:
def on_message():
services.MyVfsService.DeleteFile({
'path': '/data/inbox/report.pdf'
})
The parameter names (sourcePath, targetPath, path, content) match the service function definitions in the source. Confirm these with the UI or Service Testing tab if they differ in your version.
Service Testing
Service Testing
layline.io provides a test facility for testing your Services before you deploy them. In this way, you save time and effort by testing your Services without having to deploy and activate a whole Project with Workflows.
Once you have configured your Service(s), you can test them:
Within your Asset Configuration tab (1), switch to the Test tab (2) to test your Service.

Test Facility Toolbar
The toolbar provides the following options:

The Testing tab provides two major views:
- Testcase configuration: This is where you define the testcases to be executed.
- Testcase execution: This is where you can execute the testcases and see the results.
You switch between these two views by clicking on the leftmost icon in the toolbar (1).
Let's start with the Testcase configuration view.
Testcase Configuration
The concept of the Testing is to define a set of Testcases which can be executed in a batch or individually. For this purpose, you can define multiple Testcases and configure them individually. I.e. each Testcase groups a number of indidivual tests which can be executed individually or in a batch.
Adding a Testcase
Click Add Testcase in the toolbar to add a new testcase:

A new Testcase is added.
It is automatically named New<Service Asset Name>Test (3) and added to the list of Testcases (2).
Service test name(3): You can change the name of the Testcase here.Service test description(4): You can add a description to the Testcase here.
Test Case Setup
Basics
In this section you define the individual tests to be executed for this Testcase.
To start, click # END in the toolbar:
A new test is added to the list of tests (1), and the test is opened for configuration (2).

Next we fill in the details:
-
Test name(3): You can change the name of the Test here. -
Test description(4): You can add a description to the Test here. -
Service function to test(5): Select the Service function to test here.This list contains all Service functions which are defined in the Service Asset. Pick the one you want to test.

Once a Service function is selected, the system will automatically create a skeleton to fill in the respective parameters for the selected Service function.

Service Function Input Parameters
-
Service Function Input Parameters(6): Fill in the respective parameters for the selected Service function.In our example we have a function
GetAlertsForSitewhich takes two parametersbaseurlandriskId. If we click onAdd memberin the skeleton table the system will allow you to select the respective parameter from the list of available parameters:
Once you have selected the parameter, the system will automatically add the respective parameter name. You then add the respective value for the parameter:

Service Function Evaluation Parameters
To automatically evaluate the result, you can add a script which analyzes the results.
Testcase Execution
Once you have configured your Testcases, you can execute them.
There are two ways on how to trigger execution:
-
Option 1: Select
Run selected testin the toolbar (1) to execute the currently selected Testcase.
Executing a test this way will switch the tab to the Testcase execution view, execute the test and show the results.
-
Option 2: Switch to the Testcase execution view by clicking on the leftmost icon in the toolbar (1) select the test to execute, and then hit the
playbutton next to the test.
Each option will take us to the Testcase execution view:

In this view you can find the Testcase (1) and the Tests (2) we have created.
If we had created additional tests for this Testcase, they would be listed here as well.
Question marks indicate that the test has not yet been executed.
We can now either execute all tests, or run them individually:
-
Run all Tests(1): Click this button to execute all tests. -
Run Testcase(2): Click this button to a Testcase with all its underlying individual tests.
-
Run individual Test(3): Click this button next to a test to execute this individual test.
Once a test has been executed, the question mark will be replaced by a green check mark or a red cross depending on whether the test was successful or not.
The right hand-panel will show the results of the test execution respectively:

In case of errors, the system will show the error message for further investigation.
See Also
- Virtual File System Connection — configuring mount points and storage backends
- JavaScript Processor — calling services from JavaScript
- Python Processor — calling services from Python