Example usage for com.liferay.portal.kernel.util PortalUtil getPortletNamespace

List of usage examples for com.liferay.portal.kernel.util PortalUtil getPortletNamespace

Introduction

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

Prototype

public static String getPortletNamespace(String portletId) 

Source Link

Usage

From source file:com.liferay.invitation.invite.members.service.impl.MemberRequestLocalServiceImpl.java

License:Open Source License

protected static String addParameterWithPortletNamespace(String url, String name, String value) {

    String portletId = HttpUtil.getParameter(url, "p_p_id", false);

    if (Validator.isNotNull(portletId)) {
        name = PortalUtil.getPortletNamespace(portletId) + name;
    }//from w w  w.j  a va  2 s  . com

    return HttpUtil.addParameter(url, name, value);
}

From source file:com.liferay.item.selector.upload.web.internal.display.context.ItemSelectorUploadViewDisplayContext.java

License:Open Source License

public String getNamespace() {
    String portletId = _uploadItemSelectorCriterion.getPortletId();

    if (Validator.isNotNull(portletId)) {
        return PortalUtil.getPortletNamespace(_uploadItemSelectorCriterion.getPortletId());
    }/*from   ww w.ja v  a 2  s.  co m*/

    return StringPool.BLANK;
}

From source file:com.liferay.item.selector.web.internal.ItemSelectorImplTest.java

License:Open Source License

protected String getItemSelectorURL(String itemSelectedEventName,
        ItemSelectorCriterion... itemSelectorCriteria) {

    Map<String, String[]> itemSelectorParameters = _itemSelectorImpl
            .getItemSelectorParameters(itemSelectedEventName, itemSelectorCriteria);

    String itemSelectorURL = "http://localhost?p_p_state=popup&p_p_mode=view";

    String namespace = PortalUtil.getPortletNamespace(ItemSelectorPortletKeys.ITEM_SELECTOR);

    for (Map.Entry<String, String[]> entry : itemSelectorParameters.entrySet()) {

        itemSelectorURL = HttpUtil.addParameter(itemSelectorURL, namespace + entry.getKey(),
                entry.getValue()[0]);/*from ww w  .  ja  v a 2  s. co  m*/
    }

    return itemSelectorURL;
}

From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java

License:Open Source License

protected String buildArticleURL(String articleURL, long groupId, long folderId, String articleId) {

    String portletId = PortletProviderUtil.getPortletId(JournalArticle.class.getName(),
            PortletProvider.Action.EDIT);

    String namespace = PortalUtil.getPortletNamespace(portletId);

    articleURL = HttpUtil.addParameter(articleURL, namespace + "groupId", groupId);
    articleURL = HttpUtil.addParameter(articleURL, namespace + "folderId", folderId);
    articleURL = HttpUtil.addParameter(articleURL, namespace + "articleId", articleId);

    return articleURL;
}

From source file:com.liferay.marketplace.store.web.internal.portlet.RemoteMVCPortlet.java

License:Open Source License

protected String getServerNamespace() {
    return PortalUtil.getPortletNamespace(getServerPortletId());
}

From source file:com.liferay.mentions.web.editor.configuration.BaseMentionsEditorConfigContributor.java

License:Open Source License

@Override
public void populateConfigJSONObject(JSONObject jsonObject, Map<String, Object> inputEditorTaglibAttributes,
        ThemeDisplay themeDisplay, RequestBackedPortletURLFactory requestBackedPortletURLFactory) {

    JSONObject autoCompleteConfigJSONObject = JSONFactoryUtil.createJSONObject();

    autoCompleteConfigJSONObject.put("requestTemplate", "query={query}");

    JSONArray triggerJSONArray = JSONFactoryUtil.createJSONArray();

    JSONObject triggerJSONObject = JSONFactoryUtil.createJSONObject();

    triggerJSONObject.put("resultFilters", "function(query, results) {return results;}");
    triggerJSONObject.put("resultTextLocator", "screenName");
    triggerJSONObject.put("term", "@");
    triggerJSONObject.put("tplReplace", "{mention}");

    StringBundler sb = new StringBundler(5);

    sb.append("<div class=\"nameplate\"><div class=\"nameplate-field\">");
    sb.append("<div class=\"user-icon\"><img class=\"img-circle\" ");
    sb.append("src=\"{portraitURL}\" height=\"32px\" width=\"32px\">");
    sb.append("</img></div></div><div class=\"nameplate-content\"><h4>");
    sb.append("{fullName}<small>@{screenName}</small></h4></div></div>");

    triggerJSONObject.put("tplResults", sb.toString());

    PortletURL autoCompleteUserURL = requestBackedPortletURLFactory
            .createResourceURL(MentionsPortletKeys.MENTIONS);

    String source = autoCompleteUserURL.toString() + "&"
            + PortalUtil.getPortletNamespace(MentionsPortletKeys.MENTIONS);

    triggerJSONObject.put("source", source);

    triggerJSONArray.put(triggerJSONObject);

    autoCompleteConfigJSONObject.put("trigger", triggerJSONArray);

    jsonObject.put("autocomplete", autoCompleteConfigJSONObject);

    String extraPlugins = jsonObject.getString("extraPlugins");

    if (Validator.isNotNull(extraPlugins)) {
        extraPlugins += ",autocomplete";
    } else {/*from w w w . j a  v a 2  s .c o m*/
        extraPlugins = "autocomplete,ae_placeholder,ae_selectionregion,ae_uicore";
    }

    jsonObject.put("extraPlugins", extraPlugins);
}

