From 3f1594022edbdd5c0e0993364a2231cc06e3a696 Mon Sep 17 00:00:00 2001 From: Frank Schnicke Date: Wed, 5 Jul 2023 15:29:05 +0200 Subject: [PATCH] Fixes order of AAS/Submodel deletion * First, remove from registry, then from AAS Server Signed-off-by: Frank Schnicke --- ...nectedAssetAdministrationShellManager.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/eclipse/basyx/aas/manager/ConnectedAssetAdministrationShellManager.java b/src/main/java/org/eclipse/basyx/aas/manager/ConnectedAssetAdministrationShellManager.java index cdecc479..dcb97820 100644 --- a/src/main/java/org/eclipse/basyx/aas/manager/ConnectedAssetAdministrationShellManager.java +++ b/src/main/java/org/eclipse/basyx/aas/manager/ConnectedAssetAdministrationShellManager.java @@ -127,25 +127,28 @@ public Collection retrieveAASAll() { @Override public void deleteAAS(IIdentifier id) { - // Lookup AAS descriptor AASDescriptor aasDescriptor = aasDirectory.lookupAAS(id); - // Get AAS address from AAS descriptor String addr = aasDescriptor.getFirstEndpoint(); - // Address ends in "/aas", has to be stripped for removal - addr = VABPathTools.stripSlashes(addr); - addr = addr.substring(0, addr.length() - "/aas".length()); - - // Delete from server - proxyFactory.createProxy(addr).deleteValue(""); + String harmonizedAddress = getHarmonizedAddress(addr); - // Delete from Registry aasDirectory.delete(id); + deleteAasFromAddress(harmonizedAddress); + // TODO: How to handle submodels -> Lifecycle needs to be clarified } + private void deleteAasFromAddress(String address) { + proxyFactory.createProxy(address).deleteValue(""); + } + + private String getHarmonizedAddress(String address) { + String strippedAddr = VABPathTools.stripSlashes(address); + return strippedAddr.substring(0, strippedAddr.length() - "/aas".length()); + } + @Override public void createSubmodel(IIdentifier aasId, Submodel submodel) { @@ -167,9 +170,10 @@ public void createSubmodel(IIdentifier aasId, Submodel submodel) { @Override public void deleteSubmodel(IIdentifier aasId, IIdentifier submodelId) { IAssetAdministrationShell shell = retrieveAAS(aasId); - shell.removeSubmodel(submodelId); aasDirectory.delete(aasId, submodelId); + + shell.removeSubmodel(submodelId); } @Override