From 35cdb77b1a7ae307877358355cd130ba2f91b3bf Mon Sep 17 00:00:00 2001 From: Idevaldo De Lira Date: Mon, 16 Dec 2024 16:02:57 +0100 Subject: [PATCH] Replaces calls of fetchValue() to either one of the new variants Fixes: SIRI-1039 --- .../java/sirius/biz/storage/layer2/jdbc/SQLVariant.java | 2 +- .../java/sirius/biz/storage/layer2/mongo/MongoVariant.java | 2 +- src/main/java/sirius/biz/storage/legacy/VersionManager.java | 2 +- .../sirius/biz/storage/legacy/VirtualObjectVersion.java | 4 ++-- src/main/java/sirius/biz/tenants/TenantController.java | 2 +- src/main/java/sirius/biz/tenants/TenantUserManager.java | 6 ++++-- src/main/java/sirius/biz/tenants/UserAccountData.java | 2 +- .../java/sirius/biz/tenants/UserAccountSearchProvider.java | 6 +++--- .../templates/biz/tenants/tenant-extended.html.pasta | 2 +- 9 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main/java/sirius/biz/storage/layer2/jdbc/SQLVariant.java b/src/main/java/sirius/biz/storage/layer2/jdbc/SQLVariant.java index a49026cb0..fb2fb6298 100644 --- a/src/main/java/sirius/biz/storage/layer2/jdbc/SQLVariant.java +++ b/src/main/java/sirius/biz/storage/layer2/jdbc/SQLVariant.java @@ -109,7 +109,7 @@ public class SQLVariant extends SQLEntity implements BlobVariant { @AfterDelete protected void onDelete() { - SQLBlob sqlBlob = sourceBlob.fetchValue(); + SQLBlob sqlBlob = sourceBlob.forceFetchValue(); if (sqlBlob == null) { return; } diff --git a/src/main/java/sirius/biz/storage/layer2/mongo/MongoVariant.java b/src/main/java/sirius/biz/storage/layer2/mongo/MongoVariant.java index 3c45ef157..6ac8a7c2c 100644 --- a/src/main/java/sirius/biz/storage/layer2/mongo/MongoVariant.java +++ b/src/main/java/sirius/biz/storage/layer2/mongo/MongoVariant.java @@ -107,7 +107,7 @@ public class MongoVariant extends MongoEntity implements BlobVariant { @AfterDelete protected void onDelete() { - MongoBlob mongoBlob = blob.fetchValue(); + MongoBlob mongoBlob = blob.forceFetchValue(); if (mongoBlob == null) { return; } diff --git a/src/main/java/sirius/biz/storage/legacy/VersionManager.java b/src/main/java/sirius/biz/storage/legacy/VersionManager.java index 0d73d0eb5..0c5abee9e 100644 --- a/src/main/java/sirius/biz/storage/legacy/VersionManager.java +++ b/src/main/java/sirius/biz/storage/legacy/VersionManager.java @@ -170,7 +170,7 @@ private void computeVersion(VirtualObject object, String version) { } private void performVersionComputation(VirtualObjectVersion objectVersion) { - VirtualObject object = objectVersion.getVirtualObject().fetchValue(); + VirtualObject object = objectVersion.getVirtualObject().fetchCachedValue(); try { Tuple size = Tuple.create(0, 0); Tuple extendedSize = Tuple.create(0, 0); diff --git a/src/main/java/sirius/biz/storage/legacy/VirtualObjectVersion.java b/src/main/java/sirius/biz/storage/legacy/VirtualObjectVersion.java index c81ea0794..d3f91e7cb 100644 --- a/src/main/java/sirius/biz/storage/legacy/VirtualObjectVersion.java +++ b/src/main/java/sirius/biz/storage/legacy/VirtualObjectVersion.java @@ -100,8 +100,8 @@ protected void removePhysicalFile() { @AfterDelete protected void removeVersionFromCaches() { if (this.getVirtualObject().isFilled()) { - versionManager.clearCacheForVirtualObject(this.getVirtualObject().fetchValue()); - storage.clearCacheForVirtualObject(this.getVirtualObject().fetchValue()); + versionManager.clearCacheForVirtualObject(this.getVirtualObject().forceFetchValue()); + storage.clearCacheForVirtualObject(this.getVirtualObject().fetchCachedValue()); } } diff --git a/src/main/java/sirius/biz/tenants/TenantController.java b/src/main/java/sirius/biz/tenants/TenantController.java index 3774e3e8b..7bfcba980 100644 --- a/src/main/java/sirius/biz/tenants/TenantController.java +++ b/src/main/java/sirius/biz/tenants/TenantController.java @@ -407,7 +407,7 @@ public void selectTenant(final WebContext webContext, String tenantId) { .causedByUser(account.getUniqueName(), account.getUserAccountData().getLogin().getUsername()) .forUser(account.getUniqueName(), account.getUserAccountData().getLogin().getUsername()) .forTenant(account.getTenant().getIdAsString(), - account.getTenant().fetchValue().getTenantData().getName()) + account.getTenant().forceFetchValue().getTenantData().getName()) .log(); webContext.setSessionValue(UserContext.getCurrentScope().getScopeId() diff --git a/src/main/java/sirius/biz/tenants/TenantUserManager.java b/src/main/java/sirius/biz/tenants/TenantUserManager.java index 4b8bcb946..3ef340c0c 100644 --- a/src/main/java/sirius/biz/tenants/TenantUserManager.java +++ b/src/main/java/sirius/biz/tenants/TenantUserManager.java @@ -451,9 +451,10 @@ public UserInfo findUserByName(@Nullable WebContext webContext, String user) { } U account = optionalAccount.get(); + T tenant = account.getTenant().forceFetchValue(); userAccountCache.put(account.getUniqueName(), account); - tenantsCache.put(account.getTenant().fetchValue().getIdAsString(), account.getTenant().fetchValue()); + tenantsCache.put(tenant.getIdAsString(), tenant); rolesCache.remove(account.getUniqueName()); configCache.remove(account.getUniqueName()); @@ -569,7 +570,8 @@ protected U fetchAccount(@Nonnull String accountId) { return null; } userAccountCache.put(account.getUniqueName(), account); - tenantsCache.put(account.getTenant().fetchValue().getIdAsString(), account.getTenant().fetchValue()); + T tenant = account.getTenant().forceFetchValue(); + tenantsCache.put(tenant.getIdAsString(), tenant); rolesCache.remove(account.getUniqueName()); configCache.remove(account.getUniqueName()); diff --git a/src/main/java/sirius/biz/tenants/UserAccountData.java b/src/main/java/sirius/biz/tenants/UserAccountData.java index 5cafae33f..722eba0e0 100644 --- a/src/main/java/sirius/biz/tenants/UserAccountData.java +++ b/src/main/java/sirius/biz/tenants/UserAccountData.java @@ -239,7 +239,7 @@ public Optional tryAs(Class adapterType) { } protected Tenant getTenant() { - return ((UserAccount) userObject).getTenant().fetchValue(); + return ((UserAccount) userObject).getTenant().forceFetchValue(); } @Override diff --git a/src/main/java/sirius/biz/tenants/UserAccountSearchProvider.java b/src/main/java/sirius/biz/tenants/UserAccountSearchProvider.java index 66ed78557..1272218f3 100644 --- a/src/main/java/sirius/biz/tenants/UserAccountSearchProvider.java +++ b/src/main/java/sirius/biz/tenants/UserAccountSearchProvider.java @@ -87,7 +87,7 @@ public void query(String query, int maxResults, Consumer resul } else { openSearchResult.withDescription(userAccount + " (" - + userAccount.getTenant().fetchValue().toString() + + userAccount.getTenant().fetchCachedValue().toString() + ")") .withURL("/tenants/select/" + userAccount.getTenant().getIdAsString() @@ -103,9 +103,9 @@ public void query(String query, int maxResults, Consumer resul + label="@user.getTenant().fetchCachedValue().toString()"/> - @user.getTenant().fetchValue().toString() + @user.getTenant().fetchCachedValue().toString() ) diff --git a/src/main/resources/default/templates/biz/tenants/tenant-extended.html.pasta b/src/main/resources/default/templates/biz/tenants/tenant-extended.html.pasta index bba5ffc14..063be78e1 100644 --- a/src/main/resources/default/templates/biz/tenants/tenant-extended.html.pasta +++ b/src/main/resources/default/templates/biz/tenants/tenant-extended.html.pasta @@ -40,7 +40,7 @@ suggestionUri="/tenants/autocomplete">