- try {
- rappInstance.getSme().getInvokerIds().forEach(this::deleteInvoker);
- rappInstance.getSme().getServiceApiIds()
- .forEach(s -> deletePublishApi(s, rappInstance.getSme().getApfId()));
- rappInstance.getSme().getProviderFunctionIds().forEach(this::deleteProviderFunc);
- rappInstanceStateMachine.sendRappInstanceEvent(rappInstance, RappEvent.SMEUNDEPLOYED);
- return true;
- } catch (Exception e) {
- logger.warn("Failed to Undeploy SME functions for Rapp {}", rapp.getName(), e);
+ if (rappInstance.isSMEEnabled()) {
+ try {
+ Optional.ofNullable(rappInstance.getSme().getInvokerIds())
+ .ifPresent(invokerList -> invokerList.forEach(this::deleteInvoker));
+ Optional.ofNullable(rappInstance.getSme().getServiceApiIds()).ifPresent(
+ serviceApiList -> serviceApiList.forEach(
+ s -> deletePublishApi(s, rappInstance.getSme().getApfId())));
+ Optional.ofNullable(rappInstance.getSme().getProviderFunctionIds())
+ .ifPresent(providerList -> providerList.forEach(this::deleteProviderFunc));
+ rappInstanceStateMachine.sendRappInstanceEvent(rappInstance, RappEvent.SMEUNDEPLOYED);
+ return true;
+ } catch (Exception e) {
+ logger.warn("Failed to Undeploy SME functions for Rapp {}", rapp.getName(), e);
+ }
+ rappInstanceStateMachine.sendRappInstanceEvent(rappInstance, RappEvent.SMEUNDEPLOYFAILED);
+ rappInstance.setReason("Unable to undeploy SME");
+ return false;