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

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

Introduction

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

Prototype

String EQUAL

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

Click Source Link

Usage

From source file:com.liferay.knowledgebase.admin.importer.util.KBArticleMarkdownConverter.java

License:Open Source License

protected String stripIds(String content) {
    int index = content.indexOf("[](id=");

    if (index == -1) {
        return content;
    }// www.j  a va  2  s .  c  o m

    StringBundler sb = new StringBundler();

    do {
        int x = content.indexOf(StringPool.EQUAL, index);
        int y = content.indexOf(StringPool.CLOSE_PARENTHESIS, x);

        if (y != -1) {
            sb.append(StringUtil.trimTrailing(content.substring(0, index)));

            content = content.substring(y + 1);
        } else {
            if (_log.isWarnEnabled()) {
                String msg = content.substring(index);

                // Get the invalid id text from the content

                int spaceIndex = content.indexOf(StringPool.SPACE);

                if (spaceIndex != -1) {
                    msg = content.substring(index, spaceIndex);
                }

                _log.warn("Missing ')' for web content containing header id " + msg);
            }

            // Since no close parenthesis remains in the content, stop
            // stripping out IDs and simply include all of the remaining
            // content

            break;
        }
    } while ((index = content.indexOf("[](id=")) != -1);

    sb.append(content);

    return sb.toString();
}

From source file:com.liferay.knowledgebase.util.KnowledgeBaseUtil.java

License:Open Source License

public static String getKBArticleURL(long plid, long resourcePrimKey, int status, String portalURL,
        boolean maximized) {

    StringBundler sb = new StringBundler(11);

    sb.append(portalURL);// w w  w.jav a 2s  . c  om
    sb.append(PortalUtil.getPathMain());
    sb.append("/portal/knowledge_base/find_kb_article");
    sb.append(StringPool.QUESTION);
    sb.append("plid");
    sb.append(StringPool.EQUAL);
    sb.append(String.valueOf(plid));
    sb.append(StringPool.AMPERSAND);
    sb.append("resourcePrimKey");
    sb.append(StringPool.EQUAL);
    sb.append(String.valueOf(resourcePrimKey));

    String url = sb.toString();

    if (status != WorkflowConstants.STATUS_APPROVED) {
        url = url.concat(StringPool.AMPERSAND).concat("status").concat(StringPool.EQUAL)
                .concat(String.valueOf(status));
    }

    if (maximized) {
        url = url.concat(StringPool.AMPERSAND).concat("maximized").concat(StringPool.EQUAL)
                .concat(String.valueOf(maximized));
    }

    return url;
}

From source file:com.liferay.message.boards.parser.bbcode.internal.HtmlBBCodeTranslatorImpl.java

License:Open Source License

protected void handleImageAttributes(StringBundler sb, String attributes) {
    Matcher matcher = _attributesPattern.matcher(attributes);

    while (matcher.find()) {
        String attributeName = matcher.group(1);

        if (Validator.isNotNull(attributeName)
                && _imageAttributes.contains(StringUtil.toLowerCase(attributeName))) {

            String attributeValue = matcher.group(2);

            sb.append(StringPool.SPACE);
            sb.append(attributeName);/*from   ww w.j  a v a2  s . c  o  m*/
            sb.append(StringPool.EQUAL);
            sb.append(StringPool.QUOTE);
            sb.append(HtmlUtil.escapeAttribute(attributeValue));
            sb.append(StringPool.QUOTE);
        }
    }
}

From source file:com.liferay.message.boards.web.internal.portlet.action.MBAdminConfigurationAction.java

License:Open Source License

protected boolean isValidUserRank(String rank) {
    if ((StringUtil.count(rank, CharPool.EQUAL) != 1) || rank.startsWith(StringPool.EQUAL)
            || rank.endsWith(StringPool.EQUAL)) {

        return false;
    }//from w w  w  .  j  a  va 2 s. c  om

    return true;
}

From source file:com.liferay.message.boards.web.internal.portlet.action.MBAdminConfigurationAction.java

