/** * Create an internal call callcontext using an existing account to retrieve tenant and account record ids * <p/> * This is used for r/w operations - we need the account id to populate the account_record_id field * * @param accountId account id * @param context original call callcontext * @return internal call callcontext */ public InternalCallContext createInternalCallContext(final UUID accountId, final CallContext context) { return createInternalCallContext(accountId, ObjectType.ACCOUNT, context.getUserName(), context.getCallOrigin(), context.getUserType(), context.getUserToken(), context.getReasonCode(), context.getComments(), context.getCreatedDate(), context.getUpdatedDate()); }
public MigrationCallContext(final CallContext context, final DateTime createdDate, final DateTime updatedDate) { super(context.getTenantId(), context.getUserName(), context.getCallOrigin(), context.getUserType()); this.createdDate = createdDate; this.updatedDate = updatedDate; }
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 List<String> getTenantValueForKey(final String key, final TenantContext context) throws TenantApiException { final InternalTenantContext internalContext = internalCallContextFactory.createInternalTenantContext(context); return tenantDao.getTenantValueForKey(key, internalContext); }
/** * Create an internal tenant callcontext from a tenant callcontext * <p/> * This is used for r/o operations - we don't need the account id in that case. * You should almost never use that one, you always want to populate the accountRecordId * * @param context tenant callcontext (tenantId can be null only if multi-tenancy is disabled) * @return internal tenant callcontext */ public InternalTenantContext createInternalTenantContext(final TenantContext context) { // If tenant id is null, this will default to the default tenant record id (multi-tenancy disabled) final Long tenantRecordId = getTenantRecordId(context); return createInternalTenantContext(tenantRecordId, null); }
@Override public void test(@InternalTenantContextBinder final InternalTenantContext context) { }
@Override public CallContext toMigrationCallContext(final CallContext callContext, final DateTime createdDate, final DateTime updatedDate) { return new MigrationCallContext(callContext, createdDate, updatedDate); } }
private Long getAccountRecordId(final UUID accountId) { return getAccountRecordId(accountId, ObjectType.ACCOUNT); }
/** * Create an internal call callcontext from a call 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 call callcontext * @return internal call callcontext from callcontext, with a non null account_record_id (if found) */ public InternalCallContext createInternalCallContext(final UUID objectId, final ObjectType objectType, final CallContext 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); return createInternalCallContext(objectId, objectType, context.getUserName(), context.getCallOrigin(), context.getUserType(), context.getUserToken(), context.getReasonCode(), context.getComments(), context.getCreatedDate(), context.getUpdatedDate()); }
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<CustomFieldModelDao> build() { return customFieldDao.searchCustomFields(searchKey, offset, limit, internalCallContextFactory.createInternalTenantContext(context)); } },
protected InternalCallContext createCallContextFromPaymentId(final UUID paymentId) { return internalCallContextFactory.createInternalCallContext(paymentId, ObjectType.PAYMENT, PAYMENT_RETRY_SERVICE, CallOrigin.INTERNAL, UserType.SYSTEM, null); }
@Override public Pagination<TagModelDao> build() { return tagDao.get(offset, limit, internalCallContextFactory.createInternalTenantContext(context)); } },
protected InternalCallContext createCallContext(final UUID userToken, final Long accountRecordId, final Long tenantRecordId) { return internalCallContextFactory.createInternalCallContext(tenantRecordId, accountRecordId, "OverdueService", CallOrigin.INTERNAL, UserType.SYSTEM, userToken); }
@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; }
private InternalCallContext createCallContext(final UUID userToken, final Long accountRecordId, final Long tenantRecordId) { return internalCallContextFactory.createInternalCallContext(tenantRecordId, accountRecordId, "OverdueService", CallOrigin.INTERNAL, UserType.SYSTEM, userToken); } }
@Override public List<Refund> getAccountRefunds(final Account account, final TenantContext context) throws PaymentApiException { return refundProcessor.getAccountRefunds(account, internalCallContextFactory.createInternalTenantContext(context)); }
private InternalCallContext createCallContext(final UUID accountId, final UUID userToken) { return internalCallContextFactory.createInternalCallContext(accountId, "NextBillingDatePoster", CallOrigin.INTERNAL, UserType.SYSTEM, userToken); } }
@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 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)); } }