Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,11 @@ posted.
Note that Okapi gives us less details about the modules, for in the real life this
could be quite a long list.

Modules are immutable (for same id). There is no PUT method to update a module.
It is possible to POST the module descriptor again, if it is equivalent to the
existing module. This enforcement can be lifted, by supplying query
parameter `check=false`.

#### Deploying the module

It is not enough that Okapi knows that such a module exists. We must
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private Future<Void> loadModules() {
* Create a list of modules.
*
* @param list list of modules
* @param check whether to check dependencies
* @param check whether to check dependencies and immutability of existing modules
* @param removeIfMissingDep skip modules where dependency check fails
* @return future
*/
Expand All @@ -91,7 +91,7 @@ public Future<Void> createList(List<ModuleDescriptor> list, boolean check,
* Create a list of modules.
*
* @param list list of modules
* @param check whether to check dependencies
* @param check whether to check dependencies and immutability of existing modules
* @param moduleVersionFilter whether to allow pre-release/npmSnapshots
* @param removeIfMissingDep skip modules where dependency check fails
* @return future
Expand All @@ -110,7 +110,7 @@ public Future<Void> createList(List<ModuleDescriptor> list, boolean check,
ModuleDescriptor exMd = tempList.get(id);
String exJson = Json.encodePrettily(exMd);
String json = Json.encodePrettily(md);
if (!json.equals(exJson)) {
if (check && !json.equals(exJson)) {
return Future.failedFuture(new OkapiError(ErrorType.USER,
messages.getMessage("10203", id)));
}
Expand Down
10 changes: 8 additions & 2 deletions okapi-core/src/main/raml/okapi.raml
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,10 @@ traits:
/_/proxy/modules.
queryParameters:
check:
description: Whether to check dependencies
description: Whether to check dependencies and immutability of existing modules.
If false, modules may be imported requiring interfaces that are not currently
offered by any other module. Also with a false value an existing module may be
updated; thus breaking immutability.
type: boolean
required: false
default: true
Expand Down Expand Up @@ -530,7 +533,10 @@ traits:
selected for a specific tenant.
queryParameters:
check:
description: Whether to check dependencies
description: Whether to check dependencies and immutability of existing modules.
If false, a module may be imported requiring interfaces that are not currently
offered by any other module. Also with a false value an existing module may
be updated; thus breaking immutability.
type: boolean
required: false
default: true
Expand Down
11 changes: 11 additions & 0 deletions okapi-core/src/test/java/org/folio/okapi/ModuleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,17 @@ public void testOneModule(TestContext context) {
.body(equalTo("create: module sample-module-1+1 already exists"));
assertEmptyReport(c);

// post it again with slight modification, but check=false, so it should be allowed, and replace the old one
c = api.createRestAssured3();
c.given()
.header("Content-Type", "application/json")
.body(docSampleModule.replace("sample.extra\"", "sample.foo\""))
.queryParam("check", "false")
.post("/_/proxy/modules")
.then()
.statusCode(201);
assertEmptyReport(c);

given()
.header("Content-Type", "application/json")
.body("{}")
Expand Down
Loading