Search in sources :

Example 1 with DefaultImmutableAccountData

use of org.killbill.billing.account.api.DefaultImmutableAccountData in project killbill by killbill.

the class DefaultAccountApiBase method getAccountByKey.

protected Account getAccountByKey(final String key, final InternalTenantContext context) throws AccountApiException {
    final AccountModelDao accountModelDao = accountDao.getAccountByKey(key, context);
    if (accountModelDao == null) {
        throw new AccountApiException(ErrorCode.ACCOUNT_DOES_NOT_EXIST_FOR_KEY, key);
    }
    final Account account = new DefaultAccount(accountModelDao);
    accountCacheController.putIfAbsent(account.getId(), new DefaultImmutableAccountData(account));
    return account;
}
Also used : AccountModelDao(org.killbill.billing.account.dao.AccountModelDao) DefaultAccount(org.killbill.billing.account.api.DefaultAccount) Account(org.killbill.billing.account.api.Account) DefaultAccount(org.killbill.billing.account.api.DefaultAccount) DefaultImmutableAccountData(org.killbill.billing.account.api.DefaultImmutableAccountData) AccountApiException(org.killbill.billing.account.api.AccountApiException)

Example 2 with DefaultImmutableAccountData

use of org.killbill.billing.account.api.DefaultImmutableAccountData in project killbill by killbill.

the class DefaultAccountApiBase method getAccountById.

protected Account getAccountById(final UUID accountId, final InternalTenantContext context) throws AccountApiException {
    final Long recordId = nonEntityDao.retrieveRecordIdFromObject(accountId, ObjectType.ACCOUNT, cacheControllerDispatcher.getCacheController(CacheType.RECORD_ID));
    final Account account = getAccountByRecordIdInternal(recordId, context);
    if (account == null) {
        throw new AccountApiException(ErrorCode.ACCOUNT_DOES_NOT_EXIST_FOR_ID, accountId);
    }
    accountCacheController.putIfAbsent(accountId, new DefaultImmutableAccountData(account));
    return account;
}
Also used : DefaultAccount(org.killbill.billing.account.api.DefaultAccount) Account(org.killbill.billing.account.api.Account) DefaultImmutableAccountData(org.killbill.billing.account.api.DefaultImmutableAccountData) AccountApiException(org.killbill.billing.account.api.AccountApiException)

Example 3 with DefaultImmutableAccountData

use of org.killbill.billing.account.api.DefaultImmutableAccountData in project killbill by killbill.

the class DefaultImmutableAccountInternalApi method createImmutableAccountCacheLoaderArgument.

private CacheLoaderArgument createImmutableAccountCacheLoaderArgument(final InternalTenantContext context) {
    final LoaderCallback loaderCallback = new LoaderCallback() {

        @Override
        public Object loadAccount(final Long recordId, final InternalTenantContext context) {
            final Account account = getAccountByRecordIdInternal(recordId, context);
            return account != null ? new DefaultImmutableAccountData(account) : null;
        }
    };
    final Object[] args = { loaderCallback };
    return new CacheLoaderArgument(null, args, context);
}
Also used : DefaultAccount(org.killbill.billing.account.api.DefaultAccount) Account(org.killbill.billing.account.api.Account) DefaultImmutableAccountData(org.killbill.billing.account.api.DefaultImmutableAccountData) InternalTenantContext(org.killbill.billing.callcontext.InternalTenantContext) LoaderCallback(org.killbill.billing.util.cache.ImmutableAccountCacheLoader.LoaderCallback) CacheLoaderArgument(org.killbill.billing.util.cache.CacheLoaderArgument)

Aggregations

Account (org.killbill.billing.account.api.Account)3 DefaultAccount (org.killbill.billing.account.api.DefaultAccount)3 DefaultImmutableAccountData (org.killbill.billing.account.api.DefaultImmutableAccountData)3 AccountApiException (org.killbill.billing.account.api.AccountApiException)2 AccountModelDao (org.killbill.billing.account.dao.AccountModelDao)1 InternalTenantContext (org.killbill.billing.callcontext.InternalTenantContext)1 CacheLoaderArgument (org.killbill.billing.util.cache.CacheLoaderArgument)1 LoaderCallback (org.killbill.billing.util.cache.ImmutableAccountCacheLoader.LoaderCallback)1