protected List < BlockingState > addBlockingStatesNotOnDisk ( @ Nullable final UUID blockableId , @ Nullable final BlockingStateType blockingStateType , final Collection < BlockingState > blockingStatesOnDiskCopy , final Iterable < SubscriptionBase > baseSubscriptionsToConsider , final Iterable < EventsStream > eventsStreams ) { // Compute the blocking states not on disk for all base subscriptions final DateTime now = clock . getUTCNow ( ) ; for ( final SubscriptionBase baseSubscription : baseSubscriptionsToConsider ) { final EventsStream eventsStream = Iterables . < EventsStream > find ( eventsStreams , new Predicate < EventsStream > ( ) { @ Override public boolean apply ( final EventsStream input ) { return input . getSubscriptionBase ( ) . getId ( ) . equals ( baseSubscription . getId ( ) ) ; } } ) ; // First, check to see if the base entitlement is cancelled final Collection < BlockingState > blockingStatesNotOnDisk = eventsStream . computeAddonsBlockingStatesForFutureSubscriptionBaseEvents ( ) ; // Inject the extra blocking states into the stream if needed for ( final BlockingState blockingState : blockingStatesNotOnDisk ) { // If this entitlement is actually already cancelled, add the cancellation event we computed // only if it's prior to the blocking state on disk (e.g. add-on future cancelled but base plan cancelled earlier). BlockingState cancellationBlockingStateOnDisk = null ; boolean overrideCancellationBlockingStateOnDisk = false ; if ( isEntitlementCancellationBlockingState ( blockingState ) ) { cancellationBlockingStateOnDisk = findEntitlementCancellationBlockingState ( blockingState . getBlockedId ( ) , blockingStatesOnDiskCopy ) ; overrideCancellationBlockingStateOnDisk = cancellationBlockingStateOnDisk != null && blockingState . getEffectiveDate ( ) . isBefore ( cancellationBlockingStateOnDisk . getEffectiveDate ( ) ) ; } if ( ( blockingStateType == null || // In case we're coming from OptimizedProxyBlockingStateDao, make sure we don't add // blocking states for other add-ons on that base subscription ( BlockingStateType . SUBSCRIPTION . equals ( blockingStateType ) && blockingState . getBlockedId ( ) . equals ( blockableId ) ) ) && ( cancellationBlockingStateOnDisk == null || overrideCancellationBlockingStateOnDisk ) ) { final BlockingStateModelDao blockingStateModelDao = new BlockingStateModelDao ( blockingState , now , now ) ; blockingStatesOnDiskCopy . add ( BlockingStateModelDao . toBlockingState ( blockingStateModelDao ) ) ; if ( overrideCancellationBlockingStateOnDisk ) { blockingStatesOnDiskCopy . remove ( cancellationBlockingStateOnDisk ) ; } } } } // Return the sorted list return sortedCopy ( blockingStatesOnDiskCopy ) ; }
Special signature for OptimizedProxyBlockingStateDao