private Long getTenantRecordIdSafe(final TenantContext context) { // Default to single default tenant (e.g. single tenant mode) // TODO Extract this convention (e.g. BusinessAnalyticsBase needs to know about it) if (context.getTenantId() == null) { return INTERNAL_TENANT_RECORD_ID; } else { // This is always safe (the tenant context was created from the api key and secret) return getTenantRecordIdUnsafe(context.getTenantId(), ObjectType.TENANT); } }
@Override public InternalCallContextFactory get() { return new InternalCallContextFactory(null, clock, nonEntityDao, null); } }
/** * 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); }
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 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(); }
@Override public List<AuditLogWithHistory> getEmailAuditLogsWithHistoryForId(final UUID accountEmailId, final AuditLevel auditLevel, final TenantContext tenantContext) throws AccountApiException { return accountDao.getEmailAuditLogsWithHistoryForId(accountEmailId, auditLevel, internalCallContextFactory.createInternalTenantContext(tenantContext.getAccountId(), tenantContext)); } }
private boolean objectBelongsToTheRightTenant(final UUID objectId, final ObjectType objectType, final TenantContext context) throws ObjectDoesNotExist { final Long realTenantRecordId = getTenantRecordIdSafe(context); if (realTenantRecordId == null) { throw new ObjectDoesNotExist(String.format("Tenant id=%s doesn't exist!", context.getTenantId())); } return objectBelongsToTheRightTenant(objectId, objectType, realTenantRecordId); }
private InternalTenantContext createTenantContextFromBundleId(final UUID bundleId, final TenantContext context) { return internalCallContextFactory.createInternalTenantContext(bundleId, ObjectType.BUNDLE, context); } }
private InternalTenantContext createInternalTenantContext(final TenantContext tenantContext) { // Only tenantRecordId will be populated -- this is important to always create the (ehcache) key the same way return internalCallContextFactory.createInternalTenantContextWithoutAccountRecordId(tenantContext); } }
@Override public UUID getTenantId() { return delegate.getTenantId(); } }
@Override public UUID getUserToken() { return delegate.getUserToken(); }
@Override public String getUserName() { return delegate.getUserName(); }
@Override public String getComments() { return delegate.getComments(); }
@Override public CallOrigin getCallOrigin() { return delegate.getCallOrigin(); }
@Override public DateTime getUpdatedDate() { return delegate.getUpdatedDate(); }
@Override public UUID getAccountId() { return delegate.getAccountId(); }
@Override public UserType getUserType() { return delegate.getUserType(); }
@Override public String getReasonCode() { return delegate.getReasonCode(); }
@Override public Long getRecordId(final UUID objectId, final ObjectType objectType, final TenantContext tenantContext) { return internalCallContextFactory.getRecordIdFromObject(objectId, objectType, tenantContext); } }
private InternalTenantContext createInternalTenantContext(final TenantContext tenantContext) { // Only tenantRecordId will be populated -- this is important to always create the (ehcache) key the same way return internalCallContextFactory.createInternalTenantContextWithoutAccountRecordId(tenantContext); }