An Introduction to Lianja Cloud Server

PDF Print E-mail

The Lianja Cloud Server is a modern, fast, and flexible cross-platform cloud database Apps Server that enables you to share Apps and Data in the Cloud or on premises running on either Linux or Windows. Lianja Cloud Server provides an enterprise-class solution for both SMEs and large enterprises.

This article provides a functional overview of the Lianja Cloud Server.

This article and further information on the Lianja Cloud Server can now be found on the Lianja wiki here.

Introduction

The "Lianja Apps Platform" abbreviated to "Lianja APaaS" consists of the following products which can be bought individually or altogether as a "Lianja APaaS subscription".

The Lianja APaaS consists of:

Lianja Cloud Server at a glance

The Lianja Cloud Server provides a variety of features that are grouped by functionality.

App Deployment Services

Data Services

Dynamic Page Services

So let's take a look at these services one by one and see what they offer. If you want to skip all this read the FAQ.


App Deployment Services

Lianja HTML5 JavaScript Web Client

The Lianja Web Client is a pure HTML5 JavaScript client that runs Apps developed in the Lianja App Builder using best practices in any HTML5 compatible desktop browser. It uses best of breed technologies to provide a rich and responsive user experience.

Lianja HTML5 JavaScript Mobile Client

The Lianja Mobile Client is a pure HTML5 JavaScript client that runs Apps developed in the Lianja App Builder using best practices on mobile devices. The Lianja Mobile Client is implemented as a responsive UI and will automatically adjust its appearance on iPhone, iPad, Android Phones and Android Tablets. It incorporates the PhoneGap JavaScript APIs and can be packaged up as a self contained App using the Adobe PhoneGap Build Service that can be submitted to the Apple App Store or Google Play.

Data Services

Lianja ODBC data access

Open Database Connectivity (ODBC) is an industry standard interface for accessing data in a heterogeneous environment of relational and non- relational database management systems. Based on the Call Level Interface specification of the SQL Access Group, ODBC provides an open, vendor- neutral way of accessing data. Using the Lianja ODBC Driver in conjunction with the Lianja SQL Server, third party ODBC-aware products have full CRUD (Create, Read, Update, and Delete) access to Lianja data no matter where it resides.  

Lianja OData service

OData is a standardized protocol for creating and consuming data APIs. OData builds on core protocols like HTTP and commonly accepted methodologies like REST. The result is a uniform way to expose full-featured data APIs. The Lianja Cloud Server has built-in support for OData. There is no need to write any custom code to use this functionality, you just point at an OData URI and the Cloud Server will perform the requested OData operation returning data in industry standard JSON format. See this article for details.

Lianja WebSockets Service

WebSockets is an advanced technology that makes it possible to open an interactive communication session between the user's browser and a server. With this API, you can send messages to a server and receive event-driven responses without having to poll the server for a reply. The Lianja Cloud Server has built-in support for writing WebSocket servers in both Visual FoxPro compatible scripting or JavaScript on all supported platforms.

Dynamic Page Services

Dynamic pages contain HTML and page processing directives in the same way as a PHP page does. You use page processing directives to generate HTML code dynamically. Page processing directives are typically enclosed in Screen Shot 2013-08-28 at 2.25.32 PM and Screen Shot 2013-08-28 at 2.25.47 PM in both Visual FoxPro Server Pages (.rsp files) and JavaScript Server Pages (.jssp files).

Visual FoxPro Server Pages

Lianja Cloud Server has built-in support for Visual FoxPro Server Pages.

Visual FoxPro Server pages (.rsp pages) have the Lianja database and scripting engine embedded in them. You can write and test Visual FoxPro Server Pages in the Lianja App Builder and "Publish to the Cloud website" to deploy them.

In addition to the built-in commands and functions supported the Lianja/SDK C/C++ API provides the ability to write custom functions and classes in C/C++ to extend the functionality already offered. This is similar to but much simpler than using the PHP Extensions API to extend PHP.

Page processing directives:

Page Directive Description
<%= expression %>  Evaluates and outputs expression
<% code %>  Executes code
<%@ include=cExpression %>  Includes the file specified in cExpression
<%@ codebehind=cExpression %>  Executes the script file specified in cExpression

