killbill-uncached
Changes
beatrix/pom.xml 6(+3 -3)
entitlement/src/main/java/com/ning/billing/entitlement/api/DefaultSubscriptionBundleTimeline.java 100(+100 -0)
osgi-bundles/bundles/logger/pom.xml 2(+1 -1)
Details
beatrix/pom.xml 6(+3 -3)
diff --git a/beatrix/pom.xml b/beatrix/pom.xml
index c24024b..7a58589 100644
--- a/beatrix/pom.xml
+++ b/beatrix/pom.xml
@@ -236,9 +236,9 @@
</goals>
<configuration>
<tasks>
- <copy file="${basedir}/../osgi-bundles/tests/beatrix/target/killbill-osgi-bundles-test-beatrix-${project.version}-jar-with-dependencies.jar" tofile="${basedir}/src/test/resources/killbill-osgi-bundles-test-beatrix-${project.version}-jar-with-dependencies.jar" />
- <copy file="${basedir}/../osgi-bundles/tests/payment/target/killbill-osgi-bundles-test-payment-${project.version}-jar-with-dependencies.jar" tofile="${basedir}/src/test/resources/killbill-osgi-bundles-test-payment-${project.version}-jar-with-dependencies.jar" />
- <copy file="${basedir}/../osgi-bundles/bundles/jruby/target/killbill-osgi-bundles-jruby-${project.version}.jar" tofile="${basedir}/src/test/resources/killbill-osgi-bundles-jruby-${project.version}.jar" />
+ <copy file="${basedir}/../osgi-bundles/tests/beatrix/target/killbill-osgi-bundles-test-beatrix-${project.version}-jar-with-dependencies.jar" tofile="${basedir}/src/test/resources/killbill-osgi-bundles-test-beatrix-${project.version}-jar-with-dependencies.jar"></copy>
+ <copy file="${basedir}/../osgi-bundles/tests/payment/target/killbill-osgi-bundles-test-payment-${project.version}-jar-with-dependencies.jar" tofile="${basedir}/src/test/resources/killbill-osgi-bundles-test-payment-${project.version}-jar-with-dependencies.jar"></copy>
+ <copy file="${basedir}/../osgi-bundles/bundles/jruby/target/killbill-osgi-bundles-jruby-${project.version}.jar" tofile="${basedir}/src/test/resources/killbill-osgi-bundles-jruby-${project.version}.jar"></copy>
</tasks>
</configuration>
</execution>
diff --git a/entitlement/src/main/java/com/ning/billing/entitlement/api/DefaultSubscriptionBundleTimeline.java b/entitlement/src/main/java/com/ning/billing/entitlement/api/DefaultSubscriptionBundleTimeline.java
index 0dd0f46..e4e72cb 100644
--- a/entitlement/src/main/java/com/ning/billing/entitlement/api/DefaultSubscriptionBundleTimeline.java
+++ b/entitlement/src/main/java/com/ning/billing/entitlement/api/DefaultSubscriptionBundleTimeline.java
@@ -708,5 +708,105 @@ public class DefaultSubscriptionBundleTimeline implements SubscriptionBundleTime
public DateTime getCreatedDate() {
return createdDate;
}
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ final DefaultSubscriptionEvent that = (DefaultSubscriptionEvent) o;
+
+ if (isBlockingBilling != that.isBlockingBilling) {
+ return false;
+ }
+ if (isBlockingEntitlement != that.isBlockingEntitlement) {
+ return false;
+ }
+ if (createdDate != null ? !createdDate.equals(that.createdDate) : that.createdDate != null) {
+ return false;
+ }
+ if (effectiveDate != null ? !effectiveDate.equals(that.effectiveDate) : that.effectiveDate != null) {
+ return false;
+ }
+ if (entitlementId != null ? !entitlementId.equals(that.entitlementId) : that.entitlementId != null) {
+ return false;
+ }
+ if (eventType != that.eventType) {
+ return false;
+ }
+ if (id != null ? !id.equals(that.id) : that.id != null) {
+ return false;
+ }
+ if (nextBillingPeriod != that.nextBillingPeriod) {
+ return false;
+ }
+ if (nextPlan != null ? !nextPlan.equals(that.nextPlan) : that.nextPlan != null) {
+ return false;
+ }
+ if (nextPlanPhase != null ? !nextPlanPhase.equals(that.nextPlanPhase) : that.nextPlanPhase != null) {
+ return false;
+ }
+ if (nextPriceList != null ? !nextPriceList.equals(that.nextPriceList) : that.nextPriceList != null) {
+ return false;
+ }
+ if (nextProduct != null ? !nextProduct.equals(that.nextProduct) : that.nextProduct != null) {
+ return false;
+ }
+ if (prevBillingPeriod != that.prevBillingPeriod) {
+ return false;
+ }
+ if (prevPlan != null ? !prevPlan.equals(that.prevPlan) : that.prevPlan != null) {
+ return false;
+ }
+ if (prevPlanPhase != null ? !prevPlanPhase.equals(that.prevPlanPhase) : that.prevPlanPhase != null) {
+ return false;
+ }
+ if (prevPriceList != null ? !prevPriceList.equals(that.prevPriceList) : that.prevPriceList != null) {
+ return false;
+ }
+ if (prevProduct != null ? !prevProduct.equals(that.prevProduct) : that.prevProduct != null) {
+ return false;
+ }
+ if (requestedDate != null ? !requestedDate.equals(that.requestedDate) : that.requestedDate != null) {
+ return false;
+ }
+ if (serviceName != null ? !serviceName.equals(that.serviceName) : that.serviceName != null) {
+ return false;
+ }
+ if (serviceStateName != null ? !serviceStateName.equals(that.serviceStateName) : that.serviceStateName != null) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = id != null ? id.hashCode() : 0;
+ result = 31 * result + (entitlementId != null ? entitlementId.hashCode() : 0);
+ result = 31 * result + (effectiveDate != null ? effectiveDate.hashCode() : 0);
+ result = 31 * result + (requestedDate != null ? requestedDate.hashCode() : 0);
+ result = 31 * result + (eventType != null ? eventType.hashCode() : 0);
+ result = 31 * result + (isBlockingEntitlement ? 1 : 0);
+ result = 31 * result + (isBlockingBilling ? 1 : 0);
+ result = 31 * result + (serviceName != null ? serviceName.hashCode() : 0);
+ result = 31 * result + (serviceStateName != null ? serviceStateName.hashCode() : 0);
+ result = 31 * result + (prevProduct != null ? prevProduct.hashCode() : 0);
+ result = 31 * result + (prevPlan != null ? prevPlan.hashCode() : 0);
+ result = 31 * result + (prevPlanPhase != null ? prevPlanPhase.hashCode() : 0);
+ result = 31 * result + (prevPriceList != null ? prevPriceList.hashCode() : 0);
+ result = 31 * result + (prevBillingPeriod != null ? prevBillingPeriod.hashCode() : 0);
+ result = 31 * result + (nextProduct != null ? nextProduct.hashCode() : 0);
+ result = 31 * result + (nextPlan != null ? nextPlan.hashCode() : 0);
+ result = 31 * result + (nextPlanPhase != null ? nextPlanPhase.hashCode() : 0);
+ result = 31 * result + (nextPriceList != null ? nextPriceList.hashCode() : 0);
+ result = 31 * result + (nextBillingPeriod != null ? nextBillingPeriod.hashCode() : 0);
+ result = 31 * result + (createdDate != null ? createdDate.hashCode() : 0);
+ return result;
+ }
}
}
\ No newline at end of file
diff --git a/jaxrs/src/main/java/com/ning/billing/jaxrs/json/EntitlementJsonNoEvents.java b/jaxrs/src/main/java/com/ning/billing/jaxrs/json/EntitlementJsonNoEvents.java
index e159644..2bd4600 100644
--- a/jaxrs/src/main/java/com/ning/billing/jaxrs/json/EntitlementJsonNoEvents.java
+++ b/jaxrs/src/main/java/com/ning/billing/jaxrs/json/EntitlementJsonNoEvents.java
@@ -65,10 +65,10 @@ public class EntitlementJsonNoEvents extends EntitlementJsonSimple {
data.getId().toString(),
data.getExternalKey(),
data.getEffectiveStartDate(),
- data.getProduct().getName(),
- data.getProduct().getCategory().name(),
- data.getPlan().getBillingPeriod().name(),
- data.getPriceList().getName(),
+ data.getProduct() != null ? data.getProduct().getName() : null,
+ data.getProduct() != null ? data.getProduct().getCategory().name() : null,
+ data.getPlan() != null ? data.getPlan().getBillingPeriod().name() : null,
+ data.getPriceList() != null ? data.getPriceList().getName() : null,
data.getEffectiveEndDate(),
toAuditLogJson(auditLogs));
}
diff --git a/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/BundleResource.java b/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/BundleResource.java
index 6eed149..d1d88e6 100644
--- a/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/BundleResource.java
+++ b/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/BundleResource.java
@@ -188,8 +188,7 @@ public class BundleResource extends JaxRsResourceBase {
final UUID bundleId = UUID.fromString(id);
final SubscriptionBundle bundle = subscriptionApi.getSubscriptionBundle(bundleId, callContext);
- final DateTime inputDate = (requestedDate != null) ? DATE_TIME_FORMATTER.parseDateTime(requestedDate) : null;
- final LocalDate inputLocalDate = toLocalDate(bundle.getAccountId(), inputDate, callContext);
+ final LocalDate inputLocalDate = toLocalDate(bundle.getAccountId(), requestedDate, callContext);
final UUID newBundleId = entitlementApi.transferEntitlements(bundle.getAccountId(), UUID.fromString(json.getAccountId()), bundle.getExternalKey(), inputLocalDate, callContext);
return uriBuilder.buildResponse(BundleResource.class, "getBundle", newBundleId, uriInfo.getBaseUri().toString());
diff --git a/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/EntitlementResource.java b/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/EntitlementResource.java
index ba8bd06..2e0c428 100644
--- a/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/EntitlementResource.java
+++ b/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/EntitlementResource.java
@@ -126,19 +126,17 @@ public class EntitlementResource extends JaxRsResourceBase {
@HeaderParam(HDR_COMMENT) final String comment,
@javax.ws.rs.core.Context final HttpServletRequest request) throws EntitlementApiException, AccountApiException {
final CallContext callContext = context.createContext(createdBy, reason, comment, request);
- final DateTime inputDate = (requestedDate != null) ? DATE_TIME_FORMATTER.parseDateTime(requestedDate) : null;
final EntitlementCallCompletionCallback<Entitlement> callback = new EntitlementCallCompletionCallback<Entitlement>() {
@Override
public Entitlement doOperation(final CallContext ctx) throws InterruptedException, TimeoutException, EntitlementApiException {
- //final DateTime inputDate = (requestedDate != null) ? DATE_TIME_FORMATTER.parseDateTime(requestedDate) : null;
final PlanPhaseSpecifier spec = new PlanPhaseSpecifier(entitlement.getProductName(),
ProductCategory.valueOf(entitlement.getProductCategory()),
BillingPeriod.valueOf(entitlement.getBillingPeriod()), entitlement.getPriceList(), null);
final UUID accountId = entitlement.getAccountId() != null ? UUID.fromString(entitlement.getAccountId()) : null;
- final LocalDate inputLocalDate = toLocalDate(accountId, inputDate, callContext);
+ final LocalDate inputLocalDate = toLocalDate(accountId, requestedDate, callContext);
final UUID bundleId = entitlement.getBundleId() != null ? UUID.fromString(entitlement.getBundleId()) : null;
return (entitlement.getProductCategory().equals(ProductCategory.ADD_ON.toString())) ?
entitlementApi.addEntitlement(bundleId, spec, inputLocalDate, callContext) :
@@ -184,11 +182,9 @@ public class EntitlementResource extends JaxRsResourceBase {
public Response doOperation(final CallContext ctx) throws EntitlementApiException, InterruptedException,
TimeoutException, AccountApiException {
final UUID uuid = UUID.fromString(entitlementId);
- final DateTime inputDate = (requestedDate != null) ? DATE_TIME_FORMATTER.parseDateTime(requestedDate) : null;
-
final Entitlement current = entitlementApi.getEntitlementForId(uuid, callContext);
- final LocalDate inputLocalDate = toLocalDate(current.getAccountId(), inputDate, callContext);
+ final LocalDate inputLocalDate = toLocalDate(current.getAccountId(), requestedDate, callContext);
final Entitlement newEntitlement;
if (policyString == null) {
newEntitlement = current.changePlan(entitlement.getProductName(), BillingPeriod.valueOf(entitlement.getBillingPeriod()), entitlement.getPriceList(), inputLocalDate, ctx);
@@ -265,9 +261,7 @@ public class EntitlementResource extends JaxRsResourceBase {
final Entitlement current = entitlementApi.getEntitlementForId(uuid, ctx);
- final DateTime inputDate = (requestedDate != null) ? DATE_TIME_FORMATTER.parseDateTime(requestedDate) : null;
- final LocalDate inputLocalDate = toLocalDate(current.getAccountId(), inputDate, callContext);
-
+ final LocalDate inputLocalDate = toLocalDate(current.getAccountId(), requestedDate, callContext);
final Entitlement newEntitlement;
if (policyString == null) {
newEntitlement = current.cancelEntitlementWithDate(inputLocalDate, ctx);
diff --git a/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/JaxRsResourceBase.java b/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/JaxRsResourceBase.java
index 1310ec5..dafb1c5 100644
--- a/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/JaxRsResourceBase.java
+++ b/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/JaxRsResourceBase.java
@@ -29,6 +29,7 @@ import javax.ws.rs.core.UriInfo;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.LocalDate;
+import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
import org.slf4j.Logger;
@@ -74,6 +75,7 @@ public abstract class JaxRsResourceBase implements JaxrsResource {
protected final Clock clock;
protected final DateTimeFormatter DATE_TIME_FORMATTER = ISODateTimeFormat.dateTimeParser();
+ protected final DateTimeFormatter LOCAL_DATE_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd");
public JaxRsResourceBase(final JaxrsUriBuilder uriBuilder,
final TagUserApi tagUserApi,
@@ -196,12 +198,24 @@ public abstract class JaxRsResourceBase implements JaxrsResource {
return Response.status(Response.Status.OK).build();
}
- protected LocalDate toLocalDate(final UUID accountId, final DateTime inputDate, final TenantContext context) {
+ protected LocalDate toLocalDate(final UUID accountId, final String inputDate, final TenantContext context) {
+
+ if (inputDate != null) {
+ try {
+ final LocalDate localDate = LocalDate.parse(inputDate, LOCAL_DATE_FORMATTER);
+ return localDate;
+ } catch (IllegalArgumentException expectedAndIgnore) { /*Fall through... */ }
+ }
+ final DateTime inputDateTime = inputDate != null ? DATE_TIME_FORMATTER.parseDateTime(inputDate) : clock.getUTCNow();
+ return toLocalDate(accountId, inputDateTime, context);
+ }
+
+ private LocalDate toLocalDate(final UUID accountId, final DateTime inputDate, final TenantContext context) {
Account account = null;
try {
account = accountId != null ? accountUserApi.getAccountById(accountId, context) : null;
} catch (AccountApiException e) {
- log.info("Failed to retrieve account for id " + accountId );
+ log.info("Failed to retrieve account for id " + accountId);
}
if (account == null && inputDate == null) {
osgi-bundles/bundles/logger/pom.xml 2(+1 -1)
diff --git a/osgi-bundles/bundles/logger/pom.xml b/osgi-bundles/bundles/logger/pom.xml
index 437e773..dff155e 100644
--- a/osgi-bundles/bundles/logger/pom.xml
+++ b/osgi-bundles/bundles/logger/pom.xml
@@ -56,7 +56,7 @@
<configuration>
<instructions>
<Bundle-Activator>com.ning.billing.osgi.bundles.logger.Activator</Bundle-Activator>
- <Export-Package />
+ <Export-Package></Export-Package>
<Private-Package>com.ning.billing.osgi.bundles.logger.*</Private-Package>
<!-- Optional resolution because exported by the Felix system bundle -->
<Import-Package>*;resolution:=optional</Import-Package>