Jira Legacy | ||||||
---|---|---|---|---|---|---|
|
Participants:
Role | Name | Approval |
---|---|---|
Solution Architect | ||
Java Lead | ||
Product Owner |
Spike points:
Table of Contents | ||||||||
---|---|---|---|---|---|---|---|---|
|
Storing EBSCO KB Credentials
Existing Solution:
Currently, mod-configuration
stores EBSCO KB Credentials as 3 separate config files, such as follows
|
|
|
Proposed Solution:
- move configuration from
mod-configuration
tomod-kb-ebsco-java
- store configuration information(
apiKey, url, customerId
) as one entity in db. DB schema, json schema and sample payload file can be found below.
Warning | ||
---|---|---|
| ||
current implementation assumed that there is no permission distinction between users and particular credentials. This means the following:
|
Method | Path | Permission(s) | Response | Note(s) | |||||
---|---|---|---|---|---|---|---|---|---|
GET | /eholdings/kb-credentials | kb-ebsco.credentials.collection.get | 200 OK(with collection) | ||||||
POST | /eholdings/kb-credentials | kb-ebsco.credentials.collection.post | 201 Created(with record) | ||||||
GET | /eholdings/kb-credentials/{credId} | kb-ebsco.credentials.item.get | 200 OK(with record) | {credId} - UUID of the credential | |||||
PUT | /eholdings/kb-credentials/{credId} | kb-ebsco.credentials.item.put | 204 No Content | {credId} - UUID of the credential | |||||
DELETE | /eholdings/kb-credentials/{credId} | kb-ebsco.credentials.item.delete | 204 No Content | {credId} - UUID of the credential
|
The appropriate files attached below:
DB schema |
| ||||||||||||||||
Json Example |
| ||||||||||||||||
Json schema |
|
Configuration cache
kb-ebsco-java sequence diagram
codex-ekb sequence diagram
UI mockups
Storing association between user and settings(EBSCO KB Credentials)
Proposed Solution:
Method | Path | Permission(s) | Response | Note(s) |
---|---|---|---|---|
GET | /eholdings/kb-credentials/{credId}/users | kb-ebsco.credentials.users.collection.get | 200 OK(with collection) | {credId} - UUID of the credential |
POST | /eholdings/kb-credentials/{credId}/users | kb-ebsco.credentials.users.collection.post | 201 Created(with record) | {credId} - UUID of the credential |
PUT | /eholdings/kb-credentials/{credId}/users/{userId} | kb-ebsco.credentials.users.item.put | 204 No Content | {credId} - UUID of the credential {userId) - UUID of a user |
DELETE | /eholdings/kb-credentials/{credId}/users/{userId} | kb-ebsco.credentials.users.item.delete | 204 No Content | {credId} - UUID of the credential {userId) - UUID of a user |
The appropriate files attached below:
DB schema |
| It means that we have
It means that:
| |||||||||||||||||||||||||||||||||||||||
Json Example |
| ||||||||||||||||||||||||||||||||||||||||
Json schema |
|
UI mockups
Update mapping between credentials and user
Option #1 - add PUT collection endpoint
- UI sends full collection of users assigned to a credential(see json example above) to PUT /eholdings/kb-credentials/{credId}/users
- back-end selects records tied to credential and removes them
- back-end inserts new records based on data received
Option #2 - use separate endpoints
- on each update (assignment user to a credential) UI will send request to PUT /eholdings/kb-credentials/{credId}/users/{userId}
- back-end adds record based on credential and user id
- on each removal (unassignment user from a credential) UI will send request to DELETE /eholdings/kb-credentials/{credId}/users/{userId}
- back-end removes record based on credential and user id
Info | ||
---|---|---|
| ||
Option #2 has been chosen since it's easy to implement and it follows more traditional pattern |
Association between KB Credentials and access status types
To implement the association between KB Credentials and access status types several changes should be made:
DB schema
| It means that we have
This approach will provide the ability to separate assignment-data between each KB credentials |
Endpoints
Method | Old endpoint | New endpoint | Request body | Response status | Response body | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
GET | /eholdings/access-types | /eholdings/kb-credentials/{credId}/access-types | 200 OK |
| |||||||||||||||||||||||||
POST | /eholdings/access-types | /eholdings/kb-credentials/{credId}/access-types |
| 201 Created(with record) |
| ||||||||||||||||||||||||
GET | /eholdings/access-types/{atId} | /eholdings/kb-credentials/{credId}/access-types/{atId} | 200 OK |
| |||||||||||||||||||||||||
PUT | /eholdings/access-types/{atId} | /eholdings/kb-credentials/{credId}/access-types/{atId} |
| 204 No Content | |||||||||||||||||||||||||
DELETE | /eholdings/access-types/{atId} | /eholdings/kb-credentials/{credId}/access-types/{atId} | 204 No Content |
JSON schemas that will be used (changes will be affected only for Access Types Collection Item Schema):
Expand | ||
---|---|---|
| ||
|
Expand | ||
---|---|---|
| ||
|
Expand | ||
---|---|---|
| ||
|
Expand | ||
---|---|---|
| ||
|
Access status type to record (package, resource) mapping and filtering implementation
Endpoints that will be affected:
Method | Endpoint | Action | Notes | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
GET | /eholdings/packages | filtering | Most interactions with DB must be updated. In most cases, we need to update only '
In other cases SQL-queries need to be updated by joining
| ||||||||||
POST | /eholdings/packages | mapping | |||||||||||
PUT | /eholdings/packages/{packageId} | mapping | |||||||||||
GET | /eholdings/packages/{packageId}/resources | filtering | |||||||||||
PUT | /eholdings/resources/{resourceId} | mapping | |||||||||||
GET | /eholdings/providers/{providerId}/packages | filtering | |||||||||||
GET | /eholdings/titles | filtering |
Association between KB Credentials and custom labels
Info |
---|
Custom labels are stored on the RM API side, so in this case, we don't have to change DB schema for custom labels. |
Endpoints are needed to be changed
Method | Old endpoint | New endpoint | Request body | Response status | Response body | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
GET | /eholdings/custom-labels | /eholdings/kb-credentials/{credId}/custom-labels | 200 OK |
| |||||||||||||||||||||||||
PUT | /eholdings/custom-labels | /eholdings/kb-credentials/{credId}/custom-labels |
| 200 OK |
|
JSON schemas that will be used (changes will be affected only for Custom Labels Collection Item Schema):
Expand | ||
---|---|---|
| ||
|
Expand | ||
---|---|---|
| ||
|
Expand | ||
---|---|---|
| ||
|
Expand | ||
---|---|---|
| ||
|
Association between KB Credentials and Proxy
Info |
---|
Root proxy and proxy types are stored on the RM API side, so in this case, we don't have to change DB schema. |
Endpoints are needed to be changed
Method | Old endpoint | New endpoint | Request body | Response status | Response body | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
GET | /eholdings/proxy-types | /eholdings/kb-credentials/{credId}/proxy-types | 200 OK |
| |||||||||||||||||||||||||
GET | /eholdings/root-proxy | /eholdings/kb-credentials/{credId}/root-proxy | 200 OK |
| |||||||||||||||||||||||||
PUT | /eholdings/root-proxy | /eholdings/kb-credentials/{credId}/root-proxy |
| 200 OK |
|
JSON schemas that will be used:
Expand | ||
---|---|---|
| ||
|
Expand | ||
---|---|---|
| ||
|
Expand | ||
---|---|---|
| ||
|
Expand | ||
---|---|---|
| ||
|
Expand | ||
---|---|---|
| ||
|
Expand | ||
---|---|---|
| ||
|
Expand | ||
---|---|---|
| ||
|
Updating existing endpoints for providers/packages/resources/titles
Problem
Eholdings module provides several endpoints to operate with HoldingsIQ resources (providers/packages/resources/titles). Endpoint interfaces are listed below:
- EholdingsProviders
EholdingsPackages
- EholdingsResources
- EholdingsTitles
Detailed definition with methods of each enpoint can be found in Eholdings Record Interfaces appendix
Endpoints call HoldingsIQ services (EBSCO KB) to get or update records. Each call has to be preconfigured with valid EBSCO knowledgebase credentials. There is only one credential set available at the moment. But it has to be changed to support multiple sets and a set can be associated with a user. This requires changes in the configuration routine of endpoints so that the appropriate KB credentials could be selected from several options depending on the current user.
Another point to consider is the data that stored internally in Eholdings module and has to be also associated with different KB credentials. Some samples of the data are:
- package details (name, content type)
- provider name
- access types assigned to resource.
Each time an endpoint needs to work with such data it has to understand what the correct set of credentials is in the current context.
The code snippets provided below represent both cases:
- working with locally stored data
- calling HoldingsIQ services
Steps to address the problem
- modify configuration routine to support user related KB credentials
- apply the routine to each enpoint method which talks to HoldingsIQ service(s)
- make the code that works with locally stored data aware of applicable KB credentials
Let's describe the steps one by one in more details
Modify configuration routine to support user related KB credentials
Following points to consider:
Configuration service modification
Retrieving KB credentials for the user
Changes in RM API template context
Configuration service modification
The core service that works with KB credentials at the moment is ConfigurationService
. It provides 3 methods as shown below:
Modifications required:
retrieveConfiguration()
method will return KB credentials associated with the current user.- It differes from how it works right now: single available credentials obtained from
mod-configuration
regardless of the current user - new method implementation will benefit from a new method in
KBCredentialsService
(see later on) which is going to be responsible for finding KB credentials applicable to the current user. SoretrieveConfiguration()
will delegate almost all of its work to this new method inKBCredentialsService
- It differes from how it works right now: single available credentials obtained from
updateConfiguration()
method should be removed- all KB credentals management operations (adding, changing, removing) will be done by
KBCredentialsService
- all KB credentals management operations (adding, changing, removing) will be done by
verifyCredentials()
– NO changes needed
Retrieving KB credentials for the user
All credential management will be accumulated inside a new service: KBCredentialsService
. It will be responsible for:
- CRUD operations with KB credentials
- resolving the approproate KB credentials for user
Below is a class diagram of the service.
First four methods should provide standart CRUD operations.
The last one is responsible for getting the right KB credentials for the user. It will do the work by
- quering users assigned to KB credentials with the current user
- if no assignment present then
- testing if there is single KB credential present
Changes in RM API template context
The context serves as a holder for preconfigured HoldingsIQ services and a couple of parameters important during the calls to those services and module methods. It already contains Configuration
object to provide apiKey/customerId/url to access KB knowledge base. What's missing is KB credentials details such as id
(credentialsId) and name
. Credentials id will be important to filter local data, name might come in handy in troubleshooting/logging. So both these attributes will be added to the context and it'll look like the following:
Respectively RMAPITemplateContextBuilder
that constructs the context will be adjusted to support new fields.
Note | ||
---|---|---|
| ||
Another option would be to include credentials id/name into Pros:
Cons:
|
Apply new configuration routine to each enpoint method which talks to HoldingsIQ service(s)
This should be fairly straightforward since there is a single place where credentail details (configuration) are obtained and applied to a service. This takes place inside RMAPITemplate
class:
- configuration retrieved by
ConfigurationService
- context builder populated with configuration found
- context with configuration is created by builder and passed to request action which calls HoldingIQ service
What has to be changed:
- replace
ConfigurationService
withKBCredentialsService
- instead of calling
retrieveConfiguration()
method callfindByUser()
method ofKBCredentialsService
to findKBCredentials
applicable in the current context - populate context with
Configuration, credentialsId, credentialsName
obtained fromKBCredentials
found
Make the code that works with locally stored data aware of applicable KB credentials
The code that works with local data which has become dependent on KB credentials should be refactored to accept credentailsId
and apply it to DB statements. There are 2 cases:
- the code is called from inside RMAPITemplate request action →
In this case context
already contains valid credentialsId
thus the method could get it from there. So for instance findById() method could be changed to:
Code Block | ||
---|---|---|
| ||
accessTypesService.findById(accessTypeId, context) |
- the code is executed on its own (there is no RMAPITemplate which wraps it around) →
There is no place to take credentialsId
from so it has to be retreived first by executing KBCredentialsService.findByUser()
method. The result should be transformed into RMAPIContext
similar to how it would be done in RMAPITemplate.executeInternal()
method (see previous section). Then context can be passed to updateTags()
.
Info |
---|
Having the above RMAPIContext becomes more general than just a place to store everything relevant to RM API calls. It's worth thinking about renaming it to something more universal |
Updating the process of holdings loading
To support the background loading of holdings by an invocation of OKAPI timer interface we have to add an additional endpoint to add the possibility of loading holdings for particular credentials
The path or pathPattern can be any fixed string (no pattern).
which means the URL /loadHoldings will remain the same.
No user is involved in this.
which means we can not use 'X-Okapi-Header' to define a user and then find tied credentials to load holdings.
Method | Old Endpoint | New Endpoint | Notes | ||
---|---|---|---|---|---|
POST | /loadHoldings | /eholdings/loading | an endpoint to load holdings for all credentials available in the system | ||
POST | /loadHoldings | /eholdings/loading/kb-credentials/{credentialsId} | load holdings for particular KB Credentials Interactions with the database should be updated by adding additional For instance, the query to get holdings will look like
all other SQL queries should be updated accordingly. | ||
GET | /loadHoldings/status | /eholdings/loading/kb-credentials/{credentialsId}/status | Back-end will support storing a single record for with one difference - adding the additional column between KB credential and status Select queries should be updated by adding
|
Drawio | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
The current version of OKAPI /_/timer
interface does allow us to have only fixed string as a path as it is mentioned above, but the mod-kb-ebsco-java
module should still support holdings background loading/update. For this purpose, the existing
POST
/loadHoldings
endpoint will be updated to initiate the loading process for KB Credentials.
The activity diagram posted below shows the process of loading holdings when it is triggered by the OKAPI /_/timer
interface.
The mod-kb-ebsco-java
module is configured to load holdings every 5 days. It means that for every KB Credentials the mod-kb-ebsco-java
module should load holdings respectively. To reduce the mess of possible errors, the process of loading and storing holdings records will be organized sequentially, i.e. one by one for each KB credentials. It is also will be available to initiate a loading holdings process for particular KB credentials using endpoint POST /eholdings/loading/kb-credentials/{credentialsId}.
Once the request is received (i.e POST
/loadHoldings
), back-end gets the list of KB Credentials stored in mod-kb-ebsco-java,
iterates over it and start loading for certain KB Credentials. The next KB Credentials loading starts only when the previous iteration has been finished(by finished means status is Completed or Failed).
General overview of mod-kb-ebsco-java
module tables with KB Credentials applying
Drawio | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Data migration
initial script to migrate mod-kb-ebsco-java
existing data to "Single tenant multiple EBSCO KBs" scenario - kb_ebsco_java_new_DB_schema.sql
Appendix A. Eholdings Record Interfaces
...