From source file:com.liferay.mentions.web.internal.editor.configuration.BaseMentionsEditorConfigContributor.java

License:Open Source License

@Override
public void populateConfigJSONObject(JSONObject jsonObject, Map<String, Object> inputEditorTaglibAttributes,
        ThemeDisplay themeDisplay, RequestBackedPortletURLFactory requestBackedPortletURLFactory) {

    JSONObject autoCompleteConfigJSONObject = JSONFactoryUtil.createJSONObject();

    autoCompleteConfigJSONObject.put("requestTemplate", "query={query}");

    JSONArray triggerJSONArray = JSONFactoryUtil.createJSONArray();

    JSONObject triggerJSONObject = JSONFactoryUtil.createJSONObject();

    triggerJSONObject.put("regExp",
            "(?:\\strigger|^trigger)(" + MentionsMatcherUtil.getScreenNameRegularExpression() + ")");
    triggerJSONObject.put("resultFilters", "function(query, results) {return results;}");
    triggerJSONObject.put("resultTextLocator", "screenName");
    triggerJSONObject.put("term", "@");
    triggerJSONObject.put("tplReplace", "{mention}");

    StringBundler sb = new StringBundler(5);

    sb.append("<div class=\"nameplate\"><div class=\"nameplate-field\">");
    sb.append("<div class=\"user-icon\"><img class=\"img-circle\" ");
    sb.append("src=\"{portraitURL}\" height=\"32px\" width=\"32px\">");
    sb.append("</img></div></div><div class=\"nameplate-content\"><h4>");
    sb.append("{fullName} <small>@{screenName}</small></h4></div></div>");

    triggerJSONObject.put("tplResults", sb.toString());

    PortletURL autoCompleteUserURL = requestBackedPortletURLFactory
            .createResourceURL(MentionsPortletKeys.MENTIONS);

    String source = autoCompleteUserURL.toString() + "&"
            + PortalUtil.getPortletNamespace(MentionsPortletKeys.MENTIONS);

    triggerJSONObject.put("source", source);

    triggerJSONArray.put(triggerJSONObject);

    autoCompleteConfigJSONObject.put("trigger", triggerJSONArray);

    jsonObject.put("autocomplete", autoCompleteConfigJSONObject);

    String extraPlugins = jsonObject.getString("extraPlugins");

    if (Validator.isNotNull(extraPlugins)) {
        extraPlugins += ",autocomplete";
    } else {/*  w ww  .  ja va  2s .  c  o  m*/
        extraPlugins = "autocomplete,ae_placeholder,ae_selectionregion,ae_uicore";
    }

    jsonObject.put("extraPlugins", extraPlugins);
}

From source file:com.liferay.wiki.editor.configuration.internal.WikiCreoleAutoCompleteEditorConfigContributor.java

License:Open Source License

@Override
public void populateConfigJSONObject(JSONObject jsonObject, Map<String, Object> inputEditorTaglibAttributes,
        ThemeDisplay themeDisplay, RequestBackedPortletURLFactory requestBackedPortletURLFactory) {

    JSONObject autoCompleteConfigJSONObject = JSONFactoryUtil.createJSONObject();

    autoCompleteConfigJSONObject.put("requestTemplate", "query={query}");

    JSONArray triggerJSONArray = JSONFactoryUtil.createJSONArray();

    JSONObject triggerJSONObject = JSONFactoryUtil.createJSONObject();

    triggerJSONObject.put("resultFilters", "function(query, results) {return results;}");
    triggerJSONObject.put("resultTextLocator", "title");

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    ResourceURL autoCompletePageTitleURL = (ResourceURL) requestBackedPortletURLFactory
            .createResourceURL(portletDisplay.getId());

    Map<String, String> fileBrowserParams = (Map<String, String>) inputEditorTaglibAttributes
            .get("liferay-ui:input-editor:fileBrowserParams");

    autoCompletePageTitleURL.setParameter("nodeId", fileBrowserParams.get("nodeId"));

    autoCompletePageTitleURL.setResourceID("/wiki/autocomplete_page_title");

    String source = autoCompletePageTitleURL.toString() + "&"
            + PortalUtil.getPortletNamespace(portletDisplay.getId());

    triggerJSONObject.put("source", source);

    triggerJSONObject.put("term", "[");
    triggerJSONObject.put("tplReplace", "<a href=\"{title}\">{title}</a>");
    triggerJSONObject.put("tplResults", "<span class=\"h5 truncate-text\">{title}</span>");

    triggerJSONArray.put(triggerJSONObject);

    autoCompleteConfigJSONObject.put("trigger", triggerJSONArray);

    jsonObject.put("autocomplete", autoCompleteConfigJSONObject);

    String extraPlugins = jsonObject.getString("extraPlugins");

    if (Validator.isNotNull(extraPlugins)) {
        extraPlugins += ",autocomplete";
    } else {//from w w w .j av a 2s . c  o m
        extraPlugins = "autocomplete,ae_placeholder,ae_selectionregion,ae_uicore";
    }

    jsonObject.put("extraPlugins", extraPlugins);
}

