Compare commits
No commits in common. "e5db6ebe56ef0455012c24c825716c472cd2f5ce" and "c32361a83abc5796a594c963158544c7cf2a54a4" have entirely different histories.
e5db6ebe56
...
c32361a83a
@ -1,49 +1,6 @@
|
|||||||
## HostingAsset Type Structure
|
## HostingAsset Type Structure
|
||||||
|
|
||||||
|
|
||||||
### Webspace+Server
|
|
||||||
|
|
||||||
```plantuml
|
|
||||||
@startuml
|
|
||||||
left to right direction
|
|
||||||
|
|
||||||
package Booking #feb28c {
|
|
||||||
entity BI_PRIVATE_CLOUD
|
|
||||||
entity BI_CLOUD_SERVER
|
|
||||||
entity BI_MANAGED_SERVER
|
|
||||||
entity BI_MANAGED_WEBSPACE
|
|
||||||
}
|
|
||||||
|
|
||||||
package Hosting #feb28c{
|
|
||||||
package Server #99bcdb {
|
|
||||||
entity HA_CLOUD_SERVER
|
|
||||||
entity HA_MANAGED_SERVER
|
|
||||||
entity HA_IPV4_NUMBER
|
|
||||||
entity HA_IPV6_NUMBER
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
BI_CLOUD_SERVER *--> BI_PRIVATE_CLOUD
|
|
||||||
BI_MANAGED_SERVER *--> BI_PRIVATE_CLOUD
|
|
||||||
BI_MANAGED_WEBSPACE *--> BI_MANAGED_SERVER
|
|
||||||
|
|
||||||
HA_CLOUD_SERVER *==> BI_CLOUD_SERVER
|
|
||||||
HA_MANAGED_SERVER *==> BI_MANAGED_SERVER
|
|
||||||
HA_IPV4_NUMBER o..> HA_CLOUD_SERVER
|
|
||||||
HA_IPV4_NUMBER o..> HA_MANAGED_SERVER
|
|
||||||
HA_IPV6_NUMBER o..> HA_CLOUD_SERVER
|
|
||||||
HA_IPV6_NUMBER o..> HA_MANAGED_SERVER
|
|
||||||
|
|
||||||
package Legend #white {
|
|
||||||
SUB_ENTITY1 *--> REQUIRED_PARENT_ENTITY
|
|
||||||
SUB_ENTITY2 *..> OPTIONAL_PARENT_ENTITY
|
|
||||||
ASSIGNED_ENTITY1 o--> REQUIRED_ASSIGNED_TO_ENTITY1
|
|
||||||
ASSIGNED_ENTITY2 o..> OPTIONAL_ASSIGNED_TO_ENTITY2
|
|
||||||
}
|
|
||||||
Booking -down[hidden]->Legend
|
|
||||||
```
|
|
||||||
|
|
||||||
### Domain
|
### Domain
|
||||||
|
|
||||||
```plantuml
|
```plantuml
|
||||||
@ -67,6 +24,12 @@ package Hosting #feb28c{
|
|||||||
entity HA_EMAIL_ADDRESS
|
entity HA_EMAIL_ADDRESS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
package Server #99bcdb {
|
||||||
|
entity HA_CLOUD_SERVER
|
||||||
|
entity HA_MANAGED_SERVER
|
||||||
|
entity HA_IP_NUMBER
|
||||||
|
}
|
||||||
|
|
||||||
package Webspace #99bcdb {
|
package Webspace #99bcdb {
|
||||||
entity HA_MANAGED_WEBSPACE
|
entity HA_MANAGED_WEBSPACE
|
||||||
entity HA_UNIX_USER
|
entity HA_UNIX_USER
|
||||||
@ -79,19 +42,25 @@ BI_CLOUD_SERVER *--> BI_PRIVATE_CLOUD
|
|||||||
BI_MANAGED_SERVER *--> BI_PRIVATE_CLOUD
|
BI_MANAGED_SERVER *--> BI_PRIVATE_CLOUD
|
||||||
BI_MANAGED_WEBSPACE *--> BI_MANAGED_SERVER
|
BI_MANAGED_WEBSPACE *--> BI_MANAGED_SERVER
|
||||||
|
|
||||||
|
HA_CLOUD_SERVER *==> BI_CLOUD_SERVER
|
||||||
|
HA_MANAGED_SERVER *==> BI_MANAGED_SERVER
|
||||||
HA_MANAGED_WEBSPACE *==> BI_MANAGED_WEBSPACE
|
HA_MANAGED_WEBSPACE *==> BI_MANAGED_WEBSPACE
|
||||||
|
HA_MANAGED_WEBSPACE o..> HA_MANAGED_SERVER
|
||||||
HA_UNIX_USER *==> HA_MANAGED_WEBSPACE
|
HA_UNIX_USER *==> HA_MANAGED_WEBSPACE
|
||||||
HA_EMAIL_ALIAS *==> HA_MANAGED_WEBSPACE
|
HA_EMAIL_ALIAS *==> HA_MANAGED_WEBSPACE
|
||||||
HA_DOMAIN_SETUP o..> HA_DOMAIN_SETUP
|
HA_DOMAIN_SETUP o..> HA_DOMAIN_SETUP
|
||||||
HA_DOMAIN_DNS_SETUP *==> HA_DOMAIN_SETUP
|
HA_DOMAIN_DNS_SETUP *==> HA_DOMAIN_SETUP
|
||||||
HA_DOMAIN_DNS_SETUP o--> HA_MANAGED_WEBSPACE
|
HA_DOMAIN_DNS_SETUP o..> HA_MANAGED_WEBSPACE
|
||||||
HA_DOMAIN_HTTP_SETUP *==> HA_DOMAIN_SETUP
|
HA_DOMAIN_HTTP_SETUP *==> HA_DOMAIN_SETUP
|
||||||
HA_DOMAIN_HTTP_SETUP o--> HA_UNIX_USER
|
HA_DOMAIN_HTTP_SETUP o..> HA_UNIX_USER
|
||||||
HA_DOMAIN_SMTP_SETUP *==> HA_DOMAIN_SETUP
|
HA_DOMAIN_SMTP_SETUP *==> HA_DOMAIN_SETUP
|
||||||
HA_DOMAIN_SMTP_SETUP o--> HA_MANAGED_WEBSPACE
|
HA_DOMAIN_SMTP_SETUP o..> HA_MANAGED_WEBSPACE
|
||||||
HA_DOMAIN_MBOX_SETUP *==> HA_DOMAIN_SETUP
|
HA_DOMAIN_MBOX_SETUP *==> HA_DOMAIN_SETUP
|
||||||
HA_DOMAIN_MBOX_SETUP o--> HA_MANAGED_WEBSPACE
|
HA_DOMAIN_MBOX_SETUP o..> HA_MANAGED_WEBSPACE
|
||||||
HA_EMAIL_ADDRESS *==> HA_DOMAIN_MBOX_SETUP
|
HA_EMAIL_ADDRESS *==> HA_DOMAIN_MBOX_SETUP
|
||||||
|
HA_IP_NUMBER o..> HA_CLOUD_SERVER
|
||||||
|
HA_IP_NUMBER o..> HA_MANAGED_SERVER
|
||||||
|
HA_IP_NUMBER o..> HA_MANAGED_WEBSPACE
|
||||||
|
|
||||||
package Legend #white {
|
package Legend #white {
|
||||||
SUB_ENTITY1 *--> REQUIRED_PARENT_ENTITY
|
SUB_ENTITY1 *--> REQUIRED_PARENT_ENTITY
|
||||||
@ -122,6 +91,12 @@ package Hosting #feb28c{
|
|||||||
entity HA_MARIADB_DATABASE
|
entity HA_MARIADB_DATABASE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
package Server #99bcdb {
|
||||||
|
entity HA_CLOUD_SERVER
|
||||||
|
entity HA_MANAGED_SERVER
|
||||||
|
entity HA_IP_NUMBER
|
||||||
|
}
|
||||||
|
|
||||||
package Webspace #99bcdb {
|
package Webspace #99bcdb {
|
||||||
entity HA_MANAGED_WEBSPACE
|
entity HA_MANAGED_WEBSPACE
|
||||||
entity HA_UNIX_USER
|
entity HA_UNIX_USER
|
||||||
@ -134,12 +109,20 @@ BI_CLOUD_SERVER *--> BI_PRIVATE_CLOUD
|
|||||||
BI_MANAGED_SERVER *--> BI_PRIVATE_CLOUD
|
BI_MANAGED_SERVER *--> BI_PRIVATE_CLOUD
|
||||||
BI_MANAGED_WEBSPACE *--> BI_MANAGED_SERVER
|
BI_MANAGED_WEBSPACE *--> BI_MANAGED_SERVER
|
||||||
|
|
||||||
|
HA_CLOUD_SERVER *==> BI_CLOUD_SERVER
|
||||||
|
HA_MANAGED_SERVER *==> BI_MANAGED_SERVER
|
||||||
HA_MANAGED_WEBSPACE *==> BI_MANAGED_WEBSPACE
|
HA_MANAGED_WEBSPACE *==> BI_MANAGED_WEBSPACE
|
||||||
|
HA_MANAGED_WEBSPACE o..> HA_MANAGED_SERVER
|
||||||
HA_UNIX_USER *==> HA_MANAGED_WEBSPACE
|
HA_UNIX_USER *==> HA_MANAGED_WEBSPACE
|
||||||
HA_EMAIL_ALIAS *==> HA_MANAGED_WEBSPACE
|
HA_EMAIL_ALIAS *==> HA_MANAGED_WEBSPACE
|
||||||
|
HA_MARIADB_INSTANCE *==> HA_MANAGED_SERVER
|
||||||
HA_MARIADB_USER *==> HA_MANAGED_WEBSPACE
|
HA_MARIADB_USER *==> HA_MANAGED_WEBSPACE
|
||||||
HA_MARIADB_USER o--> HA_MARIADB_INSTANCE
|
HA_MARIADB_USER o..> HA_MARIADB_INSTANCE
|
||||||
HA_MARIADB_DATABASE *==> HA_MARIADB_USER
|
HA_MARIADB_DATABASE *==> HA_MARIADB_USER
|
||||||
|
HA_MARIADB_DATABASE o..> HA_MARIADB_INSTANCE
|
||||||
|
HA_IP_NUMBER o..> HA_CLOUD_SERVER
|
||||||
|
HA_IP_NUMBER o..> HA_MANAGED_SERVER
|
||||||
|
HA_IP_NUMBER o..> HA_MANAGED_WEBSPACE
|
||||||
|
|
||||||
package Legend #white {
|
package Legend #white {
|
||||||
SUB_ENTITY1 *--> REQUIRED_PARENT_ENTITY
|
SUB_ENTITY1 *--> REQUIRED_PARENT_ENTITY
|
||||||
@ -170,6 +153,12 @@ package Hosting #feb28c{
|
|||||||
entity HA_PGSQL_DATABASE
|
entity HA_PGSQL_DATABASE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
package Server #99bcdb {
|
||||||
|
entity HA_CLOUD_SERVER
|
||||||
|
entity HA_MANAGED_SERVER
|
||||||
|
entity HA_IP_NUMBER
|
||||||
|
}
|
||||||
|
|
||||||
package Webspace #99bcdb {
|
package Webspace #99bcdb {
|
||||||
entity HA_MANAGED_WEBSPACE
|
entity HA_MANAGED_WEBSPACE
|
||||||
entity HA_UNIX_USER
|
entity HA_UNIX_USER
|
||||||
@ -182,12 +171,20 @@ BI_CLOUD_SERVER *--> BI_PRIVATE_CLOUD
|
|||||||
BI_MANAGED_SERVER *--> BI_PRIVATE_CLOUD
|
BI_MANAGED_SERVER *--> BI_PRIVATE_CLOUD
|
||||||
BI_MANAGED_WEBSPACE *--> BI_MANAGED_SERVER
|
BI_MANAGED_WEBSPACE *--> BI_MANAGED_SERVER
|
||||||
|
|
||||||
|
HA_CLOUD_SERVER *==> BI_CLOUD_SERVER
|
||||||
|
HA_MANAGED_SERVER *==> BI_MANAGED_SERVER
|
||||||
HA_MANAGED_WEBSPACE *==> BI_MANAGED_WEBSPACE
|
HA_MANAGED_WEBSPACE *==> BI_MANAGED_WEBSPACE
|
||||||
|
HA_MANAGED_WEBSPACE o..> HA_MANAGED_SERVER
|
||||||
HA_UNIX_USER *==> HA_MANAGED_WEBSPACE
|
HA_UNIX_USER *==> HA_MANAGED_WEBSPACE
|
||||||
HA_EMAIL_ALIAS *==> HA_MANAGED_WEBSPACE
|
HA_EMAIL_ALIAS *==> HA_MANAGED_WEBSPACE
|
||||||
HA_PGSQL_USER *==> HA_MANAGED_WEBSPACE
|
HA_PGSQL_INSTANCE *==> HA_MANAGED_SERVER
|
||||||
HA_PGSQL_USER o--> HA_PGSQL_INSTANCE
|
HA_PGSQL_USER *==> HA_PGSQL_INSTANCE
|
||||||
HA_PGSQL_DATABASE *==> HA_PGSQL_USER
|
HA_PGSQL_USER o..> HA_MANAGED_WEBSPACE
|
||||||
|
HA_PGSQL_DATABASE *==> HA_MANAGED_WEBSPACE
|
||||||
|
HA_PGSQL_DATABASE o..> HA_PGSQL_INSTANCE
|
||||||
|
HA_IP_NUMBER o..> HA_CLOUD_SERVER
|
||||||
|
HA_IP_NUMBER o..> HA_MANAGED_SERVER
|
||||||
|
HA_IP_NUMBER o..> HA_MANAGED_WEBSPACE
|
||||||
|
|
||||||
package Legend #white {
|
package Legend #white {
|
||||||
SUB_ENTITY1 *--> REQUIRED_PARENT_ENTITY
|
SUB_ENTITY1 *--> REQUIRED_PARENT_ENTITY
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package net.hostsharing.hsadminng.hs.booking.item;
|
package net.hostsharing.hsadminng.hs.booking.item;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static java.util.Optional.ofNullable;
|
import static java.util.Optional.ofNullable;
|
||||||
|
|
||||||
@ -22,17 +21,12 @@ public enum HsBookingItemType implements Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> edges(final Set<String> inGroups) {
|
public List<String> edges() {
|
||||||
return ofNullable(parentItemType)
|
return ofNullable(parentItemType)
|
||||||
.map(p -> (nodeName() + " *--> " + p.nodeName()))
|
.map(p -> (nodeName() + " *--> " + p.nodeName()))
|
||||||
.stream().toList();
|
.stream().toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean belongsToAny(final Set<String> groups) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String nodeName() {
|
public String nodeName() {
|
||||||
return "BI_" + name();
|
return "BI_" + name();
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package net.hostsharing.hsadminng.hs.booking.item;
|
package net.hostsharing.hsadminng.hs.booking.item;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public interface Node {
|
public interface Node {
|
||||||
|
|
||||||
String nodeName();
|
String nodeName();
|
||||||
boolean belongsToAny(Set<String> groups);
|
List<String> edges();
|
||||||
List<String> edges(final Set<String> inGroup);
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ import java.io.IOException;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.StandardOpenOption;
|
import java.nio.file.StandardOpenOption;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -19,11 +18,7 @@ import java.util.function.Function;
|
|||||||
import static java.util.Arrays.stream;
|
import static java.util.Arrays.stream;
|
||||||
import static java.util.stream.Collectors.joining;
|
import static java.util.stream.Collectors.joining;
|
||||||
import static java.util.stream.Collectors.toSet;
|
import static java.util.stream.Collectors.toSet;
|
||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.EntityTypeRelation.assignedTo;
|
import static net.hostsharing.hsadminng.hs.hosting.asset.EntityTypeRelation.*;
|
||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.EntityTypeRelation.optionalParent;
|
|
||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.EntityTypeRelation.optionallyAssignedTo;
|
|
||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.EntityTypeRelation.requiredParent;
|
|
||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.EntityTypeRelation.requires;
|
|
||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.RelationPolicy.OPTIONAL;
|
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.RelationPolicy.OPTIONAL;
|
||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.RelationPolicy.REQUIRED;
|
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.RelationPolicy.REQUIRED;
|
||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.RelationType.ASSIGNED_TO_ASSET;
|
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.RelationType.ASSIGNED_TO_ASSET;
|
||||||
@ -111,14 +106,11 @@ public enum HsHostingAssetType implements Node {
|
|||||||
inGroup("MariaDB"),
|
inGroup("MariaDB"),
|
||||||
requiredParent(MARIADB_USER)), // thus, the MARIADB_USER:Agent becomes RBAC owner
|
requiredParent(MARIADB_USER)), // thus, the MARIADB_USER:Agent becomes RBAC owner
|
||||||
|
|
||||||
IPV4_NUMBER(
|
IP_NUMBER(
|
||||||
inGroup("Server"),
|
inGroup("Server"),
|
||||||
optionallyAssignedTo(CLOUD_SERVER).or(MANAGED_SERVER).or(MANAGED_WEBSPACE)
|
assignedTo(CLOUD_SERVER),
|
||||||
),
|
assignedTo(MANAGED_SERVER),
|
||||||
|
assignedTo(MANAGED_WEBSPACE)
|
||||||
IPV6_NUMBER(
|
|
||||||
inGroup("Server"),
|
|
||||||
optionallyAssignedTo(CLOUD_SERVER).or(MANAGED_SERVER).or(MANAGED_WEBSPACE)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
private final String groupName;
|
private final String groupName;
|
||||||
@ -152,50 +144,44 @@ public enum HsHostingAssetType implements Node {
|
|||||||
.orElse(RelationPolicy.FORBIDDEN);
|
.orElse(RelationPolicy.FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<HsBookingItemType> bookingItemTypes() {
|
public HsBookingItemType bookingItemType() {
|
||||||
return stream(relations)
|
return stream(relations)
|
||||||
.filter(r -> r.relationType == BOOKING_ITEM)
|
.filter(r -> r.relationType == BOOKING_ITEM)
|
||||||
|
.map(r -> HsBookingItemType.valueOf(r.relatedType(this).toString()))
|
||||||
.reduce(HsHostingAssetType::onlyASingleElementExpectedException)
|
.reduce(HsHostingAssetType::onlyASingleElementExpectedException)
|
||||||
.map(r -> r.relatedTypes(this))
|
.orElse(null);
|
||||||
.stream().flatMap(Set::stream)
|
|
||||||
.map(r -> (HsBookingItemType) r)
|
|
||||||
.collect(toSet());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelationPolicy parentAssetPolicy() {
|
public RelationPolicy parentAssetPolicy() {
|
||||||
return stream(relations)
|
return stream(relations)
|
||||||
.filter(r -> r.relationType == PARENT_ASSET)
|
.filter(r -> r.relationType == PARENT_ASSET)
|
||||||
.reduce(HsHostingAssetType::onlyASingleElementExpectedException)
|
|
||||||
.map(r -> r.relationPolicy)
|
.map(r -> r.relationPolicy)
|
||||||
|
.reduce(HsHostingAssetType::onlyASingleElementExpectedException)
|
||||||
.orElse(RelationPolicy.FORBIDDEN);
|
.orElse(RelationPolicy.FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<HsHostingAssetType> parentAssetTypes() {
|
public HsHostingAssetType parentAssetType() {
|
||||||
return stream(relations)
|
return stream(relations)
|
||||||
.filter(r -> r.relationType == PARENT_ASSET)
|
.filter(r -> r.relationType == PARENT_ASSET)
|
||||||
|
.map(r -> HsHostingAssetType.valueOf(r.relatedType(this).toString()))
|
||||||
.reduce(HsHostingAssetType::onlyASingleElementExpectedException)
|
.reduce(HsHostingAssetType::onlyASingleElementExpectedException)
|
||||||
.map(r -> r.relatedTypes(this))
|
.orElse(null);
|
||||||
.stream().flatMap(Set::stream)
|
|
||||||
.map(r -> (HsHostingAssetType) r)
|
|
||||||
.collect(toSet());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelationPolicy assignedToAssetPolicy() {
|
public RelationPolicy assignedToAssetPolicy() {
|
||||||
return stream(relations)
|
return stream(relations)
|
||||||
.filter(r -> r.relationType == ASSIGNED_TO_ASSET)
|
.filter(r -> r.relationType == ASSIGNED_TO_ASSET)
|
||||||
.reduce(HsHostingAssetType::onlyASingleElementExpectedException)
|
|
||||||
.map(r -> r.relationPolicy)
|
.map(r -> r.relationPolicy)
|
||||||
|
.reduce(HsHostingAssetType::onlyASingleElementExpectedException)
|
||||||
.orElse(RelationPolicy.FORBIDDEN);
|
.orElse(RelationPolicy.FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<HsHostingAssetType> assignedToAssetTypes() {
|
public HsHostingAssetType assignedToAssetType() {
|
||||||
return stream(relations)
|
return stream(relations)
|
||||||
.filter(r -> r.relationType == ASSIGNED_TO_ASSET)
|
.filter(r -> r.relationType == ASSIGNED_TO_ASSET)
|
||||||
|
.map(r -> HsHostingAssetType.valueOf(r.relatedType(this).toString()))
|
||||||
.reduce(HsHostingAssetType::onlyASingleElementExpectedException)
|
.reduce(HsHostingAssetType::onlyASingleElementExpectedException)
|
||||||
.map(r -> r.relatedTypes(this))
|
.orElse(null);
|
||||||
.stream().flatMap(Set::stream)
|
|
||||||
.map(r -> (HsHostingAssetType) r)
|
|
||||||
.collect(toSet());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <X> X onlyASingleElementExpectedException(Object a, Object b) {
|
private static <X> X onlyASingleElementExpectedException(Object a, Object b) {
|
||||||
@ -203,22 +189,12 @@ public enum HsHostingAssetType implements Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> edges(final Set<String> inGroups) {
|
public List<String> edges() {
|
||||||
return stream(relations)
|
return stream(relations)
|
||||||
.map(r -> r.relatedTypes(this).stream()
|
.map(r -> nodeName() + r.edge + r.relatedType(this).nodeName())
|
||||||
.filter(x -> x.belongsToAny(inGroups))
|
|
||||||
.map(x -> nodeName() + r.edge + x.nodeName())
|
|
||||||
.toList())
|
|
||||||
.flatMap(List::stream)
|
|
||||||
.sorted()
|
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean belongsToAny(final Set<String> groups) {
|
|
||||||
return groups.contains(this.groupName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String nodeName() {
|
public String nodeName() {
|
||||||
return "HA_" + name();
|
return "HA_" + name();
|
||||||
@ -244,12 +220,12 @@ public enum HsHostingAssetType implements Node {
|
|||||||
.map(t -> "entity " + t.nodeName())
|
.map(t -> "entity " + t.nodeName())
|
||||||
.collect(joining("\n"));
|
.collect(joining("\n"));
|
||||||
final String bookingItemEdges = stream(HsBookingItemType.values())
|
final String bookingItemEdges = stream(HsBookingItemType.values())
|
||||||
.map(t -> t.edges(includedHostingGroups))
|
.map(HsBookingItemType::edges)
|
||||||
.flatMap(Collection::stream)
|
.flatMap(Collection::stream)
|
||||||
.collect(joining("\n"));
|
.collect(joining("\n"));
|
||||||
final String hostingAssetEdges = stream(HsHostingAssetType.values())
|
final String hostingAssetEdges = stream(HsHostingAssetType.values())
|
||||||
.filter(t -> t.isInGroups(includedHostingGroups))
|
.filter(t -> t.isInGroups(includedHostingGroups))
|
||||||
.map(t -> t.edges(includedHostingGroups))
|
.map(HsHostingAssetType::edges)
|
||||||
.flatMap(Collection::stream)
|
.flatMap(Collection::stream)
|
||||||
.collect(joining("\n"));
|
.collect(joining("\n"));
|
||||||
return """
|
return """
|
||||||
@ -263,7 +239,7 @@ public enum HsHostingAssetType implements Node {
|
|||||||
package Booking #feb28c {
|
package Booking #feb28c {
|
||||||
%{bookingNodes}
|
%{bookingNodes}
|
||||||
}
|
}
|
||||||
|
|
||||||
package Hosting #feb28c{
|
package Hosting #feb28c{
|
||||||
%{hostingGroups}
|
%{hostingGroups}
|
||||||
}
|
}
|
||||||
@ -281,12 +257,12 @@ public enum HsHostingAssetType implements Node {
|
|||||||
Booking -down[hidden]->Legend
|
Booking -down[hidden]->Legend
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
.replace("%{caption}", caption)
|
.replace("%{caption}", caption)
|
||||||
.replace("%{bookingNodes}", bookingNodes)
|
.replace("%{bookingNodes}", bookingNodes)
|
||||||
.replace("%{hostingGroups}", hostingGroups)
|
.replace("%{hostingGroups}", hostingGroups)
|
||||||
.replace("%{hostingAssetNodeStyles}", hostingAssetNodes)
|
.replace("%{hostingAssetNodeStyles}", hostingAssetNodes)
|
||||||
.replace("%{bookingItemEdges}", bookingItemEdges)
|
.replace("%{bookingItemEdges}", bookingItemEdges)
|
||||||
.replace("%{hostingAssetEdges}", hostingAssetEdges);
|
.replace("%{hostingAssetEdges}", hostingAssetEdges);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isInGroups(final Set<String> assetGroups) {
|
private boolean isInGroups(final Set<String> assetGroups) {
|
||||||
@ -315,17 +291,15 @@ public enum HsHostingAssetType implements Node {
|
|||||||
.map(t -> t.groupName)
|
.map(t -> t.groupName)
|
||||||
.collect(toSet()));
|
.collect(toSet()));
|
||||||
|
|
||||||
markdown
|
markdown.append(renderAsPlantUML("Domain", Set.of("Domain", "Webspace", "Server")))
|
||||||
.append(renderAsPlantUML("Webspace+Server", Set.of("Server")))
|
.append(renderAsPlantUML("MariaDB", Set.of("MariaDB", "Webspace", "Server")))
|
||||||
.append(renderAsPlantUML("Domain", Set.of("Domain", "Webspace")))
|
.append(renderAsPlantUML("PostgreSQL", Set.of("PostgreSQL", "Webspace", "Server")));
|
||||||
.append(renderAsPlantUML("MariaDB", Set.of("MariaDB", "Webspace")))
|
|
||||||
.append(renderAsPlantUML("PostgreSQL", Set.of("PostgreSQL", "Webspace")));
|
|
||||||
|
|
||||||
markdown.append("""
|
markdown.append("""
|
||||||
|
|
||||||
This code generated was by %{this}.main, do not amend manually.
|
This code generated was by %{this}.main, do not amend manually.
|
||||||
"""
|
"""
|
||||||
.replace("%{this}", HsHostingAssetType.class.getSimpleName()));
|
.replace("%{this}", HsHostingAssetType.class.getSimpleName()));
|
||||||
|
|
||||||
return markdown.toString();
|
return markdown.toString();
|
||||||
}
|
}
|
||||||
@ -343,8 +317,8 @@ public enum HsHostingAssetType implements Node {
|
|||||||
|
|
||||||
public enum RelationType {
|
public enum RelationType {
|
||||||
BOOKING_ITEM,
|
BOOKING_ITEM,
|
||||||
PARENT_ASSET,
|
PARENT_ASSET,
|
||||||
ASSIGNED_TO_ASSET
|
ASSIGNED_TO_ASSET
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,78 +328,27 @@ class EntityTypeRelation<E, T extends Node> {
|
|||||||
final HsHostingAssetType.RelationPolicy relationPolicy;
|
final HsHostingAssetType.RelationPolicy relationPolicy;
|
||||||
final HsHostingAssetType.RelationType relationType;
|
final HsHostingAssetType.RelationType relationType;
|
||||||
final Function<HsHostingAssetEntity, E> getter;
|
final Function<HsHostingAssetEntity, E> getter;
|
||||||
private final List<T> acceptedRelatedTypes;
|
private final T relatedType;
|
||||||
final String edge;
|
final String edge;
|
||||||
|
|
||||||
private EntityTypeRelation(
|
public T relatedType(final HsHostingAssetType referringType) {
|
||||||
final HsHostingAssetType.RelationPolicy relationPolicy,
|
|
||||||
final HsHostingAssetType.RelationType relationType,
|
|
||||||
final Function<HsHostingAssetEntity, E> getter,
|
|
||||||
final T acceptedRelatedType,
|
|
||||||
final String edge
|
|
||||||
) {
|
|
||||||
this(relationPolicy, relationType, getter, modifiyableListOf(acceptedRelatedType), edge);
|
|
||||||
}
|
|
||||||
|
|
||||||
public <R extends Node> Set<R> relatedTypes(final HsHostingAssetType referringType) {
|
|
||||||
final Set<Node> result = acceptedRelatedTypes.stream()
|
|
||||||
.map(t -> t == HsHostingAssetType.SAME_TYPE ? referringType : t)
|
|
||||||
.collect(toSet());
|
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
return (Set<R>) result;
|
return relatedType == HsHostingAssetType.SAME_TYPE ? (T) referringType : relatedType;
|
||||||
}
|
}
|
||||||
|
|
||||||
static EntityTypeRelation<HsBookingItemEntity, HsBookingItemType> requires(final HsBookingItemType bookingItemType) {
|
static EntityTypeRelation<HsBookingItemEntity, HsBookingItemType> requires(final HsBookingItemType bookingItemType) {
|
||||||
return new EntityTypeRelation<>(
|
return new EntityTypeRelation<>(REQUIRED, BOOKING_ITEM, HsHostingAssetEntity::getBookingItem, bookingItemType, " *==> ");
|
||||||
REQUIRED,
|
|
||||||
BOOKING_ITEM,
|
|
||||||
HsHostingAssetEntity::getBookingItem,
|
|
||||||
bookingItemType,
|
|
||||||
" *==> ");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static EntityTypeRelation<HsHostingAssetEntity, HsHostingAssetType> optionalParent(final HsHostingAssetType hostingAssetType) {
|
static EntityTypeRelation<HsHostingAssetEntity, HsHostingAssetType> optionalParent(final HsHostingAssetType hostingAssetType) {
|
||||||
return new EntityTypeRelation<>(
|
return new EntityTypeRelation<>(OPTIONAL, PARENT_ASSET, HsHostingAssetEntity::getParentAsset, hostingAssetType, " o..> ");
|
||||||
OPTIONAL,
|
|
||||||
PARENT_ASSET,
|
|
||||||
HsHostingAssetEntity::getParentAsset,
|
|
||||||
hostingAssetType,
|
|
||||||
" o..> ");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static EntityTypeRelation<HsHostingAssetEntity, HsHostingAssetType> requiredParent(final HsHostingAssetType hostingAssetType) {
|
static EntityTypeRelation<HsHostingAssetEntity, HsHostingAssetType> requiredParent(final HsHostingAssetType hostingAssetType) {
|
||||||
return new EntityTypeRelation<>(
|
return new EntityTypeRelation<>(REQUIRED, PARENT_ASSET, HsHostingAssetEntity::getParentAsset, hostingAssetType, " *==> ");
|
||||||
REQUIRED,
|
|
||||||
PARENT_ASSET,
|
|
||||||
HsHostingAssetEntity::getParentAsset,
|
|
||||||
hostingAssetType,
|
|
||||||
" *==> ");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static EntityTypeRelation<HsHostingAssetEntity, HsHostingAssetType> assignedTo(final HsHostingAssetType hostingAssetType) {
|
static EntityTypeRelation<HsHostingAssetEntity, HsHostingAssetType> assignedTo(final HsHostingAssetType hostingAssetType) {
|
||||||
return new EntityTypeRelation<>(
|
return new EntityTypeRelation<>(REQUIRED, ASSIGNED_TO_ASSET, HsHostingAssetEntity::getAssignedToAsset, hostingAssetType, " o..> ");
|
||||||
REQUIRED,
|
|
||||||
ASSIGNED_TO_ASSET,
|
|
||||||
HsHostingAssetEntity::getAssignedToAsset,
|
|
||||||
hostingAssetType,
|
|
||||||
" o--> ");
|
|
||||||
}
|
|
||||||
|
|
||||||
EntityTypeRelation<E, T> or(final T alternativeHostingAssetType) {
|
|
||||||
acceptedRelatedTypes.add(alternativeHostingAssetType);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
static EntityTypeRelation<HsHostingAssetEntity, HsHostingAssetType> optionallyAssignedTo(final HsHostingAssetType hostingAssetType) {
|
|
||||||
return new EntityTypeRelation<>(
|
|
||||||
OPTIONAL,
|
|
||||||
ASSIGNED_TO_ASSET,
|
|
||||||
HsHostingAssetEntity::getAssignedToAsset,
|
|
||||||
hostingAssetType,
|
|
||||||
" o..> ");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static <T extends Node> ArrayList<T> modifiyableListOf(final T acceptedRelatedType) {
|
|
||||||
return new ArrayList<>(List.of(acceptedRelatedType));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,11 +12,9 @@ import net.hostsharing.hsadminng.hs.validation.ValidatableProperty;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static java.util.Arrays.stream;
|
import static java.util.Arrays.stream;
|
||||||
@ -39,17 +37,17 @@ public abstract class HostingAssetEntityValidator extends HsEntityValidator<HsHo
|
|||||||
super(properties);
|
super(properties);
|
||||||
this.bookingItemReferenceValidation = new ReferenceValidator<>(
|
this.bookingItemReferenceValidation = new ReferenceValidator<>(
|
||||||
assetType.bookingItemPolicy(),
|
assetType.bookingItemPolicy(),
|
||||||
assetType.bookingItemTypes(),
|
assetType.bookingItemType(),
|
||||||
HsHostingAssetEntity::getBookingItem,
|
HsHostingAssetEntity::getBookingItem,
|
||||||
HsBookingItemEntity::getType);
|
HsBookingItemEntity::getType);
|
||||||
this.parentAssetReferenceValidation = new ReferenceValidator<>(
|
this.parentAssetReferenceValidation = new ReferenceValidator<>(
|
||||||
assetType.parentAssetPolicy(),
|
assetType.parentAssetPolicy(),
|
||||||
assetType.parentAssetTypes(),
|
assetType.parentAssetType(),
|
||||||
HsHostingAssetEntity::getParentAsset,
|
HsHostingAssetEntity::getParentAsset,
|
||||||
HsHostingAssetEntity::getType);
|
HsHostingAssetEntity::getType);
|
||||||
this.assignedToAssetReferenceValidation = new ReferenceValidator<>(
|
this.assignedToAssetReferenceValidation = new ReferenceValidator<>(
|
||||||
assetType.assignedToAssetPolicy(),
|
assetType.assignedToAssetPolicy(),
|
||||||
assetType.assignedToAssetTypes(),
|
assetType.assignedToAssetType(),
|
||||||
HsHostingAssetEntity::getAssignedToAsset,
|
HsHostingAssetEntity::getAssignedToAsset,
|
||||||
HsHostingAssetEntity::getType);
|
HsHostingAssetEntity::getType);
|
||||||
this.alarmContactValidation = alarmContactValidation;
|
this.alarmContactValidation = alarmContactValidation;
|
||||||
@ -156,17 +154,17 @@ public abstract class HostingAssetEntityValidator extends HsEntityValidator<HsHo
|
|||||||
static class ReferenceValidator<S, T> {
|
static class ReferenceValidator<S, T> {
|
||||||
|
|
||||||
private final HsHostingAssetType.RelationPolicy policy;
|
private final HsHostingAssetType.RelationPolicy policy;
|
||||||
private final Set<T> referencedEntityTypes;
|
private final T referencedEntityType;
|
||||||
private final Function<HsHostingAssetEntity, S> referencedEntityGetter;
|
private final Function<HsHostingAssetEntity, S> referencedEntityGetter;
|
||||||
private final Function<S, T> referencedEntityTypeGetter;
|
private final Function<S, T> referencedEntityTypeGetter;
|
||||||
|
|
||||||
public ReferenceValidator(
|
public ReferenceValidator(
|
||||||
final HsHostingAssetType.RelationPolicy policy,
|
final HsHostingAssetType.RelationPolicy policy,
|
||||||
final Set<T> referencedEntityTypes,
|
final T subEntityType,
|
||||||
final Function<HsHostingAssetEntity, S> referencedEntityGetter,
|
final Function<HsHostingAssetEntity, S> referencedEntityGetter,
|
||||||
final Function<S, T> referencedEntityTypeGetter) {
|
final Function<S, T> referencedEntityTypeGetter) {
|
||||||
this.policy = policy;
|
this.policy = policy;
|
||||||
this.referencedEntityTypes = referencedEntityTypes;
|
this.referencedEntityType = subEntityType;
|
||||||
this.referencedEntityGetter = referencedEntityGetter;
|
this.referencedEntityGetter = referencedEntityGetter;
|
||||||
this.referencedEntityTypeGetter = referencedEntityTypeGetter;
|
this.referencedEntityTypeGetter = referencedEntityTypeGetter;
|
||||||
}
|
}
|
||||||
@ -175,7 +173,7 @@ public abstract class HostingAssetEntityValidator extends HsEntityValidator<HsHo
|
|||||||
final HsHostingAssetType.RelationPolicy policy,
|
final HsHostingAssetType.RelationPolicy policy,
|
||||||
final Function<HsHostingAssetEntity, S> referencedEntityGetter) {
|
final Function<HsHostingAssetEntity, S> referencedEntityGetter) {
|
||||||
this.policy = policy;
|
this.policy = policy;
|
||||||
this.referencedEntityTypes = Set.of();
|
this.referencedEntityType = null;
|
||||||
this.referencedEntityGetter = referencedEntityGetter;
|
this.referencedEntityGetter = referencedEntityGetter;
|
||||||
this.referencedEntityTypeGetter = e -> null;
|
this.referencedEntityTypeGetter = e -> null;
|
||||||
}
|
}
|
||||||
@ -187,15 +185,15 @@ public abstract class HostingAssetEntityValidator extends HsEntityValidator<HsHo
|
|||||||
|
|
||||||
switch (policy) {
|
switch (policy) {
|
||||||
case REQUIRED:
|
case REQUIRED:
|
||||||
if (!referencedEntityTypes.contains(actualEntityType)) {
|
if (actualEntityType != referencedEntityType) {
|
||||||
return List.of(actualEntityType == null
|
return List.of(actualEntityType == null
|
||||||
? referenceFieldName + "' must be of type " + toDisplay(referencedEntityTypes) + " but is null"
|
? referenceFieldName + "' must be of type " + referencedEntityType + " but is null"
|
||||||
: referenceFieldName + "' must be of type " + toDisplay(referencedEntityTypes) + " but is of type " + actualEntityType);
|
: referenceFieldName + "' must be of type " + referencedEntityType + " but is of type " + actualEntityType);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OPTIONAL:
|
case OPTIONAL:
|
||||||
if (actualEntityType != null && !referencedEntityTypes.contains(actualEntityType)) {
|
if (actualEntityType != null && actualEntityType != referencedEntityType) {
|
||||||
return List.of(referenceFieldName + "' must be null or of type " + toDisplay(referencedEntityTypes) + " but is of type "
|
return List.of(referenceFieldName + "' must be null or of type " + referencedEntityType + " but is of type "
|
||||||
+ actualEntityType);
|
+ actualEntityType);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -207,10 +205,6 @@ public abstract class HostingAssetEntityValidator extends HsEntityValidator<HsHo
|
|||||||
}
|
}
|
||||||
return emptyList();
|
return emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String toDisplay(final Set<T> referencedEntityTypes) {
|
|
||||||
return referencedEntityTypes.stream().sorted().map(Object::toString).collect(Collectors.joining(" or "));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class AlarmContact extends ReferenceValidator<HsOfficeContactEntity, Enum<?>> {
|
static class AlarmContact extends ReferenceValidator<HsOfficeContactEntity, Enum<?>> {
|
||||||
|
@ -32,8 +32,6 @@ public class HostingAssetEntityValidatorRegistry {
|
|||||||
register(PGSQL_INSTANCE, new HsPostgreSqlDbInstanceHostingAssetValidator());
|
register(PGSQL_INSTANCE, new HsPostgreSqlDbInstanceHostingAssetValidator());
|
||||||
register(PGSQL_USER, new HsPostgreSqlUserHostingAssetValidator());
|
register(PGSQL_USER, new HsPostgreSqlUserHostingAssetValidator());
|
||||||
register(PGSQL_DATABASE, new HsPostgreSqlDatabaseHostingAssetValidator());
|
register(PGSQL_DATABASE, new HsPostgreSqlDatabaseHostingAssetValidator());
|
||||||
register(IPV4_NUMBER, new HsIPv4NumberHostingAssetValidator());
|
|
||||||
register(IPV6_NUMBER, new HsIPv6NumberHostingAssetValidator());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void register(final Enum<HsHostingAssetType> type, final HsEntityValidator<HsHostingAssetEntity> validator) {
|
private static void register(final Enum<HsHostingAssetType> type, final HsEntityValidator<HsHostingAssetEntity> validator) {
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
package net.hostsharing.hsadminng.hs.hosting.asset.validators;
|
|
||||||
|
|
||||||
import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetEntity;
|
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.IPV4_NUMBER;
|
|
||||||
|
|
||||||
class HsIPv4NumberHostingAssetValidator extends HostingAssetEntityValidator {
|
|
||||||
|
|
||||||
private static final Pattern IPV4_REGEX = Pattern.compile("^((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}$");
|
|
||||||
|
|
||||||
HsIPv4NumberHostingAssetValidator() {
|
|
||||||
super(
|
|
||||||
IPV4_NUMBER,
|
|
||||||
AlarmContact.isOptional(),
|
|
||||||
|
|
||||||
NO_EXTRA_PROPERTIES
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Pattern identifierPattern(final HsHostingAssetEntity assetEntity) {
|
|
||||||
return IPV4_REGEX;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
package net.hostsharing.hsadminng.hs.hosting.asset.validators;
|
|
||||||
|
|
||||||
import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetEntity;
|
|
||||||
|
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.UnknownHostException;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.IPV6_NUMBER;
|
|
||||||
|
|
||||||
class HsIPv6NumberHostingAssetValidator extends HostingAssetEntityValidator {
|
|
||||||
|
|
||||||
// simplified pattern, the real check is done by letting Java parse the address
|
|
||||||
private static final Pattern IPV6_REGEX = Pattern.compile("([a-f0-9:]+:+)+[a-f0-9]+");
|
|
||||||
|
|
||||||
HsIPv6NumberHostingAssetValidator() {
|
|
||||||
super(
|
|
||||||
IPV6_NUMBER,
|
|
||||||
AlarmContact.isOptional(),
|
|
||||||
|
|
||||||
NO_EXTRA_PROPERTIES
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> validateEntity(final HsHostingAssetEntity assetEntity) {
|
|
||||||
final var violations = super.validateEntity(assetEntity);
|
|
||||||
|
|
||||||
if (!isValidIPv6Address(assetEntity.getIdentifier())) {
|
|
||||||
violations.add("'identifier' expected to be a valid IPv6 address, but is '" + assetEntity.getIdentifier() + "'");
|
|
||||||
}
|
|
||||||
|
|
||||||
return violations;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Pattern identifierPattern(final HsHostingAssetEntity assetEntity) {
|
|
||||||
return IPV6_REGEX;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isValidIPv6Address(final String identifier) {
|
|
||||||
try {
|
|
||||||
return InetAddress.getByName(identifier) instanceof java.net.Inet6Address;
|
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,6 @@
|
|||||||
package net.hostsharing.hsadminng.mapper;
|
package net.hostsharing.hsadminng.mapper;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -52,11 +51,6 @@ public class Array {
|
|||||||
return of();
|
return of();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T[] emptyArray(final Class<T> elementClass) {
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T[]) java.lang.reflect.Array.newInstance(elementClass, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public static <T> T[] insertNewEntriesAfterExistingEntry(final T[] array, final T entryToFind, final T... newEntries) {
|
public static <T> T[] insertNewEntriesAfterExistingEntry(final T[] array, final T entryToFind, final T... newEntries) {
|
||||||
final var arrayList = new ArrayList<>(asList(array));
|
final var arrayList = new ArrayList<>(asList(array));
|
||||||
|
@ -23,8 +23,6 @@ components:
|
|||||||
- MARIADB_INSTANCE
|
- MARIADB_INSTANCE
|
||||||
- MARIADB_USER
|
- MARIADB_USER
|
||||||
- MARIADB_DATABASE
|
- MARIADB_DATABASE
|
||||||
- IPV4_NUMBER
|
|
||||||
- IPV6_NUMBER
|
|
||||||
|
|
||||||
HsHostingAsset:
|
HsHostingAsset:
|
||||||
type: object
|
type: object
|
||||||
|
@ -21,9 +21,7 @@ create type HsHostingAssetType as enum (
|
|||||||
'PGSQL_DATABASE',
|
'PGSQL_DATABASE',
|
||||||
'MARIADB_INSTANCE',
|
'MARIADB_INSTANCE',
|
||||||
'MARIADB_USER',
|
'MARIADB_USER',
|
||||||
'MARIADB_DATABASE',
|
'MARIADB_DATABASE'
|
||||||
'IPV4_NUMBER',
|
|
||||||
'IPV6_NUMBER'
|
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE CAST (character varying as HsHostingAssetType) WITH INOUT AS IMPLICIT;
|
CREATE CAST (character varying as HsHostingAssetType) WITH INOUT AS IMPLICIT;
|
||||||
@ -87,10 +85,6 @@ begin
|
|||||||
when 'MARIADB_INSTANCE' then 'MANAGED_SERVER'
|
when 'MARIADB_INSTANCE' then 'MANAGED_SERVER'
|
||||||
when 'MARIADB_USER' then 'MANAGED_WEBSPACE'
|
when 'MARIADB_USER' then 'MANAGED_WEBSPACE'
|
||||||
when 'MARIADB_DATABASE' then 'MARIADB_USER'
|
when 'MARIADB_DATABASE' then 'MARIADB_USER'
|
||||||
|
|
||||||
when 'IPV4_NUMBER' then null
|
|
||||||
when 'IPV6_NUMBER' then null
|
|
||||||
|
|
||||||
else raiseException(format('[400] unknown asset type %s', NEW.type::text))
|
else raiseException(format('[400] unknown asset type %s', NEW.type::text))
|
||||||
end);
|
end);
|
||||||
|
|
||||||
|
@ -488,44 +488,6 @@ public class HsHostingAssetControllerRestTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
"""),
|
|
||||||
IPV4_NUMBER(
|
|
||||||
List.of(
|
|
||||||
HsHostingAssetEntity.builder()
|
|
||||||
.type(HsHostingAssetType.IPV4_NUMBER)
|
|
||||||
.assignedToAsset(TEST_MANAGED_SERVER_HOSTING_ASSET)
|
|
||||||
.identifier("11.12.13.14")
|
|
||||||
.caption("some fake IPv4 number")
|
|
||||||
.build()),
|
|
||||||
"""
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"type": "IPV4_NUMBER",
|
|
||||||
"identifier": "11.12.13.14",
|
|
||||||
"caption": "some fake IPv4 number",
|
|
||||||
"alarmContact": null,
|
|
||||||
"config": {}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
"""),
|
|
||||||
IPV6_NUMBER(
|
|
||||||
List.of(
|
|
||||||
HsHostingAssetEntity.builder()
|
|
||||||
.type(HsHostingAssetType.IPV4_NUMBER)
|
|
||||||
.assignedToAsset(TEST_MANAGED_SERVER_HOSTING_ASSET)
|
|
||||||
.identifier("2001:db8:3333:4444:5555:6666:7777:8888")
|
|
||||||
.caption("some fake IPv6 number")
|
|
||||||
.build()),
|
|
||||||
"""
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"type": "IPV4_NUMBER",
|
|
||||||
"identifier": "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
||||||
"caption": "some fake IPv6 number",
|
|
||||||
"alarmContact": null,
|
|
||||||
"config": {}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
""");
|
""");
|
||||||
|
|
||||||
final HsHostingAssetType assetType;
|
final HsHostingAssetType assetType;
|
||||||
|
@ -47,9 +47,7 @@ class HsHostingAssetPropsControllerAcceptanceTest {
|
|||||||
"MARIADB_DATABASE",
|
"MARIADB_DATABASE",
|
||||||
"PGSQL_INSTANCE",
|
"PGSQL_INSTANCE",
|
||||||
"PGSQL_USER",
|
"PGSQL_USER",
|
||||||
"PGSQL_DATABASE",
|
"PGSQL_DATABASE"
|
||||||
"IPV4_NUMBER",
|
|
||||||
"IPV6_NUMBER"
|
|
||||||
]
|
]
|
||||||
"""));
|
"""));
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
|
@ -14,62 +14,19 @@ class HsHostingAssetTypeUnitTest {
|
|||||||
## HostingAsset Type Structure
|
## HostingAsset Type Structure
|
||||||
|
|
||||||
|
|
||||||
### Webspace+Server
|
|
||||||
|
|
||||||
```plantuml
|
|
||||||
@startuml
|
|
||||||
left to right direction
|
|
||||||
|
|
||||||
package Booking #feb28c {
|
|
||||||
entity BI_PRIVATE_CLOUD
|
|
||||||
entity BI_CLOUD_SERVER
|
|
||||||
entity BI_MANAGED_SERVER
|
|
||||||
entity BI_MANAGED_WEBSPACE
|
|
||||||
}
|
|
||||||
|
|
||||||
package Hosting #feb28c{
|
|
||||||
package Server #99bcdb {
|
|
||||||
entity HA_CLOUD_SERVER
|
|
||||||
entity HA_MANAGED_SERVER
|
|
||||||
entity HA_IPV4_NUMBER
|
|
||||||
entity HA_IPV6_NUMBER
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
BI_CLOUD_SERVER *--> BI_PRIVATE_CLOUD
|
|
||||||
BI_MANAGED_SERVER *--> BI_PRIVATE_CLOUD
|
|
||||||
BI_MANAGED_WEBSPACE *--> BI_MANAGED_SERVER
|
|
||||||
|
|
||||||
HA_CLOUD_SERVER *==> BI_CLOUD_SERVER
|
|
||||||
HA_MANAGED_SERVER *==> BI_MANAGED_SERVER
|
|
||||||
HA_IPV4_NUMBER o..> HA_CLOUD_SERVER
|
|
||||||
HA_IPV4_NUMBER o..> HA_MANAGED_SERVER
|
|
||||||
HA_IPV6_NUMBER o..> HA_CLOUD_SERVER
|
|
||||||
HA_IPV6_NUMBER o..> HA_MANAGED_SERVER
|
|
||||||
|
|
||||||
package Legend #white {
|
|
||||||
SUB_ENTITY1 *--> REQUIRED_PARENT_ENTITY
|
|
||||||
SUB_ENTITY2 *..> OPTIONAL_PARENT_ENTITY
|
|
||||||
ASSIGNED_ENTITY1 o--> REQUIRED_ASSIGNED_TO_ENTITY1
|
|
||||||
ASSIGNED_ENTITY2 o..> OPTIONAL_ASSIGNED_TO_ENTITY2
|
|
||||||
}
|
|
||||||
Booking -down[hidden]->Legend
|
|
||||||
```
|
|
||||||
|
|
||||||
### Domain
|
### Domain
|
||||||
|
|
||||||
```plantuml
|
```plantuml
|
||||||
@startuml
|
@startuml
|
||||||
left to right direction
|
left to right direction
|
||||||
|
|
||||||
package Booking #feb28c {
|
package Booking #feb28c {
|
||||||
entity BI_PRIVATE_CLOUD
|
entity BI_PRIVATE_CLOUD
|
||||||
entity BI_CLOUD_SERVER
|
entity BI_CLOUD_SERVER
|
||||||
entity BI_MANAGED_SERVER
|
entity BI_MANAGED_SERVER
|
||||||
entity BI_MANAGED_WEBSPACE
|
entity BI_MANAGED_WEBSPACE
|
||||||
}
|
}
|
||||||
|
|
||||||
package Hosting #feb28c{
|
package Hosting #feb28c{
|
||||||
package Domain #99bcdb {
|
package Domain #99bcdb {
|
||||||
entity HA_DOMAIN_SETUP
|
entity HA_DOMAIN_SETUP
|
||||||
@ -79,33 +36,45 @@ class HsHostingAssetTypeUnitTest {
|
|||||||
entity HA_DOMAIN_MBOX_SETUP
|
entity HA_DOMAIN_MBOX_SETUP
|
||||||
entity HA_EMAIL_ADDRESS
|
entity HA_EMAIL_ADDRESS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
package Server #99bcdb {
|
||||||
|
entity HA_CLOUD_SERVER
|
||||||
|
entity HA_MANAGED_SERVER
|
||||||
|
entity HA_IP_NUMBER
|
||||||
|
}
|
||||||
|
|
||||||
package Webspace #99bcdb {
|
package Webspace #99bcdb {
|
||||||
entity HA_MANAGED_WEBSPACE
|
entity HA_MANAGED_WEBSPACE
|
||||||
entity HA_UNIX_USER
|
entity HA_UNIX_USER
|
||||||
entity HA_EMAIL_ALIAS
|
entity HA_EMAIL_ALIAS
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BI_CLOUD_SERVER *--> BI_PRIVATE_CLOUD
|
BI_CLOUD_SERVER *--> BI_PRIVATE_CLOUD
|
||||||
BI_MANAGED_SERVER *--> BI_PRIVATE_CLOUD
|
BI_MANAGED_SERVER *--> BI_PRIVATE_CLOUD
|
||||||
BI_MANAGED_WEBSPACE *--> BI_MANAGED_SERVER
|
BI_MANAGED_WEBSPACE *--> BI_MANAGED_SERVER
|
||||||
|
|
||||||
|
HA_CLOUD_SERVER *==> BI_CLOUD_SERVER
|
||||||
|
HA_MANAGED_SERVER *==> BI_MANAGED_SERVER
|
||||||
HA_MANAGED_WEBSPACE *==> BI_MANAGED_WEBSPACE
|
HA_MANAGED_WEBSPACE *==> BI_MANAGED_WEBSPACE
|
||||||
|
HA_MANAGED_WEBSPACE o..> HA_MANAGED_SERVER
|
||||||
HA_UNIX_USER *==> HA_MANAGED_WEBSPACE
|
HA_UNIX_USER *==> HA_MANAGED_WEBSPACE
|
||||||
HA_EMAIL_ALIAS *==> HA_MANAGED_WEBSPACE
|
HA_EMAIL_ALIAS *==> HA_MANAGED_WEBSPACE
|
||||||
HA_DOMAIN_SETUP o..> HA_DOMAIN_SETUP
|
HA_DOMAIN_SETUP o..> HA_DOMAIN_SETUP
|
||||||
HA_DOMAIN_DNS_SETUP *==> HA_DOMAIN_SETUP
|
HA_DOMAIN_DNS_SETUP *==> HA_DOMAIN_SETUP
|
||||||
HA_DOMAIN_DNS_SETUP o--> HA_MANAGED_WEBSPACE
|
HA_DOMAIN_DNS_SETUP o..> HA_MANAGED_WEBSPACE
|
||||||
HA_DOMAIN_HTTP_SETUP *==> HA_DOMAIN_SETUP
|
HA_DOMAIN_HTTP_SETUP *==> HA_DOMAIN_SETUP
|
||||||
HA_DOMAIN_HTTP_SETUP o--> HA_UNIX_USER
|
HA_DOMAIN_HTTP_SETUP o..> HA_UNIX_USER
|
||||||
HA_DOMAIN_SMTP_SETUP *==> HA_DOMAIN_SETUP
|
HA_DOMAIN_SMTP_SETUP *==> HA_DOMAIN_SETUP
|
||||||
HA_DOMAIN_SMTP_SETUP o--> HA_MANAGED_WEBSPACE
|
HA_DOMAIN_SMTP_SETUP o..> HA_MANAGED_WEBSPACE
|
||||||
HA_DOMAIN_MBOX_SETUP *==> HA_DOMAIN_SETUP
|
HA_DOMAIN_MBOX_SETUP *==> HA_DOMAIN_SETUP
|
||||||
HA_DOMAIN_MBOX_SETUP o--> HA_MANAGED_WEBSPACE
|
HA_DOMAIN_MBOX_SETUP o..> HA_MANAGED_WEBSPACE
|
||||||
HA_EMAIL_ADDRESS *==> HA_DOMAIN_MBOX_SETUP
|
HA_EMAIL_ADDRESS *==> HA_DOMAIN_MBOX_SETUP
|
||||||
|
HA_IP_NUMBER o..> HA_CLOUD_SERVER
|
||||||
|
HA_IP_NUMBER o..> HA_MANAGED_SERVER
|
||||||
|
HA_IP_NUMBER o..> HA_MANAGED_WEBSPACE
|
||||||
|
|
||||||
package Legend #white {
|
package Legend #white {
|
||||||
SUB_ENTITY1 *--> REQUIRED_PARENT_ENTITY
|
SUB_ENTITY1 *--> REQUIRED_PARENT_ENTITY
|
||||||
SUB_ENTITY2 *..> OPTIONAL_PARENT_ENTITY
|
SUB_ENTITY2 *..> OPTIONAL_PARENT_ENTITY
|
||||||
@ -114,46 +83,59 @@ class HsHostingAssetTypeUnitTest {
|
|||||||
}
|
}
|
||||||
Booking -down[hidden]->Legend
|
Booking -down[hidden]->Legend
|
||||||
```
|
```
|
||||||
|
|
||||||
### MariaDB
|
### MariaDB
|
||||||
|
|
||||||
```plantuml
|
```plantuml
|
||||||
@startuml
|
@startuml
|
||||||
left to right direction
|
left to right direction
|
||||||
|
|
||||||
package Booking #feb28c {
|
package Booking #feb28c {
|
||||||
entity BI_PRIVATE_CLOUD
|
entity BI_PRIVATE_CLOUD
|
||||||
entity BI_CLOUD_SERVER
|
entity BI_CLOUD_SERVER
|
||||||
entity BI_MANAGED_SERVER
|
entity BI_MANAGED_SERVER
|
||||||
entity BI_MANAGED_WEBSPACE
|
entity BI_MANAGED_WEBSPACE
|
||||||
}
|
}
|
||||||
|
|
||||||
package Hosting #feb28c{
|
package Hosting #feb28c{
|
||||||
package MariaDB #99bcdb {
|
package MariaDB #99bcdb {
|
||||||
entity HA_MARIADB_INSTANCE
|
entity HA_MARIADB_INSTANCE
|
||||||
entity HA_MARIADB_USER
|
entity HA_MARIADB_USER
|
||||||
entity HA_MARIADB_DATABASE
|
entity HA_MARIADB_DATABASE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
package Server #99bcdb {
|
||||||
|
entity HA_CLOUD_SERVER
|
||||||
|
entity HA_MANAGED_SERVER
|
||||||
|
entity HA_IP_NUMBER
|
||||||
|
}
|
||||||
|
|
||||||
package Webspace #99bcdb {
|
package Webspace #99bcdb {
|
||||||
entity HA_MANAGED_WEBSPACE
|
entity HA_MANAGED_WEBSPACE
|
||||||
entity HA_UNIX_USER
|
entity HA_UNIX_USER
|
||||||
entity HA_EMAIL_ALIAS
|
entity HA_EMAIL_ALIAS
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BI_CLOUD_SERVER *--> BI_PRIVATE_CLOUD
|
BI_CLOUD_SERVER *--> BI_PRIVATE_CLOUD
|
||||||
BI_MANAGED_SERVER *--> BI_PRIVATE_CLOUD
|
BI_MANAGED_SERVER *--> BI_PRIVATE_CLOUD
|
||||||
BI_MANAGED_WEBSPACE *--> BI_MANAGED_SERVER
|
BI_MANAGED_WEBSPACE *--> BI_MANAGED_SERVER
|
||||||
|
|
||||||
|
HA_CLOUD_SERVER *==> BI_CLOUD_SERVER
|
||||||
|
HA_MANAGED_SERVER *==> BI_MANAGED_SERVER
|
||||||
HA_MANAGED_WEBSPACE *==> BI_MANAGED_WEBSPACE
|
HA_MANAGED_WEBSPACE *==> BI_MANAGED_WEBSPACE
|
||||||
|
HA_MANAGED_WEBSPACE o..> HA_MANAGED_SERVER
|
||||||
HA_UNIX_USER *==> HA_MANAGED_WEBSPACE
|
HA_UNIX_USER *==> HA_MANAGED_WEBSPACE
|
||||||
HA_EMAIL_ALIAS *==> HA_MANAGED_WEBSPACE
|
HA_EMAIL_ALIAS *==> HA_MANAGED_WEBSPACE
|
||||||
|
HA_MARIADB_INSTANCE *==> HA_MANAGED_SERVER
|
||||||
HA_MARIADB_USER *==> HA_MANAGED_WEBSPACE
|
HA_MARIADB_USER *==> HA_MANAGED_WEBSPACE
|
||||||
HA_MARIADB_USER o--> HA_MARIADB_INSTANCE
|
HA_MARIADB_USER o..> HA_MARIADB_INSTANCE
|
||||||
HA_MARIADB_DATABASE *==> HA_MARIADB_USER
|
HA_MARIADB_DATABASE *==> HA_MARIADB_USER
|
||||||
|
HA_IP_NUMBER o..> HA_CLOUD_SERVER
|
||||||
|
HA_IP_NUMBER o..> HA_MANAGED_SERVER
|
||||||
|
HA_IP_NUMBER o..> HA_MANAGED_WEBSPACE
|
||||||
|
|
||||||
package Legend #white {
|
package Legend #white {
|
||||||
SUB_ENTITY1 *--> REQUIRED_PARENT_ENTITY
|
SUB_ENTITY1 *--> REQUIRED_PARENT_ENTITY
|
||||||
SUB_ENTITY2 *..> OPTIONAL_PARENT_ENTITY
|
SUB_ENTITY2 *..> OPTIONAL_PARENT_ENTITY
|
||||||
@ -162,46 +144,59 @@ class HsHostingAssetTypeUnitTest {
|
|||||||
}
|
}
|
||||||
Booking -down[hidden]->Legend
|
Booking -down[hidden]->Legend
|
||||||
```
|
```
|
||||||
|
|
||||||
### PostgreSQL
|
### PostgreSQL
|
||||||
|
|
||||||
```plantuml
|
```plantuml
|
||||||
@startuml
|
@startuml
|
||||||
left to right direction
|
left to right direction
|
||||||
|
|
||||||
package Booking #feb28c {
|
package Booking #feb28c {
|
||||||
entity BI_PRIVATE_CLOUD
|
entity BI_PRIVATE_CLOUD
|
||||||
entity BI_CLOUD_SERVER
|
entity BI_CLOUD_SERVER
|
||||||
entity BI_MANAGED_SERVER
|
entity BI_MANAGED_SERVER
|
||||||
entity BI_MANAGED_WEBSPACE
|
entity BI_MANAGED_WEBSPACE
|
||||||
}
|
}
|
||||||
|
|
||||||
package Hosting #feb28c{
|
package Hosting #feb28c{
|
||||||
package PostgreSQL #99bcdb {
|
package PostgreSQL #99bcdb {
|
||||||
entity HA_PGSQL_INSTANCE
|
entity HA_PGSQL_INSTANCE
|
||||||
entity HA_PGSQL_USER
|
entity HA_PGSQL_USER
|
||||||
entity HA_PGSQL_DATABASE
|
entity HA_PGSQL_DATABASE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
package Server #99bcdb {
|
||||||
|
entity HA_CLOUD_SERVER
|
||||||
|
entity HA_MANAGED_SERVER
|
||||||
|
entity HA_IP_NUMBER
|
||||||
|
}
|
||||||
|
|
||||||
package Webspace #99bcdb {
|
package Webspace #99bcdb {
|
||||||
entity HA_MANAGED_WEBSPACE
|
entity HA_MANAGED_WEBSPACE
|
||||||
entity HA_UNIX_USER
|
entity HA_UNIX_USER
|
||||||
entity HA_EMAIL_ALIAS
|
entity HA_EMAIL_ALIAS
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BI_CLOUD_SERVER *--> BI_PRIVATE_CLOUD
|
BI_CLOUD_SERVER *--> BI_PRIVATE_CLOUD
|
||||||
BI_MANAGED_SERVER *--> BI_PRIVATE_CLOUD
|
BI_MANAGED_SERVER *--> BI_PRIVATE_CLOUD
|
||||||
BI_MANAGED_WEBSPACE *--> BI_MANAGED_SERVER
|
BI_MANAGED_WEBSPACE *--> BI_MANAGED_SERVER
|
||||||
|
|
||||||
|
HA_CLOUD_SERVER *==> BI_CLOUD_SERVER
|
||||||
|
HA_MANAGED_SERVER *==> BI_MANAGED_SERVER
|
||||||
HA_MANAGED_WEBSPACE *==> BI_MANAGED_WEBSPACE
|
HA_MANAGED_WEBSPACE *==> BI_MANAGED_WEBSPACE
|
||||||
|
HA_MANAGED_WEBSPACE o..> HA_MANAGED_SERVER
|
||||||
HA_UNIX_USER *==> HA_MANAGED_WEBSPACE
|
HA_UNIX_USER *==> HA_MANAGED_WEBSPACE
|
||||||
HA_EMAIL_ALIAS *==> HA_MANAGED_WEBSPACE
|
HA_EMAIL_ALIAS *==> HA_MANAGED_WEBSPACE
|
||||||
|
HA_PGSQL_INSTANCE *==> HA_MANAGED_SERVER
|
||||||
HA_PGSQL_USER *==> HA_MANAGED_WEBSPACE
|
HA_PGSQL_USER *==> HA_MANAGED_WEBSPACE
|
||||||
HA_PGSQL_USER o--> HA_PGSQL_INSTANCE
|
HA_PGSQL_USER o..> HA_PGSQL_INSTANCE
|
||||||
HA_PGSQL_DATABASE *==> HA_PGSQL_USER
|
HA_PGSQL_DATABASE *==> HA_PGSQL_USER
|
||||||
|
HA_IP_NUMBER o..> HA_CLOUD_SERVER
|
||||||
|
HA_IP_NUMBER o..> HA_MANAGED_SERVER
|
||||||
|
HA_IP_NUMBER o..> HA_MANAGED_WEBSPACE
|
||||||
|
|
||||||
package Legend #white {
|
package Legend #white {
|
||||||
SUB_ENTITY1 *--> REQUIRED_PARENT_ENTITY
|
SUB_ENTITY1 *--> REQUIRED_PARENT_ENTITY
|
||||||
SUB_ENTITY2 *..> OPTIONAL_PARENT_ENTITY
|
SUB_ENTITY2 *..> OPTIONAL_PARENT_ENTITY
|
||||||
@ -210,7 +205,7 @@ class HsHostingAssetTypeUnitTest {
|
|||||||
}
|
}
|
||||||
Booking -down[hidden]->Legend
|
Booking -down[hidden]->Legend
|
||||||
```
|
```
|
||||||
|
|
||||||
This code generated was by HsHostingAssetType.main, do not amend manually.
|
This code generated was by HsHostingAssetType.main, do not amend manually.
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
|
@ -45,9 +45,7 @@ class HostingAssetEntityValidatorRegistryUnitTest {
|
|||||||
HsHostingAssetType.MARIADB_DATABASE,
|
HsHostingAssetType.MARIADB_DATABASE,
|
||||||
HsHostingAssetType.PGSQL_INSTANCE,
|
HsHostingAssetType.PGSQL_INSTANCE,
|
||||||
HsHostingAssetType.PGSQL_USER,
|
HsHostingAssetType.PGSQL_USER,
|
||||||
HsHostingAssetType.PGSQL_DATABASE,
|
HsHostingAssetType.PGSQL_DATABASE
|
||||||
HsHostingAssetType.IPV4_NUMBER,
|
|
||||||
HsHostingAssetType.IPV6_NUMBER
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,120 +0,0 @@
|
|||||||
package net.hostsharing.hsadminng.hs.hosting.asset.validators;
|
|
||||||
|
|
||||||
import net.hostsharing.hsadminng.hs.booking.item.HsBookingItemEntity;
|
|
||||||
import net.hostsharing.hsadminng.hs.booking.item.HsBookingItemType;
|
|
||||||
import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetEntity;
|
|
||||||
import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetEntity.HsHostingAssetEntityBuilder;
|
|
||||||
import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
|
||||||
import org.junit.jupiter.params.provider.EnumSource;
|
|
||||||
import org.junit.jupiter.params.provider.ValueSource;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static java.util.Map.entry;
|
|
||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.IPV4_NUMBER;
|
|
||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.MANAGED_WEBSPACE;
|
|
||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.UNIX_USER;
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
|
|
||||||
class HsIPv4NumberHostingAssetValidatorUnitTest {
|
|
||||||
|
|
||||||
static HsHostingAssetEntityBuilder validEntityBuilder() {
|
|
||||||
return HsHostingAssetEntity.builder()
|
|
||||||
.type(IPV4_NUMBER)
|
|
||||||
.identifier("83.223.95.145");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void containsExpectedProperties() {
|
|
||||||
// when
|
|
||||||
final var validator = HostingAssetEntityValidatorRegistry.forType(IPV4_NUMBER);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertThat(validator.properties()).map(Map::toString).isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void acceptsValidEntity() {
|
|
||||||
// given
|
|
||||||
final var givenEntity = validEntityBuilder().build();
|
|
||||||
final var validator = HostingAssetEntityValidatorRegistry.forType(givenEntity.getType());
|
|
||||||
|
|
||||||
// when
|
|
||||||
final var result = validator.validateEntity(givenEntity);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertThat(result).isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@ParameterizedTest
|
|
||||||
@ValueSource(strings = {"a.b.c.d", "83.223.95", "83.223.95.145.1", "2a01:37:1000::53df:5f91:0"})
|
|
||||||
void rejectsInvalidIdentifier(final String givenIdentifier) {
|
|
||||||
// given
|
|
||||||
final var givenEntity = validEntityBuilder().identifier(givenIdentifier).build();
|
|
||||||
final var validator = HostingAssetEntityValidatorRegistry.forType(givenEntity.getType());
|
|
||||||
|
|
||||||
// when
|
|
||||||
final var result = validator.validateEntity(givenEntity);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertThat(result).containsExactly(
|
|
||||||
"'identifier' expected to match '^((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}$', but is '" + givenIdentifier + "'"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ParameterizedTest
|
|
||||||
@EnumSource(value = HsHostingAssetType.class, names = { "CLOUD_SERVER", "MANAGED_SERVER", "MANAGED_WEBSPACE" })
|
|
||||||
void acceptsValidReferencedEntity(final HsHostingAssetType givenAssignedToAssetType) {
|
|
||||||
// given
|
|
||||||
final var ipNumberHostingAssetEntity = validEntityBuilder()
|
|
||||||
.assignedToAsset(HsHostingAssetEntity.builder().type(givenAssignedToAssetType).build())
|
|
||||||
.build();
|
|
||||||
final var validator = HostingAssetEntityValidatorRegistry.forType(ipNumberHostingAssetEntity.getType());
|
|
||||||
|
|
||||||
// when
|
|
||||||
final var result = validator.validateEntity(ipNumberHostingAssetEntity);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertThat(result).isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void rejectsInvalidReferencedEntities() {
|
|
||||||
// given
|
|
||||||
final var ipNumberHostingAssetEntity = validEntityBuilder()
|
|
||||||
.bookingItem(HsBookingItemEntity.builder().type(HsBookingItemType.CLOUD_SERVER).build())
|
|
||||||
.parentAsset(HsHostingAssetEntity.builder().type(MANAGED_WEBSPACE).build())
|
|
||||||
.assignedToAsset(HsHostingAssetEntity.builder().type(UNIX_USER).build())
|
|
||||||
.build();
|
|
||||||
final var validator = HostingAssetEntityValidatorRegistry.forType(ipNumberHostingAssetEntity.getType());
|
|
||||||
|
|
||||||
// when
|
|
||||||
final var result = validator.validateEntity(ipNumberHostingAssetEntity);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertThat(result).containsExactlyInAnyOrder(
|
|
||||||
"'IPV4_NUMBER:83.223.95.145.bookingItem' must be null but is of type CLOUD_SERVER",
|
|
||||||
"'IPV4_NUMBER:83.223.95.145.parentAsset' must be null but is of type MANAGED_WEBSPACE",
|
|
||||||
"'IPV4_NUMBER:83.223.95.145.assignedToAsset' must be null or of type CLOUD_SERVER or MANAGED_SERVER or MANAGED_WEBSPACE but is of type UNIX_USER");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void rejectsInvalidProperties() {
|
|
||||||
// given
|
|
||||||
final var ipNumberHostingAssetEntity = validEntityBuilder()
|
|
||||||
.config(Map.ofEntries(
|
|
||||||
entry("any", "false")
|
|
||||||
))
|
|
||||||
.build();
|
|
||||||
final var validator = HostingAssetEntityValidatorRegistry.forType(ipNumberHostingAssetEntity.getType());
|
|
||||||
|
|
||||||
// when
|
|
||||||
final var result = validator.validateEntity(ipNumberHostingAssetEntity);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertThat(result).containsExactlyInAnyOrder(
|
|
||||||
"'IPV4_NUMBER:83.223.95.145.config.any' is not expected but is set to 'false'");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
package net.hostsharing.hsadminng.hs.hosting.asset.validators;
|
|
||||||
|
|
||||||
import net.hostsharing.hsadminng.hs.booking.item.HsBookingItemEntity;
|
|
||||||
import net.hostsharing.hsadminng.hs.booking.item.HsBookingItemType;
|
|
||||||
import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetEntity;
|
|
||||||
import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetEntity.HsHostingAssetEntityBuilder;
|
|
||||||
import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
|
||||||
import org.junit.jupiter.params.provider.EnumSource;
|
|
||||||
import org.junit.jupiter.params.provider.ValueSource;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static java.util.Map.entry;
|
|
||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.IPV6_NUMBER;
|
|
||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.MANAGED_WEBSPACE;
|
|
||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.UNIX_USER;
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
|
|
||||||
class HsIPv6NumberHostingAssetValidatorUnitTest {
|
|
||||||
|
|
||||||
static HsHostingAssetEntityBuilder validEntityBuilder() {
|
|
||||||
return HsHostingAssetEntity.builder()
|
|
||||||
.type(IPV6_NUMBER)
|
|
||||||
.identifier("2001:db8:3333:4444:5555:6666:7777:8888");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void containsExpectedProperties() {
|
|
||||||
// when
|
|
||||||
final var validator = HostingAssetEntityValidatorRegistry.forType(IPV6_NUMBER);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertThat(validator.properties()).map(Map::toString).isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void acceptsValidEntity() {
|
|
||||||
// given
|
|
||||||
final var givenEntity = validEntityBuilder().build();
|
|
||||||
final var validator = HostingAssetEntityValidatorRegistry.forType(givenEntity.getType());
|
|
||||||
|
|
||||||
// when
|
|
||||||
final var result = validator.validateEntity(givenEntity);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertThat(result).isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@ParameterizedTest
|
|
||||||
@ValueSource(strings = {"83.223.95", "2a01:37:1000::53df:5f91:0:123::123"})
|
|
||||||
void rejectsInvalidIdentifier(final String givenIdentifier) {
|
|
||||||
// given
|
|
||||||
final var givenEntity = validEntityBuilder().identifier(givenIdentifier).build();
|
|
||||||
final var validator = HostingAssetEntityValidatorRegistry.forType(givenEntity.getType());
|
|
||||||
|
|
||||||
// when
|
|
||||||
final var result = validator.validateEntity(givenEntity);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertThat(result).contains(
|
|
||||||
"'identifier' expected to be a valid IPv6 address, but is '" + givenIdentifier + "'"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ParameterizedTest
|
|
||||||
@EnumSource(value = HsHostingAssetType.class, names = { "CLOUD_SERVER", "MANAGED_SERVER", "MANAGED_WEBSPACE" })
|
|
||||||
void acceptsValidReferencedEntity(final HsHostingAssetType givenAssignedToAssetType) {
|
|
||||||
// given
|
|
||||||
final var ipNumberHostingAssetEntity = validEntityBuilder()
|
|
||||||
.assignedToAsset(HsHostingAssetEntity.builder().type(givenAssignedToAssetType).build())
|
|
||||||
.build();
|
|
||||||
final var validator = HostingAssetEntityValidatorRegistry.forType(ipNumberHostingAssetEntity.getType());
|
|
||||||
|
|
||||||
// when
|
|
||||||
final var result = validator.validateEntity(ipNumberHostingAssetEntity);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertThat(result).isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void rejectsInvalidReferencedEntities() {
|
|
||||||
// given
|
|
||||||
final var ipNumberHostingAssetEntity = validEntityBuilder()
|
|
||||||
.bookingItem(HsBookingItemEntity.builder().type(HsBookingItemType.CLOUD_SERVER).build())
|
|
||||||
.parentAsset(HsHostingAssetEntity.builder().type(MANAGED_WEBSPACE).build())
|
|
||||||
.assignedToAsset(HsHostingAssetEntity.builder().type(UNIX_USER).build())
|
|
||||||
.build();
|
|
||||||
final var validator = HostingAssetEntityValidatorRegistry.forType(ipNumberHostingAssetEntity.getType());
|
|
||||||
|
|
||||||
// when
|
|
||||||
final var result = validator.validateEntity(ipNumberHostingAssetEntity);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertThat(result).containsExactlyInAnyOrder(
|
|
||||||
"'IPV6_NUMBER:2001:db8:3333:4444:5555:6666:7777:8888.bookingItem' must be null but is of type CLOUD_SERVER",
|
|
||||||
"'IPV6_NUMBER:2001:db8:3333:4444:5555:6666:7777:8888.parentAsset' must be null but is of type MANAGED_WEBSPACE",
|
|
||||||
"'IPV6_NUMBER:2001:db8:3333:4444:5555:6666:7777:8888.assignedToAsset' must be null or of type CLOUD_SERVER or MANAGED_SERVER or MANAGED_WEBSPACE but is of type UNIX_USER");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void rejectsInvalidProperties() {
|
|
||||||
// given
|
|
||||||
final var ipNumberHostingAssetEntity = validEntityBuilder()
|
|
||||||
.config(Map.ofEntries(
|
|
||||||
entry("any", "false")
|
|
||||||
))
|
|
||||||
.build();
|
|
||||||
final var validator = HostingAssetEntityValidatorRegistry.forType(ipNumberHostingAssetEntity.getType());
|
|
||||||
|
|
||||||
// when
|
|
||||||
final var result = validator.validateEntity(ipNumberHostingAssetEntity);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertThat(result).containsExactlyInAnyOrder(
|
|
||||||
"'IPV6_NUMBER:2001:db8:3333:4444:5555:6666:7777:8888.config.any' is not expected but is set to 'false'");
|
|
||||||
}
|
|
||||||
}
|
|
@ -31,7 +31,7 @@ class HsPostgreSqlDatabaseHostingAssetValidatorUnitTest {
|
|||||||
.type(PGSQL_USER)
|
.type(PGSQL_USER)
|
||||||
.parentAsset(TEST_MANAGED_WEBSPACE_HOSTING_ASSET)
|
.parentAsset(TEST_MANAGED_WEBSPACE_HOSTING_ASSET)
|
||||||
.assignedToAsset(GIVEN_PGSQL_INSTANCE)
|
.assignedToAsset(GIVEN_PGSQL_INSTANCE)
|
||||||
.identifier("xyz00_user")
|
.identifier("xyz00_temp")
|
||||||
.caption("some valid test PgSql-User")
|
.caption("some valid test PgSql-User")
|
||||||
.config(new HashMap<>(ofEntries(
|
.config(new HashMap<>(ofEntries(
|
||||||
entry("password", "Hallo Datenbank, lass mich rein!")
|
entry("password", "Hallo Datenbank, lass mich rein!")
|
||||||
@ -42,7 +42,7 @@ class HsPostgreSqlDatabaseHostingAssetValidatorUnitTest {
|
|||||||
return HsHostingAssetEntity.builder()
|
return HsHostingAssetEntity.builder()
|
||||||
.type(PGSQL_DATABASE)
|
.type(PGSQL_DATABASE)
|
||||||
.parentAsset(GIVEN_PGSQL_USER)
|
.parentAsset(GIVEN_PGSQL_USER)
|
||||||
.identifier("xyz00_db")
|
.identifier("xyz00_temp")
|
||||||
.caption("some valid test PgSql-Database")
|
.caption("some valid test PgSql-Database")
|
||||||
.config(new HashMap<>(ofEntries(
|
.config(new HashMap<>(ofEntries(
|
||||||
entry("encoding", "LATIN1")
|
entry("encoding", "LATIN1")
|
||||||
@ -94,9 +94,8 @@ class HsPostgreSqlDatabaseHostingAssetValidatorUnitTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result).containsExactlyInAnyOrder(
|
assertThat(result).containsExactlyInAnyOrder(
|
||||||
"'PGSQL_DATABASE:xyz00_db.bookingItem' must be null but is of type CLOUD_SERVER",
|
"'PGSQL_DATABASE:xyz00_temp.config.unknown' is not expected but is set to 'wrong'",
|
||||||
"'PGSQL_DATABASE:xyz00_db.parentAsset' must be of type PGSQL_USER but is of type PGSQL_INSTANCE",
|
"'PGSQL_DATABASE:xyz00_temp.config.encoding' is expected to be of type String, but is of type Integer"
|
||||||
"'PGSQL_DATABASE:xyz00_db.assignedToAsset' must be null but is of type PGSQL_INSTANCE"
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,8 +115,8 @@ class HsPostgreSqlDatabaseHostingAssetValidatorUnitTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result).containsExactlyInAnyOrder(
|
assertThat(result).containsExactlyInAnyOrder(
|
||||||
"'PGSQL_DATABASE:xyz00_db.config.unknown' is not expected but is set to 'wrong'",
|
"'PGSQL_DATABASE:xyz00_temp.config.unknown' is not expected but is set to 'wrong'",
|
||||||
"'PGSQL_DATABASE:xyz00_db.config.encoding' is expected to be of type String, but is of type Integer"
|
"'PGSQL_DATABASE:xyz00_temp.config.encoding' is expected to be of type String, but is of type Integer"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user