Details
diff --git a/api/src/main/java/com/ning/billing/junction/api/Blockable.java b/api/src/main/java/com/ning/billing/junction/api/Blockable.java
index cb5b1a0..240e70f 100644
--- a/api/src/main/java/com/ning/billing/junction/api/Blockable.java
+++ b/api/src/main/java/com/ning/billing/junction/api/Blockable.java
@@ -21,6 +21,7 @@ import java.util.UUID;
import com.ning.billing.account.api.Account;
import com.ning.billing.entitlement.api.user.Subscription;
import com.ning.billing.entitlement.api.user.SubscriptionBundle;
+import com.ning.billing.util.dao.ObjectType;
public interface Blockable {
@@ -51,6 +52,19 @@ public interface Blockable {
throw new IllegalStateException("Unsupported type of blockable " + type);
}
+ public static ObjectType getObjectType(final Blockable o) {
+ final Type type = get(o);
+ switch (type) {
+ case ACCOUNT:
+ return ObjectType.ACCOUNT;
+ case SUBSCRIPTION_BUNDLE:
+ return ObjectType.BUNDLE;
+ case SUBSCRIPTION:
+ return ObjectType.SUBSCRIPTION;
+ default:
+ throw new IllegalStateException("Unsupported type of blockable " + type);
+ }
+ }
}
public UUID getId();
diff --git a/overdue/src/main/java/com/ning/billing/overdue/api/DefaultOverdueUserApi.java b/overdue/src/main/java/com/ning/billing/overdue/api/DefaultOverdueUserApi.java
index 1ba62b3..56e46c2 100644
--- a/overdue/src/main/java/com/ning/billing/overdue/api/DefaultOverdueUserApi.java
+++ b/overdue/src/main/java/com/ning/billing/overdue/api/DefaultOverdueUserApi.java
@@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory;
import com.ning.billing.ErrorCode;
import com.ning.billing.entitlement.api.user.SubscriptionBundle;
import com.ning.billing.junction.api.Blockable;
+import com.ning.billing.junction.api.Blockable.Type;
import com.ning.billing.junction.api.BlockingApi;
import com.ning.billing.overdue.OverdueApiException;
import com.ning.billing.overdue.OverdueState;
@@ -33,8 +34,10 @@ import com.ning.billing.overdue.config.api.OverdueStateSet;
import com.ning.billing.overdue.wrapper.OverdueWrapper;
import com.ning.billing.overdue.wrapper.OverdueWrapperFactory;
import com.ning.billing.util.callcontext.CallContext;
+import com.ning.billing.util.callcontext.InternalCallContext;
import com.ning.billing.util.callcontext.InternalCallContextFactory;
import com.ning.billing.util.callcontext.TenantContext;
+import com.ning.billing.util.dao.ObjectType;
import com.google.inject.Inject;
@@ -78,8 +81,12 @@ public class DefaultOverdueUserApi implements OverdueUserApi {
public <T extends Blockable> OverdueState<T> refreshOverdueStateFor(final T blockable, final CallContext context) throws OverdueException, OverdueApiException {
log.info(String.format("Refresh of %s requested", blockable.getId()));
final OverdueWrapper<T> wrapper = factory.createOverdueWrapperFor(blockable);
- // TODO accountId?
- return wrapper.refresh(internalCallContextFactory.createInternalCallContext(context));
+ return wrapper.refresh(createInternalCallContext(blockable, context));
+ }
+
+ private <T extends Blockable> InternalCallContext createInternalCallContext(final T blockable, final CallContext context) {
+ final ObjectType objectType = Type.getObjectType(blockable);
+ return internalCallContextFactory.createInternalCallContext(blockable.getId(), objectType, context);
}
@Override
diff --git a/util/src/main/java/com/ning/billing/util/callcontext/InternalCallContextFactory.java b/util/src/main/java/com/ning/billing/util/callcontext/InternalCallContextFactory.java
index 17637d5..b19bea7 100644
--- a/util/src/main/java/com/ning/billing/util/callcontext/InternalCallContextFactory.java
+++ b/util/src/main/java/com/ning/billing/util/callcontext/InternalCallContextFactory.java
@@ -115,7 +115,7 @@ public class InternalCallContextFactory {
}
// Used for r/o or update/delete operations - we don't need the account id in that case
- // TODO - more work is needed for this statement to hold (especially for junction, overdue, custom fields and tags)
+ // Used also when we don't have an account_record_id column (e.g. tenants, tag_definitions)
public InternalCallContext createInternalCallContext(final CallContext context) {
return createInternalCallContext(getTenantRecordId(context), null, context);
}