Skip to content

Commit

Permalink
fix: urls for logging and process creation
Browse files Browse the repository at this point in the history
  • Loading branch information
schoenenberg committed Feb 3, 2024
1 parent e8e8f08 commit ac6665a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ subprojects {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/truzzt/mds-ap3")
version = "0.2.0"
version = "0.2.1"
credentials {
username = System.getenv("USERNAME")
password = System.getenv("TOKEN")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*
* Contributors:
* sovity GmbH - initial API and implementation
* truzzt GmbH - adjusted for EDC 0.x
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,18 @@ public <E extends Event> void on(EventEnvelope<E> event) {
if (event.getPayload() instanceof ContractNegotiationFinalized contractNegotiationFinalized) {
var contractAgreement = resolveContractAgreement(contractNegotiationFinalized);
var pid = contractAgreement.getId();
var extendedUrl = new URL(clearingHouseLogUrl + "/" + pid);

createProcess(contractAgreement, clearingHouseLogUrl);
logContractAgreement(contractAgreement, extendedUrl);
// Create Process
var extendedProcessUrl = new URL(clearingHouseLogUrl + "/process/" + pid);
createProcess(contractAgreement, extendedProcessUrl);

// Log Contract Agreement
var extendedLogUrl = new URL(clearingHouseLogUrl + "/messages/log/" + pid);
logContractAgreement(contractAgreement, extendedLogUrl);
} else if (event.getPayload() instanceof TransferProcessTerminated transferProcessTerminated) {
var transferProcess = resolveTransferProcess(transferProcessTerminated);
var pid = transferProcess.getContractId();
var extendedUrl = new URL(clearingHouseLogUrl + "/" + pid);
var extendedUrl = new URL(clearingHouseLogUrl + "/messages/log/" + pid);
logTransferProcess(transferProcess, extendedUrl);
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*
* Contributors:
* sovity GmbH - initial API and implementation
* truzzt GmbH - adjusted for EDC 0.x
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ public class LoggingHouseClientExtension implements ServiceExtension {
"ids", "https://w3id.org/idsa/core/",
"idsc", "https://w3id.org/idsa/code/");
@Setting
public static final String CLEARINGHOUSE_LOG_URL_SETTING = "edc.clearinghouse.log.url";
public static final String LOGGINGHOUSE_LOG_URL_SETTING = "edc.logginghouse.extension.url";

@Setting
public static final String CLEARINGHOUSE_CLIENT_EXTENSION_ENABLED = "clearinghouse.client.extension.enabled";
public static final String LOGGINGHOUSE_CLIENT_EXTENSION_ENABLED = "edc.logginghouse.extension.enabled";

private URL clearingHouseLogUrl;
private URL loggingHouseLogUrl;
public Monitor monitor;


Expand All @@ -81,38 +81,38 @@ public String name() {
@Override
public void initialize(ServiceExtensionContext context) {
monitor = context.getMonitor();
var extensionEnabled = context.getSetting(CLEARINGHOUSE_CLIENT_EXTENSION_ENABLED, false);
var extensionEnabled = context.getSetting(LOGGINGHOUSE_CLIENT_EXTENSION_ENABLED, true);

if (!extensionEnabled) {
monitor.info("Logginghouse client extension is disabled.");
return;
}
monitor.info("Logginghouse client extension is enabled.");

clearingHouseLogUrl = readUrlFromSettings(context, CLEARINGHOUSE_LOG_URL_SETTING);
loggingHouseLogUrl = readUrlFromSettings(context);
}

private URL readUrlFromSettings(ServiceExtensionContext context, String settingsPath) {
private URL readUrlFromSettings(ServiceExtensionContext context) {
try {
var urlString = context.getSetting(settingsPath, null);
var urlString = context.getSetting(LoggingHouseClientExtension.LOGGINGHOUSE_LOG_URL_SETTING, null);
if (urlString == null) {
throw new EdcException(String.format("Could not initialize " +
"LoggingHouseClientExtension: " +
"No url specified using setting %s", settingsPath));
"No url specified using setting %s", LoggingHouseClientExtension.LOGGINGHOUSE_LOG_URL_SETTING));
}

return new URL(urlString);
} catch (MalformedURLException e) {
throw new EdcException(String.format("Could not parse setting %s to Url",
settingsPath), e);
LoggingHouseClientExtension.LOGGINGHOUSE_LOG_URL_SETTING), e);
}
}

private void registerEventSubscriber(ServiceExtensionContext context) {
var eventSubscriber = new IdsClearingHouseServiceImpl(
dispatcherRegistry,
hostname,
clearingHouseLogUrl,
loggingHouseLogUrl,
contractNegotiationStore,
transferProcessStore,
monitor);
Expand Down

0 comments on commit ac6665a

Please sign in to comment.