Skip to content

Commit

Permalink
Fixes order of AAS/Submodel deletion
Browse files Browse the repository at this point in the history
* First, remove from registry, then from AAS Server

Signed-off-by: Frank Schnicke <[email protected]>
  • Loading branch information
FrankSchnicke committed Jul 5, 2023
1 parent 99855bd commit 3f15940
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,25 +127,28 @@ public Collection<IAssetAdministrationShell> 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) {

Expand All @@ -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
Expand Down

0 comments on commit 3f15940

Please sign in to comment.