private InternalCallContext createCallContext() { // TODO information about accountRecordId and tenatRecordId return internalCallContextFactory.createInternalCallContext(InternalCallContextFactory.INTERNAL_TENANT_RECORD_ID, null, "ChunkWriter", CallOrigin.INTERNAL, UserType.SYSTEM, null); } }
@Override public Pagination<CustomFieldModelDao> build() { return customFieldDao.searchCustomFields(searchKey, offset, limit, internalCallContextFactory.createInternalTenantContext(context)); } },
public InternalCallContext createInternalCallContext(final UUID objectId, final ObjectType objectType, final String userName, final CallOrigin callOrigin, final UserType userType, @Nullable final UUID userToken, @Nullable final String reasonCode, @Nullable final String comment, final DateTime createdDate, final DateTime updatedDate) { final Long tenantRecordId = nonEntityDao.retrieveTenantRecordIdFromObject(objectId, objectType, cacheControllerDispatcher.getCacheController(CacheType.TENANT_RECORD_ID)); final Long accountRecordId = getAccountRecordId(objectId, objectType); return createInternalCallContext(tenantRecordId, accountRecordId, userName, callOrigin, userType, userToken, reasonCode, comment, createdDate, updatedDate); }
/** * Crate an internal tenant callcontext from a tenant callcontext, and retrieving the account_record_id from another table * * @param objectId the id of the row in the table pointed by object type where to look for account_record_id * @param objectType the object type pointed by this objectId * @param context original tenant callcontext * @return internal tenant callcontext from callcontext, with a non null account_record_id (if found) */ public InternalTenantContext createInternalTenantContext(final UUID objectId, final ObjectType objectType, final TenantContext context) { // The callcontext may come from a user API - for security, check we're not doing cross-tenants operations //final Long tenantRecordIdFromObject = retrieveTenantRecordIdFromObject(objectId, objectType); //final Long tenantRecordIdFromContext = getTenantRecordId(callcontext); //Preconditions.checkState(tenantRecordIdFromContext.equals(tenantRecordIdFromObject), // "tenant of the pointed object (%s) and the callcontext (%s) don't match!", tenantRecordIdFromObject, tenantRecordIdFromContext); final Long tenantRecordId = getTenantRecordId(context); final Long accountRecordId = getAccountRecordId(objectId, objectType); return createInternalTenantContext(tenantRecordId, accountRecordId); }
public InternalTenantContext createInternalTenantContext(final UUID accountId, final TenantContext context) { final Long tenantRecordId = getTenantRecordId(context); final Long accountRecordId = getAccountRecordId(accountId, ObjectType.ACCOUNT); return new InternalTenantContext(tenantRecordId, accountRecordId); }
private Long getAccountRecordId(final UUID accountId) { return getAccountRecordId(accountId, ObjectType.ACCOUNT); }
@Override @BeforeMethod(groups = "fast") public void beforeMethod() throws Exception { super.beforeMethod(); final NonEntityDao nonEntityDao = Mockito.mock(NonEntityDao.class); final SubscriptionDao dao = Mockito.mock(SubscriptionDao.class); final CatalogService catalogService = new MockCatalogService(new MockCatalog()); final SubscriptionBaseApiService apiService = Mockito.mock(SubscriptionBaseApiService.class); final SubscriptionBaseTimelineApi timelineApi = Mockito.mock(SubscriptionBaseTimelineApi.class); final InternalCallContextFactory internalCallContextFactory = new InternalCallContextFactory(clock, nonEntityDao, new CacheControllerDispatcher()); transferApi = new DefaultSubscriptionBaseTransferApi(clock, dao, timelineApi, catalogService, apiService, internalCallContextFactory); }
public InternalTenantContext createInternalTenantContext(final UUID accountId, final InternalTenantContext context) { final Long tenantRecordId = context.getTenantRecordId(); final Long accountRecordId = getAccountRecordId(accountId, ObjectType.ACCOUNT); return new InternalTenantContext(tenantRecordId, accountRecordId); }
private InternalCallContext createCallContext() { // TODO add teantRecordId and accountRecordId return internalCallContextFactory.createInternalCallContext(InternalCallContextFactory.INTERNAL_TENANT_RECORD_ID, null, "TimelineAggregator", CallOrigin.INTERNAL, UserType.SYSTEM, null); } }
@Override public Pagination<TagModelDao> build() { return tagDao.get(offset, limit, internalCallContextFactory.createInternalTenantContext(context)); } },
@Inject public DefaultMeterService(final BackgroundDBChunkWriter backgroundDBChunkWriter, final TimelineEventHandler timelineEventHandler, final InternalCallContextFactory internalCallContextFactory, final TimelineAggregator timelineAggregator, final MeterConfig config) { this.backgroundDBChunkWriter = backgroundDBChunkWriter; this.timelineEventHandler = timelineEventHandler; this.timelineAggregator = timelineAggregator; this.config = config; this.internalCallContext = internalCallContextFactory.createInternalCallContext(InternalCallContextFactory.INTERNAL_TENANT_RECORD_ID, null, "MeterService", CallOrigin.INTERNAL, UserType.SYSTEM, null); }
@Override public List<Invoice> getInvoicesByAccount(final UUID accountId, final LocalDate fromDate, final TenantContext context) { return ImmutableList.<Invoice>copyOf(Collections2.transform(dao.getInvoicesByAccount(fromDate, internalCallContextFactory.createInternalTenantContext(accountId, context)), new Function<InvoiceModelDao, Invoice>() { @Override public Invoice apply(final InvoiceModelDao input) { return new DefaultInvoice(input); } })); }
@Override public void removeTags(final UUID objectId, final ObjectType objectType, final Collection<UUID> tagDefinitionIds, final CallContext context) throws TagApiException { // TODO: consider making this batch for (final UUID tagDefinitionId : tagDefinitionIds) { tagDao.deleteTag(objectId, objectType, tagDefinitionId, internalCallContextFactory.createInternalCallContext(objectId, objectType, context)); } }
@Override public BigDecimal getAccountBalance(final UUID accountId, final TenantContext context) { final BigDecimal result = dao.getAccountBalance(accountId, internalCallContextFactory.createInternalTenantContext(accountId, context)); return result == null ? BigDecimal.ZERO : result; }
@Override public void deleteTagDefinition(final UUID definitionId, final CallContext context) throws TagDefinitionApiException { tagDefinitionDao.deleteById(definitionId, internalCallContextFactory.createInternalCallContext(context)); }
@Override public List<Refund> getAccountRefunds(final Account account, final TenantContext context) throws PaymentApiException { return refundProcessor.getAccountRefunds(account, internalCallContextFactory.createInternalTenantContext(context)); }
@Override public void deleteCBA(final UUID accountId, final UUID invoiceId, final UUID invoiceItemId, final CallContext context) throws InvoiceApiException { dao.deleteCBA(accountId, invoiceId, invoiceItemId, internalCallContextFactory.createInternalCallContext(accountId, context)); }
@Override public List<PaymentMethod> getPaymentMethods(final Account account, final boolean withPluginInfo, final TenantContext context) throws PaymentApiException { return methodProcessor.getPaymentMethods(account, withPluginInfo, internalCallContextFactory.createInternalTenantContext(context)); }
@Override public void addTenantKeyValue(final String key, final String value, final CallContext context) throws TenantApiException { final InternalCallContext internalContext = internalCallContextFactory.createInternalCallContext(context); // TODO Figure out the exact verification if nay /* final Tenant tenant = tenantDao.getById(callcontext.getTenantId(), internalContext); if (tenant == null) { throw new TenantApiException(ErrorCode.TENANT_DOES_NOT_EXIST_FOR_ID, tenantId); } */ tenantDao.addTenantKeyValue(key, value, internalContext); }
@Override public Collection<UUID> checkAnalyticsInSyncWithInvoice(final TenantContext context) { final InternalTenantContext internalTenantContext = internalCallContextFactory.createInternalTenantContext(context); return dao.checkBiiMatchesInvoiceItems(internalTenantContext); }