openvidu-server: add OpenviduConfig#asOptionalStringAndNullIfBlank

pull/678/head
pabloFuente 2021-11-24 17:16:01 +01:00
parent 5ea339c3cd
commit 7470261345
1 changed files with 13 additions and 4 deletions

View File

@ -637,10 +637,10 @@ public class OpenviduConfig {
}
}
private void checkCoturnPort(){
private void checkCoturnPort() {
String property = "COTURN_PORT";
coturnPort = this.asNonNegativeInteger(property);
if (coturnPort <= 0 || coturnPort > 65535){
if (coturnPort <= 0 || coturnPort > 65535) {
addError("COTURN_PORT", "COTURN PORT is out of valid ports range (0-65535)");
}
}
@ -820,9 +820,10 @@ public class OpenviduConfig {
protected String asOptionalURL(String property) {
String optionalUrl = getValue(property);
try {
if (!optionalUrl.isEmpty()) {
checkUrl(optionalUrl);
if (optionalUrl.isBlank()) {
return null;
}
checkUrl(optionalUrl);
return optionalUrl;
} catch (Exception e) {
addError(property, "Is not a valid URL. " + e.getMessage());
@ -855,6 +856,14 @@ public class OpenviduConfig {
return getValue(property);
}
protected String asOptionalStringAndNullIfBlank(String property) {
String value = getValue(property);
if (value != null && value.isBlank()) {
value = null;
}
return value;
}
protected boolean asBoolean(String property) {
String value = getValue(property);
if (value == null) {