SiteStudio Online Documentation  

User Configuration for SiteStudio

The way SiteStudio accesses user's information is flexible and can be configured with your choice of format. It can be configured to access user's info from the database and save information on local hard-drive or via FTP. SiteStudio supports two default types of users for publishing websites:

1. Local User

This is the type where the user's website is located on the same computer as SiteStudio, or computer connected by NFS or samba. To support this kind of format, you have to configure the following SQL query so that correct information can be retrieved.

The query has to return the following fields:

Name Type Description
id int unique site ID
login string unique login name to identify user's website, it can be domain name for the site or account username for the account if only one site per account is allowed.
real_login string account user name that will be used to login as user so files are stored under user's permissions.
password string account password, used to login user into SiteStudio and into account to store files.
email string is not currently used, but will be used later to fill in the fields in SiteStudio.
dir string full directory path to user's website, will be used to store files.
url string full URL to user's website.

For example:

SELECT id, login, real_login, password, email, dir, url FROM siteowner WHERE login=''{0}''
*{0} will be substituted by the login passed by user to SiteStudio when user tries to login.
** Two single ' will be substituted by one single ' by the preprocessor.

The above query must be specified in USER_LOGIN_QUERY property of SiteStudio configuration file ( In addition to the query, you must specify initializing class which SiteStudio will use to create instances of WebsiteOwner class. You can do it using USER_CLASS property of the SiteStudio configuration file:

USER_CLASS = WebsiteOwnerInitializer

Also, the publisher type must be specified using the PUBLISHER_CLASS property. There are two types of publisher for the local users:
psoft.masonry.publisher.TestPublisher and psoft.masonry.publisher.FilePublisher

TestPublisher type is used to publish files to the local file system using JVM uid. In other words, with the TestPublisher SiteStudio can publish files only into the directories that have write permission for JVM uid. Example with the TestPublisher can be found in the How to setup section.

FilePublisher is used to publish files to the local file system using uid of any UNIX user.

For example, you have UNIX users and:
- their homes located in the directory /home/[USER_NAME]/
- web content of each user is located in the /home/[USER_NAME]/public_html/ directory
- web server is configured to access web content of each user using the url http://[YOUR_DOMAIN_OR_IP.COM]/~[USER_NAME].
As you know, each UNIX user has unique ID under which all his files are created. So SiteStudio must be able to create/publish files using user's UID. That's when FilePublisher is used.

File publisher can be used only on UNIX systems. To use the file publisher, you must download and install it as follows:
tar xvfz ./publisher-1.1.tar.gz
cd publisher-1.1
make; make install

You can use --prefix=[DESTINATION_DIR] option of the ./configure command to specify the directory to where it must be installed. If you do so, you must add the following property into SiteStudio configuration file:

Where [DESTINATION_DIR] must be substituted with the full path to the destination directory for the publisher.
By default, [DESTINATION_DIR]=/usr/local/bin/.

2. Remote User

Users of that type can be spread across different servers, running different OS. FTP protocol is used to put/access files on those servers. This type requires two additional fields:

server string ftp server from which user's website is accessible
port string ftp server's port number (usually 21)

For example:

SELECT id, login, real_login, password, email, dir, url FROM siteowner WHERE login=''{0}''
*{0} will be substituted by the login passed by user to SiteStudio when user tries to login.
** Two single ' will be substituted by one single ' by the preprocessor.

For the remote user, FTPOwnerInitializer is used to create objects of the correspondent type(FTPOwner) in SiteStudio. So USER_CLASS property must look like this:

USER_CLASS = psoft.user.FTPOwnerInitializer
In case of remote user PUBLISHER_CLASS property in the SiteStudio configuration file must look like this:
PUBLISHER_CLASS = psoft.masonry.publisher.FTPPublisher

3. How to setup.

This mini HOWTO gives instructions on how to setup SiteStudio to work with multiple users, using your database. However, if you read this document carefully and understand what each step means, you would be able to configure SiteStudio for any setup where user directories can be written for servlet runner JVM (Apache/Jserv, Tomcat or any other).

Prerequisite: Install SiteStudio according to SiteStudio Installation on UNIX.

Provided, we have Unix, PostgreSQL and all user directories are writable for servlet runner JVM (Apache/Jserv, Tomcat or any other).

  1. Create a database. Your database may already exist, or may look different from what is here. It might be several different tables, instead of single one in this example. In this case, just create a view that would give out the result that looks like table "users" below. Or change query in (2) to give out same result set as the query provided in (2).
  2. create database studio;
    \connect studio
    CREATE TABLE "users" (
            "id" int4,    -- unique user id,
            "login" character varying(20), -- unique symbolic login
            -- you type login into login form ':)'
            "real_login" character varying(20), -- system specific login
            -- UNIX system account or FTP account name
            "password" character varying(20), -- password ...
            "email" character varying(128),  -- not used, but should be here
            "dir" character varying(128),
            -- directory accessible from the web, where main index.html
            -- for this user should be
            -- example /home/www/user2/
            "url" character varying(128)
            -- full URL to the main index.html but without index.html
            -- example
            -- last '/' MUST be there

    Insert statements may be similar to the following:

    INSERT INTO "users" VALUES (1,'a','a','',
    INSERT INTO "users" VALUES (2,'b','b','',
    INSERT INTO "users" VALUES (3,'c','c','',

    The above values in the INSERT statements are short and the web server is set up so that the directory /home/SiteStudio/public_html/masonry/users is already accessible from the web as

    For example the following line:

    Alias /masonry/ /home/SiteStudio/public_html/masonry/
    can be added into the config file of the Apache web server to provide access from the web. YOURDOMAIN.COM should be substituted for whatever works for you.

    Note the last '/' in the url and dir fields. We created 3 users a, b and c and their respective passwords are a, b and c.

  3. Modify [SS_DIR]/psoft_config/ config file
    # This is JDBC driver for postgresql
    # yours might be different
    DB_DRIVER = org.postgresql.Driver
    # this is JDBC url for database 'studio' on localhost, using postgresql driver
    DB_URL = jdbc:postgresql://
    # this is login name to 'studio' database in postgres
    DB_USER = postgres
    # this is password
    # on localhost postgres in default install will actually let you in without it
    # this does not matter here
    DB_NEWID = SELECT nextval(''{1}'')
    # note (') around the ''{0}''  - it is two of ('), not one of (") ....
    # the following query should be one single line
    USER_LOGIN_QUERY = SELECT id, login, real_login, password, email, dir, url FROM users WHERE login = ''{0}''
    # this is publisher that accesses local file system.
    # This publisher runs as JVM uid only.
    PUBLISHER_CLASS = psoft.masonry.publisher.TestPublisher
    # user class for working with multiple users
    # this class takes the data retrieved from the database using USER_LOGIN_QUERY
    # and constructs the Java object with represents the WebsiteOwner
    USER_CLASS = psoft.user.WebsiteOwnerInitializer
  4. Create user's directories here because of the data that we inserted into database. Read comments for INSERT statements in (1)
    mkdir /home/Sitestudio/public_html/masonry/users/a
    mkdir /home/Sitestudio/public_html/masonry/users/b
    mkdir /home/Sitestudio/public_html/masonry/users/c
    Here we assume that SiteStudio runs as user studio.
    chown -R studio:studio /home/Sitestudio/public_html/masonry/users
  5. Restart SiteStudio.
. Positive Software Corporation.
All rights reserved.