### Install Uploaded Plugin Bundle (JavaScript) Source: https://github.com/opensourcebim/bimserver/blob/master/BimServer/www/setup.html This function handles the installation of a plugin uploaded by the user. It reads the plugin file as a data URL, extracts the base64 encoded content, and sends it to the BIMserver API for installation. It supports installing plugins for all users and recursively calls itself for multiple uploaded plugins. ```javascript this.installUploadedPlugin = function(toInstall, callback){ var reader = new FileReader(); var next = toInstall[0]; reader.addEventListener("load", function () { var base64 = reader.result.substring(reader.result.indexOf(",") + 1); Global.api.call("PluginInterface", "installPluginBundleFromFile", { data: base64, installAllPluginsForAllUsers: true, installAllPluginsForNewUsers: true }, function(){ o.logSuccess("Uploading plugin " + next.get(0).files[0].name + " installed OK"); toInstall.splice(0, 1); if (toInstall.length == 0) { o.decLevel(); callback(); } else { o.installUploadedPlugin(toInstall, callback); } }, function(message){ o.logError(message); callback(); }); }, false); var files = next.each(function(index, fileInput){ var file = fileInput.files[0]; if (file) { o.logInfo("Installing uploaded plugin " + file.name); reader.readAsDataURL(file); } else { console.log("No file"); } }); }; ``` -------------------------------- ### BIMserver Plugin Installation: Install Plugin Bundle Source: https://github.com/opensourcebim/bimserver/blob/master/BimServer/www/setup.html This function installs a plugin bundle for BIMserver. It checks if the plugin is already installed at the latest version. If not, it fetches plugin information, sets installation flags, and then calls 'PluginInterface' to install the bundle. It recursively calls itself to install remaining plugins in the bundle. ```javascript this.installPluginBundle = function(requiredPlugins, callback) { var next = Object.keys(requiredPlugins)[0]; o.logInfo("Installing " + next + "..."); Global.api.call("PluginInterface", "getPluginBundle", requiredPlugins[next], function(pluginBundle){ var latestVersion = pluginBundle.latestVersion; if (latestVersion == pluginBundle.installedVersion) { o.logError("Plugin version already installed" + "\n"); delete requiredPlugins[next]; if (Object.keys(requiredPlugins).length == 0) { callback(); return; } else { o.installPluginBundle(requiredPlugins, callback); } return; } Global.api.call("PluginInterface", "getPluginInformation", { repository: latestVersion.repository, groupId: latestVersion.groupId, artifactId: latestVersion.artifactId, version: latestVersion.version }, function(plugins){ plugins.forEach(function(plugin){ plugin.enabled = true; plugin.installForAllUsers = true; plugin.installForNewUsers = true; }); Global.api.call("PluginInterface", "installPluginBundle", { repository: latestVersion.repository, groupId: latestVersion.groupId, artifactId: latestVersion.artifactId, version: latestVersion.version, plugins: plugins }, function(){ delete requiredPlugins[latestVersion.artifactId]; o.pluginsInstalled[latestVersion.artifactId] = true; o.logSuccess("Successfully installed " + pluginBundle.name + " (" + latestVersion.groupId + ":" + latestVersion.artifactId + ":" + latestVersion.version + ")\n"); if (Object.keys(requiredPlugins).length == 0) { callback(); return; } else { o.installPluginBundle(requiredPlugins, callback); } }, function(message){ o.logError(message + "\n"); o.abort(); }); }, function(message){ o.logError(message + "\n"); o.abort(); }); }, function(message){ o.logError(message + "\n"); delete requiredPlugins[next]; if (Object.keys(requiredPlugins).length == 0) { callback(); return; } else { o.installPluginBundle(requiredPlugins, callback); } }); } ``` -------------------------------- ### Start, Stop, and Clean Up Tomcat Source: https://github.com/opensourcebim/bimserver/wiki/Install-on-Ubuntu-15 Commands to manage the Tomcat service, including starting it under the dedicated tomcat user, stopping it, and removing default web applications to clean up the installation. Proper user execution and service management are demonstrated. ```bash user@local:~$ sudo -u tomcat /opt/tomcat9/bin/startup.sh # start tomcat under dedicated user user@local:~$ sudo /opt/tomcat9/bin/shutdown.sh # stop tomcat ``` ```bash user@local:/opt/tomcat9/webapps$ rm -r ROOT manager host-manager docs examples ``` -------------------------------- ### Install All Checked Uploaded Plugins (JavaScript) Source: https://github.com/opensourcebim/bimserver/blob/master/BimServer/www/setup.html This function identifies and installs all plugins that have been uploaded and checked by the user. It finds the relevant input elements, collects the files to be installed, and then invokes the `installUploadedPlugin` function to process them. If no plugins are selected, it calls the callback immediately. ```javascript this.installUploadedPlugins = function(callback){ var checkboxes = cd.find(".plugins .uploaded input[type=\"checkbox\"]:checked"); if (checkboxes.size() == 0) { callback(); return; } var toInstall = []; checkboxes.each(function(index, checkbox){ var div = $(checkbox).parent().parent(); var input = div.find(".fileInput"); if (input.size() > 0) { if (input.get(0).files.length == 1) { toInstall.push(input); } } }); o.incLevel(); o.installUploadedPlugin(toInstall, callback); }; ``` -------------------------------- ### Install Plugins from Maven Repository (JavaScript) Source: https://github.com/opensourcebim/bimserver/blob/master/BimServer/www/setup.html This function installs plugins specified in checkboxes, fetching them from the Maven central repository. It constructs plugin metadata including repository, groupId, and artifactId, and then calls a helper function to perform the installation. Requires an internet connection. ```javascript this.installPlugins = function(callback){ if (o.hasInternet) { o.logInfo("Installing plugins..."); var pluginsToInstall = { }; cd.find(".plugins .maven input[type=\"checkbox\"]:checked").each(function(index, checkbox){ var artifactId = $(checkbox).attr("class"); pluginsToInstall[artifactId] = { repository: "https://repo1.maven.org/maven2", groupId: "org.opensourcebim", artifactId: artifactId }; }); o.incLevel(); installRequiredPlugins(pluginsToInstall, function(){ console.log("All remote plugins successfully installed"); o.decLevel(); callback(); }); } else { o.logInfo("Not installing plugins because there is no internet connection"); callback(); } }; ``` -------------------------------- ### BIMserver Extended Data Schemas: Install All Source: https://github.com/opensourcebim/bimserver/blob/master/BimServer/www/setup.html This function installs all extended data schemas available on BIMserver, provided an internet connection is available. It logs the action and calls 'ServiceInterface' to retrieve all repository extended data schemas, preparing for their installation. ```javascript this.installExtendedDataSchemas = function(callback){ if (o.hasInternet) { o.logInfo("Installing all extended data schemas..."); o.incLevel(); Global.api.call("ServiceInterface", "getAllRepositoryExtendedDataSchemas", {usePre: true}, function(data){ var requests = ``` -------------------------------- ### JavaScript Setup Wizard Functionality Source: https://github.com/opensourcebim/bimserver/blob/master/BimServer/www/setup.html This JavaScript function, `Setup`, handles the user interface logic for the BIMserver setup wizard. It manages navigation between different setup stages (Welcome, Admin, Email, Plugins, Extended Data Schemas, Finish), handles file uploads for plugins, and logs information during the setup process. It interacts with DOM elements to display or hide sections and update input fields. Dependencies include jQuery (aliased as '$') and a global `Global.api` object for making API calls. ```javascript function Setup(cd, address) { var o = this; o.level = 0; o.pluginsInstalled = {}; if (address.endsWith(":80")) { address = address.substring(0, address.length - 3); } $(".setup .siteAddressInput").val(address); $(".emailCheckBox").change(function(){ $(".emailDiv").toggle($(this).is(":checked")); }); o.stage = 0; this.showWelcome = function(){ cd.find(".nav-pills .active").removeClass("active"); cd.find(".welcomeBtn").parent().addClass("active"); cd.find(".contentdiv").hide(); cd.find(".welcome").show(); }; this.showAdmin = function(){ cd.find(".nav-pills .active").removeClass("active"); cd.find(".adminBtn").parent().addClass("active"); cd.find(".contentdiv").hide(); cd.find(".admin").show(); }; this.showEmail = function(){ cd.find(".nav-pills .active").removeClass("active"); cd.find(".emailBtn").parent().addClass("active"); cd.find(".contentdiv").hide(); cd.find(".email").show(); }; this.showPlugins = function(){ cd.find(".nav-pills .active").removeClass("active"); cd.find(".pluginsBtn").parent().addClass("active"); cd.find(".contentdiv").hide(); cd.find(".plugins").show(); }; this.showExtendedDataSchemas = function(){ cd.find(".nav-pills .active").removeClass("active"); cd.find(".extendedDataSchemasBtn").parent().addClass("active"); cd.find(".contentdiv").hide(); cd.find(".extendeddataschemas").show(); }; this.showFinish = function(){ cd.find(".nav-pills .active").removeClass("active"); cd.find(".finishBtn").parent().addClass("active"); cd.find(".contentdiv").hide(); cd.find(".finish").show(); }; this.fileChange = function(e){ var plugin = $("