Skip to content

Commit

Permalink
Replaces calls of fetchValue() to either one of the new variants
Browse files Browse the repository at this point in the history
Fixes: SIRI-1039
  • Loading branch information
idlira committed Dec 16, 2024
1 parent 74827f5 commit 35cdb77
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Integer, Integer> size = Tuple.create(0, 0);
Tuple<Integer, Integer> extendedSize = Tuple.create(0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/sirius/biz/tenants/TenantController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/sirius/biz/tenants/TenantUserManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down Expand Up @@ -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());

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/sirius/biz/tenants/UserAccountData.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public <A> Optional<A> tryAs(Class<A> adapterType) {
}

protected Tenant<?> getTenant() {
return ((UserAccount<?, ?>) userObject).getTenant().fetchValue();
return ((UserAccount<?, ?>) userObject).getTenant().forceFetchValue();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void query(String query, int maxResults, Consumer<OpenSearchResult> resul
} else {
openSearchResult.withDescription(userAccount
+ " ("
+ userAccount.getTenant().fetchValue().toString()
+ userAccount.getTenant().fetchCachedValue().toString()
+ ")")
.withURL("/tenants/select/"
+ userAccount.getTenant().getIdAsString()
Expand All @@ -103,9 +103,9 @@ public void query(String query, int maxResults, Consumer<OpenSearchResult> resul
<t:smartValue type="tenant"
id="@generateId('smarty-useraccount-%s')"
payload="@user.getTenantAsString()"
label="@user.getTenant().fetchValue().toString()"/>
label="@user.getTenant().fetchCachedValue().toString()"/>
<i:else>
@user.getTenant().fetchValue().toString()
@user.getTenant().fetchCachedValue().toString()
</i:else>
</i:if>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
suggestionUri="/tenants/autocomplete">
<i:if test="tenant.getParent().isFilled()">
<option value="@tenant.getParent().getId()" selected="selected">
@tenant.getParent().fetchValue()
@tenant.getParent().fetchCachedValue()
</option>
</i:if>
</t:singleSelect>
Expand Down

0 comments on commit 35cdb77

Please sign in to comment.