From source file:com.liferay.wiki.service.impl.WikiPageServiceImpl.java

License:Open Source License

protected String exportToRSS(String name, String description, String type, double version, String displayStyle,
        String feedURL, String entryURL, String attachmentURLPrefix, List<WikiPage> pages, boolean diff,
        Locale locale) throws PortalException {

    SyndFeed syndFeed = new SyndFeedImpl();

    syndFeed.setDescription(description);

    List<SyndEntry> syndEntries = new ArrayList<>();

    syndFeed.setEntries(syndEntries);//from   ww  w.  jav  a 2 s.co m

    WikiPage latestPage = null;

    StringBundler sb = new StringBundler(6);

    for (WikiPage page : pages) {
        SyndEntry syndEntry = new SyndEntryImpl();

        String author = PortalUtil.getUserName(page);

        syndEntry.setAuthor(author);

        SyndContent syndContent = new SyndContentImpl();

        syndContent.setType(RSSUtil.ENTRY_TYPE_DEFAULT);

        sb.setIndex(0);

        sb.append(entryURL);

        if (entryURL.endsWith(StringPool.SLASH)) {
            sb.append(HttpUtil.encodeURL(page.getTitle()));
        }

        if (diff) {
            if ((latestPage != null) || (pages.size() == 1)) {
                sb.append(StringPool.QUESTION);
                sb.append(PortalUtil.getPortletNamespace(WikiPortletKeys.WIKI));
                sb.append("version=");
                sb.append(page.getVersion());

                String value = null;

                if (latestPage == null) {
                    value = wikiEngineRenderer.convert(page, null, null, attachmentURLPrefix);
                } else {
                    try {
                        value = wikiEngineRenderer.diffHtml(latestPage, page, null, null, attachmentURLPrefix);
                    } catch (PortalException pe) {
                        throw pe;
                    } catch (SystemException se) {
                        throw se;
                    } catch (Exception e) {
                        throw new SystemException(e);
                    }
                }

                syndContent.setValue(value);

                syndEntry.setDescription(syndContent);

                syndEntries.add(syndEntry);
            }
        } else {
            String value = null;

            WikiGroupServiceOverriddenConfiguration wikiGroupServiceOverriddenConfiguration = configurationProvider
                    .getConfiguration(WikiGroupServiceOverriddenConfiguration.class,
                            new GroupServiceSettingsLocator(page.getGroupId(), WikiConstants.SERVICE_NAME));

            if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_ABSTRACT)) {
                value = StringUtil.shorten(HtmlUtil.extractText(page.getContent()),
                        wikiGroupServiceOverriddenConfiguration.rssAbstractLength(), StringPool.BLANK);
            } else if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_TITLE)) {
                value = StringPool.BLANK;
            } else {
                value = wikiEngineRenderer.convert(page, null, null, attachmentURLPrefix);
            }

            syndContent.setValue(value);

            syndEntry.setDescription(syndContent);

            syndEntries.add(syndEntry);
        }

        syndEntry.setLink(sb.toString());
        syndEntry.setPublishedDate(page.getCreateDate());

        String title = page.getTitle() + StringPool.SPACE + page.getVersion();

        if (page.isMinorEdit()) {
            title += StringPool.SPACE + StringPool.OPEN_PARENTHESIS + LanguageUtil.get(locale, "minor-edit")
                    + StringPool.CLOSE_PARENTHESIS;
        }

        syndEntry.setTitle(title);

        syndEntry.setUpdatedDate(page.getModifiedDate());
        syndEntry.setUri(sb.toString());

        latestPage = page;
    }

    syndFeed.setFeedType(RSSUtil.getFeedType(type, version));

    List<SyndLink> syndLinks = new ArrayList<>();

    syndFeed.setLinks(syndLinks);

    SyndLink syndLinkSelf = new SyndLinkImpl();

    syndLinks.add(syndLinkSelf);

    syndLinkSelf.setHref(feedURL);
    syndLinkSelf.setRel("self");

    syndFeed.setPublishedDate(new Date());
    syndFeed.setTitle(name);
    syndFeed.setUri(feedURL);

    try {
        return RSSUtil.export(syndFeed);
    } catch (FeedException fe) {
        throw new SystemException(fe);
    }
}