Skip to content

Commit

Permalink
Merge pull request #136 from catenax-ng/release/v1.2.0-removed-centra…
Browse files Browse the repository at this point in the history
…l-search

[3º] - Release/v1.2.0 removed central search: Removed Central DTR search support
  • Loading branch information
matbmoser authored Oct 30, 2023
2 parents a889de8 + c972c93 commit 5a6dd95
Show file tree
Hide file tree
Showing 21 changed files with 425 additions and 1,321 deletions.
2 changes: 1 addition & 1 deletion charts/digital-product-pass/values-beta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ backend:
dtr:
central: false
centralUrl: 'https://semantics.beta.demo.catena-x.net/registry'
assetId: 'digital-twin-registry'
assetType: 'data.core.digitalTwinRegistry'
endpointInterface: 'SUBMODEL-3.0'
dspEndpointKey: 'dspEndpoint'
internalDtr: "https://materialpass.beta.demo.catena-x.net/BPNL000000000000" # -- If there is an internal DTR available it can be referenced here and will be injected in the list of DTRs
Expand Down
2 changes: 1 addition & 1 deletion charts/digital-product-pass/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ backend:
dtr:
central: false
centralUrl: 'https://semantics.dev.demo.catena-x.net/registry'
assetId: 'registry-asset'
assetType: 'data.core.digitalTwinRegistry'
dspEndpointKey: 'dspEndpoint'
endpointInterface: 'SUBMODEL-3.0'
internalDtr: "https://materialpass.dev.demo.catena-x.net/BPNL000000000000" # -- If there is an internal DTR available it can be referenced here and will be injected in the list of DTRs
Expand Down
2 changes: 1 addition & 1 deletion charts/digital-product-pass/values-int.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ backend:
dtr:
central: false
centralUrl: 'https://semantics.int.demo.catena-x.net/registry'
assetId: 'registry-asset'
assetType: 'data.core.digitalTwinRegistry'
dspEndpointKey: 'dspEndpoint'
endpointInterface: 'SUBMODEL-3.0'
internalDtr: "https://materialpass.int.demo.catena-x.net/BPNL000000000000" # -- If there is an internal DTR available it can be referenced here and will be injected in the list of DTRs
Expand Down
4 changes: 2 additions & 2 deletions charts/digital-product-pass/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ backend:
central: false
# -- central digital twin registry url
centralUrl: 'https://<digital-twin-registry-url>'
# -- asset id to search for the registry in the edc
assetId: 'registry-asset'
# -- asset type to search for the registry in the edc
assetType: 'data.core.digitalTwinRegistry'
# -- submodel endpoint interface to search
endpointInterface: 'SUBMODEL-3.0'
# -- dsp endpoint key inside submodel body
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@
public class DtrConfig {

/** ATTRIBUTES **/
Boolean central;
String centralUrl;
String internalDtr;
Timeouts timeouts;
Boolean temporaryStorage;
DecentralApis decentralApis;
String assetId;
String assetType;
String endpointInterface;
String dspEndpointKey;

Expand All @@ -54,29 +52,25 @@ public class DtrConfig {
public DtrConfig() {
}

public DtrConfig(Boolean central, String centralUrl, String internalDtr, Timeouts timeouts, Boolean temporaryStorage, DecentralApis decentralApis, String assetId, String endpointInterface, String dspEndpointKey, String semanticIdTypeKey) {
this.central = central;
this.centralUrl = centralUrl;
public DtrConfig(String internalDtr, Timeouts timeouts, Boolean temporaryStorage, DecentralApis decentralApis, String assetType, String endpointInterface, String dspEndpointKey, String semanticIdTypeKey) {
this.internalDtr = internalDtr;
this.timeouts = timeouts;
this.temporaryStorage = temporaryStorage;
this.decentralApis = decentralApis;
this.assetId = assetId;
this.assetType = assetType;
this.endpointInterface = endpointInterface;
this.dspEndpointKey = dspEndpointKey;
this.semanticIdTypeKey = semanticIdTypeKey;
}


/** GETTERS AND SETTERS **/
public DecentralApis getDecentralApis() {
return decentralApis;
}
public void setDecentralApis(DecentralApis decentralApis) {
this.decentralApis = decentralApis;
}
public DtrConfig(Boolean central) {
this.central = central;
}
public String getInternalDtr() {
return internalDtr;
}
Expand Down Expand Up @@ -107,24 +101,11 @@ public String getDspEndpointKey() {
public void setDspEndpointKey(String dspEndpointKey) {
this.dspEndpointKey = dspEndpointKey;
}
public Boolean getCentral() {
return central;
}
public void setCentral(Boolean central) {
this.central = central;
}
public String getCentralUrl() {
return centralUrl;
}
@SuppressWarnings("Unused")
public void setCentralUrl(String centralUrl) {
this.centralUrl = centralUrl;
}
public String getAssetId() {
return assetId;
public String getAssetType() {
return assetType;
}
public void setAssetId(String assetId) {
this.assetId = assetId;
public void setAssetType(String assetType) {
this.assetType = assetType;
}

public String getSemanticIdTypeKey() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
import org.eclipse.tractusx.productpass.exceptions.ControllerException;
import org.eclipse.tractusx.productpass.managers.ProcessManager;
import org.eclipse.tractusx.productpass.models.catenax.Dtr;
import org.eclipse.tractusx.productpass.models.dtregistry.DigitalTwin3;
import org.eclipse.tractusx.productpass.models.dtregistry.EndPoint3;
import org.eclipse.tractusx.productpass.models.dtregistry.SubModel3;
import org.eclipse.tractusx.productpass.models.dtregistry.DigitalTwin;
import org.eclipse.tractusx.productpass.models.dtregistry.EndPoint;
import org.eclipse.tractusx.productpass.models.dtregistry.SubModel;
import org.eclipse.tractusx.productpass.models.edc.DataPlaneEndpoint;
import org.eclipse.tractusx.productpass.models.edc.Jwt;
import org.eclipse.tractusx.productpass.models.http.Response;
Expand Down Expand Up @@ -173,8 +173,8 @@ public Response getDigitalTwin(@RequestBody Object body, @PathVariable String pr
Thread digitalTwinRegistryThread = ThreadUtil.runThread(digitalTwinRegistry);
// Wait for digital twin query
digitalTwinRegistryThread.join();
DigitalTwin3 digitalTwin = null;
SubModel3 subModel = null;
DigitalTwin digitalTwin = null;
SubModel subModel = null;
String connectorId = null;
String assetId = null;
String connectorAddress = null;
Expand All @@ -185,7 +185,7 @@ public Response getDigitalTwin(@RequestBody Object body, @PathVariable String pr
subModel = digitalTwinRegistry.getSubModel();
semanticId = Objects.requireNonNull(subModel.getSemanticId().getKeys().stream().filter(k -> k.getType().equalsIgnoreCase(this.dtrConfig.getSemanticIdTypeKey())).findFirst().orElse(null)).getValue();
connectorId = subModel.getIdShort();
EndPoint3 endpoint = subModel.getEndpoints().stream().filter(obj -> obj.getInterfaceName().equals(dtrConfig.getEndpointInterface())).findFirst().orElse(null);
EndPoint endpoint = subModel.getEndpoints().stream().filter(obj -> obj.getInterfaceName().equals(dtrConfig.getEndpointInterface())).findFirst().orElse(null);
if (endpoint == null) {
throw new ControllerException(this.getClass().getName(), "No EDC endpoint found in DTR SubModel!");
}
Expand All @@ -210,7 +210,7 @@ public Response getDigitalTwin(@RequestBody Object body, @PathVariable String pr
processManager.setEndpoint(processId, connectorAddress);
processManager.setBpn(processId, dtr.getBpn());
processManager.setSemanticId(processId, semanticId);
processManager.saveDigitalTwin3(processId, digitalTwin, dtRequestTime);
processManager.saveDigitalTwin(processId, digitalTwin, dtRequestTime);
LogUtil.printDebug("[PROCESS " + processId + "] Digital Twin [" + digitalTwin.getIdentification() + "] and Submodel [" + subModel.getIdentification() + "] with EDC endpoint [" + connectorAddress + "] retrieved from DTR");
processManager.setStatus(processId, "digital-twin-found", new History(
assetId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,6 @@ public class ContractController {
public Response create(@Valid @RequestBody DiscoverySearch searchBody) {
Response response = httpUtil.getInternalError();
try {
// In case the configuration is setting the search as central
if(dtrConfig.getCentral()){
response.message = "The decentral Digital Twin Registry is not enabled!";
response.status = 403;
response.statusText = "Bad Request";
return httpUtil.buildResponse(response, httpResponse);
}
if (!authService.isAuthenticated(httpRequest)) {
response = httpUtil.getNotAuthorizedResponse();
return httpUtil.buildResponse(response, httpResponse);
Expand Down Expand Up @@ -249,8 +242,8 @@ public Response search(@Valid @RequestBody Search searchBody) {
return httpUtil.buildResponse(response, httpResponse);
}

List<String> versions;
/*if (searchBody.getIdShort().equalsIgnoreCase("digitalProductPass")) {
/*List<String> versions;
if (searchBody.getIdShort().equalsIgnoreCase("digitalProductPass")) {
versions = passportConfig.getDigitalProductPass().getVersions();
searchBody.setSemanticId(passportConfig.getDigitalProductPass().getFullSemanticId(versions.get(0)));
LogUtil.printWarning("SEMANTID ID: " + passportConfig.getDigitalProductPass().getFullSemanticId(versions.get(0)));
Expand All @@ -261,34 +254,34 @@ public Response search(@Valid @RequestBody Search searchBody) {

Process process = null;
AssetSearch assetSearch = null;
if(!dtrConfig.getCentral() && searchBody.getProcessId() != null) {
// Check for processId
String processId = searchBody.getProcessId();
if(processId.isEmpty()){
response = httpUtil.getBadRequest("Process id is required for decentral digital twin registry searches!");
return httpUtil.buildResponse(response, httpResponse);
}
SearchStatus searchStatus = processManager.getSearchStatus(processId);
if (searchStatus == null) {
response = httpUtil.getBadRequest("The searchStatus id does not exists!");
return httpUtil.buildResponse(response, httpResponse);
}
if(searchStatus.getDtrs().keySet().size() == 0){
response = httpUtil.getBadRequest("No digital twins are available for this process!");
return httpUtil.buildResponse(response, httpResponse);
}
process = processManager.createProcess(processId, httpRequest);
Status status = processManager.getStatus(processId);
if (status == null) {
response = httpUtil.getBadRequest("The status is not available!");
return httpUtil.buildResponse(response, httpResponse);
}
assetSearch = aasService.decentralDtrSearch(process.id, searchBody);
}else {
process = processManager.createProcess(httpRequest);
assetSearch = aasService.centralDtrSearch(process.id, searchBody);

// Check for processId
if(searchBody.getProcessId() == null){
response = httpUtil.getBadRequest("No processId was found on the request body!");
return httpUtil.buildResponse(response, httpResponse);
}

String processId = searchBody.getProcessId();
if(processId.isEmpty()){
response = httpUtil.getBadRequest("Process id is required for decentral digital twin registry searches!");
return httpUtil.buildResponse(response, httpResponse);
}
SearchStatus searchStatus = processManager.getSearchStatus(processId);
if (searchStatus == null) {
response = httpUtil.getBadRequest("The searchStatus id does not exists!");
return httpUtil.buildResponse(response, httpResponse);
}
if(searchStatus.getDtrs().keySet().size() == 0){
response = httpUtil.getBadRequest("No digital twins are available for this process!");
return httpUtil.buildResponse(response, httpResponse);
}
process = processManager.createProcess(processId, httpRequest);
Status status = processManager.getStatus(processId);
if (status == null) {
response = httpUtil.getBadRequest("The status is not available!");
return httpUtil.buildResponse(response, httpResponse);
}
assetSearch = aasService.decentralDtrSearch(process.id, searchBody);

if(assetSearch == null){
response = httpUtil.getBadRequest("No digital twin was found!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,23 +152,21 @@ public void onStartUp() {
LogUtil.printMessage(serverStartUpMessage);
LogUtil.printMessage("========= [ LOGGING STARTED ] ================================");
LogUtil.printMessage("Creating log file...");
if(!dtrConfig.getCentral()) {
Discovery discovery = catenaXService.start(); // Start the CatenaX service if the central attribute is set to false (we need the bpnDiscovery and edcDiscovery addresses)
if (discovery == null) {
LogUtil.printError("\n*************************************[CRITICAL ERROR]*************************************" +
"\nIt was not possible to start the application correctly..." +
"\nPlease configure the Discovery Service Endpoint property:" +
"\n\t- [application.configuration.discovery.endpoint]" +
"\nMake sure that the Technical User Credentials are correctly configured:" +
"\n\t- [avp.helm.clientId]" +
"\n\t- [avp.helm.clientSecret]" +
"\nThis user should be able to retrieve the token from the following Keycloak Endpoint:" +
"\n\t- [application.configuration.keycloak.tokenUri]" +
"\n*****************************************************************************************\n"
);
}
Discovery discovery = catenaXService.start(); // Start the CatenaX service (we need the bpnDiscovery and edcDiscovery addresses)
if (discovery == null) {
LogUtil.printError("\n*************************************[CRITICAL ERROR]*************************************" +
"\nIt was not possible to start the application correctly..." +
"\nPlease configure the Discovery Service Endpoint property:" +
"\n\t- [application.configuration.discovery.endpoint]" +
"\nMake sure that the Technical User Credentials are correctly configured:" +
"\n\t- [avp.helm.clientId]" +
"\n\t- [avp.helm.clientSecret]" +
"\nThis user should be able to retrieve the token from the following Keycloak Endpoint:" +
"\n\t- [application.configuration.keycloak.tokenUri]" +
"\n*****************************************************************************************\n"
);
}
}

}
// Store the process manager in memory
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.eclipse.tractusx.productpass.exceptions.ManagerException;
import org.eclipse.tractusx.productpass.models.catenax.Dtr;
import org.eclipse.tractusx.productpass.models.dtregistry.DigitalTwin;
import org.eclipse.tractusx.productpass.models.dtregistry.DigitalTwin3;
import org.eclipse.tractusx.productpass.models.edc.DataPlaneEndpoint;
import org.eclipse.tractusx.productpass.models.edc.Jwt;
import org.eclipse.tractusx.productpass.models.http.requests.Search;
Expand Down Expand Up @@ -1321,36 +1320,6 @@ public String saveDigitalTwin(String processId, DigitalTwin digitalTwin, Long st
}
}

/**
* Saves the given {@code DigitalTwin3} object in the Process with the given processId with the given timestamp.
* <p>
* @param processId
* the {@code String} id of the application's process.
* @param digitalTwin
* the {@code DigitalTwin3} object to save.
* @param startedTime
* the {@code Long} timestamp when the process's event started.
*
* @return a {@code String} file path of the file where data was stored.
*
* @throws ManagerException
* if unable to save the {@code DigitalTwin3}.
*/
public String saveDigitalTwin3(String processId, DigitalTwin3 digitalTwin, Long startedTime) {
try {
return this.saveProcessPayload(
processId,
digitalTwin,
this.digitalTwinFileName,
startedTime,
digitalTwin.getIdentification(),
"READY",
"digital-twin-request");
} catch (Exception e) {
throw new ManagerException(this.getClass().getName(), e, "It was not possible to save the digitalTwin!");
}
}

/**
* Saves the given {@code Dataset} object in the Process with the given processId with the given timestamp.
* <p>
Expand Down
Loading

0 comments on commit 5a6dd95

Please sign in to comment.