Example usage for com.liferay.portal.kernel.exception RequiredLayoutException AT_LEAST_ONE

List of usage examples for com.liferay.portal.kernel.exception RequiredLayoutException AT_LEAST_ONE

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.exception RequiredLayoutException AT_LEAST_ONE.

Prototype

int AT_LEAST_ONE

To view the source code for com.liferay.portal.kernel.exception RequiredLayoutException AT_LEAST_ONE.

Click Source Link

Usage

From source file:com.liferay.layout.admin.web.internal.portlet.action.DeleteLayoutMVCActionCommand.java

License:Open Source License

protected void deleteLayout(long selPlid, ActionRequest actionRequest, ActionResponse actionResponse)
        throws PortalException {

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

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    Layout layout = _layoutLocalService.getLayout(selPlid);

    Group group = layout.getGroup();

    if (group.isStagingGroup()
            && !GroupPermissionUtil.contains(permissionChecker, group, ActionKeys.MANAGE_STAGING)
            && !GroupPermissionUtil.contains(permissionChecker, group, ActionKeys.PUBLISH_STAGING)) {

        throw new PrincipalException.MustHavePermission(permissionChecker, Group.class.getName(),
                group.getGroupId(), ActionKeys.MANAGE_STAGING, ActionKeys.PUBLISH_STAGING);
    }//from  w w w  .j av  a 2s . c om

    if (LayoutPermissionUtil.contains(permissionChecker, layout, ActionKeys.DELETE)) {

        LayoutType layoutType = layout.getLayoutType();

        EventsProcessorUtil.process(PropsKeys.LAYOUT_CONFIGURATION_ACTION_DELETE,
                layoutType.getConfigurationActionDelete(), _portal.getHttpServletRequest(actionRequest),
                _portal.getHttpServletResponse(actionResponse));
    }

    if (group.isGuest() && !layout.isPrivateLayout() && layout.isRootLayout() && (_layoutLocalService
            .getLayoutsCount(group, false, LayoutConstants.DEFAULT_PARENT_LAYOUT_ID) == 1)) {

        throw new RequiredLayoutException(RequiredLayoutException.AT_LEAST_ONE);
    }

    ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);

    _layoutService.deleteLayout(selPlid, serviceContext);
}