Copyright (C) 2018 The Open Library Foundation
This software is distributed under the terms of the Apache License, Version 2.0. See the file "LICENSE" for more information.
- Introduction
- Compiling
- Docker
- Installing the module
- Deploying the module
- How to fill module with data for testing purposes
FOLIO compatible source record storage module.
Provides PostgreSQL based storage to complement the data import module. Written in Java, using the raml-module-builder and uses Maven as its build system.
mvn install
See that it says "BUILD SUCCESS" near the end.
Build the docker container with:
docker build -t mod-source-record-storage .
Test that it runs with:
docker run -t -i -p 8081:8081 mod-source-record-storage
Follow the guide of Deploying Modules sections of the Okapi Guide and Reference, which describe the process in detail.
First of all you need a running Okapi instance. (Note that specifying an explicit 'okapiurl' might be needed.)
cd .../okapi
java -jar okapi-core/target/okapi-core-fat.jar dev
We need to declare the module to Okapi:
curl -w '\n' -X POST -D - \
-H "Content-type: application/json" \
-d @target/ModuleDescriptor.json \
http://localhost:9130/_/proxy/modules
That ModuleDescriptor tells Okapi what the module is called, what services it provides, and how to deploy it.
Next we need to deploy the module. There is a deployment descriptor in
target/DeploymentDescriptor.json
. It tells Okapi to start the module on 'localhost'.
Deploy it via Okapi discovery:
curl -w '\n' -D - -s \
-X POST \
-H "Content-type: application/json" \
-d @target/DeploymentDescriptor.json \
http://localhost:9130/_/discovery/modules
Then we need to enable the module for the tenant:
curl -w '\n' -X POST -D - \
-H "Content-type: application/json" \
-d @target/TenantModuleDescriptor.json \
http://localhost:9130/_/proxy/tenants/<tenant_name>/modules
For using module's endpoints it provides generated by RMB client. This client is packaged into the lightweight jar.
<dependency>
<groupId>org.folio</groupId>
<artifactId>mod-source-record-storage-client</artifactId>
<version>x.y.z</version>
<type>jar</type>
</dependency>
Where x.y.z - version of mod-source-record-storage.
SourceStorageClient is generated by RMB and provide methods for all modules endpoints described into the RAML file
// create client object with okapi url, tenant id and token
SourceStorageClient client = new SourceStorageClient("localhost", "diku", "token");
Clients methods works with generated by RMB data classes based on json schemas. mod-source-record-storage-client jar contains only generated by RMB DTOs and clients.
// create new record entity
Record record = new Record();
record.setRecordType(Record.RecordType.MARC);
record.setSourceRecord(new SourceRecord().withSource("source"));
Example with sending request to the mod-source-record-storage for creating new Record
// send request to mod-source-record-storage
client.postSourceStorageRecord(null, record, response->{
// processing response
if (response.statusCode() == 201){
System.out.println("Record is successfully created.");
}
});
See project MODSOURCE at the FOLIO issue tracker.