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

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

Introduction

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

Prototype

public static String getString(String name) 

Source Link

Usage

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

License:Open Source License

private DocumentConverter _getDocumentConverter() throws SystemException {
    if ((_openOfficeConnection != null) && (_documentConverter != null)) {
        return _documentConverter;
    }//from  w w w.j av  a  2 s. c  o m

    String host = PrefsPropsUtil.getString(PropsKeys.OPENOFFICE_SERVER_HOST);
    int port = PrefsPropsUtil.getInteger(PropsKeys.OPENOFFICE_SERVER_PORT, PropsValues.OPENOFFICE_SERVER_PORT);

    if (_isRemoteOpenOfficeHost(host)) {
        _openOfficeConnection = new SocketOpenOfficeConnection(host, port);
        _documentConverter = new StreamOpenOfficeDocumentConverter(_openOfficeConnection);
    } else {
        _openOfficeConnection = new SocketOpenOfficeConnection(port);
        _documentConverter = new OpenOfficeDocumentConverter(_openOfficeConnection);
    }

    return _documentConverter;
}

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 {/*from  ww  w .  j a  v  a 2  s.co  m*/
        preferences.setValue(PropsKeys.PLUGIN_NOTIFICATIONS_PACKAGES_IGNORED, pluginPackagesIgnored);
    }

    preferences.store();

    PluginPackageUtil.refreshUpdatesAvailableCache();
}

From source file:com.liferay.portlet.portalsettings.action.EditLDAPServerAction.java

License:Open Source License

protected UnicodeProperties addLDAPServer(long companyId, UnicodeProperties properties) throws Exception {

    String defaultPostfix = LDAPSettingsUtil.getPropertyPostfix(0);

    String[] defaultKeys = new String[_KEYS.length];

    for (int i = 0; i < _KEYS.length; i++) {
        defaultKeys[i] = _KEYS[i] + defaultPostfix;
    }/* w  w  w.ja v a 2s  . c  o  m*/

    long ldapServerId = CounterLocalServiceUtil.increment();

    String postfix = LDAPSettingsUtil.getPropertyPostfix(ldapServerId);

    String[] keys = properties.keySet().toArray(new String[0]);

    for (String key : keys) {
        if (ArrayUtil.contains(defaultKeys, key)) {
            String value = properties.remove(key);

            if (key.equals(PropsKeys.LDAP_SECURITY_CREDENTIALS + defaultPostfix)
                    && value.equals(Portal.TEMP_OBFUSCATION_VALUE)) {

                value = PrefsPropsUtil.getString(PropsKeys.LDAP_SECURITY_CREDENTIALS);
            }

            properties.setProperty(key.replace(defaultPostfix, postfix), value);
        }
    }

    PortletPreferences preferences = PrefsPropsUtil.getPreferences(companyId);

    String ldapServerIds = preferences.getValue("ldap.server.ids", StringPool.BLANK);

    ldapServerIds = StringUtil.add(ldapServerIds, String.valueOf(ldapServerId));

    properties.setProperty("ldap.server.ids", ldapServerIds);

    return properties;
}

From source file:com.liferay.portlet.wiki.action.ExportPageAction.java

License:Open Source License

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

    try {/*from   w  ww. j  a va  2s  . com*/
        long nodeId = ParamUtil.getLong(actionRequest, "nodeId");
        String nodeName = ParamUtil.getString(actionRequest, "nodeName");
        String title = ParamUtil.getString(actionRequest, "title");
        double version = ParamUtil.getDouble(actionRequest, "version");

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

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

        PortletURL viewPageURL = new PortletURLImpl(actionRequest, portletConfig.getPortletName(),
                themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

        viewPageURL.setPortletMode(PortletMode.VIEW);
        viewPageURL.setWindowState(WindowState.MAXIMIZED);
        viewPageURL.setParameter("struts_action", "/wiki/view");
        viewPageURL.setParameter("nodeName", nodeName);
        viewPageURL.setParameter("title", title);

        PortletURL editPageURL = new PortletURLImpl(actionRequest, portletConfig.getPortletName(),
                themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

        editPageURL.setPortletMode(PortletMode.VIEW);
        editPageURL.setWindowState(WindowState.MAXIMIZED);
        editPageURL.setParameter("struts_action", "/wiki/edit_page");
        editPageURL.setParameter("nodeId", String.valueOf(nodeId));
        editPageURL.setParameter("title", title);

        HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest);
        HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse);

        getFile(nodeId, title, version, targetExtension, viewPageURL, editPageURL, themeDisplay, request,
                response);

        setForward(actionRequest, ActionConstants.COMMON_NULL);
    } catch (Exception e) {
        String host = PrefsPropsUtil.getString(PropsKeys.OPENOFFICE_SERVER_HOST);

        if (Validator.isNotNull(host) && !host.equals(_LOCALHOST_IP) && !host.startsWith(_LOCALHOST)) {

            StringBundler sb = new StringBundler(3);

            sb.append("Conversion using a remote OpenOffice instance is ");
            sb.append("not fully supported. Please use a local instance ");
            sb.append("to prevent any limitations and problems.");

            _log.error(sb.toString());
        }

        PortalUtil.sendError(e, actionRequest, actionResponse);
    }
}

From source file:com.liferay.wiki.web.internal.portlet.action.ExportPageMVCActionCommand.java

License:Open Source License

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

    PortletConfig portletConfig = getPortletConfig(actionRequest);

    try {//from   w w  w .  ja v a2  s.  co  m
        long nodeId = ParamUtil.getLong(actionRequest, "nodeId");
        String nodeName = ParamUtil.getString(actionRequest, "nodeName");
        String title = ParamUtil.getString(actionRequest, "title");
        double version = ParamUtil.getDouble(actionRequest, "version");

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

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

        PortletURL viewPageURL = PortletURLFactoryUtil.create(actionRequest, portletConfig.getPortletName(),
                PortletRequest.RENDER_PHASE);

        viewPageURL.setParameter("mvcRenderCommandName", "/wiki/view");
        viewPageURL.setParameter("nodeName", nodeName);
        viewPageURL.setParameter("title", title);
        viewPageURL.setPortletMode(PortletMode.VIEW);
        viewPageURL.setWindowState(WindowState.MAXIMIZED);

        PortletURL editPageURL = PortletURLFactoryUtil.create(actionRequest, portletConfig.getPortletName(),
                PortletRequest.RENDER_PHASE);

        editPageURL.setParameter("mvcRenderCommandName", "/wiki/edit_page");
        editPageURL.setParameter("nodeId", String.valueOf(nodeId));
        editPageURL.setParameter("title", title);
        editPageURL.setPortletMode(PortletMode.VIEW);
        editPageURL.setWindowState(WindowState.MAXIMIZED);

        HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest);
        HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse);

        getFile(nodeId, title, version, targetExtension, viewPageURL, editPageURL, themeDisplay, request,
                response);

        actionResponse.setRenderParameter("mvcPath", "/null.jsp");
    } catch (Exception e) {
        String host = PrefsPropsUtil.getString(PropsKeys.OPENOFFICE_SERVER_HOST);

        if (Validator.isNotNull(host) && !host.equals(_LOCALHOST_IP) && !host.startsWith(_LOCALHOST)) {

            StringBundler sb = new StringBundler(3);

            sb.append("Conversion using a remote OpenOffice instance is ");
            sb.append("not fully supported. Please use a local instance ");
            sb.append("to prevent any limitations and problems.");

            _log.error(sb.toString());
        }

        PortalUtil.sendError(e, actionRequest, actionResponse);
    }
}