### Install and manage Tomcat 7 on Ubuntu
Source: https://github.com/eistw/openldocs/blob/main/docs/documentation/guides/installation_guide.pdf
Commands to install, start, restart, and stop Tomcat 7 on Ubuntu. The restart command is used when a 404 error appears after installation.
```bash
sudo apt-get install tomcat7
```
```bash
sudo /etc/init.d/tomcat7 start
```
```bash
sudo /etc/init.d/tomcat7 restart
```
```bash
sudo /etc/init.d/tomcat7 stop
```
--------------------------------
### Install and start Tomcat from ZIP archive
Source: https://github.com/eistw/openldocs/blob/main/docs/documentation/guides/installation_guide.pdf
Commands to extract the Tomcat archive, navigate to the bin directory, check file permissions, make .sh files executable if needed, and start Tomcat.
```bash
tar -zxvf apache-tomcat-9.0.39.tar.gz
```
```bash
cd apache-tomcat-9.0.39/bin
```
```bash
ls –la
```
```bash
chmod +x ./*.sh
```
```bash
sh ./startup.sh
```
--------------------------------
### Start Tomcat
Source: https://github.com/eistw/openldocs/blob/main/docs/documentation/guides/installation_guide.md
Starts Tomcat to deploy OpenL Studio. Run from the Tomcat bin directory.
```bash
sh startup.sh
```
--------------------------------
### Launch the demo application with bash start
Source: https://github.com/eistw/openldocs/blob/main/docs/documentation/guides/demo_package_guide.md
Run this command in the terminal from the unzipped Demo folder to start the application on macOS and Linux. On some systems, you may need to grant execute permissions first with 'chmod +x start'.
```bash
bash start
```
--------------------------------
### Install and manage Tomcat 9 service on Ubuntu
Source: https://github.com/eistw/openldocs/blob/main/docs/documentation/guides/installation_guide.md
Commands to install, start, restart, and stop Tomcat 9 as a service on Ubuntu 12.x. All commands require sudo privileges. After starting, verify by opening http://localhost:8080; if a 404 error appears, restart Tomcat.
```bash
sudo apt-get install tomcat9
```
```bash
sudo /etc/init.d/tomcat9 start
```
```bash
sudo /etc/init.d/tomcat9 restart
```
```bash
sudo /etc/init.d/tomcat9 stop
```
--------------------------------
### rules-deploy.xml example
Source: https://github.com/eistw/openldocs/blob/main/docs/documentation/guides/rule_services_usage_and_customization_guide.pdf
Example of the rules-deploy.xml deployment configuration file used by the default Service Configurer implementation. It defines runtime context, service name, class, URL, publishers, and custom configuration entries. If this file is missing or publishers are not defined, only the RESTful service is deployed.
```xml
true
myService
com.example.MyService
com.example.MyService
RESTFUL
someString
someString
```
--------------------------------
### Array Functions
Source: https://github.com/eistw/openldocs/blob/main/docs/documentation/guides/reference_guide.md
This snippet documents the array functions available in the OpenL Docs reference guide.
```APIDOC
## isEmpty(array)
### Description
Checks if an array is empty or null.
### Parameters
- **array** (array) - Required - The array to check.
### Returns
Boolean indicating whether the array is empty or null.
```
```APIDOC
## flatten(arrayN)
### Description
Returns a flattened array with values from arrayN. Returns a single dimension array of elements. Converts a matrix into a list.
### Parameters
- **arrayN** (array) - Required - The array or arrays to flatten.
### Returns
A single-dimensional array containing all elements from the input arrays.
```
```APIDOC
## length(array)
### Description
Returns the number of elements in the array. It is more preferable than the array.length syntax.
### Parameters
- **array** (array) - Required - The array whose length is to be returned.
### Returns
The number of elements in the array.
```
```APIDOC
## max(array)
### Description
Returns the maximal value in the array of numbers.
### Parameters
- **array** (array) - Required - The array of numbers.
### Returns
The maximum value from the array.
```
--------------------------------
### Deploy OpenL Studio on Linux/Mac: folder setup, WAR copy, Tomcat start/stop
Source: https://github.com/eistw/openldocs/blob/main/docs/documentation/guides/installation_guide.pdf
Commands to prepare the deployment folder, copy the WAR file, and start/stop Tomcat on Linux or Mac. Run from /home/myuser//bin for the shutdown and startup commands.
```bash
sudo mkdir /
```
```bash
sudo chmod 775 -R /
```
```bash
sudo chown tomcat7:tomcat7 /
```
```bash
cp /home/myuser/Downloads//home/myuser//webapps/webstudio.war
```
```bash
sh shutdown.sh
```
```bash
sh startup.sh
```
--------------------------------
### substring(String str, int beginIndex, int endIndex)
Source: https://github.com/eistw/openldocs/blob/main/docs/documentation/guides/reference_guide.pdf
Gets a substring from the specified String. A negative start position can be used to start or end n characters from the end of the String.
```APIDOC
## substring(String str, int beginIndex, int endIndex)
### Description
Gets a substring from the specified String. A negative start position can be used to start or end n characters from the end of the String.
### Parameters
- **str** (String) - Required - The string to extract substring from.
- **beginIndex** (int) - Required - The beginning index, inclusive.
- **endIndex** (int) - Required - The ending index, exclusive.
### Returns
String - The substring from the specified string.
```
--------------------------------
### substring(String str, int beginIndex)
Source: https://github.com/eistw/openldocs/blob/main/docs/documentation/guides/reference_guide.pdf
Gets a substring from a string, supporting negative start positions.
```APIDOC
## substring(String str, int beginIndex)
### Description
Gets a substring from the specified String. A negative start position can be used to start n characters from the end of the String.
### Parameters
- **str** (String) - Required - The source string.
- **beginIndex** (int) - Required - The starting index (can be negative).
### Returns
- **String** - The substring.
### Example
```
substring("hello", 1)
```
```
--------------------------------
### Java expression for vehicle value comparison
Source: https://github.com/eistw/openldocs/blob/main/docs/documentation/guides/developer_guide.md
A simple Java expression comparing the difference between agreed and market value against a user-defined limit. This is the starting point for the BEX rewrite shown in the next example.
```plaintext
(vehicle.agreedValue - vehicle.marketValue) / vehicle.marketValue > limitDefinedByUser
```
--------------------------------
### Instantiate OpenL Tablets project with static interface
Source: https://github.com/eistw/openldocs/blob/main/docs/documentation/guides/developer_guide.pdf
Creates a project engine factory with a static interface class (SayHello) using SimpleProjectEngineFactoryBuilder. The instance is created via newInstance().
```java
SimpleProjectEngineFactory simpleProjectEngineFactory = new
SimpleProjectEngineFactoryBuilder().setProject)
.setInterfaceClass(SayHello.class)
.build();
SayHello instance = simpleProjectEngineFactory.newInstance();
```
--------------------------------
### Override HTTP Method with @GET
Source: https://github.com/eistw/openldocs/blob/main/docs/documentation/guides/rule_services_usage_and_customization_guide.pdf
Overrides the default HTTP method type to GET for a service method. The method accepts only GET requests. Use with @Path if needed, but it is not required to declare both.
```java
@GET
MyResponse someMethod(MyType myType);
```
--------------------------------
### Create OpenL Studio deployment folder
Source: https://github.com/eistw/openldocs/blob/main/docs/documentation/guides/installation_guide.md
Creates the deployment folder for OpenL Studio on Linux or Mac. Replace with the actual path.
```bash
sudo mkdir /
```
--------------------------------
### Create MySQL user and database for OpenL Studio
Source: https://github.com/eistw/openldocs/blob/main/docs/documentation/guides/installation_guide.pdf
Run these commands in the MySQL Command Line Client after installing MySQL to create a dedicated user and database for OpenL Studio. The database is created with the UTF-8 character set, and the user is granted all privileges on it.
```sql
CREATE USER openl_user IDENTIFIED BY 'openl_password';
CREATE DATABASE openl CHARACTER SET utf8;
GRANT ALL PRIVILEGES ON openl.* TO openl_user;
```