Example usage for com.liferay.portal.kernel.model Group getPrivateLayoutsPageCount

List of usage examples for com.liferay.portal.kernel.model Group getPrivateLayoutsPageCount

Introduction

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

Prototype

public int getPrivateLayoutsPageCount();

Source Link

Usage

From source file:com.liferay.exportimport.resources.importer.internal.util.BaseImporter.java

License:Open Source License

@Override
public void afterPropertiesSet() throws Exception {
    User user = UserLocalServiceUtil.getDefaultUser(companyId);

    userId = user.getUserId();/*from   w w w .  j av a2s  .c om*/

    if (isCompanyGroup()) {
        return;
    }

    Group group = null;

    if (targetClassName.equals(LayoutSetPrototype.class.getName())) {
        LayoutSetPrototype layoutSetPrototype = getLayoutSetPrototype(companyId, targetValue);

        if (layoutSetPrototype != null) {
            existing = true;
        } else {
            layoutSetPrototype = LayoutSetPrototypeLocalServiceUtil.addLayoutSetPrototype(userId, companyId,
                    getTargetValueMap(), new HashMap<Locale, String>(), true, true, new ServiceContext());
        }

        group = layoutSetPrototype.getGroup();

        targetClassPK = layoutSetPrototype.getLayoutSetPrototypeId();
    } else if (targetClassName.equals(Group.class.getName())) {
        if (targetValue.equals(GroupConstants.GLOBAL)) {
            group = GroupLocalServiceUtil.getCompanyGroup(companyId);
        } else if (targetValue.equals(GroupConstants.GUEST)) {
            group = GroupLocalServiceUtil.getGroup(companyId, GroupConstants.GUEST);

            List<Layout> layouts = LayoutLocalServiceUtil.getLayouts(group.getGroupId(), false,
                    LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, false, 0, 1);

            if (!layouts.isEmpty()) {
                Layout layout = layouts.get(0);

                LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType();

                List<String> portletIds = layoutTypePortlet.getPortletIds();

                if (portletIds.size() != 2) {
                    existing = true;
                }

                for (String portletId : portletIds) {
                    if (!portletId.equals("47") && !portletId.equals("58")) {

                        existing = true;
                    }
                }
            }
        } else {
            group = GroupLocalServiceUtil.fetchGroup(companyId, targetValue);

            if (group != null) {
                int privateLayoutPageCount = group.getPrivateLayoutsPageCount();

                int publicLayoutPageCount = group.getPublicLayoutsPageCount();

                if ((privateLayoutPageCount != 0) || (publicLayoutPageCount != 0)) {

                    existing = true;
                }
            } else {
                group = GroupLocalServiceUtil.addGroup(userId, GroupConstants.DEFAULT_PARENT_GROUP_ID,
                        StringPool.BLANK, GroupConstants.DEFAULT_PARENT_GROUP_ID,
                        GroupConstants.DEFAULT_LIVE_GROUP_ID, getMap(targetValue), null,
                        GroupConstants.TYPE_SITE_OPEN, true, GroupConstants.DEFAULT_MEMBERSHIP_RESTRICTION,
                        null, true, true, new ServiceContext());
            }
        }

        targetClassPK = group.getGroupId();
    }

    if (group != null) {
        groupId = group.getGroupId();
    }
}

From source file:com.liferay.layout.item.selector.web.internal.PrivateLayoutsItemSelectorView.java

License:Open Source License

@Override
public boolean isVisible(ThemeDisplay themeDisplay) {
    Group group = themeDisplay.getScopeGroup();

    if (group.getPrivateLayoutsPageCount() <= 0) {
        return false;
    }// w  w  w  .j  a v  a  2s  .  c o  m

    return true;
}

From source file:com.liferay.layout.set.prototype.exportimport.test.LayoutSetPrototypeExportImportTest.java

License:Open Source License

protected void exportImportLayoutSetPrototype(boolean layoutPrototype) throws Exception {

    // Exclude default site templates

    LayoutSetPrototypeLocalServiceUtil.deleteLayoutSetPrototypes();

    LayoutSetPrototype exportedLayoutSetPrototype = LayoutTestUtil
            .addLayoutSetPrototype(RandomTestUtil.randomString());

    Group exportedLayoutSetPrototypeGroup = exportedLayoutSetPrototype.getGroup();

    if (layoutPrototype) {
        LayoutPrototype exportedLayoutPrototype = LayoutTestUtil
                .addLayoutPrototype(RandomTestUtil.randomString());

        LayoutTestUtil.addLayout(exportedLayoutSetPrototypeGroup, true, exportedLayoutPrototype, true);
    } else {//  www . j a  va2 s  .  c  om
        LayoutTestUtil.addLayout(exportedLayoutSetPrototypeGroup, true);
    }

    exportImportPortlet(LayoutSetPrototypePortletKeys.LAYOUT_SET_PROTOTYPE);

    LayoutSetPrototype importedLayoutSetPrototype = LayoutSetPrototypeLocalServiceUtil
            .getLayoutSetPrototypeByUuidAndCompanyId(exportedLayoutSetPrototype.getUuid(),
                    exportedLayoutSetPrototype.getCompanyId());

    Group importedLayoutSetPrototypeGroup = importedLayoutSetPrototype.getGroup();

    Assert.assertEquals(exportedLayoutSetPrototypeGroup.getPrivateLayoutsPageCount(),
            importedLayoutSetPrototypeGroup.getPrivateLayoutsPageCount());
}

From source file:com.liferay.user.groups.admin.web.internal.portlet.configuration.icon.DashboardPagesPortletConfigurationIcon.java

License:Open Source License

@Override
public boolean isShow(PortletRequest portletRequest) {
    try {//from   ww w. j  a v  a 2 s  . c  o m
        ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

        UserGroup userGroup = ActionUtil.getUserGroup(portletRequest);

        Group group = userGroup.getGroup();

        if (GroupPermissionUtil.contains(themeDisplay.getPermissionChecker(), group, ActionKeys.VIEW)
                && (group.getPrivateLayoutsPageCount() > 0)) {

            return true;
        }

        return false;
    } catch (Exception e) {
    }

    return false;
}