@Override public String getUserToken() { if (auditLogModelDao.getCallContext().getUserToken() == null) { return null; } else { return auditLogModelDao.getCallContext().getUserToken().toString(); } }
@Override public UUID getUserToken() { return delegate.getUserToken(); }
/** * Create an internal call callcontext without populating the account record id * <p/> * This is used for update/delete operations - we don't need the account id in that case - and * also when we don't have an account_record_id column (e.g. tenants, tag_definitions) * * @param context original call callcontext * @return internal call callcontext */ public InternalCallContext createInternalCallContextWithoutAccountRecordId(final CallContext context) { // If tenant id is null, this will default to the default tenant record id (multi-tenancy disabled) final Long tenantRecordId = getTenantRecordIdSafe(context); populateMDCContext(context.getUserToken(), null, tenantRecordId); return new InternalCallContext(tenantRecordId, context, context.getCreatedDate()); }
public InternalCallContext(final Long tenantRecordId, final CallContext callContext, final DateTime utcNow) { this(tenantRecordId, null, null, null, callContext.getUserToken(), callContext.getUserName(), callContext.getCallOrigin(), callContext.getUserType(), callContext.getReasonCode(), callContext.getComments(), utcNow, utcNow); }
public TestCallContext(final CallContext context, final DateTime utcNow) { this.userName = context.getUserName(); this.createdDate = utcNow; this.updatedDate = utcNow; this.userToken = context.getUserToken(); this.accountId = context.getAccountId(); this.tenantId = context.getTenantId(); }
public DefaultCallContext(final CallContext callContext) { super(callContext.getAccountId(), callContext.getTenantId(), callContext.getUserName(), callContext.getCallOrigin(), callContext.getUserType(), callContext.getReasonCode(), callContext.getComments(), callContext.getUserToken()); this.createdDate = callContext.getCreatedDate(); this.updateDate = callContext.getUpdatedDate(); }
/** * 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 = getTenantRecordIdSafe(callcontext); //Preconditions.checkState(tenantRecordIdFromContext.equals(tenantRecordIdFromObject), // "tenant of the pointed object (%s) and the callcontext (%s) don't match!", tenantRecordIdFromObject, tenantRecordIdFromContext); final Long tenantRecordId = getTenantRecordIdSafe(context); final Long accountRecordId = getAccountRecordIdSafe(objectId, objectType, context); return createInternalCallContext(tenantRecordId, accountRecordId, context.getUserName(), context.getCallOrigin(), context.getUserType(), context.getUserToken(), context.getReasonCode(), context.getComments(), context.getCreatedDate(), context.getUpdatedDate()); }
@Override public String getUserToken() { if (auditLogModelDao.getCallContext().getUserToken() == null) { return null; } else { return auditLogModelDao.getCallContext().getUserToken().toString(); } }
@Override public UUID getUserToken() { return delegate.getUserToken(); }
/** * Create an internal call callcontext without populating the account record id * <p/> * This is used for update/delete operations - we don't need the account id in that case - and * also when we don't have an account_record_id column (e.g. tenants, tag_definitions) * * @param context original call callcontext * @return internal call callcontext */ public InternalCallContext createInternalCallContextWithoutAccountRecordId(final CallContext context) { // If tenant id is null, this will default to the default tenant record id (multi-tenancy disabled) final Long tenantRecordId = getTenantRecordIdSafe(context); populateMDCContext(context.getUserToken(), null, tenantRecordId); return new InternalCallContext(tenantRecordId, context, context.getCreatedDate()); }
public Response withSynchronization(final EntitlementCallCompletionCallback<T> callback, final long timeoutSec, final boolean callCompletion, final CallContext callContext) throws SubscriptionApiException, AccountApiException, EntitlementApiException { final CompletionUserRequestEntitlement waiter = callCompletion ? new CompletionUserRequestEntitlement(callContext.getUserToken()) : null; try { if (waiter != null) { killbillHandler.registerCompletionUserRequestWaiter(waiter); } final T operationValue = callback.doOperation(callContext); if (waiter != null && callback.isImmOperation()) { waiter.waitForCompletion(timeoutSec * 1000); } return callback.doResponseOk(operationValue); } catch (final InterruptedException e) { return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } catch (final CatalogApiException e) { throw new EntitlementApiException(e); } catch (final TimeoutException e) { return Response.status(408).build(); } finally { if (waiter != null) { killbillHandler.unregisterCompletionUserRequestWaiter(waiter); } } } }
public InternalCallContext(final Long tenantRecordId, final CallContext callContext, final DateTime utcNow) { this(tenantRecordId, null, null, null, callContext.getUserToken(), callContext.getUserName(), callContext.getCallOrigin(), callContext.getUserType(), callContext.getReasonCode(), callContext.getComments(), utcNow, utcNow); }
private <T extends EntitySqlDao<M, E>, M extends EntityModelDao<E>, E extends Entity> void checkAuditLog(final ChangeType changeType, @Nullable final CallContext context, final AuditLog auditLog, final UUID entityId, Class<T> sqlDao, boolean useHistory, boolean checkContext) { Assert.assertEquals(auditLog.getChangeType(), changeType); if (checkContext) { Assert.assertEquals(auditLog.getUserName(), context.getUserName()); Assert.assertEquals(auditLog.getComment(), context.getComments()); //Assert.assertEquals(auditLog.getCreatedDate().comparesTo(callcontext.getCreatedDate())); // We can't take userToken oustide of the 'if' because for instance NextBillingDate invoice will not have it. Assert.assertEquals(auditLog.getUserToken(), context.getUserToken().toString()); } final M entityModel = extractEntityModelFromEntityWithTargetRecordId(entityId, auditLog.getId(), sqlDao, context, useHistory); Assert.assertEquals(entityModel.getId(), entityId); }
public TestCallContext(final CallContext context, final DateTime utcNow) { this.userName = context.getUserName(); this.createdDate = utcNow; this.updatedDate = utcNow; this.userToken = context.getUserToken(); this.accountId = context.getAccountId(); this.tenantId = context.getTenantId(); }
public DefaultCallContext(final CallContext callContext) { super(callContext.getAccountId(), callContext.getTenantId(), callContext.getUserName(), callContext.getCallOrigin(), callContext.getUserType(), callContext.getReasonCode(), callContext.getComments(), callContext.getUserToken()); this.createdDate = callContext.getCreatedDate(); this.updateDate = callContext.getUpdatedDate(); }
public DefaultInvoiceContext(final LocalDate targetDate, final Invoice invoice, final List<Invoice> existingInvoices, final boolean isDryRun, final boolean isRescheduled, final CallContext context) { super(context.getAccountId(), context.getTenantId(), context.getUserName(), context.getCallOrigin(), context.getUserType(), context.getReasonCode(), context.getComments(), context.getUserToken(), context.getCreatedDate(), context.getUpdatedDate()); this.targetDate = targetDate; this.invoice = invoice; this.existingInvoices = existingInvoices; this.isDryRun = isDryRun; this.isRescheduled = isRescheduled; }
/** * 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 = getTenantRecordIdSafe(callcontext); //Preconditions.checkState(tenantRecordIdFromContext.equals(tenantRecordIdFromObject), // "tenant of the pointed object (%s) and the callcontext (%s) don't match!", tenantRecordIdFromObject, tenantRecordIdFromContext); final Long tenantRecordId = getTenantRecordIdSafe(context); final Long accountRecordId = getAccountRecordIdSafe(objectId, objectType, context); return createInternalCallContext(tenantRecordId, accountRecordId, context.getUserName(), context.getCallOrigin(), context.getUserType(), context.getUserToken(), context.getReasonCode(), context.getComments(), context.getCreatedDate(), context.getUpdatedDate()); }