Example usage for com.liferay.portal.util PrefsPropsUtil getPreferences

List of usage examples for com.liferay.portal.util PrefsPropsUtil getPreferences

Introduction

In this page you can find the example usage for com.liferay.portal.util PrefsPropsUtil getPreferences.

Prototype

public static PortletPreferences getPreferences() 

Source Link

Usage

From source file:com.liferay.portlet.admin.action.EditServerAction.java

License:Open Source License

@Override
public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    if (!permissionChecker.isOmniadmin()) {
        SessionErrors.add(actionRequest, PrincipalException.class.getName());

        setForward(actionRequest, "portlet.admin.error");

        return;/* w  w  w .  ja  v a2  s.  co m*/
    }

    PortletPreferences preferences = PrefsPropsUtil.getPreferences();

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    String redirect = null;

    if (cmd.equals("addLogLevel")) {
        addLogLevel(actionRequest);
    } else if (cmd.equals("cacheDb")) {
        cacheDb();
    } else if (cmd.equals("cacheMulti")) {
        cacheMulti();
    } else if (cmd.equals("cacheSingle")) {
        cacheSingle();
    } else if (cmd.equals("cleanUpPermissions")) {
        CleanUpPermissionsUtil.cleanUpAddToPagePermissions(actionRequest);
    } else if (cmd.startsWith("convertProcess.")) {
        redirect = convertProcess(actionRequest, actionResponse, cmd);
    } else if (cmd.equals("dlPreviews")) {
        DLPreviewableProcessor.deleteFiles();
    } else if (cmd.equals("gc")) {
        gc();
    } else if (cmd.equals("reindex")) {
        reindex(actionRequest);
    } else if (cmd.equals("runScript")) {
        runScript(portletConfig, actionRequest, actionResponse);
    } else if (cmd.equals("shutdown")) {
        shutdown(actionRequest);
    } else if (cmd.equals("threadDump")) {
        threadDump();
    } else if (cmd.equals("updateCaptcha")) {
        updateCaptcha(actionRequest, preferences);
    } else if (cmd.equals("updateExternalServices")) {
        updateExternalServices(actionRequest, preferences);
    } else if (cmd.equals("updateFileUploads")) {
        updateFileUploads(actionRequest, preferences);
    } else if (cmd.equals("updateLogLevels")) {
        updateLogLevels(actionRequest);
    } else if (cmd.equals("updateMail")) {
        updateMail(actionRequest, preferences);
    } else if (cmd.equals("verifyPluginTables")) {
        verifyPluginTables();
    }

    sendRedirect(actionRequest, actionResponse, redirect);
}

From source file:com.liferay.portlet.documentlibrary.util.PDFProcessorImpl.java

License:Open Source License

public String getGlobalSearchPath() throws Exception {
    PortletPreferences preferences = PrefsPropsUtil.getPreferences();

    String globalSearchPath = preferences.getValue(PropsKeys.IMAGEMAGICK_GLOBAL_SEARCH_PATH, null);

    if (Validator.isNotNull(globalSearchPath)) {
        return globalSearchPath;
    }//from   www .  ja  v a 2  s .co  m

    String filterName = null;

    if (OSDetector.isApple()) {
        filterName = "apple";
    } else if (OSDetector.isWindows()) {
        filterName = "windows";
    } else {
        filterName = "unix";
    }

    return PropsUtil.get(PropsKeys.IMAGEMAGICK_GLOBAL_SEARCH_PATH, new Filter(filterName));
}

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();// www.j  av a 2s.  co 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.liferay.portlet.plugininstaller.action.InstallPluginAction.java

License:Open Source License

protected void ignorePackages(ActionRequest actionRequest) throws Exception {

    String pluginPackagesIgnored = ParamUtil.getString(actionRequest, "pluginPackagesIgnored");

    String oldPluginPackagesIgnored = PrefsPropsUtil.getString(PropsKeys.PLUGIN_NOTIFICATIONS_PACKAGES_IGNORED);

    PortletPreferences preferences = PrefsPropsUtil.getPreferences();

    if (Validator.isNotNull(oldPluginPackagesIgnored)) {
        preferences.setValue(PropsKeys.PLUGIN_NOTIFICATIONS_PACKAGES_IGNORED,
                oldPluginPackagesIgnored.concat(StringPool.NEW_LINE).concat(pluginPackagesIgnored));
    } else {// w  w w . j a v a 2s  . c o  m
        preferences.setValue(PropsKeys.PLUGIN_NOTIFICATIONS_PACKAGES_IGNORED, pluginPackagesIgnored);
    }

    preferences.store();

    PluginPackageUtil.refreshUpdatesAvailableCache();
}

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

