Service validation fixes

This commit is contained in:
crschnick
2026-06-15 19:37:41 +00:00
parent 0c4c37eccf
commit aa00541aaf
3 changed files with 49 additions and 0 deletions
@@ -48,11 +48,26 @@ public abstract class AbstractServiceStore
@Override
public void checkComplete() throws Throwable {
// We do not require the host to be complete
if (getHost() != null) {
Validators.isType(getHost(), HostAddressStore.class);
}
Validators.nonNull(remotePort);
Validators.nonNull(serviceProtocolType);
if (getHost() == null) {
Validators.nonNull(getAddress());
}
if (serviceProtocolType.hasScheme()) {
var addr = serviceProtocolType.formatAddress(getOpenTargetUrl());
if (addr != null) {
try {
URI.create(addr);
} catch (IllegalArgumentException e) {
throw new ValidationException(e.getMessage());
}
}
}
}
public String getOpenTargetUrl() {
@@ -95,6 +110,10 @@ public abstract class AbstractServiceStore
return false;
}
if (!getHost().getStore().isComplete()) {
return false;
}
if (getHost().getStore() instanceof HostAddressGatewayStore g
&& !(getHost().getStore() instanceof NetworkTunnelStore)) {
var gw = g.getTunnelGateway();
@@ -127,6 +146,10 @@ public abstract class AbstractServiceStore
}
if (getHost() != null) {
if (!getHost().getStore().isComplete()) {
return null;
}
if (!(getHost().getStore() instanceof NetworkTunnelStore)
&& getHost().getStore() instanceof HostAddressGatewayStore g) {
if (g.getTunnelGateway() == null
@@ -39,6 +39,10 @@ public abstract class AbstractServiceStoreProvider implements SingletonSessionSt
}
if (abs.getHost() != null) {
if (!abs.getHost().getStore().isComplete()) {
return false;
}
if (abs.getHost().getStore() instanceof HostAddressGatewayStore a) {
if (a.getTunnelGateway() != null
&& a.getTunnelGateway().getStore().requiresTunnel()
@@ -21,6 +21,8 @@ import java.util.Locale;
})
public interface ServiceProtocolType {
boolean hasScheme();
String formatAddress(String base);
void open(String url) throws Exception;
@@ -33,6 +35,11 @@ public interface ServiceProtocolType {
@Builder
class Undefined implements ServiceProtocolType {
@Override
public boolean hasScheme() {
return false;
}
@Override
public String formatAddress(String base) {
return base;
@@ -55,6 +62,11 @@ public interface ServiceProtocolType {
String path;
@Override
public boolean hasScheme() {
return true;
}
@Override
public String formatAddress(String base) {
var url = "http://" + base;
@@ -83,6 +95,11 @@ public interface ServiceProtocolType {
String path;
@Override
public boolean hasScheme() {
return true;
}
@Override
public String formatAddress(String base) {
var url = "https://" + base;
@@ -111,6 +128,11 @@ public interface ServiceProtocolType {
String commandTemplate;
@Override
public boolean hasScheme() {
return false;
}
@Override
public String formatAddress(String base) {
return base;