/** * 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 createInternalCallContext(final CallContext context) { // If tenant id is null, this will default to the default tenant record id (multi-tenancy disabled) final Long tenantRecordId = getTenantRecordId(context); return new InternalCallContext(tenantRecordId, null, context); }
/** * 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); }
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); }
/** * 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); }