When a Visual FoxPro Server Page is executed the following are available to the script (in addition to the complete VFP compatible cross-platform scripting language implemented in Lianja).

Global associative arrays:

Array Description
_ARGS[] Contains all arguments passed to the rsp page. 
_COOKIE[] Contains cookie names and values. 
_FILES[] Contains information about uploaded files. 
_GET[] Contains GET parameter names and values. 
_POST[] Contains POST parameter names and values. 
_REQUEST[] Contains all arguments passed to the rsp page. 
_SERVER[] Contains server information. 
_SESSION[] Contains session information. 

Global objects:

  • Response
Method Description
addCookie(name, value) Adds the specified cookie to the cookies that will be sent back to the browser.
addHeader(name, value) Adds a custom HTTP response header to the response headers which will be sent back to the browser.
appendToLog( message ) Writes a message to the end of the system log. 
authenticate( [message] ) Causes the browser to prompt for username/password with optional message
clear() Clears the response output buffer. 
flush() Flushes out the buffers and sends data to the browser. 
include( filename ) Includes the contents of filename into the output data that will be sent back to the browser. 
redirect( url ) Redirects to the specified url
write( text ) Writes text into the output stream that will be sent back to the browser. 
writeFile( filename ) Writes out the contents of filename into the output stream that will be sent back to the browser. 

Built-in commands/functions:

Command/Function Description
? cExpression Evaluates and outputs the result of cExpression into the output stream. 
base64_encode_image(object_fieldname [,width,height [,cssattr ]]) Generates the base64 encoded contents of an object field image as an IMG tag with the specified dimensions and outputs into the output stream. cssattr can be used to add additional CSS attributes onto the IMG tag e.g. "class='myclass'".
die(message) Terminates the request and returns a custom message which will be displayed in the browser.
echo cExpression Evaluates and outputs the specified cExpression into the output stream.
getUrl( url [, timeout [, headers, [,filename]]] ) Fetch the contents of the specified url and return the result of the HTTP GET as a string or if the optional filename is specified into that file. If JSON data is returned you can use json_decode() on the result and them access the JSON objects in VFP-style scripting syntax.
include( filename ) Includes the file contents specified by filename at this point in the script.
json_encode( oVar ) Encodes the object oVar in JSON format.
json_decode( cExpr ) Decodes the specified JSON string which is the result of the expression cExpr as an object.
json_decode_file( filename ) Decodes the JSON in the specified file designated by filename as an object.
move_uploaded_file(tofilename, fromfilename) Moves the uploaded file tofilename to the location specified in fromfilename
odata_Create( url, jsondatastring ) Inserts a new record described by the specified OData url whose field names and values are in the specified JSON encoded string e.g. '{"name":"smith", "salary":1000}'
odata_Delete( url, jsondatastring ) Deletes the record described by the specified OData url whose field names and values are in the specified JSON encoded string e.g. '{"name":"smith"}'
odata_Read( url [, filename] ) Queries data based on the specified OData url and sends the JSON encoded data back to the browser. If filename is specified the JSON data is saved into the specified file.
odata_Update( url, jsondatastring ) Updates a record described by the specified OData url with field names and values as specified by the JSON encoded string e.g. '{"name":"smith", "salary":1000}'
postUrl( url [, timeout [, headers, [,filename]]] ) post the specified url using a HTTP POST request. Send the contents of the optional file if filename is a valid filename or send it as the data in the POST request.
include_once( cExpression ) Loads the library specified in cExpression only once.  
All of the VFP commands and functions supported by Lianja All non-UI VFP commands and functions supported by Lianja can be used in Visual FoxPro Server Pages. This includes the NoSQL navigational commands and the SQL commands.

You can view an example Visual FoxPro Server Page on the documentation wiki.


JavaScript Server Pages

Lianja Cloud Server has built-in support for JavaScript Server Pages.

JavaScript Server Pages (.jssp pages) are modeled on PHP Server Pages. They embed the V8 JavaScript engine which is used by Google Chrome and Node.js. The JavaScript engine implements ECMAScript as specified in ECMA-262, 5th edition. 

