Example usage for com.liferay.portal.kernel.deploy.auto AutoDeployUtil registerDir

List of usage examples for com.liferay.portal.kernel.deploy.auto AutoDeployUtil registerDir

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.deploy.auto AutoDeployUtil registerDir.

Prototype

public static void registerDir(AutoDeployDir autoDeployDir) 

Source Link

Usage

From source file:com.liferay.portlet.plugininstaller.action.InstallPluginAction.java

License:Open Source License

protected void deployConfiguration(ActionRequest actionRequest) throws Exception {

    boolean enabled = ParamUtil.getBoolean(actionRequest, "enabled");
    String deployDir = ParamUtil.getString(actionRequest, "deployDir");
    String destDir = ParamUtil.getString(actionRequest, "destDir");
    long interval = ParamUtil.getLong(actionRequest, "interval");
    int blacklistThreshold = ParamUtil.getInteger(actionRequest, "blacklistThreshold");
    boolean unpackWar = ParamUtil.getBoolean(actionRequest, "unpackWar");
    boolean customPortletXml = ParamUtil.getBoolean(actionRequest, "customPortletXml");
    String jbossPrefix = ParamUtil.getString(actionRequest, "jbossPrefix");
    String tomcatConfDir = ParamUtil.getString(actionRequest, "tomcatConfDir");
    String tomcatLibDir = ParamUtil.getString(actionRequest, "tomcatLibDir");
    String pluginRepositoriesTrusted = ParamUtil.getString(actionRequest, "pluginRepositoriesTrusted");
    String pluginRepositoriesUntrusted = ParamUtil.getString(actionRequest, "pluginRepositoriesUntrusted");
    boolean pluginNotificationsEnabled = ParamUtil.getBoolean(actionRequest, "pluginNotificationsEnabled");
    String pluginPackagesIgnored = ParamUtil.getString(actionRequest, "pluginPackagesIgnored");

    PortletPreferences preferences = PrefsPropsUtil.getPreferences();

    preferences.setValue(PropsKeys.AUTO_DEPLOY_ENABLED, String.valueOf(enabled));
    preferences.setValue(PropsKeys.AUTO_DEPLOY_DEPLOY_DIR, deployDir);
    preferences.setValue(PropsKeys.AUTO_DEPLOY_DEST_DIR, destDir);
    preferences.setValue(PropsKeys.AUTO_DEPLOY_INTERVAL, String.valueOf(interval));
    preferences.setValue(PropsKeys.AUTO_DEPLOY_BLACKLIST_THRESHOLD, String.valueOf(blacklistThreshold));
    preferences.setValue(PropsKeys.AUTO_DEPLOY_UNPACK_WAR, String.valueOf(unpackWar));
    preferences.setValue(PropsKeys.AUTO_DEPLOY_CUSTOM_PORTLET_XML, String.valueOf(customPortletXml));
    preferences.setValue(PropsKeys.AUTO_DEPLOY_JBOSS_PREFIX, jbossPrefix);
    preferences.setValue(PropsKeys.AUTO_DEPLOY_TOMCAT_CONF_DIR, tomcatConfDir);
    preferences.setValue(PropsKeys.AUTO_DEPLOY_TOMCAT_LIB_DIR, tomcatLibDir);
    preferences.setValue(PropsKeys.PLUGIN_REPOSITORIES_TRUSTED, pluginRepositoriesTrusted);
    preferences.setValue(PropsKeys.PLUGIN_REPOSITORIES_UNTRUSTED, pluginRepositoriesUntrusted);
    preferences.setValue(PropsKeys.PLUGIN_NOTIFICATIONS_ENABLED, String.valueOf(pluginNotificationsEnabled));
    preferences.setValue(PropsKeys.PLUGIN_NOTIFICATIONS_PACKAGES_IGNORED, pluginPackagesIgnored);

    preferences.store();//from w  w  w.j a va 2 s .  c o  m

    reloadRepositories(actionRequest);

    if (_log.isInfoEnabled()) {
        _log.info("Unregistering auto deploy directories");
    }

    AutoDeployUtil.unregisterDir("defaultAutoDeployDir");

    if (enabled) {
        if (_log.isInfoEnabled()) {
            _log.info("Registering auto deploy directories");
        }

        List<AutoDeployListener> autoDeployListeners = GlobalStartupAction.getAutoDeployListeners();

        AutoDeployDir autoDeployDir = new AutoDeployDir("defaultAutoDeployDir", new File(deployDir),
                new File(destDir), interval, blacklistThreshold, autoDeployListeners);

        AutoDeployUtil.registerDir(autoDeployDir);
    } else {
        if (_log.isInfoEnabled()) {
            _log.info("Not registering auto deploy directories");
        }
    }
}