License:Open Source License

protected void updateUserRanks(ActionRequest actionRequest) {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    for (Locale locale : LanguageUtil.getAvailableLocales(themeDisplay.getSiteGroupId())) {

        String languageId = LocaleUtil.toLanguageId(locale);

        String[] ranks = StringUtil.splitLines(ParamUtil.getString(actionRequest, "ranks_" + languageId));

        Map<String, String> map = new TreeMap<>(new NaturalOrderStringComparator());

        for (String rank : ranks) {
            if (!isValidUserRank(rank)) {
                SessionErrors.add(actionRequest, "userRank");

                return;
            }/*from  w  w  w  .  j  a  va 2 s  . co m*/

            String[] kvp = StringUtil.split(rank, CharPool.EQUAL);

            String kvpName = kvp[0];
            String kvpValue = kvp[1];

            map.put(kvpValue, kvpName);
        }

        ranks = new String[map.size()];

        int count = 0;

        for (Map.Entry<String, String> entry : map.entrySet()) {
            String kvpValue = entry.getKey();
            String kvpName = entry.getValue();

            ranks[count++] = kvpName + StringPool.EQUAL + kvpValue;
        }

        String preferenceName = LocalizationUtil.getLocalizedName("ranks", languageId);

        setPreference(actionRequest, preferenceName, ranks);
    }
}

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);//from  ww w .j  a v  a2  s  . c  om

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

        if (pos == -1) {
            continue;
        }

        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.portlet.admin.action.EditServerAction.java

License:Open Source License

protected String convertProcess(ActionRequest actionRequest, ActionResponse actionResponse, String cmd)
        throws Exception {

    ActionResponseImpl actionResponseImpl = (ActionResponseImpl) actionResponse;

    PortletSession portletSession = actionRequest.getPortletSession();

    String className = StringUtil.replaceFirst(cmd, "convertProcess.", StringPool.BLANK);

    ConvertProcess convertProcess = (ConvertProcess) InstancePool.get(className);

    String[] parameters = convertProcess.getParameterNames();

    if (parameters != null) {
        String[] values = new String[parameters.length];

        for (int i = 0; i < parameters.length; i++) {
            String parameter = className + StringPool.PERIOD + parameters[i];

            if (parameters[i].contains(StringPool.EQUAL)) {
                String[] parameterPair = StringUtil.split(parameters[i], CharPool.EQUAL);

                parameter = className + StringPool.PERIOD + parameterPair[0];
            }/* w  w  w  .  ja  v  a 2 s  .  co m*/

            values[i] = ParamUtil.getString(actionRequest, parameter);
        }

        convertProcess.setParameterValues(values);
    }

    String path = convertProcess.getPath();

    if (path != null) {
        PortletURL portletURL = actionResponseImpl.createRenderURL();

        portletURL.setWindowState(WindowState.MAXIMIZED);

        portletURL.setParameter("struts_action", path);

        return portletURL.toString();
    } else {
        MaintenanceUtil.maintain(portletSession.getId(), className);

        MessageBusUtil.sendMessage(DestinationNames.CONVERT_PROCESS, className);

        return null;
    }
}

From source file:com.liferay.portlet.asset.model.BaseAssetRenderer.java

License:Open Source License

protected String getURLViewInContext(LiferayPortletRequest liferayPortletRequest, String noSuchEntryRedirect,
        String path, String primaryKeyParameterName, long primaryKeyParameterValue) {

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

    StringBundler sb = new StringBundler(11);

    sb.append(themeDisplay.getPortalURL());
    sb.append(themeDisplay.getPathMain());
    sb.append(path);//from  www  .  ja va  2  s .co  m
    sb.append("?p_l_id=");
    sb.append(themeDisplay.getPlid());
    sb.append("&noSuchEntryRedirect=");
    sb.append(HttpUtil.encodeURL(noSuchEntryRedirect));
    sb.append(StringPool.AMPERSAND);
    sb.append(primaryKeyParameterName);
    sb.append(StringPool.EQUAL);
    sb.append(primaryKeyParameterValue);

    return sb.toString();
}