Lianja JavaScript Server Pages provide the ability to write both the client and the server code in JavaScript. You can use them in place of PHP server pages. If you know JavaScript and HTML these are for you. You are not required to learn any new programming language in order to build custom Web and Mobile Apps.

JavaScript Server Pages have embedded Lianja database and OData support and they are fast as the whole engine is written in C/C++, no Java or other dependencies required. 

Additionally they support "one-time" loading of JavaScript libraries to enable team sharing of code libraries and open source JavaScript libraries using the built-in include_once("library_name.js") and the require("module_name") function.

They also provide a lot of functionality that will be familiar to PHP developers (details below). 

You can write and test JavaScript Server Pages in the Lianja App Builder and "Publish to the Cloud website" to deploy them.

Page processing directives:

Page Directive Description
<%= expression %>  Evaluates and outputs expression
<% code %>  Executes code
<%@ include=cExpression %>  Includes the file specified in cExpression
<%@ codebehind=cExpression %>  Executes the script file specified in cExpression

When a JavaScript Server Page is executed the following are available to the script (in addition to the built-in ECMAScript JavaScript functions). These should be familiar to PHP Web developers as they use the same naming convention.

Global associative arrays(objects):

Array Description
$_ARGS[] Contains all arguments passed to the jssp page.
$_COOKIE[] Contains cookie names and values.
$_FILES[] Contains information about uploaded files. 
$_GET[] Contains GET parameter names and values.
$_POST[] Contains POST parameter names and values.
$_REQUEST[] Contains all arguments passed to the jssp page.
$_SERVER[] Contains server information.
$_SESSION[] Contains session information.

Global objects:

  • Lianja
Method Description
evaluate( vfp_expression ) Evaluates vfp_expression and returns the result.
execute( vfp_command ) Executes vfp_command.
openDatabase( databasename ) Opens the database databasename and returns an object reference.
  • Database
Method Description
close() Closes the database.
openRecordSet( table_or_sqlselect ) Opens a recordset for table_or_sqlselect and returns an object reference.
  • Recordset
Property Type Description
bof Boolean (R) Whether record pointer is at beginning of the recordset.
eof Boolean (R) Whether record pointer is at end of the recordset.
fieldcount Numeric (R) Number of fields in the recordset.
filter Character (RW) Filter expression to restrict records.
found Boolean (R) Whether the last seek or find operation found a match.
index Character (RW) Name of the index tag.
nomatch Boolean (R) Whether the last seek or find operation did not find any matches.
recno Numeric (R) Current record number in the recordset.
reccount Numeric (R) Number of records in the recordset.

 

Method Description
close() Closes the recordset.
delete() Marks the current record in a table recordset for deletion.
edit() Puts the current record in edit mode prior to field value modification. Complete the modification by calling update().
field( name_or_number ) Returns an object reference to the specified field in the current record.
findFirst( condition ) Moves the record pointer to the first record to match the condition.
findLast( condition ) Moves the record pointer to the last record to match the condition.
findNext( condition ) Moves the record pointer to the next record to match the condition.
findPrevious( condition ) Moves the record pointer to the previous record to match the condition.
move( numrecords, numbookmark ) Moves the record pointer by numrecords number of records from the numbookmark position.
moveBookmark( numbookmark ) Moves bookmark to the specified record number numbookmark in the recordset.
moveFirst() Moves the record pointer to the first record in the recordset.
moveLast() Moves the record pointer to the last record in the recordset.
moveNext() Moves the record pointer to the next record in the recordset.
movePrevious() Moves the record pointer to the previous record in the recordset.
moveRelative( numrecords ) Moves the record pointer by numrecords number of records.
requery() Requeries the recordset. 
update() Completes an edit() method operation.
  • Field
Property Type Description
decimals Numeric (R) Field decimal places.
name Character (R) Field name.
type Numeric (R) Field data type.
value Expr (RW) Field value.
width Numeric (R) Field width.
  • Response
Method Description
addCookie(name, value) Sends specified cookie. 
addHeader(name, value) Sends specified response headers. 
appendToLog( message ) Writes message to the end of the system log. 
authenticate( [message] ) Causes the browser to prompt for username/password with optional message
clear() Clears the output buffer. 
flush() Flushes out the buffers and sends to the browser. 
include( filename ) Includes filename
redirect( url ) Redirects to url
write( text ) Writes text
writeFile( filename ) Writes out the contents of filename

