Example usage for com.liferay.portal.kernel.util StringPool NEW_LINE

List of usage examples for com.liferay.portal.kernel.util StringPool NEW_LINE

Introduction

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

Prototype

String NEW_LINE

To view the source code for com.liferay.portal.kernel.util StringPool NEW_LINE.

Click Source Link

Usage

From source file:com.liferay.jira.metrics.util.graph.GraphData.java

License:Open Source License

public String getGraphSeriesStyles() {
    if (_series != null) {
        StringBundler sb = new StringBundler(19);

        sb.append(StringPool.BLANK);/*ww w  . j  av  a2 s .  co m*/

        for (int i = 0; i < _series.size(); i++) {
            String serie = _series.get(i);

            concatObjectOpener(sb, serie);

            concatObjectOpener(sb, "area");

            concatQuotedAttribute(sb, "color", _BACKGROUND_COLORS[i]);

            concatCloseAndContinue(sb);

            concatObjectOpener(sb, "marker");

            concatObjectOpener(sb, "fill");

            concatQuotedAttribute(sb, "color", _BACKGROUND_COLORS[i]);

            concatCloseAndContinue(sb);

            concatObjectOpener(sb, "border");

            concatQuotedAttribute(sb, "color", _LINES_COLORS[i]);

            concatCloseAndContinue(sb);

            concatObjectOpener(sb, "over");

            concatObjectOpener(sb, "fill");

            concatQuotedAttribute(sb, "color", _LINES_COLORS[i]);

            concatCloseAndContinue(sb);

            concatObjectOpener(sb, "border");

            concatQuotedAttribute(sb, "color", _LINES_COLORS[i]);

            concatCloseAndContinue(sb);

            concatAttributeAndContinue(sb, "width", "12");
            concatAttribute(sb, "height", "12");

            concatCloseAndContinue(sb);

            concatCloseAndContinue(sb);

            concatObjectOpener(sb, "line");

            concatQuotedAttribute(sb, "color", _LINES_COLORS[i]);

            sb.append(StringPool.CLOSE_CURLY_BRACE);

            sb.append(StringPool.CLOSE_CURLY_BRACE);

            if (i != (_series.size() - 1)) {
                sb.append(StringPool.COMMA);
                sb.append(StringPool.NEW_LINE);
            }
        }

        return sb.toString();
    }

    return null;
}

From source file:com.liferay.jira.metrics.util.graph.GraphData.java

License:Open Source License

public String getStringData() {
    if (_data != null) {
        StringBundler sb = new StringBundler(23);

        sb.append(StringPool.BLANK);//from w  ww. j a va2s  .co  m

        for (Date date : _data.keySet()) {
            String stringDate = _formatter.format(date);

            if (!StringPool.BLANK.equals(sb.toString())) {
                sb.append(StringPool.COMMA);
                sb.append(StringPool.NEW_LINE);
            }

            sb.append(StringPool.OPEN_CURLY_BRACE);

            concatQuotedAttribute(sb, "date", stringDate);

            for (Values value : _data.get(date)) {
                sb.append(StringPool.COMMA);

                concatAttribute(sb, value.getSerieName(), String.valueOf(value.getValue()));
            }

            sb.append(StringPool.CLOSE_CURLY_BRACE);
        }

        return sb.toString();
    }

    return null;
}

From source file:com.liferay.localization.zh.util.LocalizationZHUtil.java

License:Open Source License

private LocalizationZHUtil() {
    try {// www  .j  a  v  a 2 s. c om
        Class<?> clazz = getClass();

        InputStream inputStream = clazz.getResourceAsStream("dependencies/zh_CN-to-zh_TW.txt");

        String[] lines = StringUtil.split(StringUtil.read(inputStream), StringPool.NEW_LINE);

        for (String line : lines) {
            char simplifiedChar = line.charAt(0);
            char traditionalChar = line.charAt(2);

            _simplifiedCharactersToTraditionalCharactersMap.put(simplifiedChar, traditionalChar);
            _traditionalCharactersToSimplifiedCharactersMap.put(traditionalChar, simplifiedChar);
        }
    } catch (Exception e) {
        _log.error(e, e);
    }
}

From source file:com.liferay.netvibeswidget.action.ConfigurationActionImpl.java

