private boolean objectBelongsToTheRightTenant(final UUID objectId, final ObjectType objectType, final Long realTenantRecordId) throws ObjectDoesNotExist { final Long objectTenantRecordId = getTenantRecordIdUnsafe(objectId, objectType); if (objectTenantRecordId == null) { throw new ObjectDoesNotExist(String.format("Object id=%s type=%s doesn't exist!", objectId, objectType)); } return objectTenantRecordId.equals(realTenantRecordId); }
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); } }
private boolean objectBelongsToTheRightTenant(final UUID objectId, final ObjectType objectType, final Long realTenantRecordId) throws ObjectDoesNotExist { final Long objectTenantRecordId = getTenantRecordIdUnsafe(objectId, objectType); if (objectTenantRecordId == null) { throw new ObjectDoesNotExist(String.format("Object id=%s type=%s doesn't exist!", objectId, objectType)); } return objectTenantRecordId.equals(realTenantRecordId); }
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); } }