collect validation errors during save

This commit is contained in:
Michael Hoennig 2024-08-08 06:42:19 +02:00
parent 6e5d51384b
commit 855c5e44b0

View File

@ -783,8 +783,9 @@ public class ImportHostingAssets extends ImportOfficeData {
private void persistHostingAssetsOfType(final HsHostingAssetType... hsHostingAssetTypes) { private void persistHostingAssetsOfType(final HsHostingAssetType... hsHostingAssetTypes) {
final var hsHostingAssetTypeSet = stream(hsHostingAssetTypes).collect(toSet()); final var hsHostingAssetTypeSet = stream(hsHostingAssetTypes).collect(toSet());
// jpaAttempt.transacted(() -> {
hostingAssets.forEach((key, ha) -> { hostingAssets.forEach((key, ha) -> {
logError(() ->
jpaAttempt.transacted(() -> { jpaAttempt.transacted(() -> {
context(rbacSuperuser); context(rbacSuperuser);
if (hsHostingAssetTypeSet.contains(ha.getType())) { if (hsHostingAssetTypeSet.contains(ha.getType())) {
@ -795,10 +796,9 @@ public class ImportHostingAssets extends ImportOfficeData {
.saveUsing(entity -> persist(key, entity)) .saveUsing(entity -> persist(key, entity))
.validateContext(); .validateContext();
} }
}).assertSuccessful(); }).assertSuccessful()
}
); );
// }).assertSuccessful(); });
} }
private void importIpNumbers(final String[] header, final List<String[]> records) { private void importIpNumbers(final String[] header, final List<String[]> records) {
@ -1249,13 +1249,17 @@ public class ImportHostingAssets extends ImportOfficeData {
entry("multiviews", options.contains("multiviews")), entry("multiviews", options.contains("multiviews")),
entry("subdomains", withDefault(rec.getString("valid_subdomain_names"), "*") entry("subdomains", withDefault(rec.getString("valid_subdomain_names"), "*")
.split(",")), .split(",")),
entry("fcgi-php-bin", withDefault(rec.getString("fcgi_php_bin"), entry("fcgi-php-bin", withDefault(
rec.getString("fcgi_php_bin"),
httpDomainSetupValidator.getProperty("fcgi-php-bin").defaultValue())), httpDomainSetupValidator.getProperty("fcgi-php-bin").defaultValue())),
entry("passenger-nodejs", withDefault(rec.getString("passenger_nodejs"), entry("passenger-nodejs", withDefault(
rec.getString("passenger_nodejs"),
httpDomainSetupValidator.getProperty("passenger-nodejs").defaultValue())), httpDomainSetupValidator.getProperty("passenger-nodejs").defaultValue())),
entry("passenger-python", withDefault(rec.getString("passenger_python"), entry("passenger-python", withDefault(
rec.getString("passenger_python"),
httpDomainSetupValidator.getProperty("passenger-python").defaultValue())), httpDomainSetupValidator.getProperty("passenger-python").defaultValue())),
entry("passenger-ruby", withDefault(rec.getString("passenger_ruby"), entry("passenger-ruby", withDefault(
rec.getString("passenger_ruby"),
httpDomainSetupValidator.getProperty("passenger-ruby").defaultValue())) httpDomainSetupValidator.getProperty("passenger-ruby").defaultValue()))
)) ))
.build(); .build();
@ -1304,7 +1308,9 @@ public class ImportHostingAssets extends ImportOfficeData {
if (defaultValue instanceof String defaultStringValue) { if (defaultValue instanceof String defaultStringValue) {
return givenValue != null && !givenValue.isBlank() ? givenValue : defaultStringValue; return givenValue != null && !givenValue.isBlank() ? givenValue : defaultStringValue;
} }
throw new RuntimeException("property default value expected to be of type string, but is of type " + defaultValue.getClass().getSimpleName()); throw new RuntimeException(
"property default value expected to be of type string, but is of type " + defaultValue.getClass()
.getSimpleName());
} }
private void importZonefiles(final String vmName, final String zonenfilesJson) { private void importZonefiles(final String vmName, final String zonenfilesJson) {
@ -1346,7 +1352,8 @@ public class ImportHostingAssets extends ImportOfficeData {
); );
domainDnsSetupAsset.getConfig().putAll(zoneData); domainDnsSetupAsset.getConfig().putAll(zoneData);
} else { } else {
logError("zonedata dom_owner of " + domainAsset.getIdentifier() + " is " + domOwner + " but expected to be " + expectedDomOwner); logError("zonedata dom_owner of " + domainAsset.getIdentifier() + " is " + domOwner + " but expected to be "
+ expectedDomOwner);
} }
} }
}); });