Skip to content

Commit

Permalink
Bugfix/microstream persistence error leads to unscheduled imports (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
saschadoemer authored May 16, 2024
1 parent 0b3213d commit 65fe3ab
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
29 changes: 18 additions & 11 deletions src/main/java/de/app/fivegla/persistence/TenantRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,24 @@ public class TenantRepository {
* @return The updated tenant.
*/
public Tenant updateTenant(String tenantId, String name, String description) {
var tenant = applicationData.getTenants().stream()
.filter(t -> t.getTenantId().equals(tenantId))
.findFirst()
.orElseThrow(() -> new BusinessException(ErrorMessage.builder()
.error(Error.TENANT_NOT_FOUND)
.message("Could not update tenant, since the tenant was not found.")
.build()));
tenant.setName(name);
tenant.setDescription(description);
applicationData.persist();
return tenant;
if (null != applicationData.getTenants()) {
var tenant = applicationData.getTenants().stream()
.filter(t -> t.getTenantId().equals(tenantId))
.findFirst()
.orElseThrow(() -> new BusinessException(ErrorMessage.builder()
.error(Error.TENANT_NOT_FOUND)
.message("Could not update tenant, since the tenant was not found.")
.build()));
tenant.setName(name);
tenant.setDescription(description);
applicationData.persist();
return tenant;
} else {
throw new BusinessException(ErrorMessage.builder()
.error(Error.TENANT_NOT_FOUND)
.message("Could not update tenant, since the tenant was not found.")
.build());
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

Expand All @@ -20,10 +21,9 @@ public class ThirdPartyApiConfigurationRepository {
*/
public void addThirdPartyApiConfiguration(ThirdPartyApiConfiguration configuration) {
if (applicationData.getThirdPartyApiConfigurations() == null) {
applicationData.setThirdPartyApiConfigurations(List.of(configuration));
} else {
applicationData.getThirdPartyApiConfigurations().add(configuration);
applicationData.setThirdPartyApiConfigurations(new ArrayList<>());
}
applicationData.getThirdPartyApiConfigurations().add(configuration);
applicationData.persist();
}

Expand Down

0 comments on commit 65fe3ab

Please sign in to comment.