- 06 May 2024
- 2 Minutes to read
- Print
Install Shared Data Service add-on
- Updated on 06 May 2024
- 2 Minutes to read
- Print
Shared Data Service is an add-on for the Grassfish Windows and Linux Player. It can store data on the player and query data from the player via a REST web service interface.
This can be useful, for example, to send photos from a tablet directly to a player.
Install the add-on
You can either install the add-on on the server via an update package or locally on the player. To do so, perform the following steps:
Store the installation package in any folder on the player.
Open a console with administrator rights.
Enter the command that matches your operating system:
Windows: C:\GVClient\tools\current\gfBootstrap\gfBootstrap "[path to]\SharedDataService.zip"
Linux: sudo /opt/grassfish/tools/current/gfBootstrap/gfBootstrap "[path to]/SharedDataService.zip”
Use the add-on
SharedDataService is a console application written in ASP.NET Core. It provides two REST interfaces for storing and retrieving JSON documents and binary data. The data is stored and queried via a string key.
Perform a cleanup
A cleanup task runs every 30 seconds and permanently deletes all expired entries from the file system.
All stored data has a validity period measured in seconds. There are two variants:
Absolute: the validity is absolute and cannot be extended. Only re-saving can extend the validity.
Sliding: as long as the entry has not yet expired, the validity of each Get call is extended to now + expirationSeconds.
Configure add-on settings
You can edit the configuration settings in the user.config file. Depending on the operating system of the player, the path to the file is as follows:
Windows: C:\GVClient\addons\gfPlayer\SharedDataService\current\user.config
Linux: /opt/grassfish/addons/gfPlayer/SharedDataService/current/user.config
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><appSettings>
<add key="LogLevel" value="2"/></appSettings>
You can edit the following settings:
Key | Default | Description |
---|---|---|
LogLevel | 3 | 1 - Error 2 - Warn 3 - Info 4 - Debug 5 - Debug |
LogDir | ./log |
|
DataDir | ./data | Folder the binary data is stored in. |
DbConnectionString | Data source=./data/data.db |
|
MaxRequestBodySize | 52428800 | Maximum size of an HTTP request in bytes. |
ServiceUrls | http://*:5003 | URLs under which the service is accessible. Separated by ';'. |
MaxStorageSizeMegaBytes | -1 | If the maximum folder size of DataDir is exceeded, the service returns the HTTP code 507 to further insert calls. A value of <= 0 deactivates this limit. |
KeepLogsXDays | 10 | Logs older than KeepLogsXDays are automatically deleted. A value of <= 0 deactivates this function. |
Access Swagger
After launching the application, you can access the Swagger user interface at http://localhost:5003/swagger.
Examples
Files
Get List | |
Request: GET http://localhost:5003/api/Files
| Response: HTTP/1.1 200 OK Date: Wed, 16 May 2018 06:28:54 GMT Content-Type: application/json; charset=utf-8 Server: Kestrel Transfer-Encoding: chunked |
Get File | |
Request: GET http://localhost:5003/api/Files/{key}
| Response: HTTP/1.1 200 OK Date: Wed, 16 May 2018 06:30:09 GMT Content-Type: image/jpeg Server: Kestrel Content-Length: 378299 Last-Modified: Wed, 16 May 2018 06:28:48 GMT Accept-Ranges: bytes Access-Control-Allow-Origin: *
BINARYDATA... |
Delete File | |
Request: DELETE http://localhost:5003/api/Files/{key}
| Response: HTTP/1.1 200 OK Date: Wed, 16 May 2018 06:34:33 GMT Server: Kestrel Content-Length: 0 |
Insert/Update File (application/json) | |
Request: PUT http://localhost:5003/api/Files/sample_text HTTP/1.1 Content-Type: application/json
{ "expirationType": "Absolute", "expirationSeconds": 120, "mimeType": "text/plain", "data": "VGVzdCBUZXh0" }
| Response: HTTP/1.1 201 Created Date: Wed, 16 May 2018 06:41:18 GMT Content-Type: application/json; charset=utf-8 Server: Kestrel Transfer-Encoding: chunked Location: http://localhost:5003/api/Files/sample_text
{ "key": "sample_text" } |
Insert/Update File (multipart/form-data) | |
Request: POST http://localhost:5003/api/Files/upload HTTP/1.1 Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryBz1rPpiFH0Pj0RAN
------WebKitFormBoundaryBz1rPpiFH0Pj0RAN Content-Disposition: form-data; name="key"
key123 ------WebKitFormBoundaryBz1rPpiFH0Pj0RAN Content-Disposition: form-data; name="expirationType"
Absolute ------WebKitFormBoundaryBz1rPpiFH0Pj0RAN Content-Disposition: form-data; name="expirationSeconds"120------WebKitFormBoundaryBz1rPpiFH0Pj0RAN Content-Disposition: form-data; name="file"; filename="test.txt" Content-Type: text/plain
dsfgsdfgsdfgsdfgdfgdfgdghfghdfghfgh ------WebKitFormBoundaryBz1rPpiFH0Pj0RAN--
| Response: HTTP/1.1 201 Created Date: Wed, 16 May 2018 06:42:58 GMT Content-Type: application/json; charset=utf-8 Server: Kestrel Transfer-Encoding: chunked Location: http://localhost:5003/api/Files
{ "key": "key123" } |
JSON
Get List | |
Request: GET http://localhost:5003/api/Json
| Response: HTTP/1.1 200 OK Date: Wed, 16 May 2018 06:54:45 GMT Content-Type: application/json; charset=utf-8 Server: Kestrel Transfer-Encoding: chunked
[ "sample_json" ] |
Get JSON Document | |
Request: GET http://localhost:5003/api/Files/{key}
| Response: HTTP/1.1 200 OK Date: Wed, 16 May 2018 06:55:39 GMT Content-Type: application/json; charset=utf-8 Server: Kestrel Transfer-Encoding: chunked
{ "expirationType": 0, "expirationSeconds": 117, "value": {} } |
Delete JSON Document | |
Request: DELETE http://localhost:5003/api/Json/{key}
| Response: HTTP/1.1 200 OK Date: Wed, 16 May 2018 06:56:13 GMT Server: Kestrel Content-Length: 0 |
Insert/Update JSON Document | |
Request: PUT http://localhost:5003/api/Json/sample_json HTTP/1.1 Content-Type: application/json
{ "expirationType": "Absolute", "expirationSeconds": 120, "value": {} }
| Response: HTTP/1.1 201 Created Date: Wed, 16 May 2018 06:57:06 GMT Content-Type: application/json; charset=utf-8 Server: Kestrel Transfer-Encoding: chunked Location: http://localhost:5003/api/Json/sample_json
{ "key": "sample_json" } |