- try {
- rapp.getSmeInvokers().forEach(this::deleteInvoker);
- rapp.getSmeServiceApis().forEach(s -> deletePublishApi(s, rapp.getSmeApfId()));
- rapp.getSmeProviderFunctions().values().forEach(this::deleteProviderFunc);
- rappStateMachine.sendRappEvent(rapp, RappEvent.SMEUNDEPLOYED);
- return true;
- } catch (Exception e) {
- logger.warn("Failed to Undeploy SME functions for Rapp {}", rapp.getName());
+ if (rappInstance.isSMEEnabled()) {
+ 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);
+ }
+ rappInstanceStateMachine.sendRappInstanceEvent(rappInstance, RappEvent.SMEUNDEPLOYFAILED);
+ rappInstance.setReason("Unable to undeploy SME");
+ return false;