From source file:com.liferay.portlet.asset.service.persistence.AssetEntryFinderImpl.java

License:Open Source License

protected SQLQuery buildAssetQuerySQL(AssetEntryQuery entryQuery, boolean count, Session session) {

    StringBundler sb = new StringBundler();

    if (count) {/*from w  w  w.  j  a  v a 2 s .  co  m*/
        sb.append("SELECT COUNT(DISTINCT AssetEntry.entryId) AS COUNT_VALUE ");
    } else {
        sb.append("SELECT DISTINCT {AssetEntry.*} ");

        String orderByCol1 = entryQuery.getOrderByCol1();
        String orderByCol2 = entryQuery.getOrderByCol2();

        if (orderByCol1.equals("ratings") || orderByCol2.equals("ratings")) {

            sb.append(", RatingsEntry.score ");
        }
    }

    sb.append("FROM AssetEntry ");

    if (entryQuery.getAnyTagIds().length > 0) {
        sb.append("INNER JOIN ");
        sb.append("AssetEntries_AssetTags ON ");
        sb.append("(AssetEntries_AssetTags.entryId = ");
        sb.append("AssetEntry.entryId) ");
        sb.append("INNER JOIN ");
        sb.append("AssetTag ON ");
        sb.append("(AssetTag.tagId = AssetEntries_AssetTags.tagId) ");
    }

    if (entryQuery.getAnyCategoryIds().length > 0) {
        sb.append("INNER JOIN ");
        sb.append("AssetEntries_AssetCategories ON ");
        sb.append("(AssetEntries_AssetCategories.entryId = ");
        sb.append("AssetEntry.entryId) ");
        sb.append("INNER JOIN ");
        sb.append("AssetCategory ON ");
        sb.append("(AssetCategory.categoryId = ");
        sb.append("AssetEntries_AssetCategories.categoryId) ");
    }

    if (entryQuery.getLinkedAssetEntryId() > 0) {
        sb.append("INNER JOIN ");
        sb.append("AssetLink ON ");
        sb.append("(AssetEntry.entryId = AssetLink.entryId1) ");
        sb.append("OR (AssetEntry.entryId = AssetLink.entryId2)");
    }

    if (entryQuery.getOrderByCol1().equals("ratings") || entryQuery.getOrderByCol2().equals("ratings")) {

        sb.append(" LEFT JOIN ");
        sb.append("RatingsEntry ON ");
        sb.append("(RatingsEntry.classNameId = ");
        sb.append("AssetEntry.classNameId) AND ");
        sb.append("(RatingsEntry.classPK = AssetEntry.classPK)");
    }

    sb.append("WHERE ");

    int whereIndex = sb.index();

    if (entryQuery.getLinkedAssetEntryId() > 0) {
        sb.append(" AND ((AssetLink.entryId1 = ?) OR ");
        sb.append("(AssetLink.entryId2 = ?))");
        sb.append(" AND (AssetEntry.entryId != ?)");
    }

    if (entryQuery.isVisible() != null) {
        sb.append(" AND (visible = ?)");
    }

    if (entryQuery.isExcludeZeroViewCount()) {
        sb.append(" AND (AssetEntry.viewCount > 0)");
    }

    // Layout

    Layout layout = entryQuery.getLayout();

    if (layout != null) {
        sb.append(" AND (AssetEntry.layoutUuid = ?)");
    }

    // Category conditions

    if (entryQuery.getAllCategoryIds().length > 0) {
        if (PropsValues.ASSET_CATEGORIES_SEARCH_HIERARCHICAL) {
            buildAllCategoriesSQL(FIND_BY_AND_CATEGORY_IDS_TREE, entryQuery.getAllCategoryIds(), sb);
        } else {
            buildAllCategoriesSQL(FIND_BY_AND_CATEGORY_IDS, entryQuery.getAllCategoryIds(), sb);
        }
    }

    if (entryQuery.getAnyCategoryIds().length > 0) {
        if (PropsValues.ASSET_CATEGORIES_SEARCH_HIERARCHICAL) {
            sb.append(getCategoryIds(FIND_BY_AND_CATEGORY_IDS_TREE, entryQuery.getAnyCategoryIds()));
        } else {
            sb.append(getCategoryIds(FIND_BY_AND_CATEGORY_IDS, entryQuery.getAnyCategoryIds()));
        }
    }

    if (entryQuery.getNotAllCategoryIds().length > 0) {
        if (PropsValues.ASSET_CATEGORIES_SEARCH_HIERARCHICAL) {
            buildNotAnyCategoriesSQL(FIND_BY_AND_CATEGORY_IDS_TREE, entryQuery.getNotAllCategoryIds(), sb);
        } else {
            buildNotAnyCategoriesSQL(FIND_BY_AND_CATEGORY_IDS, entryQuery.getNotAllCategoryIds(), sb);
        }
    }

    if (entryQuery.getNotAnyCategoryIds().length > 0) {
        sb.append(" AND (");

        if (PropsValues.ASSET_CATEGORIES_SEARCH_HIERARCHICAL) {
            sb.append(getNotCategoryIds(FIND_BY_AND_CATEGORY_IDS_TREE, entryQuery.getNotAnyCategoryIds()));
        } else {
            sb.append(getNotCategoryIds(FIND_BY_AND_CATEGORY_IDS, entryQuery.getNotAnyCategoryIds()));
        }

        sb.append(") ");
    }

    // Asset entry subtypes

    if (entryQuery.getClassTypeIds().length > 0) {
        buildClassTypeIdsSQL(entryQuery.getClassTypeIds(), sb);
    }

    // Tag conditions

    if (entryQuery.getAllTagIds().length > 0) {
        buildAllTagsSQL(entryQuery.getAllTagIds(), sb);
    }

    if (entryQuery.getAnyTagIds().length > 0) {
        sb.append(" AND (");
        sb.append(getTagIds(entryQuery.getAnyTagIds(), StringPool.EQUAL));
        sb.append(") ");
    }

    if (entryQuery.getNotAllTagIds().length > 0) {
        buildNotAnyTagsSQL(entryQuery.getNotAllTagIds(), sb);
    }

    if (entryQuery.getNotAnyTagIds().length > 0) {
        sb.append(" AND (");
        sb.append(getNotTagIds(entryQuery.getNotAnyTagIds()));
        sb.append(") ");
    }

    // Other conditions

    sb.append(getDates(entryQuery.getPublishDate(), entryQuery.getExpirationDate()));
    sb.append(getGroupIds(entryQuery.getGroupIds()));
    sb.append(getClassNameIds(entryQuery.getClassNameIds()));

    if (!count) {
        sb.append(" ORDER BY ");

        if (entryQuery.getOrderByCol1().equals("ratings")) {
            sb.append("RatingsEntry.score");
        } else {
            sb.append("AssetEntry.");
            sb.append(entryQuery.getOrderByCol1());
        }

        sb.append(StringPool.SPACE);
        sb.append(entryQuery.getOrderByType1());

        if (Validator.isNotNull(entryQuery.getOrderByCol2())
                && !entryQuery.getOrderByCol1().equals(entryQuery.getOrderByCol2())) {

            if (entryQuery.getOrderByCol2().equals("ratings")) {
                sb.append(", RatingsEntry.score");
            } else {
                sb.append(", AssetEntry.");
                sb.append(entryQuery.getOrderByCol2());
            }

            sb.append(StringPool.SPACE);
            sb.append(entryQuery.getOrderByType2());
        }
    }

    if (sb.index() > whereIndex) {
        String where = sb.stringAt(whereIndex);

        if (where.startsWith(" AND")) {
            sb.setStringAt(where.substring(4), whereIndex);
        }
    }

    String sql = sb.toString();

    SQLQuery q = session.createSQLQuery(sql);

    if (count) {
        q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
    } else {
        q.addEntity("AssetEntry", AssetEntryImpl.class);
    }

    QueryPos qPos = QueryPos.getInstance(q);

    if (entryQuery.getLinkedAssetEntryId() > 0) {
        qPos.add(entryQuery.getLinkedAssetEntryId());
        qPos.add(entryQuery.getLinkedAssetEntryId());
        qPos.add(entryQuery.getLinkedAssetEntryId());
    }

    if (entryQuery.isVisible() != null) {
        qPos.add(entryQuery.isVisible());
    }

    if (layout != null) {
        qPos.add(layout.getUuid());
    }

    if (PropsValues.ASSET_CATEGORIES_SEARCH_HIERARCHICAL) {
        qPos.add(entryQuery.getAllLeftAndRightCategoryIds());
        qPos.add(entryQuery.getAnyLeftAndRightCategoryIds());
        qPos.add(entryQuery.getNotAllLeftAndRightCategoryIds());
        qPos.add(entryQuery.getNotAnyLeftAndRightCategoryIds());
    } else {
        qPos.add(entryQuery.getAllCategoryIds());
        qPos.add(entryQuery.getAnyCategoryIds());
        qPos.add(entryQuery.getNotAllCategoryIds());
        qPos.add(entryQuery.getNotAnyCategoryIds());
    }

    qPos.add(entryQuery.getAllTagIds());
    qPos.add(entryQuery.getAnyTagIds());
    qPos.add(entryQuery.getNotAllTagIds());
    qPos.add(entryQuery.getNotAnyTagIds());

    setDates(qPos, entryQuery.getPublishDate(), entryQuery.getExpirationDate());

    qPos.add(entryQuery.getGroupIds());
    qPos.add(entryQuery.getClassNameIds());

    return q;
}

