List of usage examples for com.liferay.portal.kernel.model Layout hasScopeGroup
public boolean hasScopeGroup() throws com.liferay.portal.kernel.exception.PortalException;
From source file:com.liferay.exportimport.staging.StagingImpl.java
License:Open Source License
protected long publishPortlet(long userId, long scopeGroupId, long plid, String portletId, Map<String, String[]> parameterMap, boolean copyFromLive) throws PortalException { Layout sourceLayout = _layoutLocalService.getLayout(plid); Group scopeGroup = sourceLayout.getScopeGroup(); Group stagingGroup = null;/*from w w w .j av a 2 s .c om*/ Group liveGroup = null; Layout targetLayout = null; if (sourceLayout.isTypeControlPanel()) { stagingGroup = _groupLocalService.fetchGroup(scopeGroupId); liveGroup = stagingGroup.getLiveGroup(); targetLayout = sourceLayout; } else if (sourceLayout.hasScopeGroup() && (scopeGroup.getGroupId() == scopeGroupId)) { stagingGroup = scopeGroup; liveGroup = stagingGroup.getLiveGroup(); targetLayout = _layoutLocalService.getLayout(liveGroup.getClassPK()); } else { stagingGroup = sourceLayout.getGroup(); liveGroup = stagingGroup.getLiveGroup(); targetLayout = _layoutLocalService.fetchLayoutByUuidAndGroupId(sourceLayout.getUuid(), liveGroup.getGroupId(), sourceLayout.isPrivateLayout()); } if (copyFromLive) { return publishPortlet(userId, liveGroup.getGroupId(), stagingGroup.getGroupId(), targetLayout.getPlid(), sourceLayout.getPlid(), portletId, parameterMap); } return publishPortlet(userId, stagingGroup.getGroupId(), liveGroup.getGroupId(), sourceLayout.getPlid(), targetLayout.getPlid(), portletId, parameterMap); }
From source file:com.liferay.portlet.configuration.web.internal.portlet.PortletConfigurationPortlet.java
License:Open Source License
protected Tuple getNewScope(ActionRequest actionRequest) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); String[] scopes = StringUtil.split(ParamUtil.getString(actionRequest, "scope")); String scopeType = scopes[0]; long scopeGroupId = 0; String scopeName = null;// w ww . j a va 2 s . co m if (Validator.isNull(scopeType)) { scopeGroupId = layout.getGroupId(); } else if (scopeType.equals("company")) { scopeGroupId = themeDisplay.getCompanyGroupId(); scopeName = themeDisplay.translate("global"); } else if (scopeType.equals("layout")) { String scopeLayoutUuid = scopes[1]; Layout scopeLayout = _layoutLocalService.getLayoutByUuidAndGroupId(scopeLayoutUuid, layout.getGroupId(), layout.isPrivateLayout()); if (!scopeLayout.hasScopeGroup()) { Map<Locale, String> nameMap = new HashMap<>(); String name = String.valueOf(scopeLayout.getPlid()); nameMap.put(LocaleUtil.getDefault(), name); _groupLocalService.addGroup(themeDisplay.getUserId(), GroupConstants.DEFAULT_PARENT_GROUP_ID, Layout.class.getName(), scopeLayout.getPlid(), GroupConstants.DEFAULT_LIVE_GROUP_ID, nameMap, null, 0, true, GroupConstants.DEFAULT_MEMBERSHIP_RESTRICTION, null, false, true, null); } scopeGroupId = scopeLayout.getGroupId(); scopeName = scopeLayout.getName(themeDisplay.getLocale()); } else { throw new IllegalArgumentException("Scope type " + scopeType + " is invalid"); } return new Tuple(scopeGroupId, scopeName); }
From source file:com.liferay.site.internal.exportimport.data.handler.StagedGroupStagedModelDataHandler.java
License:Open Source License
protected void exportSitePortlets(PortletDataContext portletDataContext, StagedGroup group, Set<String> portletIds, long[] layoutIds) throws Exception { // Prepare XML Element rootElement = portletDataContext.getExportDataRootElement(); Element portletsElement = rootElement.element("site-portlets"); Element servicesElement = rootElement.element("site-services"); String type = portletDataContext.getType(); // Export portlets Map<String, String[]> parameterMap = portletDataContext.getParameterMap(); boolean permissions = MapUtil.getBoolean(parameterMap, PortletDataHandlerKeys.PERMISSIONS); List<Layout> layouts = _layoutLocalService.getLayouts(group.getGroupId(), portletDataContext.isPrivateLayout()); for (String portletId : portletIds) { // Default scope exportPortlet(portletDataContext, portletId, LayoutConstants.DEFAULT_PLID, portletDataContext.getGroupId(), StringPool.BLANK, StringPool.BLANK, type, portletsElement, servicesElement, permissions); Portlet portlet = _portletLocalService.getPortletById(portletDataContext.getCompanyId(), portletId); if (!portlet.isScopeable()) { continue; }// w w w .j a v a 2 s .c o m // Scoped data for (Layout layout : layouts) { if (!ArrayUtil.contains(layoutIds, layout.getLayoutId()) || !layout.isTypePortlet() || !layout.hasScopeGroup()) { continue; } LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType(); if (!layoutTypePortlet.hasPortletId(portletId)) { continue; } Group scopeGroup = layout.getScopeGroup(); exportPortlet(portletDataContext, portletId, layout.getPlid(), scopeGroup.getGroupId(), StringPool.BLANK, layout.getUuid(), type, portletsElement, servicesElement, permissions); } } }
From source file:com.liferay.site.service.persistence.test.GroupServiceTest.java
License:Open Source License
@Test public void testScopes() throws Exception { Group group = GroupTestUtil.addGroup(); Layout layout = LayoutTestUtil.addLayout(group); Assert.assertFalse(layout.hasScopeGroup()); Map<Locale, String> nameMap = new HashMap<>(); nameMap.put(LocaleUtil.getDefault(), layout.getName(LocaleUtil.getDefault())); Group scope = GroupLocalServiceUtil.addGroup(TestPropsValues.getUserId(), GroupConstants.DEFAULT_PARENT_GROUP_ID, Layout.class.getName(), layout.getPlid(), GroupConstants.DEFAULT_LIVE_GROUP_ID, nameMap, (Map<Locale, String>) null, 0, true, GroupConstants.DEFAULT_MEMBERSHIP_RESTRICTION, null, false, true, null); Assert.assertFalse(scope.isRoot());/* w w w . j ava 2s . co m*/ Assert.assertEquals(scope.getParentGroupId(), group.getGroupId()); GroupLocalServiceUtil.deleteGroup(scope); GroupLocalServiceUtil.deleteGroup(group); }