killbill-uncached
Changes
subscription/src/main/java/org/killbill/billing/subscription/alignment/MigrationPlanAligner.java 8(+4 -4)
Details
diff --git a/catalog/src/main/java/org/killbill/billing/catalog/StandaloneCatalog.java b/catalog/src/main/java/org/killbill/billing/catalog/StandaloneCatalog.java
index 596c5cd..0acb75d 100644
--- a/catalog/src/main/java/org/killbill/billing/catalog/StandaloneCatalog.java
+++ b/catalog/src/main/java/org/killbill/billing/catalog/StandaloneCatalog.java
@@ -163,7 +163,7 @@ public class StandaloneCatalog extends ValidatingConfig<StandaloneCatalog> imple
* @see org.killbill.billing.catalog.ICatalog#getPlan(java.lang.String, java.lang.String)
*/
@Override
- public DefaultPlan findCurrentPlan(final String productName, final BillingPeriod period, final String priceListName, final PlanPhasePriceOverridesWithCallContext unused) throws CatalogApiException {
+ public DefaultPlan createOrFindCurrentPlan(final String productName, final BillingPeriod period, final String priceListName, final PlanPhasePriceOverridesWithCallContext unused) throws CatalogApiException {
if (productName == null) {
throw new CatalogApiException(ErrorCode.CAT_NULL_PRODUCT_NAME);
}
@@ -346,7 +346,7 @@ public class StandaloneCatalog extends ValidatingConfig<StandaloneCatalog> imple
@Override
public boolean canCreatePlan(final PlanSpecifier specifier) throws CatalogApiException {
final Product product = findCurrentProduct(specifier.getProductName());
- final Plan plan = findCurrentPlan(specifier.getProductName(), specifier.getBillingPeriod(), specifier.getPriceListName(), null);
+ final Plan plan = createOrFindCurrentPlan(specifier.getProductName(), specifier.getBillingPeriod(), specifier.getPriceListName(), null);
final DefaultPriceList priceList = findCurrentPriceList(specifier.getPriceListName());
return (!product.isRetired()) &&
diff --git a/catalog/src/main/java/org/killbill/billing/catalog/StandaloneCatalogWithPriceOverride.java b/catalog/src/main/java/org/killbill/billing/catalog/StandaloneCatalogWithPriceOverride.java
index e3d0b39..11b1bfe 100644
--- a/catalog/src/main/java/org/killbill/billing/catalog/StandaloneCatalogWithPriceOverride.java
+++ b/catalog/src/main/java/org/killbill/billing/catalog/StandaloneCatalogWithPriceOverride.java
@@ -103,8 +103,8 @@ public class StandaloneCatalogWithPriceOverride extends ValidatingConfig<Standal
}
@Override
- public Plan findCurrentPlan(final String productName, final BillingPeriod period, final String priceListName, final PlanPhasePriceOverridesWithCallContext overrides) throws CatalogApiException {
- final Plan defaultPlan = standaloneCatalog.findCurrentPlan(productName, period, priceListName, null);
+ public Plan createOrFindCurrentPlan(final String productName, final BillingPeriod period, final String priceListName, final PlanPhasePriceOverridesWithCallContext overrides) throws CatalogApiException {
+ final Plan defaultPlan = standaloneCatalog.createOrFindCurrentPlan(productName, period, priceListName, null);
if (overrides == null ||
overrides.getOverrides() == null ||
diff --git a/catalog/src/main/java/org/killbill/billing/catalog/VersionedCatalog.java b/catalog/src/main/java/org/killbill/billing/catalog/VersionedCatalog.java
index 9170593..77de272 100644
--- a/catalog/src/main/java/org/killbill/billing/catalog/VersionedCatalog.java
+++ b/catalog/src/main/java/org/killbill/billing/catalog/VersionedCatalog.java
@@ -133,7 +133,7 @@ public class VersionedCatalog extends ValidatingConfig<StandaloneCatalogWithPric
if (name != null) {
return catalog.findCurrentPlan(name);
} else {
- return catalog.findCurrentPlan(productName, bp, priceListName, overrides);
+ return catalog.createOrFindCurrentPlan(productName, bp, priceListName, overrides);
}
}
}
@@ -246,13 +246,13 @@ public class VersionedCatalog extends ValidatingConfig<StandaloneCatalogWithPric
}
@Override
- public Plan findPlan(final String productName,
+ public Plan createOrFindPlan(final String productName,
final BillingPeriod term,
final String priceListName,
final PlanPhasePriceOverridesWithCallContext overrides,
final DateTime requestedDate)
throws CatalogApiException {
- return versionForDate(requestedDate).findCurrentPlan(productName, term, priceListName, overrides);
+ return versionForDate(requestedDate).createOrFindCurrentPlan(productName, term, priceListName, overrides);
}
@Override
@@ -264,7 +264,7 @@ public class VersionedCatalog extends ValidatingConfig<StandaloneCatalogWithPric
}
@Override
- public Plan findPlan(final String productName,
+ public Plan createOrFindPlan(final String productName,
final BillingPeriod term,
final String priceListName,
final PlanPhasePriceOverridesWithCallContext overrides,
@@ -404,9 +404,9 @@ public class VersionedCatalog extends ValidatingConfig<StandaloneCatalogWithPric
}
@Override
- public Plan findCurrentPlan(final String productName, final BillingPeriod term,
+ public Plan createOrFindCurrentPlan(final String productName, final BillingPeriod term,
final String priceList, PlanPhasePriceOverridesWithCallContext overrides) throws CatalogApiException {
- return versionForDate(clock.getUTCNow()).findCurrentPlan(productName, term, priceList, overrides);
+ return versionForDate(clock.getUTCNow()).createOrFindCurrentPlan(productName, term, priceList, overrides);
}
@Override
diff --git a/catalog/src/test/java/org/killbill/billing/catalog/MockCatalog.java b/catalog/src/test/java/org/killbill/billing/catalog/MockCatalog.java
index 88e6cd6..b6df395 100644
--- a/catalog/src/test/java/org/killbill/billing/catalog/MockCatalog.java
+++ b/catalog/src/test/java/org/killbill/billing/catalog/MockCatalog.java
@@ -112,9 +112,9 @@ public class MockCatalog extends StandaloneCatalog implements Catalog {
}
@Override
- public Plan findPlan(final String productName, final BillingPeriod term, final String priceListName, PlanPhasePriceOverridesWithCallContext overrides, final DateTime requestedDate)
+ public Plan createOrFindPlan(final String productName, final BillingPeriod term, final String priceListName, PlanPhasePriceOverridesWithCallContext overrides, final DateTime requestedDate)
throws CatalogApiException {
- return findCurrentPlan(productName, term, priceListName, overrides);
+ return createOrFindCurrentPlan(productName, term, priceListName, overrides);
}
@Override
@@ -124,9 +124,9 @@ public class MockCatalog extends StandaloneCatalog implements Catalog {
}
@Override
- public Plan findPlan(final String productName, final BillingPeriod term, final String priceListName, PlanPhasePriceOverridesWithCallContext overrides, final DateTime requestedDate,
+ public Plan createOrFindPlan(final String productName, final BillingPeriod term, final String priceListName, PlanPhasePriceOverridesWithCallContext overrides, final DateTime requestedDate,
final DateTime subscriptionStartDate) throws CatalogApiException {
- return findCurrentPlan(productName, term, priceListName, overrides);
+ return createOrFindCurrentPlan(productName, term, priceListName, overrides);
}
@Override
diff --git a/subscription/src/main/java/org/killbill/billing/subscription/alignment/MigrationPlanAligner.java b/subscription/src/main/java/org/killbill/billing/subscription/alignment/MigrationPlanAligner.java
index 8c2c903..c7b054e 100644
--- a/subscription/src/main/java/org/killbill/billing/subscription/alignment/MigrationPlanAligner.java
+++ b/subscription/src/main/java/org/killbill/billing/subscription/alignment/MigrationPlanAligner.java
@@ -48,11 +48,11 @@ public class MigrationPlanAligner extends BaseAligner {
try {
TimedMigration[] events;
- final Plan plan0 = catalogService.getFullCatalog(context).findPlan(input[0].getPlanPhaseSpecifier().getProductName(),
- input[0].getPlanPhaseSpecifier().getBillingPeriod(), input[0].getPlanPhaseSpecifier().getPriceListName(), null, now);
+ final Plan plan0 = catalogService.getFullCatalog(context).createOrFindPlan(input[0].getPlanPhaseSpecifier().getProductName(),
+ input[0].getPlanPhaseSpecifier().getBillingPeriod(), input[0].getPlanPhaseSpecifier().getPriceListName(), null, now);
- final Plan plan1 = (input.length > 1) ? catalogService.getFullCatalog(context).findPlan(input[1].getPlanPhaseSpecifier().getProductName(),
- input[1].getPlanPhaseSpecifier().getBillingPeriod(), input[1].getPlanPhaseSpecifier().getPriceListName(), null, now) :
+ final Plan plan1 = (input.length > 1) ? catalogService.getFullCatalog(context).createOrFindPlan(input[1].getPlanPhaseSpecifier().getProductName(),
+ input[1].getPlanPhaseSpecifier().getBillingPeriod(), input[1].getPlanPhaseSpecifier().getPriceListName(), null, now) :
null;
DateTime migrationStartDate = input[0].getEffectiveDate();
diff --git a/subscription/src/main/java/org/killbill/billing/subscription/api/svcs/DefaultSubscriptionInternalApi.java b/subscription/src/main/java/org/killbill/billing/subscription/api/svcs/DefaultSubscriptionInternalApi.java
index 2819f8b..8650ea8 100644
--- a/subscription/src/main/java/org/killbill/billing/subscription/api/svcs/DefaultSubscriptionInternalApi.java
+++ b/subscription/src/main/java/org/killbill/billing/subscription/api/svcs/DefaultSubscriptionInternalApi.java
@@ -117,7 +117,7 @@ public class DefaultSubscriptionInternalApi extends SubscriptionApiBase implemen
final Catalog catalog = catalogService.getFullCatalog(context);
final PlanPhasePriceOverridesWithCallContext overridesWithContext = new DefaultPlanPhasePriceOverridesWithCallContext(overrides, callContext);
- final Plan plan = catalog.findPlan(spec.getProductName(), spec.getBillingPeriod(), realPriceList, overridesWithContext, requestedDate);
+ final Plan plan = catalog.createOrFindPlan(spec.getProductName(), spec.getBillingPeriod(), realPriceList, overridesWithContext, requestedDate);
final PlanPhase phase = plan.getAllPhases()[0];
if (phase == null) {
throw new SubscriptionBaseError(String.format("No initial PlanPhase for Product %s, term %s and set %s does not exist in the catalog",
@@ -403,7 +403,7 @@ public class DefaultSubscriptionInternalApi extends SubscriptionApiBase implemen
final PlanPhasePriceOverridesWithCallContext overridesWithContext = null; // TODO not supported to dryRun with custom price
final Plan plan = (inputSpec != null && inputSpec.getProductName() != null && inputSpec.getBillingPeriod() != null) ?
- catalog.findPlan(inputSpec.getProductName(), inputSpec.getBillingPeriod(), realPriceList, overridesWithContext, utcNow) : null;
+ catalog.createOrFindPlan(inputSpec.getProductName(), inputSpec.getBillingPeriod(), realPriceList, overridesWithContext, utcNow) : null;
final TenantContext tenantContext = internalCallContextFactory.createTenantContext(context);
if (dryRunArguments != null) {
diff --git a/subscription/src/main/java/org/killbill/billing/subscription/api/user/DefaultSubscriptionBaseApiService.java b/subscription/src/main/java/org/killbill/billing/subscription/api/user/DefaultSubscriptionBaseApiService.java
index cf1be9b..9601adf 100644
--- a/subscription/src/main/java/org/killbill/billing/subscription/api/user/DefaultSubscriptionBaseApiService.java
+++ b/subscription/src/main/java/org/killbill/billing/subscription/api/user/DefaultSubscriptionBaseApiService.java
@@ -121,7 +121,7 @@ public class DefaultSubscriptionBaseApiService implements SubscriptionBaseApiSer
final String realPriceList = (spec.getPriceListName() == null) ? PriceListSet.DEFAULT_PRICELIST_NAME : spec.getPriceListName();
final InternalTenantContext internalCallContext = createTenantContextFromBundleId(subscription.getBundleId(), context);
final PlanPhasePriceOverridesWithCallContext overridesWithContext = new DefaultPlanPhasePriceOverridesWithCallContext(overrides, context);
- final Plan plan = catalogService.getFullCatalog(internalCallContext).findPlan(spec.getProductName(), spec.getBillingPeriod(), realPriceList, overridesWithContext, effectiveDate);
+ final Plan plan = catalogService.getFullCatalog(internalCallContext).createOrFindPlan(spec.getProductName(), spec.getBillingPeriod(), realPriceList, overridesWithContext, effectiveDate);
final PlanPhase phase = plan.getAllPhases()[0];
if (phase == null) {
throw new SubscriptionBaseError(String.format("No initial PlanPhase for Product %s, term %s and set %s does not exist in the catalog",
@@ -353,7 +353,7 @@ public class DefaultSubscriptionBaseApiService implements SubscriptionBaseApiSer
final CallContext context) throws SubscriptionBaseApiException, CatalogApiException {
final InternalCallContext internalCallContext = createCallContextFromBundleId(subscription.getBundleId(), context);
final PlanPhasePriceOverridesWithCallContext overridesWithContext = new DefaultPlanPhasePriceOverridesWithCallContext(overrides, context);
- final Plan newPlan = catalogService.getFullCatalog(internalCallContext).findPlan(newProductName, newBillingPeriod, newPriceList, overridesWithContext, effectiveDate, subscription.getStartDate());
+ final Plan newPlan = catalogService.getFullCatalog(internalCallContext).createOrFindPlan(newProductName, newBillingPeriod, newPriceList, overridesWithContext, effectiveDate, subscription.getStartDate());
final List<SubscriptionBaseEvent> changeEvents = getEventsOnChangePlan(subscription, newPlan, newPriceList, now, effectiveDate, now, false, internalCallContext);
dao.changePlan(subscription, changeEvents, internalCallContext);