Example usage for com.liferay.portal.kernel.theme ThemeDisplay getPlid

List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getPlid

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.theme ThemeDisplay getPlid.

Prototype

public long getPlid() 

Source Link

Document

Returns the primary key of the page.

Usage

From source file:blade.document.action.configurationicon.BladeActionConfigurationIcon.java

License:Apache License

public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) {

    HttpServletRequest servletRequest = _portal.getHttpServletRequest(portletRequest);

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

    FileEntry fileEntry = _retrieveFile(servletRequest);

    PortletURL portletURL = PortletURLFactoryUtil.create(servletRequest,
            "blade_document_action_portlet_BladeDocumentActionPortlet", themeDisplay.getPlid(),
            PortletRequest.RENDER_PHASE);

    String fileName = fileEntry.getFileName();
    String mimeType = fileEntry.getMimeType();
    String version = fileEntry.getVersion();
    String createdDate = fileEntry.getCreateDate().toString();
    String createdUserName = fileEntry.getUserName();
    String statusLabel = null;/*from w  w w.  j a  v a  2  s.com*/

    try {
        statusLabel = WorkflowConstants.getStatusLabel(fileEntry.getLatestFileVersion().getStatus());
    } catch (PortalException pe) {
        _log.error(pe);
    }

    portletURL.setParameter("fileName", fileName);
    portletURL.setParameter("mimeType", mimeType);
    portletURL.setParameter("version", version);
    portletURL.setParameter("statusLabel", statusLabel);
    portletURL.setParameter("createdDate", createdDate);
    portletURL.setParameter("createdUserName", createdUserName);

    try {
        portletURL.setWindowState(LiferayWindowState.POP_UP);
    } catch (WindowStateException wse) {
        _log.error(wse);
    }

    StringBuilder stringBuilder = new StringBuilder();

    stringBuilder.append("javascript:Liferay.Util.openWindow(");
    stringBuilder.append("{dialog: {cache: false,width:800,modal: true},");
    stringBuilder.append("title: 'basic information',id: ");
    stringBuilder.append("'testPopupIdUnique',uri: '");
    stringBuilder.append(portletURL.toString() + "'});");

    return stringBuilder.toString();
}

From source file:com.liferay.alloy.mvc.jsonwebservice.BaseAlloyControllerInvokerImpl.java

License:Open Source License

protected DynamicServletRequest createRequest(String lifecycle, Object... parameters) throws Exception {

    if ((parameters.length % 2) != 0) {
        throw new IllegalArgumentException("Parameters length is not an even number");
    }/*from   www  .j  a v  a  2  s  . c om*/

    HttpServletRequestWrapper requestWrapper = new HttpServletRequestWrapper(
            new AlloyMockUtil.MockHttpServletRequest());

    DynamicServletRequest request = new DynamicServletRequest(requestWrapper, false);

    for (int i = 0; i < parameters.length; i += 2) {
        request.appendParameter(String.valueOf(parameters[i]), String.valueOf(parameters[i + 1]));
    }

    request.appendParameter("controller", _controller);
    request.appendParameter("format", "json");

    ThemeDisplay themeDisplay = (ThemeDisplay) _themeDisplay.clone();

    PermissionChecker permissionChecker = PermissionThreadLocal.getPermissionChecker();

    User user = UserLocalServiceUtil.getUser(permissionChecker.getUserId());

    themeDisplay.setUser(user);

    request.setAttribute(WebKeys.THEME_DISPLAY, themeDisplay);

    request.setAttribute(WebKeys.LAYOUT, themeDisplay.getLayout());

    LiferayPortletConfig liferayPortletConfig = (LiferayPortletConfig) PortletConfigFactoryUtil.create(_portlet,
            null);

    request.setAttribute(JavaConstants.JAVAX_PORTLET_CONFIG, liferayPortletConfig);

    request.setAttribute(JavaConstants.JAVAX_PORTLET_PORTLET, _alloyPortlet);

    PortletRequest portletRequest = null;
    PortletResponse portletResponse = null;

    if (lifecycle.equals(PortletRequest.ACTION_PHASE)) {
        portletRequest = createActionRequest();
        portletResponse = createActionResponse();
    } else {
        portletRequest = createRenderRequest();
        portletResponse = createRenderResponse(request, _portlet.getRootPortletId(), themeDisplay.getPlid(),
                lifecycle);
    }

    request.setAttribute(JavaConstants.JAVAX_PORTLET_REQUEST, portletRequest);
    request.setAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE, portletResponse);

    request.setAttribute(PortletRequest.LIFECYCLE_PHASE, lifecycle);

    request.setAttribute(BaseAlloyControllerImpl.VIEW_PATH, StringPool.BLANK);

    return request;
}

From source file:com.liferay.arquillian.sample.portlet.SamplePortlet.java

License:Open Source License

public void add(final ActionRequest actionRequest, final ActionResponse actionResponse) {

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

    final int firstParameter = ParamUtil.getInteger(actionRequest, "firstParameter");
    final int secondParameter = ParamUtil.getInteger(actionRequest, "secondParameter");

    final long result = _sampleService.add(firstParameter, secondParameter);

    final long plid = themeDisplay.getPlid();

    final PortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, "arquillian_sample_portlet", plid,
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("firstParameter", String.valueOf(firstParameter));
    portletURL.setParameter("secondParameter", String.valueOf(secondParameter));
    portletURL.setParameter("result", String.valueOf(result));

    actionRequest.setAttribute(WebKeys.REDIRECT, portletURL.toString());
}

From source file:com.liferay.asset.browser.web.internal.display.context.AssetBrowserDisplayContext.java

License:Open Source License