Built-in functions:

Function Description
base64_encode_image(object_fieldname [,width,height [,cssattr ]]) Generates the base64 encoded contents of an object field image as an IMG tag with the specified dimensions and outputs into the HTML5. "cssattr" can be used to add additional CSS attributes onto the IMG tag e.g. "class='myclass'".
die(message) Terminates the session and displays the HTML encoded message
debugout(message) Writes message to the debug output file. 
echo( cExpression ) Evaluates and outputs cExpression.
include( filename ) Includes the file contents specified by filename at this point in the script.
include_once( filename ) Includes the file contents specified by filename at this point in the script only once.
move_uploaded_file(tofilename, fromfilename) Moves the uploaded file tofilename to the location specified in fromfilename
objectRead( from_filename, object_fieldname ) Reads the data from the from_filename file into the field object_fieldname
objectType( object_fieldname ) Returns the type (file extension) of the field object_fieldname
objectWrite( to_filename, object_fieldname ) Writes the data from the field object_fieldname into the file to_filename.
odata_Create( url, jsondatastring ) Inserts a new record described by the specified OData url whose field names and values are in the specified JSON encoded string e.g. '{"name":"smith", "salary":1000}'
odata_Delete( url, jsondatastring ) Deletes the record described by the specified OData url whose field names and values are in the specified JSON encoded string e.g. '{"name":"smith"}'
odata_Read( url [, filename] ) Queries data based on the specified OData url and sends the JSON encoded data back to the browser. If "filename" is specified the JSON data is saved into the specified file.
odata_Update( url, jsondatastring ) Updates a record described by the specified OData url with field names and values as specified by the JSON encoded string e.g. '{"name":"smith", "salary":1000}'
print( cExpression ) Evaluates and outputs cExpression.
require( cExpression )

Loads the JavaScript library module file specified in cExpression and returns back the module.exports object. This is used in a similar way to node.js require() e.g.

var utils = require("./utils");

where ./utils.js contains:

var myfunc = function() {
    // code for myfunc
};
var myfunc2 = function() {
    // code for myfunc2
};
module.exports.myfunc = myfunc;
module.exports.myfunc2 = myfunc2;
tmpnam() Returns a temporary file name. 
unlink( filename ) Deletes the file filename
All of the VFP commands and functions supported by Lianja Using:

Lianja.execute( vfp_command )
result = Lianja.evaluate( vfp_expression )

You can view an example JavaScript Server Page on the documentation wiki.


FAQ

Can I use Lianja Cloud Server with my existing Web Servers?

Yes. Lianja Cloud Server can operate standalone and works as a traditional Web Server "out-of-the-box" but it also includes an Apache plugin mod_lianja for Linux and an ISAPI filter for IIS on Windows.

What about security, can I restrict what services are available from the internet?

Yes. Lianja Cloud Server can be configured to enable or disable OData Read/Update requests as well as WebSocket Services. You can also configure a whitelist and blacklist for IP addresses.

Does Lianja Cloud Server support https and SSL certificates?

Yes. To use https you need to install the apache plugin mod_lianja on Linux or the ISAPI filter isapi_lianja on Microsoft Windows.

Do Visual FoxPro Server Pages only work on Windows?

No they run on Windows and Linux (both x86 and x86_64) and use the Lianja database and scripting engine that is embedded in the Lianja App Builder.

What JavaScript engine is Lianja Cloud Server using and is this cross-platform?

JavaScript Server Pages (.jssp pages) is a page processing service modeled on PHP server pages. The Lianja Cloud Server has the V8 JavaScript engine embedded into it with many built-in objects and functions as well as the Lianja database engine embedded within it. The V8 JavaScript engine is the same engine used in Node.js but we have ported it to Windows, Linux and Mac and integrated it in so it operates seamlessly as part of Lianja Cloud Server.

What would you recommend me to write my server pages in, Visual FoxPro or JavaScript?

You can write them in whatever you feel comfortable with and have knowledge of. This reduces the learning curve for building polished custom Web Applications. Both types of server pages are data-centric. You can call Visual FoxPro code directly from JavaScript Server Pages using Lianja.execute() and Lianja.evaluate() which are described above in this article.

