code improvements & delete task endpoint

This commit is contained in:
2021-11-02 20:58:59 +01:00
parent 6752454838
commit 06172b34cd
29 changed files with 256 additions and 24 deletions

View File

@@ -8,11 +8,16 @@ public class ExecutorURI {
private String value;
public ExecutorURI(String uri) throws InvalidExecutorURIException {
if (uri.equalsIgnoreCase("localhost") ||
uri.matches("^((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)(\\.(?!$)|$)){4}$")) {
this.value = uri;
} else {
String ip = uri.split(":")[0];
int port = Integer.parseInt(uri.split(":")[1]);
// Check if valid ip4
if (!ip.equalsIgnoreCase("localhost") &&
!uri.matches("^((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)(\\.(?!$)|$)){4}$")) {
throw new InvalidExecutorURIException();
// Check if valid port
} else if (port < 1024 || port > 65535) {
throw new InvalidExecutorURIException();
}
this.value = uri;
}
}