public String getAddButtonURL() throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    long groupId = getGroupId();

    if (groupId == 0) {
        groupId = themeDisplay.getScopeGroupId();
    }/*from   w ww .j av a2  s  . co  m*/

    LiferayPortletRequest liferayPortletRequest = PortalUtil.getLiferayPortletRequest(_renderRequest);

    LiferayPortletResponse liferayPortletResponse = PortalUtil.getLiferayPortletResponse(_renderResponse);

    AssetRendererFactory assetRendererFactory = getAssetRendererFactory();

    PortletURL addPortletURL = null;

    if (assetRendererFactory.isSupportsClassTypes() && (getSubtypeSelectionId() > 0)) {

        addPortletURL = _assetHelper.getAddPortletURL(liferayPortletRequest, liferayPortletResponse, groupId,
                getTypeSelection(), getSubtypeSelectionId(), null, null, getPortletURL().toString());
    } else {
        addPortletURL = _assetHelper.getAddPortletURL(liferayPortletRequest, liferayPortletResponse, groupId,
                getTypeSelection(), 0, null, null, getPortletURL().toString());
    }

    if (addPortletURL == null) {
        return StringPool.BLANK;
    }

    addPortletURL.setParameter("groupId", String.valueOf(groupId));

    return HttpUtil.addParameter(addPortletURL.toString(), "refererPlid", themeDisplay.getPlid());
}

From source file:com.liferay.asset.publisher.web.internal.portlet.filter.AssetPublisherRenderParametersPortletFilter.java

License:Open Source License

protected void clearRenderRequestParameters(RenderRequest renderRequest,
        HttpServletRequest httpServletRequest) {

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

    String portletId = _portal.getPortletId(renderRequest);

    RenderParametersPool.clear(httpServletRequest, themeDisplay.getPlid(), portletId);
}

From source file:com.liferay.asset.publisher.web.internal.portlet.toolbar.contributor.AssetPublisherPortletToolbarContributor.java

License:Open Source License

private URLMenuItem _getPortletTitleAddAssetEntryMenuItem(ThemeDisplay themeDisplay,
        AssetPublisherDisplayContext assetPublisherDisplayContext, long groupId,
        AssetPublisherAddItemHolder assetPublisherAddItemHolder) {

    URLMenuItem urlMenuItem = new URLMenuItem();

    Map<String, Object> data = new HashMap<>();

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    data.put("id", HtmlUtil.escape(portletDisplay.getNamespace()) + "editAsset");

    String message = assetPublisherAddItemHolder.getModelResource();

    String title = LanguageUtil.format(themeDisplay.getLocale(), "new-x", message, false);

    data.put("title", title);

    urlMenuItem.setData(data);/*from   w  w  w  . j  a  va  2 s.  com*/

    urlMenuItem.setLabel(HtmlUtil.escape(message));

    long curGroupId = groupId;

    Group group = _groupLocalService.fetchGroup(groupId);

    if (!group.isStagedPortlet(assetPublisherAddItemHolder.getPortletId()) && !group.isStagedRemotely()) {

        curGroupId = group.getLiveGroupId();
    }

    boolean addDisplayPageParameter = _assetPublisherWebUtil.isDefaultAssetPublisher(themeDisplay.getLayout(),
            portletDisplay.getId(), assetPublisherDisplayContext.getPortletResource());

    String url = _assetHelper.getAddURLPopUp(curGroupId, themeDisplay.getPlid(),
            assetPublisherAddItemHolder.getPortletURL(), addDisplayPageParameter, themeDisplay.getLayout());

    urlMenuItem.setURL(url);

    urlMenuItem.setUseDialog(true);

    return urlMenuItem;
}

From source file:com.liferay.asset.publisher.web.internal.util.AssetPublisherWebUtil.java

License:Open Source License

public void addAndStoreSelection(PortletRequest portletRequest, String className, long classPK,
        int assetEntryOrder) throws Exception {

    String portletId = _portal.getPortletId(portletRequest);

    String rootPortletId = PortletIdCodec.decodePortletName(portletId);

    if (!rootPortletId.equals(AssetPublisherPortletKeys.ASSET_PUBLISHER)) {
        return;//from  w ww . j  a v a2  s  .  c om
    }

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

    Layout layout = _layoutLocalService.fetchLayout(themeDisplay.getPlid());

    PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.getStrictPortletSetup(layout,
            portletId);

    if (portletPreferences instanceof StrictPortletPreferencesImpl) {
        return;
    }

    String selectionStyle = portletPreferences.getValue("selectionStyle", "dynamic");

    if (selectionStyle.equals("dynamic")) {
        return;
    }

    AssetEntry assetEntry = _assetEntryLocalService.getEntry(className, classPK);

    addSelection(portletPreferences, assetEntry.getEntryId(), assetEntryOrder, className);

    portletPreferences.store();
}

From source file:com.liferay.asset.publisher.web.portlet.AssetPublisherAddPortletProvider.java

License:Open Source License

/**
 * @deprecated As of 1.2.0/* w w w.  j a  v  a 2 s . co  m*/
 */
@Deprecated
@Override
protected long getPlid(ThemeDisplay themeDisplay) {
    return themeDisplay.getPlid();
}

From source file:com.liferay.asset.publisher.web.portlet.AssetPublisherPortlet.java

License:Open Source License

public void subscribe(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

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

    assetPublisherWebUtil.subscribe(themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(),
            themeDisplay.getPlid(), themeDisplay.getPpid());
}

From source file:com.liferay.asset.publisher.web.portlet.AssetPublisherPortlet.java

License:Open Source License

public void unsubscribe(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

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

    assetPublisherWebUtil.unsubscribe(themeDisplay.getPermissionChecker(), themeDisplay.getPlid(),
            themeDisplay.getPpid());/*  w  w  w  .ja va  2 s .  c  om*/
}