Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Commit

Permalink
Stop the entitle subscriber operation when any entitlement cannot be
Browse files Browse the repository at this point in the history
added. The current hold doesn't handle the case were you are entitleing
a subscriber to multiple subscriptions and one of them fails.
  • Loading branch information
mwallace committed Sep 29, 2015
1 parent 3469589 commit 3c32ece
Showing 1 changed file with 27 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -351,26 +351,33 @@ private String getSubscriberState(){
* <p>
* @return <code>true</code> if the subscriber is entitled, <code>false</code> otherwise
*/
private boolean entitleSubscriber(){
Boolean suscriberEntitled = false ;
logger.info("Entitling subscriber...");
String subscriberState = getSubscriberState();
if(!"ACTIVE".equals(subscriberState)){
return suscriberEntitled;
}
for(SubscriptionEntitlement entitlement:entitlements){
WeightedBSSCall<Boolean> entitleSubscriber = new EntitleSubscriber(this.subscriberId, entitlement.getSubscriptionId(), this.subscriberEmail);
try{
suscriberEntitled = entitleSubscriber.call();
if( suscriberEntitled == null ){
suscriberEntitled = false ;
}
} catch (Exception e) {
logger.severe(e.getClass()+" : " + e.getMessage());
}
}
return suscriberEntitled ;
}
private boolean entitleSubscriber() {
Boolean subscriberEntitled = false;
logger.info("Entitling subscriber...");
String subscriberState = getSubscriberState();
if (!"ACTIVE".equals(subscriberState)) {
return subscriberEntitled;
}
for (SubscriptionEntitlement entitlement : entitlements) {
WeightedBSSCall<Boolean> entitleSubscriber = new EntitleSubscriber(
this.subscriberId, entitlement.getSubscriptionId(),
this.subscriberEmail);
try {
subscriberEntitled = entitleSubscriber.call();
if (subscriberEntitled == null) {
subscriberEntitled = false;
}
if (!subscriberEntitled) {
// stop when any entitle subscriber fails
logger.severe("Unable to entitle subscriber: " + subscriberState + " to subscription: " + entitlement.getPartNumber());
break;
}
} catch (Exception e) {
logger.severe(e.getClass() + " : " + e.getMessage());
}
}
return subscriberEntitled;
}

/**
* This method will trigger the retrieval of the subscriber by mean of invocation of the <code>call()</code> method of the <code>abstract
Expand Down

0 comments on commit 3c32ece

Please sign in to comment.