License:Open Source License

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

    String[] htmlAttributes = StringUtil.split(getParameter(actionRequest, "htmlAttributes"),
            StringPool.NEW_LINE);

    for (String htmlAttribute : htmlAttributes) {
        int pos = htmlAttribute.indexOf(StringPool.EQUAL);

        if (pos == -1) {
            continue;
        }/*from w  ww . j  a  v  a2s  . c  om*/

        String key = htmlAttribute.substring(0, pos);
        String value = htmlAttribute.substring(pos + 1);

        setPreference(actionRequest, key, value);
    }

    super.processAction(portletConfig, actionRequest, actionResponse);
}

From source file:com.liferay.opensocial.shindig.oauth.LiferayOAuthStoreProvider.java

License:Open Source License

private String _convertFromOpenSsl(String key) {
    key = key.replaceAll(_OPEN_SSL_A_Z, StringPool.BLANK);
    key = key.replace(StringPool.NEW_LINE, StringPool.BLANK);

    return key;
}

From source file:com.liferay.portlet.dynamicdatalists.util.DDLCSVExporter.java

License:Open Source License

@Override
protected byte[] doExport(long recordSetId, int status, int start, int end, OrderByComparator orderByComparator)
        throws Exception {

    DDLRecordSet recordSet = DDLRecordSetServiceUtil.getRecordSet(recordSetId);

    DDMStructure ddmStructure = recordSet.getDDMStructure();

    Map<String, Map<String, String>> fieldsMap = ddmStructure.getFieldsMap();

    StringBundler sb = new StringBundler();

    for (Map<String, String> fieldMap : fieldsMap.values()) {
        String label = fieldMap.get(FieldConstants.LABEL);

        sb.append(label);/*from  w  w  w  .  j  a  v a  2  s. c o m*/
        sb.append(CharPool.COMMA);
    }

    sb.setIndex(sb.index() - 1);
    sb.append(StringPool.NEW_LINE);

    List<DDLRecord> records = DDLRecordLocalServiceUtil.getRecords(recordSetId, status, start, end,
            orderByComparator);

    for (DDLRecord record : records) {
        Fields fields = record.getFields();

        for (Map<String, String> fieldMap : fieldsMap.values()) {
            String name = fieldMap.get(FieldConstants.NAME);

            Field field = fields.get(name);

            Serializable value = field.getValue();

            sb.append(CSVUtil.encode(value));
            sb.append(CharPool.COMMA);
        }

        sb.setIndex(sb.index() - 1);
        sb.append(StringPool.NEW_LINE);
    }

    String csv = sb.toString();

    return csv.getBytes();
}

From source file:com.liferay.portlet.expando.action.EditExpandoAction.java

License:Open Source License

