Skip to content

Commit f0ec6bb

Browse files
committed
Don't return 500 if we cannot unsubscribe from service, just delete it
1 parent 41a000a commit f0ec6bb

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

src/main/java/international/dmc/secom_mms_gateway/controllers/management/SubscriptionManagementController.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,7 @@ public ResponseEntity<Void> deleteSubscriptionByMrn(@PathVariable String mrn) {
106106
if (subscription == null) {
107107
return ResponseEntity.notFound().build();
108108
}
109-
boolean removed = subscriptionService.unsubscribeAndRemoveSubscription(mrn);
110-
if (!removed) {
111-
return ResponseEntity.internalServerError().build();
112-
}
109+
subscriptionService.unsubscribeAndRemoveSubscription(mrn);
113110
return ResponseEntity.ok().build();
114111
}
115112

@@ -122,10 +119,7 @@ public ResponseEntity<Subscription> deleteSubscriptionById(@PathVariable String
122119
if (subscription == null) {
123120
return ResponseEntity.notFound().build();
124121
}
125-
boolean removed = subscriptionService.unsubscribeAndRemoveSubscription(subscription.getServiceMrn());
126-
if (!removed) {
127-
return ResponseEntity.internalServerError().build();
128-
}
122+
subscriptionService.unsubscribeAndRemoveSubscription(subscription.getServiceMrn());
129123
return ResponseEntity.ok().build();
130124
}
131125
}

src/main/java/international/dmc/secom_mms_gateway/services/SubscriptionService.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,11 @@ public Subscription addSubscription(Subscription subscription) throws Subscripti
108108
return subscription;
109109
}
110110

111-
public boolean unsubscribeAndRemoveSubscription(String serviceMrn) {
112-
if (!unsubscribeFromService(serviceMrn)) return false;
111+
public void unsubscribeAndRemoveSubscription(String serviceMrn) {
112+
if (!unsubscribeFromService(serviceMrn)) {
113+
log.error("Unsubscribe failed for service mrn = {}, deleting it anyway", serviceMrn);
114+
}
113115
subscriptionRepository.deleteByServiceMrn(serviceMrn);
114-
return true;
115116
}
116117

117118
public void removeSubscription(String serviceMrn) {

0 commit comments

Comments
 (0)