Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bumps sirius libs and applies breaking changes #2065

Merged
merged 8 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

<properties>
<sirius.kernel>dev-44.1.0</sirius.kernel>
<sirius.web>dev-86.1.0</sirius.web>
<sirius.db>dev-59.0.0</sirius.db>
<sirius.web>dev-86.3.0</sirius.web>
<sirius.db>dev-60.0.0</sirius.db>
</properties>

<repositories>
Expand Down
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());
sabieber marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/sirius/biz/tenants/SAMLController.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ protected List<T> querySAMLTenants() {

private void verifyUser(SAMLResponse response, UserInfo user) {
U account = user.getUserObject(getUserClass());
T tenant = account.getTenant().fetchValue();
T tenant = account.getTenant().forceFetchValue();

if (!checkIssuer(tenant, response)) {
throw Exceptions.createHandled().withSystemErrorMessage("SAML Error: Issuer mismatch!").handle();
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
31 changes: 16 additions & 15 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 @@ -525,7 +526,7 @@ private UserInfo verifyIpRange(WebContext webContext, UserInfo info) {
return defaultUser;
}

T tenant = account.getTenant().fetchValue();
T tenant = fetchTenant(account.getTenant().getIdAsString());

if (tenant != null && !tenant.getTenantData().matchesIPRange(webContext)) {
return createUserWithLimitedRoles(info, tenant.getTenantData().getRolesToKeepAsSet());
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 Expand Up @@ -604,7 +606,8 @@ private UserInfo asUserWithRoles(U account, Set<String> roles, @Nullable Supplie
return UserInfo.Builder.createUser(account.getUniqueName())
.withUsername(account.getUserAccountData().getLogin().getUsername())
.withTenantId(String.valueOf(account.getTenant().getId()))
.withTenantName(account.getTenant().fetchValue().getTenantData().getName())
.withTenantName(fetchTenant(account.getTenant().getIdAsString()).getTenantData()
.getName())
.withLanguage(computeLanguage(null, account.getUniqueName()))
.withPermissions(roles)
.withSettingsSupplier(user -> getUserSettings(getScopeSettings(), user))
Expand Down Expand Up @@ -637,13 +640,12 @@ public UserInfo findUserByCredentials(@Nullable WebContext webContext, String us
}

U account = result.getUserObject(getUserClass());
T tenant = fetchTenant(account.getTenant().getIdAsString());
if (account.getUserAccountData().isExternalLoginRequired() && !isWithinInterval(account.getUserAccountData()
.getLogin()
.getLastExternalLogin(),
account.getTenant()
.fetchValue()
.getTenantData()
.getExternalLoginIntervalDays())) {
tenant.getTenantData()
.getExternalLoginIntervalDays())) {
completeAuditLogForUser(auditLog.negative("AuditLog.externalLoginRequired"), account);
throw Exceptions.createHandled().withNLSKey("UserAccount.externalLoginMustBePerformed").handle();
}
Expand Down Expand Up @@ -672,8 +674,7 @@ public UserInfo findUserByCredentials(@Nullable WebContext webContext, String us

auditLog.negative("AuditLog.loginRejected")
.forUser(account.getUniqueName(), account.getUserAccountData().getLogin().getUsername())
.forTenant(String.valueOf(account.getTenant().getId()),
account.getTenant().fetchValue().getTenantData().getName())
.forTenant(tenant.getIdAsString(), tenant.getTenantData().getName())
.log();

return null;
Expand Down Expand Up @@ -718,7 +719,7 @@ protected void completeAuditLogForUser(AuditLog.AuditLogBuilder builder, U accou
builder.causedByUser(account.getUniqueName(), account.getUserAccountData().getLogin().getUsername())
.forUser(account.getUniqueName(), account.getUserAccountData().getLogin().getUsername())
.forTenant(String.valueOf(account.getTenant().getId()),
account.getTenant().fetchValue().getTenantData().getName())
fetchTenant(account.getTenant().getIdAsString()).getTenantData().getName())
.log();
}

Expand Down Expand Up @@ -791,7 +792,7 @@ protected U getUserObject(UserInfo userInfo) {
protected UserSettings getUserSettings(UserSettings scopeSettings, UserInfo userInfo) {
U user = userInfo.getUserObject(getUserClass());
Config userAccountConfig = user.getUserAccountData().getPermissions().getConfig();
Config tenantConfig = user.getTenant().fetchValue().getTenantData().getConfig();
Config tenantConfig = fetchTenant(user.getTenant().getIdAsString()).getTenantData().getConfig();

if (userAccountConfig == null) {
if (tenantConfig == null) {
Expand Down Expand Up @@ -852,7 +853,7 @@ protected boolean isUserStillValid(String userId, WebContext webContext) {
}

LoginData loginData = user.getUserAccountData().getLogin();
TenantData tenantData = user.getTenant().fetchValue().getTenantData();
TenantData tenantData = fetchTenant(user.getTenant().getIdAsString()).getTenantData();

if (loginData.isAccountLocked()) {
return false;
Expand Down Expand Up @@ -966,7 +967,7 @@ protected Set<String> computeRoles(WebContext webContext, String accountUniqueNa
}

Set<String> roles = computeRoles(user,
user.getTenant().fetchValue(),
fetchTenant(user.getTenant().getIdAsString()),
Strings.areEqual(systemTenant, String.valueOf(user.getTenant().getId())));

rolesCache.put(accountUniqueName, Tuple.create(roles, user.getTenant().getUniqueObjectName()));
Expand Down Expand Up @@ -1041,7 +1042,7 @@ protected String computeLanguage(WebContext webContext, String userId) {
return NLS.getDefaultLanguage();
}
return Strings.firstFilled(userAccount.getUserAccountData().getLanguage().getValue(),
userAccount.getTenant().fetchValue().getTenantData().getLanguage().getValue(),
fetchTenant(userAccount.getTenant().getIdAsString()).getTenantData().getLanguage().getValue(),
NLS.getDefaultLanguage());
}
}
8 changes: 0 additions & 8 deletions src/main/java/sirius/biz/tenants/Tenants.java
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,6 @@ public Optional<T> fetchCachedTenant(BaseEntityRef<I, T> tenantRef) {
return Optional.empty();
}

if (tenantRef.isValueLoaded()) {
return Optional.of(tenantRef.fetchValue());
}

return fetchCachedTenant(String.valueOf(tenantRef.getId()));
}

Expand Down Expand Up @@ -401,10 +397,6 @@ public Optional<U> fetchCachedUserAccount(BaseEntityRef<I, U> userRef) {
return Optional.empty();
}

if (userRef.isValueLoaded()) {
return Optional.of(userRef.fetchValue());
}

return fetchCachedUserAccount(userRef.getIdAsString());
}

Expand Down
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -369,7 +369,7 @@ public boolean isOwnUser() {
* @return <tt>true</tt> if this user belongs to the current user's tenant, <tt>false</tt> otherwise
*/
public boolean isOwnTenant() {
return Objects.equals(UserContext.getCurrentUser().as(UserAccount.class).getTenant().fetchValue(), getTenant());
return Objects.equals(UserContext.getCurrentUser().as(UserAccount.class).getTenant().getIdAsString(), getTenant().getIdAsString());
}

/**
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
Loading