Example usage for com.liferay.portal.kernel.util WebKeys PRIVATE_LAYOUT

List of usage examples for com.liferay.portal.kernel.util WebKeys PRIVATE_LAYOUT

Introduction

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

Prototype

String PRIVATE_LAYOUT

To view the source code for com.liferay.portal.kernel.util WebKeys PRIVATE_LAYOUT.

Click Source Link

Usage

From source file:com.liferay.staging.taglib.servlet.taglib.DefineObjectsTag.java

License:Open Source License

@Override
public int doStartTag() {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

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

    long groupId = ParamUtil.getLong(request, "groupId");

    Group group = GroupLocalServiceUtil.fetchGroup(groupId);

    if (group == null) {
        group = (Group) request.getAttribute(WebKeys.GROUP);
    }/*from w  w  w .j a  v a2s .co  m*/

    if (group == null) {
        group = themeDisplay.getScopeGroup();
    }

    if (group == null) {
        return SKIP_BODY;
    }

    pageContext.setAttribute("group", group);
    pageContext.setAttribute("groupId", group.getGroupId());
    pageContext.setAttribute("liveGroup", null);
    pageContext.setAttribute("liveGroupId", 0L);

    Layout layout = themeDisplay.getLayout();

    String privateLayoutString = request.getParameter("privateLayout");

    if (Validator.isNull(privateLayoutString)) {
        privateLayoutString = GetterUtil.getString(request.getAttribute(WebKeys.PRIVATE_LAYOUT), null);
    }

    boolean privateLayout = GetterUtil.getBoolean(privateLayoutString, layout.isPrivateLayout());

    pageContext.setAttribute("privateLayout", privateLayout);

    pageContext.setAttribute("stagingGroup", null);
    pageContext.setAttribute("stagingGroupId", 0L);

    if (!group.isStaged() && !group.isStagedRemotely() && !group.hasLocalOrRemoteStagingGroup()) {

        return SKIP_BODY;
    }

    Group liveGroup = StagingUtil.getLiveGroup(group.getGroupId());

    pageContext.setAttribute("liveGroup", liveGroup);
    pageContext.setAttribute("liveGroupId", liveGroup.getGroupId());

    Group stagingGroup = null;

    if (!group.hasRemoteStagingGroup() || group.isStagedRemotely()) {
        stagingGroup = StagingUtil.getStagingGroup(group.getGroupId());
    }

    if (stagingGroup != null) {
        pageContext.setAttribute("stagingGroup", stagingGroup);
        pageContext.setAttribute("stagingGroupId", stagingGroup.getGroupId());
    }

    if (Validator.isNotNull(_portletId)) {
        boolean stagedPortlet = liveGroup.isStagedPortlet(_portletId);

        if (group.isStagedRemotely()) {
            stagedPortlet = stagingGroup.isStagedPortlet(_portletId);
        }

        if (stagedPortlet) {
            pageContext.setAttribute("group", stagingGroup);
            pageContext.setAttribute("groupId", stagingGroup.getGroupId());
            pageContext.setAttribute("scopeGroup", stagingGroup);
            pageContext.setAttribute("scopeGroupId", stagingGroup.getGroupId());
        }
    }

    return SKIP_BODY;
}