mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: beautify some empty lines
parent
bc2ced6220
commit
169e313b8c
|
@ -242,15 +242,12 @@ public class OpenViduServer implements JsonRpcConfigurer {
|
||||||
String msg = "\n\n\n" + " Configuration errors\n" + " --------------------\n" + "\n";
|
String msg = "\n\n\n" + " Configuration errors\n" + " --------------------\n" + "\n";
|
||||||
|
|
||||||
for (Error error : config.getConfigErrors()) {
|
for (Error error : config.getConfigErrors()) {
|
||||||
|
|
||||||
msg += " * Property " + config.getPropertyName(error.getProperty());
|
msg += " * Property " + config.getPropertyName(error.getProperty());
|
||||||
|
|
||||||
if (error.getValue() == null || error.getValue().equals("")) {
|
if (error.getValue() == null || error.getValue().equals("")) {
|
||||||
msg += " is not set. ";
|
msg += " is not set. ";
|
||||||
} else {
|
} else {
|
||||||
msg += "=" + error.getValue() + ". ";
|
msg += "=" + error.getValue() + ". ";
|
||||||
}
|
}
|
||||||
|
|
||||||
msg += error.getMessage() + "\n";
|
msg += error.getMessage() + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,6 @@ public class OpenviduConfig {
|
||||||
|
|
||||||
protected int openviduSessionsGarbageThreshold;
|
protected int openviduSessionsGarbageThreshold;
|
||||||
|
|
||||||
|
|
||||||
// Derived properties
|
// Derived properties
|
||||||
|
|
||||||
public static String finalUrl;
|
public static String finalUrl;
|
||||||
|
@ -275,11 +274,11 @@ public class OpenviduConfig {
|
||||||
public int getSessionGarbageInterval() {
|
public int getSessionGarbageInterval() {
|
||||||
return openviduSessionsGarbageInterval;
|
return openviduSessionsGarbageInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSessionGarbageThreshold() {
|
public int getSessionGarbageThreshold() {
|
||||||
return openviduSessionsGarbageThreshold;
|
return openviduSessionsGarbageThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Derived properties methods
|
// Derived properties methods
|
||||||
|
|
||||||
public String getSpringProfile() {
|
public String getSpringProfile() {
|
||||||
|
@ -381,13 +380,13 @@ public class OpenviduConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
userConfigProps = new ArrayList<>(configProps.keySet());
|
userConfigProps = new ArrayList<>(configProps.keySet());
|
||||||
|
|
||||||
userConfigProps.removeAll(getNonUserProperties());
|
userConfigProps.removeAll(getNonUserProperties());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<String> getNonUserProperties() {
|
protected List<String> getNonUserProperties() {
|
||||||
return Arrays.asList("coturn.ip", "coturn.redis.ip", "kms.uris", "server.port",
|
return Arrays.asList("coturn.ip", "coturn.redis.ip", "kms.uris", "server.port", "coturn.redis.dbname",
|
||||||
"coturn.redis.dbname", "coturn.redis.password", "coturn.redis.connect-timeout");
|
"coturn.redis.password", "coturn.redis.connect-timeout");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
|
@ -431,34 +430,30 @@ public class OpenviduConfig {
|
||||||
coturnRedisIp = asOptionalInetAddress("coturn.redis.ip");
|
coturnRedisIp = asOptionalInetAddress("coturn.redis.ip");
|
||||||
|
|
||||||
checkWebhook();
|
checkWebhook();
|
||||||
|
|
||||||
checkCertificateType();
|
checkCertificateType();
|
||||||
|
|
||||||
openviduSessionsGarbageInterval = asNonNegativeInteger("openvidu.sessions.garbage.interval");
|
openviduSessionsGarbageInterval = asNonNegativeInteger("openvidu.sessions.garbage.interval");
|
||||||
openviduSessionsGarbageThreshold = asNonNegativeInteger("openvidu.sessions.garbage.threshold");
|
openviduSessionsGarbageThreshold = asNonNegativeInteger("openvidu.sessions.garbage.threshold");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkCertificateType() {
|
private void checkCertificateType() {
|
||||||
|
|
||||||
String property = "certificate.type";
|
String property = "certificate.type";
|
||||||
|
|
||||||
certificateType = asNonEmptyString(property);
|
certificateType = asNonEmptyString(property);
|
||||||
|
|
||||||
if(certificateType != null && !certificateType.isEmpty()) {
|
if (certificateType != null && !certificateType.isEmpty()) {
|
||||||
List<String> validValues = Arrays.asList("selfsigned", "owncert", "letsencrypt");
|
List<String> validValues = Arrays.asList("selfsigned", "owncert", "letsencrypt");
|
||||||
if(!validValues.contains(certificateType)) {
|
if (!validValues.contains(certificateType)) {
|
||||||
addError(property,"Invalid value '"+certificateType+"'. Valid values are "+validValues);
|
addError(property, "Invalid value '" + certificateType + "'. Valid values are " + validValues);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkCoturnIp() {
|
private void checkCoturnIp() {
|
||||||
|
|
||||||
coturnIp = getConfigValue("coturn.ip");
|
coturnIp = getConfigValue("coturn.ip");
|
||||||
|
|
||||||
if (coturnIp == null || this.coturnIp.isEmpty()) {
|
if (coturnIp == null || this.coturnIp.isEmpty()) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.coturnIp = new URL(this.getFinalUrl()).getHost();
|
this.coturnIp = new URL(this.getFinalUrl()).getHost();
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
|
@ -467,9 +462,7 @@ public class OpenviduConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void checkWebhook() {
|
private void checkWebhook() {
|
||||||
|
|
||||||
openviduWebhookEnabled = asBoolean("openvidu.webhook");
|
openviduWebhookEnabled = asBoolean("openvidu.webhook");
|
||||||
openviduWebhookEndpoint = asOptionalURL("openvidu.webhook.endpoint");
|
openviduWebhookEndpoint = asOptionalURL("openvidu.webhook.endpoint");
|
||||||
webhookHeadersList = checkWebhookHeaders();
|
webhookHeadersList = checkWebhookHeaders();
|
||||||
|
@ -493,27 +486,17 @@ public class OpenviduConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkOpenviduPublicurl() {
|
private void checkOpenviduPublicurl() {
|
||||||
|
|
||||||
final String property = "openvidu.domain.or.public.ip";
|
final String property = "openvidu.domain.or.public.ip";
|
||||||
|
|
||||||
String domain = getConfigValue(property);
|
String domain = getConfigValue(property);
|
||||||
|
|
||||||
if (domain != null && !domain.isEmpty()) {
|
if (domain != null && !domain.isEmpty()) {
|
||||||
|
|
||||||
this.openviduPublicUrl = "https://" + domain;
|
this.openviduPublicUrl = "https://" + domain;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
final String urlProperty = "openvidu.publicurl";
|
final String urlProperty = "openvidu.publicurl";
|
||||||
|
|
||||||
String publicurl = getConfigValue(urlProperty);
|
String publicurl = getConfigValue(urlProperty);
|
||||||
|
|
||||||
if (publicurl == null || publicurl.isEmpty()) {
|
if (publicurl == null || publicurl.isEmpty()) {
|
||||||
|
|
||||||
addError(property, "Cannot be empty");
|
addError(property, "Cannot be empty");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (!OPENVIDU_VALID_PUBLICURL_VALUES.contains(publicurl)) {
|
if (!OPENVIDU_VALID_PUBLICURL_VALUES.contains(publicurl)) {
|
||||||
try {
|
try {
|
||||||
checkUrl(publicurl);
|
checkUrl(publicurl);
|
||||||
|
@ -521,18 +504,16 @@ public class OpenviduConfig {
|
||||||
addError(property, "Is not a valid URL. " + e.getMessage());
|
addError(property, "Is not a valid URL. " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.openviduPublicUrl = publicurl;
|
this.openviduPublicUrl = publicurl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(openviduPublicUrl != null && !openviduPublicUrl.isEmpty()) {
|
if (openviduPublicUrl != null && !openviduPublicUrl.isEmpty()) {
|
||||||
calculatePublicUrl();
|
calculatePublicUrl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calculatePublicUrl() {
|
|
||||||
|
|
||||||
|
private void calculatePublicUrl() {
|
||||||
String publicUrl = this.getOpenViduPublicUrl();
|
String publicUrl = this.getOpenViduPublicUrl();
|
||||||
|
|
||||||
String type = "";
|
String type = "";
|
||||||
|
@ -564,7 +545,6 @@ public class OpenviduConfig {
|
||||||
type = "local";
|
type = "local";
|
||||||
OpenViduServer.wsUrl = "wss://localhost:" + this.getServerPort();
|
OpenViduServer.wsUrl = "wss://localhost:" + this.getServerPort();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OpenViduServer.wsUrl.endsWith("/")) {
|
if (OpenViduServer.wsUrl.endsWith("/")) {
|
||||||
OpenViduServer.wsUrl = OpenViduServer.wsUrl.substring(0, OpenViduServer.wsUrl.length() - 1);
|
OpenViduServer.wsUrl = OpenViduServer.wsUrl.substring(0, OpenViduServer.wsUrl.length() - 1);
|
||||||
}
|
}
|
||||||
|
@ -575,13 +555,9 @@ public class OpenviduConfig {
|
||||||
OpenViduServer.publicurlType = type;
|
OpenViduServer.publicurlType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<String> checkKmsUris() {
|
public List<String> checkKmsUris() {
|
||||||
|
|
||||||
String property = "kms.uris";
|
String property = "kms.uris";
|
||||||
|
|
||||||
String kmsUris = getConfigValue(property);
|
String kmsUris = getConfigValue(property);
|
||||||
|
|
||||||
if (kmsUris == null || kmsUris.isEmpty()) {
|
if (kmsUris == null || kmsUris.isEmpty()) {
|
||||||
return Arrays.asList();
|
return Arrays.asList();
|
||||||
}
|
}
|
||||||
|
@ -594,7 +570,6 @@ public class OpenviduConfig {
|
||||||
kmsUris = kmsUris.replaceAll(",", "\\\",\\\""); // Escape middle uris
|
kmsUris = kmsUris.replaceAll(",", "\\\",\\\""); // Escape middle uris
|
||||||
|
|
||||||
List<String> kmsUrisArray = asJsonStringsArray(property);
|
List<String> kmsUrisArray = asJsonStringsArray(property);
|
||||||
|
|
||||||
for (String uri : kmsUrisArray) {
|
for (String uri : kmsUrisArray) {
|
||||||
try {
|
try {
|
||||||
this.checkWebsocketUri(uri);
|
this.checkWebsocketUri(uri);
|
||||||
|
@ -607,15 +582,11 @@ public class OpenviduConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Header> checkWebhookHeaders() {
|
private List<Header> checkWebhookHeaders() {
|
||||||
|
|
||||||
String property = "openvidu.webhook.headers";
|
String property = "openvidu.webhook.headers";
|
||||||
|
|
||||||
List<String> headers = asJsonStringsArray(property);
|
List<String> headers = asJsonStringsArray(property);
|
||||||
|
|
||||||
List<Header> headerList = new ArrayList<>();
|
List<Header> headerList = new ArrayList<>();
|
||||||
|
|
||||||
for (String header : headers) {
|
for (String header : headers) {
|
||||||
|
|
||||||
String[] headerSplit = header.split(": ", 2);
|
String[] headerSplit = header.split(": ", 2);
|
||||||
if (headerSplit.length != 2) {
|
if (headerSplit.length != 2) {
|
||||||
addError(property, "HTTP header '" + header
|
addError(property, "HTTP header '" + header
|
||||||
|
@ -636,11 +607,8 @@ public class OpenviduConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<CDREventName> getWebhookEvents() {
|
private List<CDREventName> getWebhookEvents() {
|
||||||
|
|
||||||
String property = "openvidu.webhook.events";
|
String property = "openvidu.webhook.events";
|
||||||
|
|
||||||
List<String> events = asJsonStringsArray(property);
|
List<String> events = asJsonStringsArray(property);
|
||||||
|
|
||||||
List<CDREventName> eventList = new ArrayList<>();
|
List<CDREventName> eventList = new ArrayList<>();
|
||||||
|
|
||||||
for (String event : events) {
|
for (String event : events) {
|
||||||
|
@ -658,7 +626,6 @@ public class OpenviduConfig {
|
||||||
// -------------------------------------------------------
|
// -------------------------------------------------------
|
||||||
|
|
||||||
protected String asOptionalURL(String property) {
|
protected String asOptionalURL(String property) {
|
||||||
|
|
||||||
String optionalUrl = getConfigValue(property);
|
String optionalUrl = getConfigValue(property);
|
||||||
try {
|
try {
|
||||||
if (!optionalUrl.isEmpty()) {
|
if (!optionalUrl.isEmpty()) {
|
||||||
|
@ -672,9 +639,7 @@ public class OpenviduConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String asNonEmptyString(String property) {
|
protected String asNonEmptyString(String property) {
|
||||||
|
|
||||||
String stringValue = getConfigValue(property);
|
String stringValue = getConfigValue(property);
|
||||||
|
|
||||||
if (stringValue != null && !stringValue.isEmpty()) {
|
if (stringValue != null && !stringValue.isEmpty()) {
|
||||||
return stringValue;
|
return stringValue;
|
||||||
} else {
|
} else {
|
||||||
|
@ -682,15 +647,13 @@ public class OpenviduConfig {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String asOptionalString(String property) {
|
protected String asOptionalString(String property) {
|
||||||
return getConfigValue(property);
|
return getConfigValue(property);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean asBoolean(String property) {
|
protected boolean asBoolean(String property) {
|
||||||
|
|
||||||
String value = getConfigValue(property);
|
String value = getConfigValue(property);
|
||||||
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
addError(property, "Cannot be empty");
|
addError(property, "Cannot be empty");
|
||||||
return false;
|
return false;
|
||||||
|
@ -719,7 +682,7 @@ public class OpenviduConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This method checks all types of internet addresses (IPv4, IPv6 and Domains)
|
* This method checks all types of Internet addresses (IPv4, IPv6 and Domains)
|
||||||
*/
|
*/
|
||||||
protected String asOptionalInetAddress(String property) {
|
protected String asOptionalInetAddress(String property) {
|
||||||
String inetAddress = getConfigValue(property);
|
String inetAddress = getConfigValue(property);
|
||||||
|
@ -748,9 +711,7 @@ public class OpenviduConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<String> asJsonStringsArray(String property) {
|
protected List<String> asJsonStringsArray(String property) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
JsonArray jsonArray = gson.fromJson(getConfigValue(property), JsonArray.class);
|
JsonArray jsonArray = gson.fromJson(getConfigValue(property), JsonArray.class);
|
||||||
List<String> list = JsonUtils.toStringList(jsonArray);
|
List<String> list = JsonUtils.toStringList(jsonArray);
|
||||||
|
@ -758,22 +719,20 @@ public class OpenviduConfig {
|
||||||
list = new ArrayList<>();
|
list = new ArrayList<>();
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
|
|
||||||
} catch (JsonSyntaxException e) {
|
} catch (JsonSyntaxException e) {
|
||||||
addError(property, "Is not a valid strings array in JSON format. " + e.getMessage());
|
addError(property, "Is not a valid strings array in JSON format. " + e.getMessage());
|
||||||
return Arrays.asList();
|
return Arrays.asList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <E extends Enum<E>> E asEnumValue(String property, Class<E> enumType) {
|
protected <E extends Enum<E>> E asEnumValue(String property, Class<E> enumType) {
|
||||||
|
|
||||||
String value = this.getConfigValue(property);
|
String value = this.getConfigValue(property);
|
||||||
try {
|
try {
|
||||||
return Enum.valueOf(enumType, value);
|
return Enum.valueOf(enumType, value);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
addError(property, "Must be one of " + Arrays.asList(enumType.getEnumConstants()));
|
addError(property, "Must be one of " + Arrays.asList(enumType.getEnumConstants()));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public URI checkWebsocketUri(String uri) throws Exception {
|
public URI checkWebsocketUri(String uri) throws Exception {
|
||||||
|
|
Loading…
Reference in New Issue