Example usage for com.liferay.portal.kernel.model LayoutStagingHandler setLayoutRevision

List of usage examples for com.liferay.portal.kernel.model LayoutStagingHandler setLayoutRevision

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.model LayoutStagingHandler setLayoutRevision.

Prototype

public void setLayoutRevision(LayoutRevision layoutRevision) 

Source Link

Usage

From source file:com.liferay.exportimport.staging.LayoutStagingImpl.java

License:Open Source License

@Override
public boolean prepareLayoutStagingHandler(PortletDataContext portletDataContext, Layout layout) {

    boolean exportLAR = MapUtil.getBoolean(portletDataContext.getParameterMap(), "exportLAR");

    if (exportLAR || !LayoutStagingUtil.isBranchingLayout(layout)) {
        return true;
    }/*from w  ww .  j a  v  a 2  s . c o m*/

    long layoutSetBranchId = MapUtil.getLong(portletDataContext.getParameterMap(), "layoutSetBranchId");

    if (layoutSetBranchId <= 0) {
        return false;
    }

    LayoutRevision layoutRevision = null;

    List<LayoutRevision> layoutRevisions = _layoutRevisionLocalService.getLayoutRevisions(layoutSetBranchId,
            layout.getPlid(), true);

    if (!layoutRevisions.isEmpty()) {
        if (layoutRevisions.size() > 1) {
            layoutRevision = getLayoutRevision(layout);

            long layoutBranchId = GetterUtil.DEFAULT_LONG;

            if (layoutRevision != null) {
                layoutBranchId = layoutRevision.getLayoutBranchId();
            }

            layoutRevision = _layoutRevisionLocalService.fetchLayoutRevision(layoutSetBranchId, layoutBranchId,
                    true, layout.getPlid());
        }

        if ((layoutRevision == null) && !layoutRevisions.isEmpty()) {
            layoutRevision = layoutRevisions.get(0);
        }
    }

    if (layoutRevision == null) {
        return false;
    }

    LayoutStagingHandler layoutStagingHandler = LayoutStagingUtil.getLayoutStagingHandler(layout);

    layoutStagingHandler.setLayoutRevision(layoutRevision);

    return true;
}