diff --git a/openvidu-server/src/main/java/io/openvidu/server/config/OpenviduConfig.java b/openvidu-server/src/main/java/io/openvidu/server/config/OpenviduConfig.java index 0abf2980..5b25dd70 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/config/OpenviduConfig.java +++ b/openvidu-server/src/main/java/io/openvidu/server/config/OpenviduConfig.java @@ -22,7 +22,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.info.BuildProperties; import org.springframework.stereotype.Component; -import io.openvidu.server.core.ParticipantRole; +import io.openvidu.java.client.OpenViduRole; @Component public class OpenviduConfig { @@ -200,24 +200,23 @@ public class OpenviduConfig { return this.openviduRecordingNotification; } - public ParticipantRole[] getRolesFromRecordingNotification() { - ParticipantRole[] roles; + public OpenViduRole[] getRolesFromRecordingNotification() { + OpenViduRole[] roles; switch (this.openviduRecordingNotification) { case "none": - roles = new ParticipantRole[0]; + roles = new OpenViduRole[0]; break; case "moderator": - roles = new ParticipantRole[] { ParticipantRole.MODERATOR }; + roles = new OpenViduRole[] { OpenViduRole.MODERATOR }; break; case "publisher_moderator": - roles = new ParticipantRole[] { ParticipantRole.PUBLISHER, ParticipantRole.MODERATOR }; + roles = new OpenViduRole[] { OpenViduRole.PUBLISHER, OpenViduRole.MODERATOR }; break; case "all": - roles = new ParticipantRole[] { ParticipantRole.SUBSCRIBER, ParticipantRole.PUBLISHER, - ParticipantRole.MODERATOR }; + roles = new OpenViduRole[] { OpenViduRole.SUBSCRIBER, OpenViduRole.PUBLISHER, OpenViduRole.MODERATOR }; break; default: - roles = new ParticipantRole[] { ParticipantRole.PUBLISHER, ParticipantRole.MODERATOR }; + roles = new OpenViduRole[] { OpenViduRole.PUBLISHER, OpenViduRole.MODERATOR }; } return roles; } diff --git a/openvidu-server/src/main/java/io/openvidu/server/core/ParticipantRole.java b/openvidu-server/src/main/java/io/openvidu/server/core/ParticipantRole.java deleted file mode 100644 index d8104305..00000000 --- a/openvidu-server/src/main/java/io/openvidu/server/core/ParticipantRole.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * (C) Copyright 2017-2019 OpenVidu (https://openvidu.io/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package io.openvidu.server.core; - -public enum ParticipantRole { - SUBSCRIBER, - PUBLISHER, - MODERATOR; -} diff --git a/openvidu-server/src/main/java/io/openvidu/server/core/SessionEventsHandler.java b/openvidu-server/src/main/java/io/openvidu/server/core/SessionEventsHandler.java index f07e841d..bc4a47ec 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/core/SessionEventsHandler.java +++ b/openvidu-server/src/main/java/io/openvidu/server/core/SessionEventsHandler.java @@ -36,6 +36,7 @@ import com.google.gson.JsonObject; import io.openvidu.client.OpenViduException; import io.openvidu.client.OpenViduException.Code; import io.openvidu.client.internal.ProtocolElements; +import io.openvidu.java.client.OpenViduRole; import io.openvidu.server.cdr.CallDetailRecord; import io.openvidu.server.config.InfoHandler; import io.openvidu.server.config.OpenviduConfig; @@ -552,13 +553,13 @@ public class SessionEventsHandler { return this.infoHandler; } - private Set filterParticipantsByRole(ParticipantRole[] roles, Set participants) { + private Set filterParticipantsByRole(OpenViduRole[] roles, Set participants) { return participants.stream().filter(part -> { if (ProtocolElements.RECORDER_PARTICIPANT_PUBLICID.equals(part.getParticipantPublicId())) { return false; } boolean isRole = false; - for (ParticipantRole role : roles) { + for (OpenViduRole role : roles) { isRole = role.equals(part.getToken().getRole()); if (isRole) break; diff --git a/openvidu-server/src/main/java/io/openvidu/server/core/SessionManager.java b/openvidu-server/src/main/java/io/openvidu/server/core/SessionManager.java index 01a6ff20..f2215342 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/core/SessionManager.java +++ b/openvidu-server/src/main/java/io/openvidu/server/core/SessionManager.java @@ -38,6 +38,7 @@ import com.google.gson.JsonObject; import io.openvidu.client.OpenViduException; import io.openvidu.client.OpenViduException.Code; import io.openvidu.client.internal.ProtocolElements; +import io.openvidu.java.client.OpenViduRole; import io.openvidu.java.client.SessionProperties; import io.openvidu.server.OpenViduServer; import io.openvidu.server.cdr.CallDetailRecord; @@ -225,7 +226,7 @@ public abstract class SessionManager { return sessionNotActive; } - public String newToken(String sessionId, ParticipantRole role, String serverMetadata, + public String newToken(String sessionId, OpenViduRole role, String serverMetadata, KurentoTokenOptions kurentoTokenOptions) throws OpenViduException { ConcurrentHashMap map = this.sessionidTokenTokenobj.putIfAbsent(sessionId, @@ -273,7 +274,7 @@ public abstract class SessionManager { this.sessionidParticipantpublicidParticipant.putIfAbsent(sessionId, new ConcurrentHashMap<>()); this.sessionidTokenTokenobj.putIfAbsent(sessionId, new ConcurrentHashMap<>()); this.sessionidTokenTokenobj.get(sessionId).putIfAbsent(token, - new Token(token, ParticipantRole.PUBLISHER, "", + new Token(token, OpenViduRole.PUBLISHER, "", this.coturnCredentialsService.isCoturnAvailable() ? this.coturnCredentialsService.createUser() : null, @@ -285,8 +286,8 @@ public abstract class SessionManager { public boolean isPublisherInSession(String sessionId, Participant participant) { if (!this.isInsecureParticipant(participant.getParticipantPrivateId())) { if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) { - return (ParticipantRole.PUBLISHER.equals(participant.getToken().getRole()) - || ParticipantRole.MODERATOR.equals(participant.getToken().getRole())); + return (OpenViduRole.PUBLISHER.equals(participant.getToken().getRole()) + || OpenViduRole.MODERATOR.equals(participant.getToken().getRole())); } else { return false; } @@ -298,7 +299,7 @@ public abstract class SessionManager { public boolean isModeratorInSession(String sessionId, Participant participant) { if (!this.isInsecureParticipant(participant.getParticipantPrivateId())) { if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) { - return ParticipantRole.MODERATOR.equals(participant.getToken().getRole()); + return OpenViduRole.MODERATOR.equals(participant.getToken().getRole()); } else { return false; } diff --git a/openvidu-server/src/main/java/io/openvidu/server/core/Token.java b/openvidu-server/src/main/java/io/openvidu/server/core/Token.java index 75d380f1..215024ce 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/core/Token.java +++ b/openvidu-server/src/main/java/io/openvidu/server/core/Token.java @@ -17,13 +17,14 @@ package io.openvidu.server.core; +import io.openvidu.java.client.OpenViduRole; import io.openvidu.server.coturn.TurnCredentials; import io.openvidu.server.kurento.core.KurentoTokenOptions; public class Token { private String token; - private ParticipantRole role; + private OpenViduRole role; private String serverMetadata = ""; private TurnCredentials turnCredentials; @@ -33,7 +34,7 @@ public class Token { this.token = token; } - public Token(String token, ParticipantRole role, String serverMetadata, TurnCredentials turnCredentials, + public Token(String token, OpenViduRole role, String serverMetadata, TurnCredentials turnCredentials, KurentoTokenOptions kurentoTokenOptions) { this.token = token; this.role = role; @@ -46,7 +47,7 @@ public class Token { return token; } - public ParticipantRole getRole() { + public OpenViduRole getRole() { return role; } diff --git a/openvidu-server/src/main/java/io/openvidu/server/rest/SessionRestController.java b/openvidu-server/src/main/java/io/openvidu/server/rest/SessionRestController.java index caa17775..7746ae8f 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/rest/SessionRestController.java +++ b/openvidu-server/src/main/java/io/openvidu/server/rest/SessionRestController.java @@ -43,6 +43,7 @@ import com.google.gson.JsonParser; import io.openvidu.client.OpenViduException; import io.openvidu.client.internal.ProtocolElements; import io.openvidu.java.client.MediaMode; +import io.openvidu.java.client.OpenViduRole; import io.openvidu.java.client.Recording.OutputMode; import io.openvidu.java.client.RecordingLayout; import io.openvidu.java.client.RecordingMode; @@ -50,7 +51,6 @@ import io.openvidu.java.client.RecordingProperties; import io.openvidu.java.client.SessionProperties; import io.openvidu.server.config.OpenviduConfig; import io.openvidu.server.core.Participant; -import io.openvidu.server.core.ParticipantRole; import io.openvidu.server.core.Session; import io.openvidu.server.core.SessionManager; import io.openvidu.server.kurento.core.KurentoTokenOptions; @@ -300,12 +300,12 @@ public class SessionRestController { } } - ParticipantRole role; + OpenViduRole role; try { if (roleString != null) { - role = ParticipantRole.valueOf(roleString); + role = OpenViduRole.valueOf(roleString); } else { - role = ParticipantRole.PUBLISHER; + role = OpenViduRole.PUBLISHER; } } catch (IllegalArgumentException e) { return this.generateErrorResponse("Parameter role " + params.get("role") + " is not defined", "/api/tokens",