-
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.
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)
- Loading branch information
Showing
36 changed files
with
429 additions
and
179 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
45 changes: 45 additions & 0 deletions
45
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,45 @@ | ||
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<JsonArray> getEntries(RoutingContext routingContext, String moduleName, String configName) { | ||
|
||
String query = "module==" + moduleName + " and configName==" + configName + " and enabled==true"; | ||
return Folio.okapiClient(routingContext).get(CONFIGURATIONS_PATH + | ||
"?query=(" + URLEncoder.encode(query, StandardCharsets.UTF_8) +")") | ||
.map(result -> new JsonObject(result).getJsonArray(RECORDS)) | ||
.recover(e -> Future.failedFuture(e.getMessage())); | ||
} | ||
|
||
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; | ||
} | ||
|
||
} |
4 changes: 2 additions & 2 deletions
4
...arvesteradmin/dataaccess/JobLauncher.java → ...arvesteradmin/legacydata/JobLauncher.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
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
2 changes: 1 addition & 1 deletion
2
...ess/dataconverters/HarvesterXml2Json.java → ...ata/dataconverters/HarvesterXml2Json.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
6 changes: 3 additions & 3 deletions
6
...rters/HarvesterXml2JsonFailedRecords.java → ...rters/HarvesterXml2JsonFailedRecords.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
2 changes: 1 addition & 1 deletion
2
...ss/dataconverters/JsonToHarvesterXml.java → ...ta/dataconverters/JsonToHarvesterXml.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
2 changes: 1 addition & 1 deletion
2
...ehandlers/ProcessedHarvesterResponse.java → ...ehandlers/ProcessedHarvesterResponse.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
4 changes: 2 additions & 2 deletions
4
...ers/ProcessedHarvesterResponseDelete.java → ...ers/ProcessedHarvesterResponseDelete.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
4 changes: 2 additions & 2 deletions
4
...ndlers/ProcessedHarvesterResponseGet.java → ...ndlers/ProcessedHarvesterResponseGet.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
6 changes: 3 additions & 3 deletions
6
...rs/ProcessedHarvesterResponseGetById.java → ...rs/ProcessedHarvesterResponseGetById.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
2 changes: 1 addition & 1 deletion
2
...ssedHarvesterResponseGetUniqueByName.java → ...ssedHarvesterResponseGetUniqueByName.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
2 changes: 1 addition & 1 deletion
2
...dlers/ProcessedHarvesterResponsePost.java → ...dlers/ProcessedHarvesterResponsePost.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
2 changes: 1 addition & 1 deletion
2
...ndlers/ProcessedHarvesterResponsePut.java → ...ndlers/ProcessedHarvesterResponsePut.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
2 changes: 1 addition & 1 deletion
2
...teradmin/dataaccess/statics/ApiPaths.java → ...teradmin/legacydata/statics/ApiPaths.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
12 changes: 6 additions & 6 deletions
12
...n/dataaccess/statics/EntityRootNames.java → ...n/legacydata/statics/EntityRootNames.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
2 changes: 1 addition & 1 deletion
2
...taaccess/statics/LegacyServiceConfig.java → ...gacydata/statics/LegacyServiceConfig.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
2 changes: 1 addition & 1 deletion
2
...dataaccess/statics/RequestParameters.java → ...legacydata/statics/RequestParameters.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
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.