protected Serializable getValue(PortletRequest portletRequest, String name, int type)
        throws PortalException, SystemException {

    String delimiter = StringPool.COMMA;

    Serializable value = null;//ww  w  . j  a  va2 s .c o  m

    if (type == ExpandoColumnConstants.BOOLEAN) {
        value = ParamUtil.getBoolean(portletRequest, name);
    } else if (type == ExpandoColumnConstants.BOOLEAN_ARRAY) {
    } else if (type == ExpandoColumnConstants.DATE) {
        User user = PortalUtil.getUser(portletRequest);

        int valueDateMonth = ParamUtil.getInteger(portletRequest, name + "Month");
        int valueDateDay = ParamUtil.getInteger(portletRequest, name + "Day");
        int valueDateYear = ParamUtil.getInteger(portletRequest, name + "Year");
        int valueDateHour = ParamUtil.getInteger(portletRequest, name + "Hour");
        int valueDateMinute = ParamUtil.getInteger(portletRequest, name + "Minute");
        int valueDateAmPm = ParamUtil.getInteger(portletRequest, name + "AmPm");

        if (valueDateAmPm == Calendar.PM) {
            valueDateHour += 12;
        }

        value = PortalUtil.getDate(valueDateMonth, valueDateDay, valueDateYear, valueDateHour, valueDateMinute,
                user.getTimeZone(), new ValueDataException());
    } else if (type == ExpandoColumnConstants.DATE_ARRAY) {
    } else if (type == ExpandoColumnConstants.DOUBLE) {
        value = ParamUtil.getDouble(portletRequest, name);
    } else if (type == ExpandoColumnConstants.DOUBLE_ARRAY) {
        String paramValue = ParamUtil.getString(portletRequest, name);

        if (paramValue.contains(StringPool.NEW_LINE)) {
            delimiter = StringPool.NEW_LINE;
        }

        String[] values = StringUtil.split(paramValue, delimiter);

        value = GetterUtil.getDoubleValues(values);
    } else if (type == ExpandoColumnConstants.FLOAT) {
        value = ParamUtil.getFloat(portletRequest, name);
    } else if (type == ExpandoColumnConstants.FLOAT_ARRAY) {
        String paramValue = ParamUtil.getString(portletRequest, name);

        if (paramValue.contains(StringPool.NEW_LINE)) {
            delimiter = StringPool.NEW_LINE;
        }

        String[] values = StringUtil.split(paramValue, delimiter);

        value = GetterUtil.getFloatValues(values);
    } else if (type == ExpandoColumnConstants.INTEGER) {
        value = ParamUtil.getInteger(portletRequest, name);
    } else if (type == ExpandoColumnConstants.INTEGER_ARRAY) {
        String paramValue = ParamUtil.getString(portletRequest, name);

        if (paramValue.contains(StringPool.NEW_LINE)) {
            delimiter = StringPool.NEW_LINE;
        }

        String[] values = StringUtil.split(paramValue, delimiter);

        value = GetterUtil.getIntegerValues(values);
    } else if (type == ExpandoColumnConstants.LONG) {
        value = ParamUtil.getLong(portletRequest, name);
    } else if (type == ExpandoColumnConstants.LONG_ARRAY) {
        String paramValue = ParamUtil.getString(portletRequest, name);

        if (paramValue.contains(StringPool.NEW_LINE)) {
            delimiter = StringPool.NEW_LINE;
        }

        String[] values = StringUtil.split(paramValue, delimiter);

        value = GetterUtil.getLongValues(values);
    } else if (type == ExpandoColumnConstants.SHORT) {
        value = ParamUtil.getShort(portletRequest, name);
    } else if (type == ExpandoColumnConstants.SHORT_ARRAY) {
        String paramValue = ParamUtil.getString(portletRequest, name);

        if (paramValue.contains(StringPool.NEW_LINE)) {
            delimiter = StringPool.NEW_LINE;
        }

        String[] values = StringUtil.split(paramValue, delimiter);

        value = GetterUtil.getShortValues(values);
    } else if (type == ExpandoColumnConstants.STRING_ARRAY) {
        String paramValue = ParamUtil.getString(portletRequest, name);

        if (paramValue.contains(StringPool.NEW_LINE)) {
            delimiter = StringPool.NEW_LINE;
        }

        value = StringUtil.split(paramValue, delimiter);
    } else {
        value = ParamUtil.getString(portletRequest, name);
    }

    return value;
}

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  2  s .  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);// w w w  .ja  v a 2 s .co  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.portlet.usersadmin.action.ExportUsersAction.java

License:Open Source License

protected String getUserCSV(User user) {
    StringBundler sb = new StringBundler(PropsValues.USERS_EXPORT_CSV_FIELDS.length * 2);

    for (int i = 0; i < PropsValues.USERS_EXPORT_CSV_FIELDS.length; i++) {
        String field = PropsValues.USERS_EXPORT_CSV_FIELDS[i];

        if (field.equals("fullName")) {
            sb.append(CSVUtil.encode(user.getFullName()));
        } else if (field.startsWith("expando:")) {
            String attributeName = field.substring(8);

            ExpandoBridge expandoBridge = user.getExpandoBridge();

            sb.append(CSVUtil.encode(expandoBridge.getAttribute(attributeName)));
        } else {//from   w ww .  java 2  s. c  o m
            sb.append(CSVUtil.encode(BeanPropertiesUtil.getString(user, field)));
        }

        if ((i + 1) < PropsValues.USERS_EXPORT_CSV_FIELDS.length) {
            sb.append(StringPool.COMMA);
        }
    }

    sb.append(StringPool.NEW_LINE);

    return sb.toString();
}