Search in sources :

Example 91 with InternalTenantContext

use of org.killbill.billing.callcontext.InternalTenantContext in project killbill by killbill.

the class InternalCallContextFactory method getImmutableAccountData.

private ImmutableAccountData getImmutableAccountData(final Long accountRecordId, final Long tenantRecordId) {
    Preconditions.checkNotNull(accountRecordId, "Missing accountRecordId");
    final InternalTenantContext tmp = new InternalTenantContext(tenantRecordId, accountRecordId, null, null);
    try {
        final ImmutableAccountData immutableAccountData = accountInternalApi.getImmutableAccountDataByRecordId(accountRecordId, tmp);
        Preconditions.checkNotNull(immutableAccountData, "Unable to retrieve immutableAccountData");
        return immutableAccountData;
    } catch (final AccountApiException e) {
        throw new RuntimeException(e);
    }
}
Also used : ImmutableAccountData(org.killbill.billing.account.api.ImmutableAccountData) InternalTenantContext(org.killbill.billing.callcontext.InternalTenantContext) AccountApiException(org.killbill.billing.account.api.AccountApiException)

Example 92 with InternalTenantContext

use of org.killbill.billing.callcontext.InternalTenantContext in project killbill by killbill.

the class TenantKVCacheLoader method compute.

@Override
public String compute(final String key, final CacheLoaderArgument cacheLoaderArgument) {
    final String[] parts = key.split(CacheControllerDispatcher.CACHE_KEY_SEPARATOR);
    final String rawKey = parts[0];
    final String tenantRecordId = parts[1];
    final InternalTenantContext internalTenantContext = new InternalTenantContext(Long.valueOf(tenantRecordId));
    final List<String> valuesForKey = tenantApi.getTenantValuesForKey(rawKey, internalTenantContext);
    if (valuesForKey == null || valuesForKey.isEmpty()) {
        return EMPTY_VALUE_PLACEHOLDER;
    }
    if (valuesForKey.size() > 1) {
        throw new IllegalStateException("TenantKVCacheLoader expecting no more than one value for key " + key);
    }
    return valuesForKey.get(0);
}
Also used : InternalTenantContext(org.killbill.billing.callcontext.InternalTenantContext)

Aggregations

InternalTenantContext (org.killbill.billing.callcontext.InternalTenantContext)92 UUID (java.util.UUID)15 CatalogApiException (org.killbill.billing.catalog.api.CatalogApiException)13 CacheLoaderArgument (org.killbill.billing.util.cache.CacheLoaderArgument)11 InternalCallContext (org.killbill.billing.callcontext.InternalCallContext)10 ArrayList (java.util.ArrayList)9 ObjectType (org.killbill.billing.ObjectType)9 SubscriptionBaseApiException (org.killbill.billing.subscription.api.user.SubscriptionBaseApiException)9 TenantContext (org.killbill.billing.util.callcontext.TenantContext)9 ImmutableList (com.google.common.collect.ImmutableList)8 List (java.util.List)8 DefaultInvoice (org.killbill.billing.invoice.model.DefaultInvoice)8 IOException (java.io.IOException)7 InputStream (java.io.InputStream)7 DateTime (org.joda.time.DateTime)7 LocalDate (org.joda.time.LocalDate)7 Predicate (com.google.common.base.Predicate)6 AccountApiException (org.killbill.billing.account.api.AccountApiException)6 VersionedCatalog (org.killbill.billing.catalog.api.VersionedCatalog)6 InvoiceApiException (org.killbill.billing.invoice.api.InvoiceApiException)6