From source file:com.sqli.liferay.imex.portal.events.ImExStartupAction.java

License:Open Source License

@Override
public void run(String[] ids) throws ActionException {
    // Auto deploy

    if (this.executed) {
        return;//from  ww w  . j av a2  s.  c  o  m
    }

    if (_log.isInfoEnabled()) {
        _log.info("Unregistering IMEX auto deploy directories");
    }

    AutoDeployUtil.unregisterDir(IMEX_AUTO_DEPLOY_DIR);

    try {
        if (PrefsPropsUtil.getBoolean(ImExPropsKeys.ENABLED, ImExPropsValues.ENABLED)) {

            if (_log.isInfoEnabled()) {
                _log.info("Registering IMEX auto deploy directories");
            }

            File deployDir = new File(
                    PrefsPropsUtil.getString(ImExPropsKeys.DEPLOY_DIR, ImExPropsValues.DEPLOY_DIR));
            long interval = PrefsPropsUtil.getLong(ImExPropsKeys.INTERVAL, ImExPropsValues.INTERVAL);
            int blacklistThreshold = PrefsPropsUtil.getInteger(ImExPropsKeys.BLACKLIST_THRESHOLD,
                    ImExPropsValues.BLACKLIST_THRESHOLD);

            List<AutoDeployListener> autoDeployListeners = getAutoDeployListeners();

            AutoDeployDir autoDeployDir = new ImExAutoDeployDir(IMEX_AUTO_DEPLOY_DIR, deployDir, interval,
                    blacklistThreshold, autoDeployListeners);

            AutoDeployUtil.registerDir(autoDeployDir);
        } else {
            if (_log.isInfoEnabled()) {
                _log.info("Not registering IMEX auto deploy directories");
            }
        }
    } catch (Exception e) {
        _log.error(e);
    }

    this.executed = true;
}

From source file:com.sqli.liferay.imex.servlet.ImExServletContextListener.java

License:Open Source License

@Override
protected void doPortalInit() throws Exception {

    if (_log.isInfoEnabled()) {
        _log.info("Unregistering IMEX auto deploy directories");
    }/* w  ww. ja  v a 2 s  . com*/

    AutoDeployUtil.unregisterDir(IMEX_AUTO_DEPLOY_DIR);

    try {
        if (PrefsPropsUtil.getBoolean(ImExPropsKeys.ENABLED, ImExPropsValues.ENABLED)) {

            if (_log.isInfoEnabled()) {
                _log.info("Registering IMEX auto deploy directories");
            }

            File deployDir = new File(
                    PrefsPropsUtil.getString(ImExPropsKeys.DEPLOY_DIR, ImExPropsValues.DEPLOY_DIR));
            long interval = PrefsPropsUtil.getLong(ImExPropsKeys.INTERVAL, ImExPropsValues.INTERVAL);
            int blacklistThreshold = PrefsPropsUtil.getInteger(ImExPropsKeys.BLACKLIST_THRESHOLD,
                    ImExPropsValues.BLACKLIST_THRESHOLD);

            List<AutoDeployListener> autoDeployListeners = getAutoDeployListeners();

            AutoDeployDir autoDeployDir = new ImExAutoDeployDir(IMEX_AUTO_DEPLOY_DIR, deployDir, interval,
                    blacklistThreshold, autoDeployListeners);

            AutoDeployUtil.registerDir(autoDeployDir);
        } else {
            if (_log.isInfoEnabled()) {
                _log.info("Not registering IMEX auto deploy directories");
            }
        }
    } catch (Exception e) {
        _log.error(e);
    }

}