### 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 = $("
"); plugin.addClass("media"); plugin.addClass("list-group-item"); plugin.addClass("uploaded"); var middle = $("
"); var checkbox = $(""); middle.append(checkbox); var mediaBody = $("
"); plugin.append(middle); plugin.append(mediaBody); mediaBody.append("

" + e.currentTarget.files[0].name + "

"); cd.find(".uploadPlugins").after(plugin); var file = $(e.currentTarget); file.hide(); file.detach().appendTo(plugin); var file = $(""); cd.find(".uploadPlugins").append(file); file.change(o.fileChange); }; this.showUploadPlugins = function(){ var uploadDiv = cd.find(".uploadPlugins"); uploadDiv.show(); if (uploadDiv.find(".fileInput").length == 0){ var file = $(""); file.change(o.fileChange); cd.find(".uploadPlugins").append(file); } }; cd.find(".welcomeBtn").click(o.showWelcome); cd.find(".adminBtn").click(o.showAdmin); cd.find(".emailBtn").click(o.showEmail); cd.find(".pluginsBtn").click(o.showPlugins); cd.find(".extendedDataSchemasBtn").click(o.showExtendedDataSchemas); cd.find(".finishBtn").click(o.showFinish); cd.find(".welcome").show(); cd.find(".btnUploadPlugins").click(o.showUploadPlugins); this.incLevel = function(){ o.level++; }; this.decLevel = function(){ o.level--; }; this.logError = function(message){ for (var i=0; i" + message + "\n"); }; this.logInfo = function(message){ for (var i=0; i" + message + "\n"); }; this.logSuccess = function(message){ if (message == null) { message = ""; } var msg = $(""); for (var i=0; i org.bimserver.plugins.serializers.SerializerPlugin test.TestSerializerPlugin true ``` -------------------------------- ### BIMserver Plugin Installation: Install Required Plugins Source: https://github.com/opensourcebim/bimserver/blob/master/BimServer/www/setup.html This function orchestrates the installation of required plugins for BIMserver. It first sets strict version checking to true. Then, it checks for pre-built plugins and installs them if available. Otherwise, it checks for already installed plugin bundles and then proceeds to install any remaining required plugins using 'installPluginBundle'. ```javascript function installRequiredPlugins(requiredPlugins, callback) { var scratchmap = {}; Object.keys(requiredPlugins).forEach(function(key, index) { scratchmap[key] = requiredPlugins[key]; }); Global.api.call("SettingsInterface", "setPluginStrictVersionChecking", {strict: true}, function(){ Global.api.call("PluginInterface", "hasPreBuiltPlugins", {}, function(prebuilt){ if (prebuilt) { var artifacts = []; for (var key in requiredPlugins) { artifacts.push(requiredPlugins[key].artifactId); } console.log("Prebuilt artifacts", artifacts); Global.api.call("PluginInterface", "installPreBuiltPlugins", { artifacts: artifacts }, function(){ callback(); }); } else { Global.api.call("PluginInterface", "getInstalledPluginBundles", {}, function(bundles){ bundles.forEach(function(bundle){ var installedVersion = bundle.installedVersion; if (scratchmap[installedVersion.artifactId] != null) { o.logInfo("Already installed " + installedVersion.artifactId); delete scratchmap[installedVersion.artifactId]; } }); if (Object.keys(scratchmap).length > 0) { o.installPluginBundle(scratchmap, callback); } else { callback(); } }, function(message){ o.logError(message); o.abort(); }); } }); }, function(message){ o.logError(message); o.abort(); }); } ``` -------------------------------- ### BIMserver API Initialization and Server State Handling (JavaScript) Source: https://github.com/opensourcebim/bimserver/blob/master/BimServer/www/index.html This JavaScript code initializes the BIMserver API connection and dynamically loads either the setup or status interface based on the server's state. It retrieves the server's address, makes an API call to get server information, and then uses jQuery's load function to inject the appropriate HTML. Dependencies include jQuery. ```javascript var Global = {}; function getApiAddress() { var fullpath = document.location.origin + document.location.pathname; if (fullpath.substring(fullpath.length - 1) == "/") { fullpath = fullpath.substring(0, fullpath.length - 1); } return fullpath; } var apiAddress = getApiAddress(); Global.api = new BasicApi(apiAddress); Global.api.call("AdminInterface", "getServerInfo", {}, function(serverInfo){ var state = serverInfo.serverState; if (state == "NOT_SETUP") { $(".indexcontainer").load("setup.html", function(){ new Setup($(this), apiAddress); }); } else { $(".indexcontainer").load("status.html", function(){ new Status($(this), serverInfo); }); } }); ``` -------------------------------- ### Initialize Tooltip and Setup Button Click Handler (jQuery/JavaScript) Source: https://github.com/opensourcebim/bimserver/blob/master/BimServer/www/setup.html Initializes tooltips for elements with the `rel="tooltip"` attribute using the Bootstrap tooltip plugin. It also attaches a click event handler to a setup button, triggering the `o.setup` function when clicked, likely to initiate the server setup process. ```javascript $("[rel=tooltip]").tooltip(); $(".setup .setupButton").click(o.setup); ``` -------------------------------- ### Java QueryEnginePlugin Interface for BIMserver Source: https://github.com/opensourcebim/bimserver/wiki/Query-Engine-Plugin Defines the interface for plugins that provide QueryEngine implementations to BIMserver. It includes methods to get a QueryEngine instance, retrieve available example keys, and fetch specific code examples. ```java public interface QueryEnginePlugin extends Plugin { /** * @return A usable QueryEngine implementation */ QueryEngine getQueryEngine(PluginConfiguration pluginConfiguration); /** * @return Return a list of keys (usually file names) corresponding to code examples for this plugin */ Collection getExampleKeys(); /** * @param key * @return Return the code example for the given key */ String getExample(String key); } ``` -------------------------------- ### Configure Automatic Tomcat Startup with systemd Source: https://github.com/opensourcebim/bimserver/wiki/Install-on-Ubuntu-15 Instructions for setting up Tomcat to start automatically on system boot using a systemd service file. This includes creating the service configuration file, reloading the daemon, enabling the service, and checking its status. The provided service file configures Tomcat to run as the tomcat user with specific memory settings. ```bash user@local:~$ vim /etc/systemd/system/tomcat.service # create and edit the service configuration user@local:~$ systemctl daemon-reload # reload the service configuration user@local:~$ systemctl enable tomcat # enable automatic startup user@local:~$ systemctl start tomcat # manually start the service user@local:~$ systemctl status tomcat # check the status of the service ``` ```declarative [Unit] Description=Tomcat After=network.target [Service] Type=forking User=tomcat Group=tomcat ExecStart=/opt/tomcat9/bin/startup.sh ExecStop=/opt/tomcat9/bin/shutdown.sh Environment="CATALINA_OPTS=-Xmx8G" Restart=always RestartSec=30 [Install] WantedBy=multi-user.target ``` -------------------------------- ### Install Extended Data Schemas (JavaScript) Source: https://github.com/opensourcebim/bimserver/blob/master/BimServer/www/setup.html This function iterates through provided extended data schemas and adds them using the BIMserver API. It handles API calls and logs success messages upon completion. It requires an active internet connection. ```javascript this.installExtendedDataSchemas = function(callback){ if (o.hasInternet) { o.logInfo("Installing extended data schemas..."); var requests = []; data.forEach(function(extendedDataSchema){ var request = { interface: "ServiceInterface", method: "addExtendedDataSchema", parameters: {extendedDataSchema: extendedDataSchema} }; requests.push(request); }); Global.api.multiCall(requests, function(){ data.forEach(function(extendedDataSchema){ o.logSuccess(extendedDataSchema.name + " installed OK"); }); o.logSuccess("Extended Data Schemas installed OK"); o.decLevel(); callback(); }); } else { o.logInfo("Not installing extended data schemas because there is no internet connection"); callback(); } }; ``` -------------------------------- ### Update and Install Packages on Ubuntu Source: https://github.com/opensourcebim/bimserver/wiki/Install-on-Ubuntu-15 Updates the package list, upgrades installed packages, and installs necessary software like wget, unzip, and the default Java Runtime Environment (JRE). These commands are essential for preparing the Ubuntu system for further installations. ```bash user@local:~$ apt update # update package list user@local:~$ apt upgrade # update installed packages to latest version user@local:~$ apt install wget unzip default-jre # install necessary packages ``` -------------------------------- ### Update and Install Packages (Ubuntu) Source: https://github.com/opensourcebim/bimserver/wiki/Install-on-Ubuntu Updates the package index, upgrades installed packages, and installs the Java Runtime Environment (JRE) 7, wget, unzip, nano, and ntpdate. These are essential for setting up the server environment. ```bash apt-get update apt-get upgrade apt-get install openjdk-7-jre-headless wget unzip nano ntpdate ``` -------------------------------- ### REST API: Download Model via HTTP GET (Bash) Source: https://context7.com/opensourcebim/bimserver/llms.txt Shows how to download a specific BIMserver model revision directly using an HTTP GET request. It provides an example of using a `longActionId` for direct download and an alternative method involving a POST request to initiate the download via the JSON API. ```bash # Download IFC file curl -X GET "http://localhost:8080/download?longActionId=TOPIC_ID" \ -H "Authorization: Bearer TOKEN_STRING" \ -o output.ifc # Or initiate download first via JSON API curl -X POST http://localhost:8080/jsonapi \ -H "Content-Type: application/json" \ -H "Authorization: Bearer TOKEN_STRING" \ -d '{ "request": { "interface": "ServiceInterface", "method": "download", "parameters": { "roids": [655360], "query": "{\"type\":\"IfcProduct\"}", "serializerOid": 262144, "sync": false } } }' # Then poll for completion and download using returned topic ID ``` -------------------------------- ### Install Certbot and Generate SSL Certificate (Shell) Source: https://github.com/opensourcebim/bimserver/wiki/SSL-setup These commands install Certbot using snap, generate an SSL certificate for a given domain (e.g., opensourcebim.org) using the standalone authenticator, and adjust file permissions for the private key to be readable by the tomcat group. It's recommended to check if snap is installed first. ```shell user@local:~$ man snap # check if snap is installed user@local:~$ snap install --classic certbot # install certbot user@local:~$ certbot certonly --standalone # generate SSL certificate (interactively enter required information) user@local:~$ systemctl list-timers # check automatic renewal user@local:~$ chgrp tomcat /etc/letsencrypt/live/opensourcebim.org/privkey.pem # own private key by group tomcat user@local:~$ chmod g+r /etc/letsencrypt/live/opensourcebim.org/privkey.pem # allow group to read private key user@local:~$ chmod +rx /etc/letsencrypt/live /etc/letsencrypt/archive # allow anyone to read key folders (may already be set) ``` -------------------------------- ### Install and Configure Tomcat 9 Source: https://github.com/opensourcebim/bimserver/wiki/Install-on-Ubuntu-15 This set of commands outlines the process of downloading, unzipping, organizing, and setting permissions for Tomcat 9. It includes downloading the Tomcat zip file, moving it, extracting it, renaming the folder, making scripts executable, and assigning ownership to the tomcat user. ```bash user@local:~$ wget [link of tomcat.zip] # Download tomcat (Make sure you replace this with the latest release!) user@local:~$ mv apache-tomcat-9.0.93.zip /opt/ # move to opt folder (folder for additional software installations) user@local:/opt$ unzip apache-tomcat-9.0.93.zip # unzip Tomcat user@local:/opt$ rm apache-tomcat-9.0.93.zip # remove zip, keep exploded folder user@local:/opt$ mv apache-tomcat-9.0.93 tomcat9 # rename folder user@local:/opt$ chmod u+x tomcat9/bin/*.sh # make scripts executable user@local:/opt$ chown -R tomcat:tomcat tomcat9 # assign ownership to tomcat user and group ``` -------------------------------- ### Create and Start BIMserver Instance in Java Source: https://github.com/opensourcebim/bimserver/wiki/Embedding Demonstrates the creation of a BIMserver instance using a pre-configured BimServerConfig object, followed by starting the server. This is a fundamental step for embedding BIMserver. ```java BimServer bimServer = new BimServer(config); bimServer.start(); ``` -------------------------------- ### Java Example: Connect and Create Project with BIMserver Client Source: https://github.com/opensourcebim/bimserver/wiki/BimServerClient This Java code demonstrates how to connect to a local BIMserver instance using the JSON API, authenticate with provided credentials, and create a new project. It handles potential exceptions during the process. ```java package org.opensourcebim; import org.bimserver.client.BimServerClient; import org.bimserver.client.json.JsonBimServerClientFactory; import org.bimserver.interfaces.objects.SProject; import org.bimserver.shared.ChannelConnectionException; import org.bimserver.shared.UsernamePasswordAuthenticationInfo; import org.bimserver.shared.exceptions.BimServerClientException; import org.bimserver.shared.exceptions.PublicInterfaceNotFoundException; import org.bimserver.shared.exceptions.ServiceException; public class ClientDemo { public static void main(String[] args) { try { JsonBimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080"); BimServerClient client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin")); SProject newProject = client.getServiceInterface().addProject("Test Project", "ifc2x3tc1"); System.out.println(newProject.getOid()); } catch (BimServerClientException e) { e.printStackTrace(); } catch (ServiceException e) { e.printStackTrace(); } catch (ChannelConnectionException e) { e.printStackTrace(); } } } ``` -------------------------------- ### Download and Deploy BIMserver WAR File Source: https://github.com/opensourcebim/bimserver/wiki/Install-on-Ubuntu This bash snippet details the commands to download the BIMserver WAR file and place it in the web application directory for Tomcat to automatically deploy. The `wget` command fetches the specified version of the WAR file, and `-O ROOT.war` renames it appropriately for Tomcat's context. This is a fundamental step in installing BIMserver. ```bash cd /var/www/[YOUR DOMAIN] wget [location of war file](https://github.com/opensourceBIM/BIMserver/releases/download/v1.5.185/bimserverwar-1.5.185.war) -O ROOT.war ``` -------------------------------- ### Install Tomcat7 Application Server (Ubuntu) Source: https://github.com/opensourcebim/bimserver/wiki/Install-on-Ubuntu Downloads, extracts, and configures Tomcat7, a web server and servlet container, for running the BIMserver application. It includes setting execute permissions and creating a policy directory. ```bash cd /opt wget [location of tomcat] -O tomcat7.zip unzip [filename] rm [filename] mv [extracted directory] tomcat7 chmod +x /opt/tomcat7/bin/*.sh mkdir /opt/tomcat7/conf/policy.d chown -R tomcat7 /opt/tomcat7 ``` -------------------------------- ### BIMserver Setup Stage 2: Email Configuration Source: https://github.com/opensourcebim/bimserver/blob/master/BimServer/www/setup.html This snippet handles the second stage of BIMserver setup, focusing on configuring email settings. It logs information, calls the 'AuthInterface' for login, and then calls 'SettingsInterface' to set SMTP server details and sender information. It includes error handling and progresses to the next stage upon success. ```javascript this.stage2 = function(){ o.incLevel(); o.logInfo("Setting up email..."); Global.api.call("AuthInterface", "login", {username: $(".setup .adminUsernameInput").val(), password: $(".setup .adminPasswordInput").val()}, function(data){ Global.api.call("SettingsInterface", "getServerSettings", {}, function(serverSettings){ serverSettings.smtpServer = $(".setup .smtpServer").val(); serverSettings.smtpProtocol = $(".setup .smtpProtocol").val(); serverSettings.smtpPort = $(".setup .smtpPort").val(); serverSettings.smtpUsername = $(".setup .smtpUsername").val(); serverSettings.smtpPassword = $(".setup .smtpPassword").val(); serverSettings.emailSenderAddress = $(".setup .emailSenderAddress").val(); serverSettings.emailSenderName = $(".setup .emailSenderName").val(); Global.api.call("SettingsInterface", "setServerSettings", {serverSettings: serverSettings}, function(data){ o.logSuccess("Email successfully setup"); o.decLevel(); o.stage3(); }); }, function(message){ o.logError(message); o.decLevel(); o.abort(); }); }, function(message){ o.logError(message); o.decLevel(); o.abort(); }); }; ``` -------------------------------- ### Create Directories and User for BIMserver (Ubuntu) Source: https://github.com/opensourcebim/bimserver/wiki/Install-on-Ubuntu Creates necessary directories for BIMserver deployment and a dedicated user 'tomcat7' for running the application. It also sets appropriate ownership for these directories. ```bash mkdir /var/www mkdir /var/www/[YOUR DOMAIN] useradd -s /sbin/nologin tomcat7 chown -R tomcat7 /var/www/[YOUR DOMAIN] mkdir /var/bimserver chown -R tomcat7 /var/bimserver ``` -------------------------------- ### Deploy BIMserver WAR file to Tomcat Source: https://github.com/opensourcebim/bimserver/wiki/Install-on-Ubuntu-15 Moves the BIMserver WAR file to the Tomcat webapps directory for deployment. Assumes the WAR file is named 'bimserverwar-1.5.185.war' and Tomcat is installed in '/opt/tomcat9'. ```bash user@local:~$ mv bimserverwar-1.5.185.war /opt/tomcat9/webapps/bimserver.war ``` -------------------------------- ### Download BIMserver WAR File Source: https://github.com/opensourcebim/bimserver/wiki/Install-on-Ubuntu-15 This command demonstrates how to download the BIMserver WAR file, which is the deployment package for the BIMserver application. This WAR file will then be deployed into the Tomcat webapps directory. ```bash user@local:~$ wget [link of BIMserver.war] # Download BIMserver ``` -------------------------------- ### Specify Plugin Directories in Eclipse Run Configuration Source: https://github.com/opensourcebim/bimserver/wiki/Eclipse This configuration example shows how to add custom plugin directories to the BIMserver's run configuration in Eclipse. This allows developers to easily integrate and test their own plugins without modifying source code. Multiple plugin paths can be specified. ```text -plugins "C:\Users\My Name\Plugin 1" -plugins "/home/myname/plugin2" ``` -------------------------------- ### BIMserver Setup Stage 2: Skip Email Configuration Source: https://github.com/opensourcebim/bimserver/blob/master/BimServer/www/setup.html This snippet represents the option to skip email setup during the BIMserver configuration process. It logs the skipping action, performs an authentication login using provided credentials, and then proceeds directly to the next stage. ```javascript this.nostage2 = function(){ o.logInfo("Skipping email setup..."); Global.api.call("AuthInterface", "login", {username: $(".setup .adminUsernameInput").val(), password: $(".setup .adminPasswordInput").val()}, function(data){ o.stage3(); }, function(message){ o.logError(message); o.abort(); }); }; ``` -------------------------------- ### Configure Tomcat 7 Startup Script Environment Variables Source: https://github.com/opensourcebim/bimserver/wiki/Install-on-Ubuntu This bash snippet outlines the necessary environment variable modifications within a Tomcat 7 init.d startup script. Key variables like CATALINA_HOME, CATALINA_BASE, TOMCAT7_SECURITY, and JAVA_HOME need to be set correctly for Tomcat to start and operate properly. The JAVA_HOME variable should point to a valid Java Runtime Environment directory. ```bash CATALINA_HOME=/opt/$NAME CATALINA_BASE=/opt/$NAME TOMCAT7_SECURITY=no // You can change this to yes later on JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre // Change this to a JRE directory of your choosing, run 'update-alternatives --list java' to see the available ones. Make sure you point to a JRE directory, for example: /usr/lib/jvm/java-7-openjdk-amd64/jre ``` -------------------------------- ### Download Model via Direct HTTP GET (HTTP Request) Source: https://github.com/opensourcebim/bimserver/wiki/Downloading-models Downloads BIMserver models directly via an HTTP GET request to the '/download' servlet. This method is efficient and suitable for browser downloads. It requires authentication token and TopicId as parameters. The response may be compressed. ```HTTP GET [yourbimserver]/download?token=[Your BIMserver auth token]&topicId=[The TopicId returned by the download method]&zip=true HTTP/1.1 Host: [yourbimserver] ``` -------------------------------- ### Configure BIMserver Home Directory in Tomcat Context Source: https://github.com/opensourcebim/bimserver/wiki/Install-on-Ubuntu This XML snippet demonstrates setting the 'homedir' parameter for BIMserver within a default Tomcat Context configuration. This method is an alternative to the Host configuration and is useful for specifying the persistent data directory when a full Host setup is not required or desired. It ensures logs and database files are stored outside the web application's deployable directory. ```xml ``` -------------------------------- ### Install Postfix Mail Server Source: https://github.com/opensourcebim/bimserver/wiki/Install-on-Ubuntu This bash command installs the Postfix mail transfer agent on a Debian-based system. Postfix is used here to set up a local SMTP server for BIMserver's email notification functionality. During installation, users are prompted to configure domain settings and server roles, such as 'Internet Site'. ```bash apt-get install postfix ``` -------------------------------- ### Configure BIMserver XML context for Tomcat Source: https://github.com/opensourcebim/bimserver/wiki/Install-on-Ubuntu-15 Creates a Tomcat context configuration file to specify the BIMserver home directory. This is essential for BIMserver to locate its configuration and data files. ```bash user@local:~$ mkdir /opt/tomcat9/conf/Catalina/localhost # might already exist user@local:~$ vim /opt/tomcat9/conf/Catalina/localhost/bimserver.xml # configure bimserver homedir (see below) ``` ```xml ``` -------------------------------- ### Example: Include Furniture and Geometry in Java Source: https://github.com/opensourcebim/bimserver/wiki/Object-IDMs Provides a Java code example demonstrating how to implement the `shouldIncludeClass` method to include all furniture elements and their associated geometry. It highlights the importance of checking supertypes to ensure related classes are also included. ```java @Override public boolean shouldIncludeClass(EClass eClass) { return !Ifc2x3Package.eINSTANCE.getIfcRoot().isSuperTypeOf(eClass) || eClass == Ifc2x3Package.eINSTANCE.getIfcFurnishingElement(); } ``` -------------------------------- ### Java Client to Add Project to BIMserver Source: https://github.com/opensourcebim/bimserver/wiki/BimServerClientMavenEclipse A basic Java application demonstrating how to connect to a BIMserver instance, authenticate, and add a new project. It utilizes the `bimserverclientlib` and requires the BIMserver URL and user credentials. The example adds a project named 'test' with the 'ifc2x3tc1' schema. ```java import org.bimserver.client.BimServerClient; import org.bimserver.client.json.JsonBimServerClientFactory; import org.bimserver.shared.ChannelConnectionException; import org.bimserver.shared.UsernamePasswordAuthenticationInfo; import org.bimserver.shared.exceptions.BimServerClientException; import org.bimserver.shared.exceptions.PublicInterfaceNotFoundException; import org.bimserver.shared.exceptions.ServiceException; public class Main { public static void main(String[] args) { try { JsonBimServerClientFactory clientFactory = new JsonBimServerClientFactory("http://localhost:8080"); BimServerClient client = clientFactory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin")); client.getServiceInterface().addProject("test", "ifc2x3tc1"); } catch (BimServerClientException | ServiceException | ChannelConnectionException e) { e.printStackTrace(); } catch (PublicInterfaceNotFoundException e) { e.printStackTrace(); } } } ``` -------------------------------- ### JavaScript Client Integration Source: https://github.com/opensourcebim/bimserver/wiki/JSON-API Instructions and code examples for integrating with the BIMserver using the provided JavaScript library. ```APIDOC ## JavaScript Client Integration ### Description BIMserver provides a JavaScript library to facilitate connections from web applications and websites. This library can be accessed at `[address]/js/bimserver.js`. ### Usage Include the library in your project and instantiate the API with your BIMserver address. ### Request Example ```javascript var bimServerApi = new BimServerApi("http://examplebimserver:port"); ``` ### Further Details Refer to the [JavaScriptApi](http://code.google.com/p/bimserver/wiki/JavaScriptApi) or [JavaScriptClient](JavaScriptClient) pages for more comprehensive information. ``` -------------------------------- ### Configure Tomcat7 Security Policy (Java) Source: https://github.com/opensourcebim/bimserver/wiki/Install-on-Ubuntu Defines a security policy for Tomcat7 by creating a default policy file. This configuration grants all permissions, which can be refined for more secure deployments. ```java grant { permission java.security.AllPermission; }; ``` -------------------------------- ### Configure Tomcat7 Server XML (XML) Source: https://github.com/opensourcebim/bimserver/wiki/Install-on-Ubuntu Modifies the Tomcat7 server.xml file to define the host and context for the BIMserver application. This includes setting the application base, unpack options, and specifying the BIMserver home directory. ```xml ``` -------------------------------- ### Start BIMserver Transaction Source: https://github.com/opensourcebim/bimserver/wiki/Low-Level-Calls Initiates a new transaction in BIMserver to allow for granular data access. Requires a Project ID (poid) and returns a Transaction ID (tid) for subsequent operations. No external dependencies are mentioned. ```text startTransaction(poid) ``` -------------------------------- ### Configure Tomcat Proxy Settings Source: https://github.com/opensourcebim/bimserver/wiki/Install-on-Ubuntu-15 Sets up proxy host and port configurations for Tomcat by modifying the 'setenv.sh' script. This is crucial for BIMserver to access external resources through a proxy server. ```bash user@local:~$ vim /opt/tomcat9/bin/setenv.sh # enter proxy settings for Tomcat ``` ```bash CATALINA_OPTS="-Dhttp.proxyHost=[PROXY HOST] -Dhttp.proxyPort=[PORT] -Dhttps.proxyHost=[PROXY HOST] -Dhttps.proxyPort=[PORT]" ``` -------------------------------- ### Adjust Tomcat Memory Settings with setenv.sh Source: https://github.com/opensourcebim/bimserver/wiki/Install-on-Ubuntu-15 This snippet demonstrates how to adjust Tomcat's memory settings, specifically the heap size, by creating or editing the `setenv.sh` file. It shows the basic content required to set the maximum heap size using `CATALINA_OPTS`. ```bash user@local:~$ sudo vim /opt/tomcat/bin/setenv.sh # create if not existing and edit ``` ```sh CATALINA_OPTS="-Xmx4G" # use space to combine with other options if any ``` -------------------------------- ### BimBotsServiceInterface: Get Available Inputs Source: https://github.com/opensourcebim/bimserver/wiki/Writing-a-BimBot-service-for-BIMserver Implement this method to specify the schema types that your BimBot service can accept as input. Common schema types include IFC_STEP_2X3TC1, IFC_STEP_4, IFC_XML_2X3TC1, or IFC_XML_4. ```java Set getAvailableInputs(); ``` -------------------------------- ### Loading Local Eclipse Project Plugin (Java) Source: https://github.com/opensourcebim/bimserver/wiki/Plugin-Development Demonstrates how to configure BIMserver to load a plugin directly from a local Eclipse project during development. This involves modifying `LocalDevPluginLoader.java` to include the path to the plugin project. ```java pluginManager.loadPluginsFromEclipseProject(new File("../PluginTest")); ``` -------------------------------- ### BIMserver Plugin Interface Definition (Java) Source: https://github.com/opensourcebim/bimserver/wiki/Plugin-Development Defines the core `Plugin` interface for all BIMserver plugins. It includes methods for initialization, retrieving plugin metadata (name, description, version), and checking initialization status. Plugins should not implement this directly but rather its sub-interfaces. ```java public interface Plugin { void init(PluginManager pluginManager) throws PluginException; // Initialization code, if your plugin requires other plugins, this is the time to check for them, be sure to throw a PluginException when something is wrong String getName(); // A short name of this plugin String getDescription(); // A short description of this plugin String getVersion(); // A version, not used for dependencies (yet) boolean isInitialized(); // Should return whether this plugin is successfully initialized } ``` -------------------------------- ### JSON: Multiple Includes for IfcBuildingStorey Source: https://github.com/opensourcebim/bimserver/wiki/JSON-Queries This JSON example illustrates the use of 'includes' to follow multiple attributes from a single object type, IfcBuildingStorey. It shows how to retrieve related elements through 'IsDecomposedBy' and 'ContainsElements' relationships. ```json { "type": "IfcBuildingStorey", "includes": [ { "type": "IfcBuildingStorey", "field": "IsDecomposedBy", "include": { "type": "IfcRelAggregates", "field": "RelatedElements" } }, { "type": "IfcBuildingStorey", "field": "ContainsElements", "include": { "type": "IfcRelContainedInSpatialStructure", "field": "RelatedElements" } } ] } ``` -------------------------------- ### IFC Format: Example IFC File Body for Wall Query Source: https://github.com/opensourcebim/bimserver/wiki/JSON-Queries This snippet shows a fragment of an IFC file body, representing IfcWallStandardCase objects. It illustrates the basic structure for defining entities but notes that geometric representations are required for visualization. ```ifc #1= IFCWALLSTANDARDCASE('1hmUg1hfv4UPf0UtHFe7ta',$,'SW - 009',$,$,$,$,'6BC1EA81-AE9E-4479-9A-40-7B744FA07DE4'); #2= IFCWALLSTANDARDCASE('05UYVl82vAa8mFc3FMTYL7',$,'SW - 010',$,$,$,$,'057A27EF-202E-4A90-8C-0F-9833D6762547'); #3= IFCWALLSTANDARDCASE('37ZZt1nzL2nu6PjSr0Wa2a',$,'SW - 011',$,$,$,$,'C78E3DC1-C7D5-42C7-81-99-B5CD408240A4'); #4= IFCWALLSTANDARDCASE('1EzyXtTtv7RAinwkFVr6_I',$,'SW - 012',$,$,$,$,'4EF7C877-777E-476C-AB-31-EAE3DFD46F92'); #5= IFCWALLSTANDARDCASE('08u2EMNSnBL8Izk3LNHAwK',$,'SW - 013',$,$,$,$,'08E02396-5DCC-4B54-84-BD-B8355744AE94'); ``` -------------------------------- ### Set Up Directories and User for Tomcat Source: https://github.com/opensourcebim/bimserver/wiki/Install-on-Ubuntu-15 This section details the creation of necessary directories and a dedicated user for Tomcat. It includes creating a non-login user, setting up home directories in /var, assigning ownership to the tomcat user and group, and configuring the user's home directory in /etc/passwd. ```bash user@local:~$ useradd -s /sbin/nologin tomcat # dedicated user for tomcat without shell access user@local:~$ mkdir -p /var/bimserver/home # create bimserver home (including parent directory) user@local:~$ mkdir /var/tomcat # create Tomcat home directory for the Tomcat user user@local:~$ chown -R tomcat:tomcat /var/bimserver # assign ownership to tomcat user and group user@local:~$ chown -R tomcat:tomcat /var/tomcat # assign ownership to tomcat user and group user@local:~$ vim /etc/passwd # edit to set Tomcat home (see below) ``` ```passwd tomcat:x:1009:1009::/var/tomcat:/sbin/nologin ```