import-hosting-domain-assets #84

Merged
hsh-michaelhoennig merged 12 commits from import-hosting-domain-assets into master 2024-08-08 10:40:35 +02:00
Showing only changes of commit 855c5e44b0 - Show all commits

View File

@ -480,7 +480,7 @@ public class ImportHostingAssets extends ImportOfficeData {
} }
private String vmName(final String zonenfileName) { private String vmName(final String zonenfileName) {
return zonenfileName.substring(zonenfileName.length()-"vm0000.json".length()).substring(0, 6); return zonenfileName.substring(zonenfileName.length() - "vm0000.json".length()).substring(0, 6);
} }
@Test @Test
@ -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,14 +1249,18 @@ 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(
httpDomainSetupValidator.getProperty("fcgi-php-bin").defaultValue() )), rec.getString("fcgi_php_bin"),
entry("passenger-nodejs", withDefault(rec.getString("passenger_nodejs"), httpDomainSetupValidator.getProperty("fcgi-php-bin").defaultValue())),
httpDomainSetupValidator.getProperty("passenger-nodejs").defaultValue() )), entry("passenger-nodejs", withDefault(
entry("passenger-python", withDefault(rec.getString("passenger_python"), rec.getString("passenger_nodejs"),
httpDomainSetupValidator.getProperty("passenger-python").defaultValue() )), httpDomainSetupValidator.getProperty("passenger-nodejs").defaultValue())),
entry("passenger-ruby", withDefault(rec.getString("passenger_ruby"), entry("passenger-python", withDefault(
httpDomainSetupValidator.getProperty("passenger-ruby").defaultValue() )) rec.getString("passenger_python"),
httpDomainSetupValidator.getProperty("passenger-python").defaultValue())),
entry("passenger-ruby", withDefault(
rec.getString("passenger_ruby"),
httpDomainSetupValidator.getProperty("passenger-ruby").defaultValue()))
)) ))
.build(); .build();
hostingAssets.put(DOMAIN_HTTP_SETUP_OFFSET + domain_id, domainHttpSetupAsset); hostingAssets.put(DOMAIN_HTTP_SETUP_OFFSET + domain_id, domainHttpSetupAsset);
@ -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) {
@ -1317,11 +1323,11 @@ public class ImportHostingAssets extends ImportOfficeData {
final Map<String, Map<String, Object>> zoneData = jsonMapper.readValue(zonenfilesJson, Map.class); final Map<String, Map<String, Object>> zoneData = jsonMapper.readValue(zonenfilesJson, Map.class);
importZonenfile(vmName, zoneData); importZonenfile(vmName, zoneData);
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
throw new RuntimeException("cannot read zonefile JSON: '"+zonenfilesJson+"'", e); throw new RuntimeException("cannot read zonefile JSON: '" + zonenfilesJson + "'", e);
} }
} }
private void importZonenfile( final String vmName, final Map<String, Map<String, Object>> zoneDataForVM) { private void importZonenfile(final String vmName, final Map<String, Map<String, Object>> zoneDataForVM) {
zoneDataForVM.forEach((domainName, zoneData) -> { zoneDataForVM.forEach((domainName, zoneData) -> {
final var domainAsset = domainSetupsByName.get(domainName); final var domainAsset = domainSetupsByName.get(domainName);
if (domainAsset != null) { if (domainAsset != null) {
@ -1336,8 +1342,8 @@ public class ImportHostingAssets extends ImportOfficeData {
.getAssignedToAsset(); .getAssignedToAsset();
final var domOwner = zoneData.remove("DOM_OWNER"); final var domOwner = zoneData.remove("DOM_OWNER");
final var expectedDomOwner = domUser.getIdentifier(); final var expectedDomOwner = domUser.getIdentifier();
if ( domOwner.equals(expectedDomOwner) ) { if (domOwner.equals(expectedDomOwner)) {
logError( () -> assertThat(vmName).isEqualTo(domUser.getParentAsset().getParentAsset().getIdentifier() )); logError(() -> assertThat(vmName).isEqualTo(domUser.getParentAsset().getParentAsset().getIdentifier()));
//noinspection unchecked //noinspection unchecked
zoneData.put("user-RR", ((ArrayList<ArrayList<Object>>) zoneData.get("user-RR")).stream() zoneData.put("user-RR", ((ArrayList<ArrayList<Object>>) zoneData.get("user-RR")).stream()
@ -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);
} }
} }
}); });