Why do I need to write server pages, I thought the Lianja App Builder would generate Web Apps and Mobile Apps?

The Lianja HTML5-JavaScript Web Client and the Lianja HTML5-JavaScript Mobile Client will run Apps developed in the Lianja App Builder if you have followed best practices and developed your App the way we have recommended using standard pre-built sections and gadgets. Many Apps can be built like this and will run without changes in the Web Client and Mobile Client.

How scalable is the Lianja Cloud Server?

Highly! You can load balance web connections across multiple App Servers. There is no practical limit to the number of connections that can be made and it is extremely fast.

Can I have a mixture of clients accessing and updating data concurrently e.g. desktop apps, web apps, mobile apps?

Yes, the underlying database and scripting engine is embedded in all of the Lianja products; Lianja App Center, Lianja SQL Server and Lianja Cloud Server.

If I wanted to develop a custom mobile app in a non-Lianja product that performs CRUD operations on my Lianja data how would I do that?

Mobile apps typically use OData calls to perform CRUD operations on a remote server data source. You would use the OData Service built into the Lianja Cloud Server to achieve this. The OData Service generates JSON and handles CRUD operations using JSON formatted data. We recommend jQuery, jQuery Mobile and Twitter Boostrap which we in fact use ourselves.

Does the Lianja OData Service handle JSONP so I can get around SOP (Same-Origin Policy) issues?

Yes. See the article on using OData with Lianja, the $callback=myfunction argument will wrap the JSON data that it returns by a function call.

Typically HTTP requests are stateless how can I maintain state between requests?

You can use the _SESSION[] or $_SESSION[] associative array which persists between HTTP requests.

Can I retrieve photos and other images in the Lianja database and display them in a web page?

Yes, both Visual FoxPro Server Pages (.rsp pages) and JavaScript Server pages (.jssp pages) have a built-in function that will generate an HTML img tag which contains the image. This function is called base64_encode_image() and is described above in this article.

How do I store the photos or other images?

You use the objectRead() built-in function in conjunction with the _FILES[] or $_FILES[] associative array as described above in this article. Both Visual FoxPro Server Pages and JavaScript Server Pages handle multiple file uploads using HTTP POST and setup the _FILES[] or $_FILES[] array which is described above in this article. You can store the photo directly in a Lianja database table using objectRead($_FILES[0].tmp_nam, object_field_name ) in JavaScript or objectRead(_FILES[0].tmp_nam, object_field_name) in Visual FoxPro scripting.

I need to store a large amount of photos can Lianja Cloud Server handle that?

Yes, the Lianja database engine is 64-bit on all supported platforms (including 32 bit ones). It supports huge table sizes up to 2^64. Thats big!

I need to handle 10s of thousands of users, can Lianja Cloud Server be clustered?

Yes, on Linux you can setup Lianja Cloud Server in an Enterprise-class HA (High Availability) cluster consisting of 2 x load balancers, multiple App Servers and 2 x Data Servers with automatic failover and fallback. It can also handle real-time geographic off-site data replication. If you need help with this contact us as we have significant expertise in this area.

In a nutshell, what makes Lianja Cloud Server so much better than other solutions?

It is completely cross-platform (not just Windows, Linux x86 and x86_64 too), has a highly scalable embedded 64-bit database, has a small memory footprint and is a part of the Lianja APaaS so you have a single vendor providing support and updates. It is currently the only cross-platform solution for data-centric Visual FoxPro and JavaScript Server Pages.

If I purchase Lianja Cloud Server do I need to also purchase Lianja SQL Server?

No. Lianja Cloud Server includes Lianja SQL Server.

When will the Lianja Cloud Server be available?

The Lianja Cloud Server has already been released. As additional functionality is added and enhanced customers who purchase the Lianja APaaS subscription will receive these updates at no additional cost.

How much does Lianja Cloud Server cost?

Lianja Cloud Server pricing information can be found here.

We are a software development shop. What does ISV (Independent Software Vendor) pricing look like?

Lianja ISV pricing and qualification requirements can be found here.

Do you have any further questions?

If you have any questions not covered on this FAQ then contact us and ask us, we will be pleased to help you.