feat(akka): Plugin Js relative entrypoint and refactor of pluginManifests
parameter (#21485)
* [js-relative-endpoint-refactors] - Added relative js entrypoint - just the name and extension * [js-relative-endpoint-refactors] - Changes name and references of to and adapt all the rest. * [js-relative-endpoint-refactors] changes in review
This commit is contained in:
parent
873b590e91
commit
a9e0e872b1
@ -61,13 +61,26 @@ object PluginModel {
|
|||||||
def getPlugins(instance: PluginModel): Map[String, Plugin] = {
|
def getPlugins(instance: PluginModel): Map[String, Plugin] = {
|
||||||
instance.plugins
|
instance.plugins
|
||||||
}
|
}
|
||||||
|
def replaceRelativeJavascriptEntrypoint(plugin: Plugin): Plugin = {
|
||||||
|
val jsEntrypoint = plugin.manifest.content.javascriptEntrypointUrl
|
||||||
|
if (jsEntrypoint.startsWith("http://") || jsEntrypoint.startsWith("https://")) {
|
||||||
|
plugin
|
||||||
|
} else {
|
||||||
|
val baseUrl = plugin.manifest.url.substring(0, plugin.manifest.url.lastIndexOf('/') + 1)
|
||||||
|
val absoluteJavascriptEntrypoint = baseUrl + jsEntrypoint
|
||||||
|
val newPluginManifestContent = plugin.manifest.content.copy(javascriptEntrypointUrl = absoluteJavascriptEntrypoint)
|
||||||
|
val newPluginManifest = plugin.manifest.copy(content = newPluginManifestContent)
|
||||||
|
plugin.copy(manifest = newPluginManifest)
|
||||||
|
}
|
||||||
|
}
|
||||||
def createPluginModelFromJson(json: util.Map[String, AnyRef]): PluginModel = {
|
def createPluginModelFromJson(json: util.Map[String, AnyRef]): PluginModel = {
|
||||||
val instance = new PluginModel()
|
val instance = new PluginModel()
|
||||||
var pluginsMap: Map[String, Plugin] = Map.empty[String, Plugin]
|
var pluginsMap: Map[String, Plugin] = Map.empty[String, Plugin]
|
||||||
json.forEach { case (pluginName, plugin) =>
|
json.forEach { case (pluginName, plugin) =>
|
||||||
try {
|
try {
|
||||||
val pluginObject = objectMapper.readValue(objectMapper.writeValueAsString(plugin), classOf[Plugin])
|
val pluginObject = objectMapper.readValue(objectMapper.writeValueAsString(plugin), classOf[Plugin])
|
||||||
pluginsMap = pluginsMap + (pluginName -> pluginObject)
|
val pluginObjectWithAbsoluteJavascriptEntrypoint = replaceRelativeJavascriptEntrypoint(pluginObject)
|
||||||
|
pluginsMap = pluginsMap + (pluginName -> pluginObjectWithAbsoluteJavascriptEntrypoint)
|
||||||
} catch {
|
} catch {
|
||||||
case err @ (_: JsonProcessingException | _: JsonMappingException) => println("Error while processing plugin " +
|
case err @ (_: JsonProcessingException | _: JsonMappingException) => println("Error while processing plugin " +
|
||||||
pluginName + ": ", err)
|
pluginName + ": ", err)
|
||||||
|
@ -73,7 +73,7 @@ public class ApiParams {
|
|||||||
public static final String ROLE = "role";
|
public static final String ROLE = "role";
|
||||||
public static final String GROUPS = "groups";
|
public static final String GROUPS = "groups";
|
||||||
public static final String DISABLED_FEATURES = "disabledFeatures";
|
public static final String DISABLED_FEATURES = "disabledFeatures";
|
||||||
public static final String PLUGINS_MANIFESTS = "pluginsManifests";
|
public static final String PLUGIN_MANIFESTS = "pluginManifests";
|
||||||
public static final String DISABLED_FEATURES_EXCLUDE = "disabledFeaturesExclude";
|
public static final String DISABLED_FEATURES_EXCLUDE = "disabledFeaturesExclude";
|
||||||
public static final String NOTIFY_RECORDING_IS_ON = "notifyRecordingIsOn";
|
public static final String NOTIFY_RECORDING_IS_ON = "notifyRecordingIsOn";
|
||||||
|
|
||||||
|
@ -404,10 +404,10 @@ public class MeetingService implements MessageListener {
|
|||||||
Map<String, String> metadata = m.getMetadata();
|
Map<String, String> metadata = m.getMetadata();
|
||||||
|
|
||||||
// Fetch content for each URL and store in the map
|
// Fetch content for each URL and store in the map
|
||||||
for (PluginsManifest pluginsManifest : m.getPluginsManifests()) {
|
for (PluginManifest pluginManifest : m.getPluginManifests()) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String urlString = pluginsManifest.getUrl();
|
String urlString = pluginManifest.getUrl();
|
||||||
URL url = new URL(urlString);
|
URL url = new URL(urlString);
|
||||||
StringBuilder content = new StringBuilder();
|
StringBuilder content = new StringBuilder();
|
||||||
try (BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()))) {
|
try (BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()))) {
|
||||||
@ -421,15 +421,15 @@ public class MeetingService implements MessageListener {
|
|||||||
JsonNode jsonNode = objectMapper.readTree(content.toString());
|
JsonNode jsonNode = objectMapper.readTree(content.toString());
|
||||||
|
|
||||||
// Validate checksum if any:
|
// Validate checksum if any:
|
||||||
String paramChecksum = pluginsManifest.getChecksum();
|
String paramChecksum = pluginManifest.getChecksum();
|
||||||
if (!StringUtils.isEmpty(paramChecksum)) {
|
if (!StringUtils.isEmpty(paramChecksum)) {
|
||||||
String hash = DigestUtils.sha256Hex(content.toString());
|
String hash = DigestUtils.sha256Hex(content.toString());
|
||||||
if (!paramChecksum.equals(hash)) {
|
if (!paramChecksum.equals(hash)) {
|
||||||
log.info("Plugin's manifest.json checksum mismatch with that of the URL parameter for {}.",
|
log.info("Plugin's manifest.json checksum mismatch with that of the URL parameter for {}.",
|
||||||
pluginsManifest.getUrl()
|
pluginManifest.getUrl()
|
||||||
);
|
);
|
||||||
log.info("Plugin {} is not going to be loaded",
|
log.info("Plugin {} is not going to be loaded",
|
||||||
pluginsManifest.getUrl()
|
pluginManifest.getUrl()
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -458,7 +458,7 @@ public class MeetingService implements MessageListener {
|
|||||||
urlContents.put(pluginKey, manifestWrapper);
|
urlContents.put(pluginKey, manifestWrapper);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
log.error("Failed with the following plugin manifest URL: {}. Error: ",
|
log.error("Failed with the following plugin manifest URL: {}. Error: ",
|
||||||
pluginsManifest.getUrl(), e);
|
pluginManifest.getUrl(), e);
|
||||||
log.error("Therefore this plugin will not be loaded");
|
log.error("Therefore this plugin will not be loaded");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ public class ParamsProcessorUtil {
|
|||||||
private boolean defaultAllowModsToUnmuteUsers = false;
|
private boolean defaultAllowModsToUnmuteUsers = false;
|
||||||
private boolean defaultAllowModsToEjectCameras = false;
|
private boolean defaultAllowModsToEjectCameras = false;
|
||||||
private String defaultDisabledFeatures;
|
private String defaultDisabledFeatures;
|
||||||
private String defaultPluginsManifests;
|
private String defaultPluginManifests;
|
||||||
private boolean defaultNotifyRecordingIsOn = false;
|
private boolean defaultNotifyRecordingIsOn = false;
|
||||||
private boolean defaultKeepEvents = false;
|
private boolean defaultKeepEvents = false;
|
||||||
private Boolean useDefaultLogo;
|
private Boolean useDefaultLogo;
|
||||||
@ -428,31 +428,31 @@ public class ParamsProcessorUtil {
|
|||||||
return groups;
|
return groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<PluginsManifest> processPluginsManifests(String pluginsManifestsParam) {
|
private ArrayList<PluginManifest> processPluginManifests(String pluginManifestsParam) {
|
||||||
ArrayList<PluginsManifest> pluginsManifests = new ArrayList<PluginsManifest>();
|
ArrayList<PluginManifest> pluginManifests = new ArrayList<PluginManifest>();
|
||||||
JsonElement pluginsManifestsJsonElement = new Gson().fromJson(pluginsManifestsParam, JsonElement.class);
|
JsonElement pluginManifestsJsonElement = new Gson().fromJson(pluginManifestsParam, JsonElement.class);
|
||||||
try {
|
try {
|
||||||
if (pluginsManifestsJsonElement != null && pluginsManifestsJsonElement.isJsonArray()) {
|
if (pluginManifestsJsonElement != null && pluginManifestsJsonElement.isJsonArray()) {
|
||||||
JsonArray pluginsManifestsJson = pluginsManifestsJsonElement.getAsJsonArray();
|
JsonArray pluginManifestsJson = pluginManifestsJsonElement.getAsJsonArray();
|
||||||
for (JsonElement pluginsManifestJson : pluginsManifestsJson) {
|
for (JsonElement pluginManifestJson : pluginManifestsJson) {
|
||||||
if (pluginsManifestJson.isJsonObject()) {
|
if (pluginManifestJson.isJsonObject()) {
|
||||||
JsonObject pluginsManifestJsonObj = pluginsManifestJson.getAsJsonObject();
|
JsonObject pluginManifestJsonObj = pluginManifestJson.getAsJsonObject();
|
||||||
if (pluginsManifestJsonObj.has("url")) {
|
if (pluginManifestJsonObj.has("url")) {
|
||||||
String url = pluginsManifestJsonObj.get("url").getAsString();
|
String url = pluginManifestJsonObj.get("url").getAsString();
|
||||||
PluginsManifest newPlugin = new PluginsManifest(url);
|
PluginManifest newPlugin = new PluginManifest(url);
|
||||||
if (pluginsManifestJsonObj.has("checksum")) {
|
if (pluginManifestJsonObj.has("checksum")) {
|
||||||
newPlugin.setChecksum(pluginsManifestJsonObj.get("checksum").getAsString());
|
newPlugin.setChecksum(pluginManifestJsonObj.get("checksum").getAsString());
|
||||||
}
|
}
|
||||||
pluginsManifests.add(newPlugin);
|
pluginManifests.add(newPlugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(JsonSyntaxException err){
|
} catch(JsonSyntaxException err){
|
||||||
log.error("Error in pluginsManifests URL parameter's json structure.");
|
log.error("Error in pluginManifests URL parameter's json structure.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return pluginsManifests;
|
return pluginManifests;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Meeting processCreateParams(Map<String, String> params) {
|
public Meeting processCreateParams(Map<String, String> params) {
|
||||||
@ -574,17 +574,17 @@ public class ParamsProcessorUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse Plugins Manifests from config and param
|
// Parse Plugins Manifests from config and param
|
||||||
ArrayList<PluginsManifest> listOfPluginsManifests = new ArrayList<PluginsManifest>();
|
ArrayList<PluginManifest> listOfPluginManifests = new ArrayList<PluginManifest>();
|
||||||
//Process plugins from config
|
//Process plugins from config
|
||||||
if(defaultPluginsManifests != null && !defaultPluginsManifests.isEmpty()) {
|
if(defaultPluginManifests != null && !defaultPluginManifests.isEmpty()) {
|
||||||
ArrayList<PluginsManifest> pluginsManifestsFromConfig = processPluginsManifests(defaultPluginsManifests);
|
ArrayList<PluginManifest> pluginManifestsFromConfig = processPluginManifests(defaultPluginManifests);
|
||||||
listOfPluginsManifests.addAll(pluginsManifestsFromConfig);
|
listOfPluginManifests.addAll(pluginManifestsFromConfig);
|
||||||
}
|
}
|
||||||
//Process plugins from /create param
|
//Process plugins from /create param
|
||||||
String pluginsManifestsParam = params.get(ApiParams.PLUGINS_MANIFESTS);
|
String pluginManifestsParam = params.get(ApiParams.PLUGIN_MANIFESTS);
|
||||||
if (!StringUtils.isEmpty(pluginsManifestsParam)) {
|
if (!StringUtils.isEmpty(pluginManifestsParam)) {
|
||||||
ArrayList<PluginsManifest> pluginsManifestsFromParam = processPluginsManifests(pluginsManifestsParam);
|
ArrayList<PluginManifest> pluginManifestsFromParam = processPluginManifests(pluginManifestsParam);
|
||||||
listOfPluginsManifests.addAll(pluginsManifestsFromParam);
|
listOfPluginManifests.addAll(pluginManifestsFromParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if VirtualBackgrounds is disabled
|
// Check if VirtualBackgrounds is disabled
|
||||||
@ -827,7 +827,7 @@ public class ParamsProcessorUtil {
|
|||||||
.withLearningDashboardCleanupDelayInMinutes(learningDashboardCleanupMins)
|
.withLearningDashboardCleanupDelayInMinutes(learningDashboardCleanupMins)
|
||||||
.withLearningDashboardAccessToken(learningDashboardAccessToken)
|
.withLearningDashboardAccessToken(learningDashboardAccessToken)
|
||||||
.withGroups(groups)
|
.withGroups(groups)
|
||||||
.withPluginManifests(listOfPluginsManifests)
|
.withPluginManifests(listOfPluginManifests)
|
||||||
.withDisabledFeatures(listOfDisabledFeatures)
|
.withDisabledFeatures(listOfDisabledFeatures)
|
||||||
.withNotifyRecordingIsOn(notifyRecordingIsOn)
|
.withNotifyRecordingIsOn(notifyRecordingIsOn)
|
||||||
.withPresentationUploadExternalDescription(presentationUploadExternalDescription)
|
.withPresentationUploadExternalDescription(presentationUploadExternalDescription)
|
||||||
@ -1620,8 +1620,8 @@ public class ParamsProcessorUtil {
|
|||||||
this.defaultDisabledFeatures = disabledFeatures;
|
this.defaultDisabledFeatures = disabledFeatures;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPluginsManifests(String pluginsManifests) {
|
public void setPluginManifests(String pluginManifests) {
|
||||||
this.defaultPluginsManifests = pluginsManifests;
|
this.defaultPluginManifests = pluginManifests;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNotifyRecordingIsOn(Boolean notifyRecordingIsOn) {
|
public void setNotifyRecordingIsOn(Boolean notifyRecordingIsOn) {
|
||||||
|
@ -79,7 +79,7 @@ public class Meeting {
|
|||||||
private String defaultAvatarURL;
|
private String defaultAvatarURL;
|
||||||
private String defaultWebcamBackgroundURL;
|
private String defaultWebcamBackgroundURL;
|
||||||
private Map<String, Object> plugins;
|
private Map<String, Object> plugins;
|
||||||
private ArrayList<PluginsManifest> pluginsManifests;
|
private ArrayList<PluginManifest> pluginManifests;
|
||||||
private String guestPolicy = GuestPolicy.ASK_MODERATOR;
|
private String guestPolicy = GuestPolicy.ASK_MODERATOR;
|
||||||
private String guestLobbyMessage = "";
|
private String guestLobbyMessage = "";
|
||||||
private Map<String,String> usersWithGuestLobbyMessages;
|
private Map<String,String> usersWithGuestLobbyMessages;
|
||||||
@ -130,7 +130,7 @@ public class Meeting {
|
|||||||
extMeetingId = builder.externalId;
|
extMeetingId = builder.externalId;
|
||||||
intMeetingId = builder.internalId;
|
intMeetingId = builder.internalId;
|
||||||
disabledFeatures = builder.disabledFeatures;
|
disabledFeatures = builder.disabledFeatures;
|
||||||
pluginsManifests = builder.pluginsManifests;
|
pluginManifests = builder.pluginManifests;
|
||||||
notifyRecordingIsOn = builder.notifyRecordingIsOn;
|
notifyRecordingIsOn = builder.notifyRecordingIsOn;
|
||||||
presentationUploadExternalDescription = builder.presentationUploadExternalDescription;
|
presentationUploadExternalDescription = builder.presentationUploadExternalDescription;
|
||||||
presentationUploadExternalUrl = builder.presentationUploadExternalUrl;
|
presentationUploadExternalUrl = builder.presentationUploadExternalUrl;
|
||||||
@ -452,8 +452,8 @@ public class Meeting {
|
|||||||
plugins = p;
|
plugins = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<PluginsManifest> getPluginsManifests() {
|
public ArrayList<PluginManifest> getPluginManifests() {
|
||||||
return pluginsManifests;
|
return pluginManifests;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getNotifyRecordingIsOn() {
|
public Boolean getNotifyRecordingIsOn() {
|
||||||
@ -943,7 +943,7 @@ public class Meeting {
|
|||||||
private int learningDashboardCleanupDelayInMinutes;
|
private int learningDashboardCleanupDelayInMinutes;
|
||||||
private String learningDashboardAccessToken;
|
private String learningDashboardAccessToken;
|
||||||
private ArrayList<String> disabledFeatures;
|
private ArrayList<String> disabledFeatures;
|
||||||
private ArrayList<PluginsManifest> pluginsManifests;
|
private ArrayList<PluginManifest> pluginManifests;
|
||||||
private Boolean notifyRecordingIsOn;
|
private Boolean notifyRecordingIsOn;
|
||||||
private String presentationUploadExternalDescription;
|
private String presentationUploadExternalDescription;
|
||||||
private String presentationUploadExternalUrl;
|
private String presentationUploadExternalUrl;
|
||||||
@ -1078,8 +1078,8 @@ public class Meeting {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder withPluginManifests(ArrayList<PluginsManifest> map) {
|
public Builder withPluginManifests(ArrayList<PluginManifest> map) {
|
||||||
this.pluginsManifests = map;
|
this.pluginManifests = map;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,18 +1,16 @@
|
|||||||
package org.bigbluebutton.api.domain;
|
package org.bigbluebutton.api.domain;
|
||||||
|
|
||||||
import java.util.Vector;
|
public class PluginManifest {
|
||||||
|
|
||||||
public class PluginsManifest {
|
|
||||||
|
|
||||||
private String url = "";
|
private String url = "";
|
||||||
private String checksum = "";
|
private String checksum = "";
|
||||||
public PluginsManifest(
|
public PluginManifest(
|
||||||
String url,
|
String url,
|
||||||
String checksum) {
|
String checksum) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.checksum = checksum;
|
this.checksum = checksum;
|
||||||
}
|
}
|
||||||
public PluginsManifest(
|
public PluginManifest(
|
||||||
String url) {
|
String url) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
}
|
}
|
@ -480,4 +480,4 @@ allowDuplicateExtUserid=true
|
|||||||
|
|
||||||
# list of plugins manifests (json array)
|
# list of plugins manifests (json array)
|
||||||
# e.g: [{url: "https://plugin_manifest.json"}]
|
# e.g: [{url: "https://plugin_manifest.json"}]
|
||||||
pluginsManifests=
|
pluginManifests=
|
||||||
|
@ -201,7 +201,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
|||||||
<property name="defaultKeepEvents" value="${defaultKeepEvents}"/>
|
<property name="defaultKeepEvents" value="${defaultKeepEvents}"/>
|
||||||
<property name="allowRevealOfBBBVersion" value="${allowRevealOfBBBVersion}"/>
|
<property name="allowRevealOfBBBVersion" value="${allowRevealOfBBBVersion}"/>
|
||||||
<property name="allowOverrideClientSettingsOnCreateCall" value="${allowOverrideClientSettingsOnCreateCall}"/>
|
<property name="allowOverrideClientSettingsOnCreateCall" value="${allowOverrideClientSettingsOnCreateCall}"/>
|
||||||
<property name="pluginsManifests" value="${pluginsManifests}"/>
|
<property name="pluginManifests" value="${pluginManifests}"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="presentationService" class="org.bigbluebutton.web.services.PresentationService">
|
<bean id="presentationService" class="org.bigbluebutton.web.services.PresentationService">
|
||||||
|
Loading…
Reference in New Issue
Block a user