view src/kryshen/catalina/startup/HomesUserConfig.java @ 9:a3321ea9b33f

Update.
author Mikhail Kryshen <mikhail@kryshen.net>
date Mon, 02 Nov 2009 18:36:24 +0300
parents ff1e55a2171f
children 086a55aa2620
line wrap: on
line source

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package kryshen.catalina.startup;

import java.io.File;

/**
 *
 * @author Mikhail Kryshen
 */
public class HomesUserConfig extends UserConfig {

    /**
     * The directory name to be searched for within each user home directory.
     */
    private String directoryName = "public_webapps";
    /**
     * The base directory containing user home directories.
     */
    private String homeBase = null;

    public String getDirectoryName() {
        return directoryName;
    }

    /**
     * Set the directory name for user web applications.
     *
     * @param directoryName The new directory name
     */
    public void setDirectoryName(String directoryName) {
        this.directoryName = directoryName;
    }

    /**
     * Return the base directory containing user home directories.
     */
    public String getHomeBase() {
        return homeBase;
    }

    /**
     * Set the base directory containing user home directories.
     *
     * @param homeBase The new base directory
     */
    public void setHomeBase(String homeBase) {
        this.homeBase = homeBase;
    }

    @Override
    protected void deployUserApps() {
        File homeBaseFile = new File(homeBase);

        if (!homeBaseFile.exists() || !homeBaseFile.isDirectory()) {
            host.getLogger().error("Invalid home base.");
            return;
        }

        String[] homes = homeBaseFile.list();

        for (String name : homes) {
            File home = new File(homeBaseFile, name);
            
            if (!home.isDirectory() /* || !home.canExecute() */) {
                continue;
            }

            File base = new File(home, directoryName);
            deployUserApps(name, base);
        }
    }
}