Skip to content

Commit

Permalink
issue #1080: alternatively gets the tenant via Datasource (workaround)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrk-vi committed Sep 17, 2024
1 parent 039041a commit 6fac570
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,23 @@ protected void setupIndexName() throws UnknownTenantException {
String tenantId = getTenant();

// This is a workaround needed when a new DataIndex is being created.
// The tenant is not identified, probably because the entity has not
// The tenant is not identified, likely because the entity has not
// been persisted yet. Therefore, it is obtained from an entity that
// is already in the persistence context, in this case, the first
// DocType associated with the new DataIndex.
// is already in the persistence context, typically, the first
// DocType associated with the new DataIndex, or alternatively,
// the Datasource associated with it.
if (tenantId == null) {
var iterator = docTypes.iterator();
if (iterator.hasNext()) {
var docType = iterator.next();
tenantId = docType.getTenant();
}
else {
var ds = getDatasource();
if (ds != null) {
tenantId = ds.getTenant();
}
}
if (tenantId == null) {
throw new UnknownTenantException(
String.format("Cannot identify the tenant for DataIndex: %s", getName()));
Expand Down

0 comments on commit 6fac570

Please sign in to comment.