License:Open Source License

protected void unignorePackages(ActionRequest actionRequest) throws Exception {

    String[] pluginPackagesUnignored = StringUtil
            .splitLines(ParamUtil.getString(actionRequest, "pluginPackagesUnignored"));

    String[] pluginPackagesIgnored = PrefsPropsUtil.getStringArray(
            PropsKeys.PLUGIN_NOTIFICATIONS_PACKAGES_IGNORED, StringPool.NEW_LINE,
            PropsValues.PLUGIN_NOTIFICATIONS_PACKAGES_IGNORED);

    StringBundler sb = new StringBundler();

    for (int i = 0; i < pluginPackagesIgnored.length; i++) {
        String packageId = pluginPackagesIgnored[i];

        if (!ArrayUtil.contains(pluginPackagesUnignored, packageId)) {
            sb.append(packageId);//from   w  w  w . j a v a 2s.c o  m
            sb.append(StringPool.NEW_LINE);
        }
    }

    PortletPreferences preferences = PrefsPropsUtil.getPreferences();

    preferences.setValue(PropsKeys.PLUGIN_NOTIFICATIONS_PACKAGES_IGNORED, sb.toString());

    preferences.store();

    PluginPackageUtil.refreshUpdatesAvailableCache();
}

From source file:com.liferay.server.admin.web.internal.portlet.action.EditServerMVCActionCommand.java

License:Open Source License

@Override
public void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    if (!permissionChecker.isOmniadmin()) {
        SessionErrors.add(actionRequest, PrincipalException.MustBeOmniadmin.class.getName());

        actionResponse.setRenderParameter("mvcPath", "/error.jsp");

        return;/*from   w w  w.  j av  a2s.co  m*/
    }

    PortletPreferences portletPreferences = PrefsPropsUtil.getPreferences();

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    String redirect = ParamUtil.getString(actionRequest, "redirect");

    if (cmd.equals("addLogLevel")) {
        addLogLevel(actionRequest);
    } else if (cmd.equals("cacheDb")) {
        cacheDb();
    } else if (cmd.equals("cacheMulti")) {
        cacheMulti();
    } else if (cmd.equals("cacheServlet")) {
        cacheServlet();
    } else if (cmd.equals("cacheSingle")) {
        cacheSingle();
    } else if (cmd.equals("cleanUpPermissions")) {
        CleanUpPermissionsUtil.cleanUpAddToPagePermissions(actionRequest);
    } else if (cmd.equals("cleanUpPortletPreferences")) {
        CleanUpPortletPreferencesUtil.cleanUpLayoutRevisionPortletPreferences();
    } else if (cmd.startsWith("convertProcess.")) {
        redirect = convertProcess(actionRequest, actionResponse, cmd);
    } else if (cmd.equals("dlPreviews")) {
        DLPreviewableProcessor.deleteFiles();
    } else if (cmd.equals("gc")) {
        gc();
    } else if (cmd.equals("installXuggler")) {
        try {
            installXuggler(actionRequest, actionResponse);
        } catch (XugglerInstallException xie) {
            SessionErrors.add(actionRequest, XugglerInstallException.class.getName(), xie);
        }
    } else if (cmd.equals("reindex")) {
        reindex(actionRequest);
    } else if (cmd.equals("reindexDictionaries")) {
        reindexDictionaries(actionRequest);
    } else if (cmd.equals("runScript")) {
        runScript(actionRequest, actionResponse);
    } else if (cmd.equals("shutdown")) {
        shutdown(actionRequest);
    } else if (cmd.equals("threadDump")) {
        threadDump();
    } else if (cmd.equals("updateExternalServices")) {
        updateExternalServices(actionRequest, portletPreferences);
    } else if (cmd.equals("updateLogLevels")) {
        updateLogLevels(actionRequest);
    } else if (cmd.equals("updateMail")) {
        updateMail(actionRequest, portletPreferences);
    } else if (cmd.equals("verifyMembershipPolicies")) {
        verifyMembershipPolicies();
    } else if (cmd.equals("verifyPluginTables")) {
        verifyPluginTables();
    }

    sendRedirect(actionRequest, actionResponse, redirect);
}