-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* MODHAADM-71 add timer process for purging logs * add Okapi timer process for deleting old jobs, record failures and logs * add APIs for importing jobs, record failures and logs, i.e. from exports or from other FOLIO instances * MODHAADM-71 add timer process for purging logs * add Okapi timer process for deleting old jobs, record failures and logs * add APIs for importing jobs, record failures and logs, i.e. from exports or from other FOLIO instances * MODHAADM-71 wip Reorganize Java classes (rename packages, classes, move classes) Update logging dependencies Add Okapi client for configuration look-up Preparations for unit tests (settable clock, APIs for populating jobs and logs with sample data) * MODHAADM-71 wip Remove test resources directory * MODHAADM-71 wip, test infrastructure Expand test harness to cover local mod-harvester-admin APIs (purge old jobs) and FOLIO APIs (/configuration/entries) along existing legacy harvester interaction tests. * MODHAADM-71 wip, unit tests * MODHAADM-71 revert renaming of test suite class After renaming the test suite from HarvesterAdminTestSuite to HarvesterAdminTestSuiteIT, the environment variables set in the configuration of the maven-surefire-plugin are no longer available in the module when running the unit tests by `mvn install` on the command line. Reverting the name to HarvesterAdminTestSuite, at least until it is clear why the env vars disappear. When running the tests in IDEA, the environment variables seems to be forwarded fine with either name for the unit test suite class. * MODHAADM-71 separate test suites for exclude/include Harvester Adding profile for running tests against installed and running Harvester, activate with `-PharvesterTests` Default is to run unit tests that doesn't require Harvester * MODHAADM-71 Tests: adding fake configurations module * MODHAADM-71 Reorganize, fix tests * MODHAADM-71 Clean up db init code, error reporting * MODHAADM-71 support purge setting in German * MODHAADM-71 Add integration test suite - requires Harvester to be running (at localhost:8080) * MODHAADM-71 Documentation. Default schedule for timer process. * MODHAADM-71 SC
- Loading branch information
Showing
87 changed files
with
2,152 additions
and
1,646 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/org/folio/harvesteradmin/foliodata/ConfigurationsClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.folio.harvesteradmin.foliodata; | ||
|
||
import io.vertx.core.Future; | ||
import io.vertx.core.json.JsonArray; | ||
import io.vertx.core.json.JsonObject; | ||
import io.vertx.ext.web.RoutingContext; | ||
import io.vertx.reactivex.core.Promise; | ||
|
||
import java.net.URLEncoder; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
public class ConfigurationsClient { | ||
private static final String CONFIGURATIONS_PATH = "/configurations/entries"; | ||
private static final String RECORDS = "configs"; | ||
public static final String MODULE_HARVESTER_ADMIN = "HARVESTER_ADMIN"; | ||
public static final String CONFIG_NAME_PURGE_LOGS_AFTER = "PURGE_LOGS_AFTER"; | ||
|
||
public static Future<String> getStringValue (RoutingContext routingContext, String moduleName, String configName) { | ||
String query = "module==" + moduleName + " and configName==" + configName + " and enabled=true"; | ||
Promise<String> promise = Promise.promise(); | ||
Folio.okapiClient(routingContext).get(CONFIGURATIONS_PATH + | ||
"?query=(" + URLEncoder.encode(query, StandardCharsets.UTF_8) +")") | ||
.onComplete(response -> { | ||
JsonObject json = new JsonObject(response.result()); | ||
JsonArray entries = json.getJsonArray(RECORDS); | ||
if (entries.isEmpty()) { | ||
promise.complete(null); | ||
|
||
} else { | ||
JsonObject entry = entries.getJsonObject(0); | ||
promise.complete(entry.getString("value")); | ||
} | ||
}); | ||
return promise.future(); | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/org/folio/harvesteradmin/foliodata/Folio.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.folio.harvesteradmin.foliodata; | ||
|
||
import io.vertx.ext.web.RoutingContext; | ||
import org.folio.okapi.common.OkapiClient; | ||
import org.folio.okapi.common.WebClientFactory; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class Folio { | ||
public static OkapiClient okapiClient(RoutingContext ctx) { | ||
OkapiClient client = new OkapiClient(WebClientFactory.getWebClient(ctx.vertx()), ctx); | ||
Map<String, String> headers = new HashMap<>(); | ||
headers.put("Content-type", "application/json"); | ||
if (ctx.request().getHeader("X-Okapi-Tenant") != null) headers.put("X-Okapi-Tenant", ctx.request().getHeader("X-Okapi-Tenant")); | ||
if (ctx.request().getHeader("X-Okapi-Token") != null) headers.put("X-Okapi-Token", ctx.request().getHeader("X-Okapi-Token")); | ||
headers.put("Accept", "application/json, text/plain"); | ||
client.setHeaders(headers); | ||
return client; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.