From source file:com.liferay.portlet.dynamicdatamapping.service.persistence.DDMStructureFinderImpl.java

License:Open Source License

public int countByC_G_C_N_D_S_T(long companyId, long[] groupIds, long[] classNameIds, String[] names,
        String[] descriptions, String[] storageTypes, int type, boolean andOperator) throws SystemException {

    String[] classNameIdsString = null;

    if (classNameIds == null) {
        classNameIdsString = new String[] { null };
    } else {//www .j ava  2s  .  co m
        classNameIdsString = ArrayUtil.toStringArray(classNameIds);
    }

    names = CustomSQLUtil.keywords(names);
    descriptions = CustomSQLUtil.keywords(descriptions, false);
    storageTypes = CustomSQLUtil.keywords(storageTypes, false);

    Session session = null;

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(COUNT_BY_C_G_C_N_D_S_T);

        sql = StringUtil.replace(sql, "[$GROUP_ID$]", getGroupIds(groupIds));
        sql = CustomSQLUtil.replaceKeywords(sql, "classNameId", StringPool.EQUAL, false, classNameIdsString);
        sql = CustomSQLUtil.replaceKeywords(sql, "lower(name)", StringPool.LIKE, false, names);
        sql = CustomSQLUtil.replaceKeywords(sql, "description", StringPool.LIKE, false, descriptions);
        sql = CustomSQLUtil.replaceKeywords(sql, "storageType", StringPool.LIKE, true, storageTypes);
        sql = CustomSQLUtil.replaceAndOperator(sql, andOperator);

        SQLQuery q = session.createSQLQuery(sql);

        q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(companyId);
        qPos.add(groupIds);
        qPos.add(classNameIds, 2);
        qPos.add(names, 2);
        qPos.add(descriptions, 2);
        qPos.add(storageTypes, 2);
        qPos.add(type);

        Iterator<Long> itr = q.iterate();

        if (itr.hasNext()) {
            Long count = itr.next();

            if (count != null) {
                return count.intValue();
            }
        }

        return 0;
    } catch (Exception e) {
        throw new SystemException(e);
    } finally {
        closeSession(session);
    }
}