Skip to content

Commit

Permalink
jaxrs: Minor renaming/refactoring related to fce39c3
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrossie committed Apr 12, 2018
1 parent c81db07 commit 949d5aa
Showing 1 changed file with 9 additions and 7 deletions.
Expand Up @@ -193,12 +193,14 @@ public Response createEntitlement(final SubscriptionJson entitlement,

logDeprecationParameterWarningIfNeeded(QUERY_REQUESTED_DT, QUERY_ENTITLEMENT_REQUESTED_DT, QUERY_BILLING_REQUESTED_DT);

// For ADD_ON we can provide externalKey or the bundleId
final boolean createAddOnEntitlement = ProductCategory.ADD_ON.toString().equals(entitlement.getProductCategory());
if (createAddOnEntitlement) {
// For ADD_ON we need to provide externalKey or the bundleId
if (ProductCategory.ADD_ON.toString().equals(entitlement.getProductCategory())) {
Preconditions.checkArgument(entitlement.getExternalKey() != null || entitlement.getBundleId() != null, "SubscriptionJson bundleId or externalKey should be specified for ADD_ON");
}
final boolean createStandaloneEntitlement = ProductCategory.STANDALONE.toString().equals(entitlement.getProductCategory()) && entitlement.getBundleId() != null;

final boolean isInitialBundle = ProductCategory.BASE.name() == entitlement.getProductCategory() ||

This comment has been minimized.

Copy link
@pierre

pierre Apr 16, 2018

Member

== used for String. Will fix.

This comment has been minimized.

Copy link
@sbrossie

sbrossie Apr 16, 2018

Author Member

Yeah, because in my branch entitlement.getProductCategory() is a ProductCategory not a string, got confused.. 😱

(ProductCategory.STANDALONE.name() == entitlement.getProductCategory() && entitlement.getBundleId() == null);


final Iterable<PluginProperty> pluginProperties = extractPluginProperties(pluginPropertiesString);
final CallContext callContext = context.createCallContextNoAccountId(createdBy, reason, comment, request);
Expand All @@ -217,9 +219,9 @@ public Entitlement doOperation(final CallContext ctx) throws InterruptedExceptio
final LocalDate resolvedEntitlementDate = requestedDate != null ? toLocalDate(requestedDate) : toLocalDate(entitlementDate);
final LocalDate resolvedBillingDate = requestedDate != null ? toLocalDate(requestedDate) : toLocalDate(billingDate);
final List<PlanPhasePriceOverride> overrides = PhasePriceOverrideJson.toPlanPhasePriceOverrides(entitlement.getPriceOverrides(), spec, account.getCurrency());
final Entitlement result = createAddOnEntitlement || createStandaloneEntitlement
? entitlementApi.addEntitlement(getBundleIdForAddOnCreation(entitlement), spec, overrides, resolvedEntitlementDate, resolvedBillingDate, isMigrated, pluginProperties, callContext)
: entitlementApi.createBaseEntitlement(account.getId(), spec, entitlement.getExternalKey(), overrides, resolvedEntitlementDate, resolvedBillingDate, isMigrated, renameKeyIfExistsAndUnused, pluginProperties, callContext);
final Entitlement result = isInitialBundle
? entitlementApi.createBaseEntitlement(account.getId(), spec, entitlement.getExternalKey(), overrides, resolvedEntitlementDate, resolvedBillingDate, isMigrated, renameKeyIfExistsAndUnused, pluginProperties, callContext)
: entitlementApi.addEntitlement(getBundleIdForAddOnCreation(entitlement), spec, overrides, resolvedEntitlementDate, resolvedBillingDate, isMigrated, pluginProperties, callContext);

if (newBCD != null) {
result.updateBCD(newBCD, null, callContext);
Expand Down

0 comments on commit 949d5aa

Please sign in to comment.