Skip to content

Commit

Permalink
feat: updated notification endpoint to use context path and removed s…
Browse files Browse the repository at this point in the history
…emantic id from notification asset
  • Loading branch information
ReneSchroederLJ committed Jun 19, 2024
1 parent 29b644a commit 84ceb5c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ public boolean registerAssetsInitially() {
result &= assetRegistration;
log.info("Registration of Demand and Capacity Notification 2.0.0 asset successful {}", (assetRegistration = registerNotificationAsset(
variablesService.getNotificationApiAssetId(),
variablesService.getNotificationEndpoint(),
AssetType.NOTIFICATION.URN_SEMANTIC_ID
variablesService.getNotificationEndpoint()
)));
log.info("Registration of PartTypeInformation 1.0.0 submodel successful {}", (assetRegistration = registerPartTypeInfoSubmodelAsset()));
result &= assetRegistration;
Expand Down Expand Up @@ -291,8 +290,8 @@ private boolean registerSubmodelAsset(String assetId, String endpoint, String se
return sendAssetRegistrationRequest(body, assetId);
}

private boolean registerNotificationAsset(String assetId, String endpoint, String semanticId) {
var body = edcRequestBodyBuilder.buildNotificationRegistrationBody(assetId, endpoint, semanticId);
private boolean registerNotificationAsset(String assetId, String endpoint) {
var body = edcRequestBodyBuilder.buildNotificationRegistrationBody(assetId, endpoint);
return sendAssetRegistrationRequest(body, assetId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ public JsonNode buildSubmodelRegistrationBody(String assetId, String endpoint, S
return body;
}

public JsonNode buildNotificationRegistrationBody(String assetId, String endpoint, String semanticId) {
public JsonNode buildNotificationRegistrationBody(String assetId, String endpoint) {
var body = getAssetRegistrationContext();
body.put("@id", assetId);
var propertiesObject = MAPPER.createObjectNode();
Expand All @@ -433,10 +433,6 @@ public JsonNode buildNotificationRegistrationBody(String assetId, String endpoin
propertiesObject.set("dct:type", dctTypeObject);
dctTypeObject.put("@id", "cx-taxo:DemandAndCapacityNotificationApi");
propertiesObject.put("cx-common:version", "1.0");
var semanticIdObject = MAPPER.createObjectNode();
propertiesObject.set("aas-semantics:semanticId", semanticIdObject);
semanticIdObject.put("@id", semanticId);
body.set("privateProperties", MAPPER.createObjectNode());
body.set("dataAddress", createDataAddressObject(endpoint, "true"));
return body;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ public class VariablesService {
@Value("${puris.baseurl}")
private String purisBaseUrl;

/**
* The puris base url as defined in the property puris.baseurl,
* ending with a slash ('/').
*/
public String getPurisBaseUrl() {
return purisBaseUrl.endsWith("/") ? purisBaseUrl : purisBaseUrl + "/";
}

@Value("${puris.demonstrator.role}")
/**
* Must be set to "CUSTOMER" or "SUPPLIER" if
Expand All @@ -50,6 +58,17 @@ public class VariablesService {
*/
private String demoRole;

@Value("${server.servlet.context-path}")
private String contextPath;

/**
* The context path as defined in the property server.servlet.context-path,
* ending with a slash ('/').
*/
public String getContextPath() {
return contextPath.replace("/", "") + "/";
}

@Value("${puris.baseurl}" + "catena/edrendpoint")
/**
* The edrEndpoint to be used during consumer pull asset transfers.
Expand Down Expand Up @@ -112,12 +131,13 @@ public class VariablesService {
*/
private String deliverySubmodelAssetId;

@Value("${puris.baseurl}" + "catena/demand-and-capacity-notification/request")
/**
* The url under which this application's request endpoint can
* The url under which this application's demand and capacity notification request endpoint can
* be reached by external machines.
*/
private String notificationEndpoint;
public String getNotificationEndpoint() {
return getPurisBaseUrl() + getContextPath() + "demand-and-capacity-notification/request";
}

@Value("${puris.notification.apiassetid}")
/**
Expand Down

0 comments on commit 84ceb5c

Please sign in to comment.