Example usage for com.liferay.portal.kernel.util StringUtil add

List of usage examples for com.liferay.portal.kernel.util StringUtil add

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util StringUtil add.

Prototype

public static String add(String s, String add) 

Source Link

Document

Adds string add to string s resulting in a comma delimited list of strings, disallowing duplicate strings in the list.

Usage

From source file:com.liferay.mail.service.impl.MessageLocalServiceImpl.java

License:Open Source License

public Message updateFlag(long messageId, int flag, boolean value) throws PortalException {

    String flagString = String.valueOf(flag);

    Message message = messagePersistence.findByPrimaryKey(messageId);

    String flags = message.getFlags();

    if (value && !StringUtil.contains(flags, flagString)) {
        message.setFlags(StringUtil.add(flags, flagString));
    } else if (!value && StringUtil.contains(flags, flagString)) {
        message.setFlags(StringUtil.remove(flags, flagString));
    }/*from   ww w .j  av  a  2  s  .  com*/

    return messagePersistence.update(message);
}

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  .  j  av a 2 s .  c om

    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.so.hook.upgrade.v1_5_1.UpgradeGroup.java

License:Open Source License

protected void updatePortlets(Group group, Layout layout) throws Exception {
    String prefix = PortletPropsKeys.SITE_PROTOTYPE_PORTLETS;

    Filter filter = new Filter(layout.getFriendlyURL());

    if (group.isUser()) {
        prefix = PortletPropsKeys.USER_PRIVATE_LAYOUT_PORTLETS;
    }//from  w ww .j  a  v  a 2  s.c  om

    LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType();

    LayoutTemplate layoutTemplate = layoutTypePortlet.getLayoutTemplate();

    List<String> columns = layoutTemplate.getColumns();

    for (String column : columns) {
        String[] portletIds = PortletProps.getArray(prefix + column, filter);

        String portlets = StringPool.BLANK;

        for (String portletId : portletIds) {
            portlets = StringUtil.add(portlets, portletId);
        }

        layoutTypePortlet.setPortletIds(column, portlets);
    }

    if (!layoutTypePortlet.hasPortletId("1_WAR_soportlet")) {
        return;
    }

    PortletPreferences portletSetup = PortletPreferencesFactoryUtil.getLayoutPortletSetup(layout,
            "1_WAR_soportlet");

    portletSetup.setValue("portletSetupShowBorders", String.valueOf(Boolean.TRUE));

    portletSetup.store();
}