Example usage for com.liferay.portal.kernel.model LayoutSetBranchConstants ALL_BRANCHES

List of usage examples for com.liferay.portal.kernel.model LayoutSetBranchConstants ALL_BRANCHES

Introduction

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

Prototype

long ALL_BRANCHES

To view the source code for com.liferay.portal.kernel.model LayoutSetBranchConstants ALL_BRANCHES.

Click Source Link

Usage

From source file:com.liferay.staging.bar.web.internal.portlet.action.EditLayoutSetBranchMVCActionCommand.java

License:Open Source License

@Override
protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    long layoutSetBranchId = ParamUtil.getLong(actionRequest, "layoutSetBranchId");

    long groupId = ParamUtil.getLong(actionRequest, "groupId");
    boolean privateLayout = ParamUtil.getBoolean(actionRequest, "privateLayout");
    String name = ParamUtil.getString(actionRequest, "name");
    String description = ParamUtil.getString(actionRequest, "description");
    long copyLayoutSetBranchId = ParamUtil.getLong(actionRequest, "copyLayoutSetBranchId",
            LayoutSetBranchConstants.ALL_BRANCHES);

    ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);

    try {/*ww w . ja  v a 2 s. c  o  m*/
        if (layoutSetBranchId <= 0) {
            _layoutSetBranchService.addLayoutSetBranch(groupId, privateLayout, name, description, false,
                    copyLayoutSetBranchId, serviceContext);

            SessionMessages.add(actionRequest, "sitePageVariationAdded");
        } else {
            _layoutSetBranchLocalService.updateLayoutSetBranch(layoutSetBranchId, name, description,
                    serviceContext);

            SessionMessages.add(actionRequest, "sitePageVariationUpdated");
        }

        ActionUtil.addLayoutBranchSessionMessages(actionRequest, actionResponse);
    } catch (Exception e) {
        SessionErrors.add(actionRequest, e.getClass(), e);

        if (e instanceof LayoutSetBranchNameException) {
            actionResponse.setRenderParameter("mvcPath", "/edit_layout_set_branch.jsp");
        } else {
            actionResponse.setRenderParameter("mvcPath", "/error.jsp");
        }
    }
}