protected String addJournalContentPortletToLayout( long userId, Layout layout, JournalArticle journalArticle, String columnId) throws Exception { LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType(); String journalPortletId = layoutTypePortlet.addPortletId(userId, PortletKeys.JOURNAL_CONTENT, columnId, -1); LayoutLocalServiceUtil.updateLayout( layout.getGroupId(), layout.isPrivateLayout(), layout.getLayoutId(), layout.getTypeSettings()); javax.portlet.PortletPreferences prefs = getPortletPreferences(layout.getCompanyId(), layout.getPlid(), journalPortletId); prefs.setValue("articleId", journalArticle.getArticleId()); prefs.setValue("groupId", String.valueOf(journalArticle.getGroupId())); prefs.setValue("showAvailableLocales", Boolean.TRUE.toString()); updatePortletPreferences(layout.getPlid(), journalPortletId, prefs); return journalPortletId; }
@Override protected StagedModel addStagedModel( Group group, Map<String, List<StagedModel>> dependentStagedModelsMap) throws Exception { _layoutSetPrototype = LayoutTestUtil.addLayoutSetPrototype(RandomTestUtil.randomString()); List<Layout> layouts = LayoutLocalServiceUtil.getLayouts( _layoutSetPrototype.getGroupId(), true, LayoutConstants.DEFAULT_PARENT_LAYOUT_ID); Assert.assertEquals(1, layouts.size()); Layout layout = layouts.get(0); addLayout(LayoutSetPrototype.class, layout); addLayoutFriendlyURLs(LayoutSetPrototype.class, layout.getPlid()); LayoutPrototype layoutPrototype = addLayoutPrototype(dependentStagedModelsMap); Layout prototypedLayout = LayoutTestUtil.addLayout(_layoutSetPrototype.getGroupId(), true, layoutPrototype, true); addLayout(LayoutSetPrototype.class, prototypedLayout); addLayoutFriendlyURLs(LayoutSetPrototype.class, prototypedLayout.getPlid()); return _layoutSetPrototype; }
@Test public void testExportImportPortletPreferences() throws Exception { // Check preferences after site creation JournalArticle journalArticle = JournalArticleLocalServiceUtil.getArticleByUrlTitle( _group.getGroupId(), _layoutSetPrototypeJournalArticle.getUrlTitle()); Layout layout = LayoutLocalServiceUtil.getFriendlyURLLayout( _group.getGroupId(), false, _layoutSetPrototypeLayout.getFriendlyURL()); javax.portlet.PortletPreferences jxPreferences = getPortletPreferences( layout.getCompanyId(), layout.getPlid(), _layoutSetPrototypeJournalContentPortletId); Assert.assertEquals( journalArticle.getArticleId(), jxPreferences.getValue("articleId", StringPool.BLANK)); Assert.assertEquals( String.valueOf(journalArticle.getGroupId()), jxPreferences.getValue("groupId", StringPool.BLANK)); Assert.assertEquals( String.valueOf(true), jxPreferences.getValue("showAvailableLocales", StringPool.BLANK)); // Update site template preferences javax.portlet.PortletPreferences layoutSetprototypeJxPreferences = getPortletPreferences( _layoutSetPrototypeLayout.getCompanyId(), _layoutSetPrototypeLayout.getPlid(), _layoutSetPrototypeJournalContentPortletId); layoutSetprototypeJxPreferences.setValue("showAvailableLocales", String.valueOf(false)); updatePortletPreferences( _layoutSetPrototypeLayout.getPlid(), _layoutSetPrototypeJournalContentPortletId, layoutSetprototypeJxPreferences); // Check preferences after layout reset SitesUtil.resetPrototype(layout); jxPreferences = getPortletPreferences( _group.getCompanyId(), layout.getPlid(), _layoutSetPrototypeJournalContentPortletId); Assert.assertEquals( journalArticle.getArticleId(), jxPreferences.getValue("articleId", StringPool.BLANK)); Assert.assertEquals( String.valueOf(journalArticle.getGroupId()), jxPreferences.getValue("groupId", StringPool.BLANK)); Assert.assertEquals( Boolean.FALSE.toString(), jxPreferences.getValue("showAvailableLocales", StringPool.BLANK)); }
@Override protected void doExportStagedModel(PortletDataContext portletDataContext, Layout layout) throws Exception { if (layout.isTypeSharedPortlet()) { return; } Element layoutElement = portletDataContext.getExportDataElement(layout); populateElementLayoutMetadata(layoutElement, layout); layoutElement.addAttribute(Constants.ACTION, Constants.ADD); portletDataContext.setPlid(layout.getPlid()); long parentLayoutId = layout.getParentLayoutId(); if (parentLayoutId != LayoutConstants.DEFAULT_PARENT_LAYOUT_ID) { Layout parentLayout = _layoutLocalService.fetchLayout( layout.getGroupId(), layout.isPrivateLayout(), parentLayoutId); if (parentLayout != null) { StagedModelDataHandlerUtil.exportReferenceStagedModel( portletDataContext, layout, parentLayout, PortletDataContext.REFERENCE_TYPE_PARENT); layoutElement.addAttribute("parent-layout-uuid", parentLayout.getUuid()); } } List<LayoutFriendlyURL> layoutFriendlyURLs = _layoutFriendlyURLLocalService.getLayoutFriendlyURLs(layout.getPlid()); for (LayoutFriendlyURL layoutFriendlyURL : layoutFriendlyURLs) { StagedModelDataHandlerUtil.exportReferenceStagedModel( portletDataContext, layout, layoutFriendlyURL, PortletDataContext.REFERENCE_TYPE_DEPENDENCY); } if (layout.isIconImage()) { exportLayoutIconImage(portletDataContext, layout, layoutElement); } if (layout.isTypeLinkToLayout()) { exportLinkedLayout(portletDataContext, layout, layoutElement); } fixExportTypeSettings(layout); exportTheme(portletDataContext, layout); portletDataContext.addClassedModel( layoutElement, ExportImportPathUtil.getModelPath(layout), layout); }
protected void importAssets( PortletDataContext portletDataContext, Layout layout, Layout importedLayout) throws Exception { long userId = portletDataContext.getUserId(layout.getUserUuid()); long[] assetCategoryIds = portletDataContext.getAssetCategoryIds(Layout.class, layout.getPlid()); String[] assetTagNames = portletDataContext.getAssetTagNames(Layout.class, layout.getPlid()); _layoutLocalService.updateAsset(userId, importedLayout, assetCategoryIds, assetTagNames); }
@Test public void testFriendlyURLCollision() throws Exception { String defaultLanguageId = LocaleUtil.toLanguageId(LocaleUtil.getDefault()); Layout layoutA = LayoutTestUtil.addLayout(group.getGroupId(), "layoutA"); layoutA = LayoutLocalServiceUtil.updateFriendlyURL(layoutA.getPlid(), "/layoutA-de", "de"); Layout layoutB = LayoutTestUtil.addLayout(group.getGroupId(), "layoutB"); layoutB = LayoutLocalServiceUtil.updateFriendlyURL(layoutB.getPlid(), "/layoutB-de", "de"); long[] layoutIds = {layoutA.getLayoutId(), layoutB.getLayoutId()}; exportImportLayouts(layoutIds, getImportParameterMap()); layoutA = LayoutLocalServiceUtil.updateFriendlyURL(layoutA.getPlid(), "/temp", defaultLanguageId); layoutA = LayoutLocalServiceUtil.updateFriendlyURL(layoutA.getPlid(), "/temp-de", "de"); layoutB = LayoutLocalServiceUtil.updateFriendlyURL(layoutB.getPlid(), "/layoutA", defaultLanguageId); LayoutLocalServiceUtil.updateFriendlyURL(layoutB.getPlid(), "/layoutA-de", "de"); layoutA = LayoutLocalServiceUtil.updateFriendlyURL(layoutA.getPlid(), "/layoutB", defaultLanguageId); LayoutLocalServiceUtil.updateFriendlyURL(layoutA.getPlid(), "/layoutB-de", "de"); exportImportLayouts(layoutIds, getImportParameterMap()); }
@Test public void testTypeLinkToLayout() throws Exception { initExport(); Map<String, List<StagedModel>> dependentStagedModelsMap = new HashMap<>(); Layout linkedLayout = LayoutTestUtil.addLayout(stagingGroup); List<LayoutFriendlyURL> linkedLayoutFriendlyURLs = LayoutFriendlyURLLocalServiceUtil.getLayoutFriendlyURLs(linkedLayout.getPlid()); addDependentStagedModel(dependentStagedModelsMap, Layout.class, linkedLayout); addDependentLayoutFriendlyURLs(dependentStagedModelsMap, linkedLayout); Layout layout = LayoutTestUtil.addTypeLinkToLayoutLayout( stagingGroup.getGroupId(), linkedLayout.getLayoutId()); List<LayoutFriendlyURL> layoutFriendlyURLs = LayoutFriendlyURLLocalServiceUtil.getLayoutFriendlyURLs(layout.getPlid()); addDependentLayoutFriendlyURLs(dependentStagedModelsMap, layout); StagedModelDataHandlerUtil.exportStagedModel(portletDataContext, layout); validateExport(portletDataContext, layout, dependentStagedModelsMap); initImport(); Layout exportedLayout = (Layout) readExportedStagedModel(layout); StagedModelDataHandlerUtil.importStagedModel(portletDataContext, exportedLayout); LayoutLocalServiceUtil.getLayoutByUuidAndGroupId( linkedLayout.getUuid(), liveGroup.getGroupId(), false); LayoutFriendlyURL linkedLayoutFriendlyURL = linkedLayoutFriendlyURLs.get(0); LayoutFriendlyURLLocalServiceUtil.getLayoutFriendlyURLByUuidAndGroupId( linkedLayoutFriendlyURL.getUuid(), liveGroup.getGroupId()); LayoutLocalServiceUtil.getLayoutByUuidAndGroupId( layout.getUuid(), liveGroup.getGroupId(), false); LayoutFriendlyURL layoutFriendlyURL = layoutFriendlyURLs.get(0); LayoutFriendlyURLLocalServiceUtil.getLayoutFriendlyURLByUuidAndGroupId( layoutFriendlyURL.getUuid(), liveGroup.getGroupId()); }
protected void redirectActionURL( HttpServletRequest request, HttpServletResponse response, ActionResponseImpl actionResponseImpl, Portlet portlet) throws Exception { ActionRequestImpl actionRequestImpl = (ActionRequestImpl) request.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST); Layout layout = (Layout) request.getAttribute(WebKeys.LAYOUT); PortletURL portletURL = new PortletURLImpl( actionRequestImpl, actionRequestImpl.getPortletName(), layout.getPlid(), PortletRequest.RENDER_PHASE); Map<String, String[]> renderParameters = actionResponseImpl.getRenderParameterMap(); for (Map.Entry<String, String[]> entry : renderParameters.entrySet()) { String key = entry.getKey(); String[] value = entry.getValue(); portletURL.setParameter(key, value); } response.sendRedirect(portletURL.toString()); }
private LiferayPortletURL createLiferayPortletURL( PortletRequest request, String toPage, String portletId) { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); // String portletId = (String) request.getAttribute(WebKeys.PORTLET_ID); LiferayPortletURL renderURL = null; String localHost = themeDisplay.getPortalURL(); List<Layout> layouts = null; try { layouts = LayoutLocalServiceUtil.getLayouts(themeDisplay.getLayout().getGroupId(), false); for (Layout layout : layouts) { String nodeNameRemoved = PortalUtil.getLayoutFriendlyURL(layout, themeDisplay).replace(localHost, ""); // Viene ricercato l'URL esatto per la pagina successiva if (nodeNameRemoved.indexOf(toPage) > 0) { renderURL = PortletURLFactoryUtil.create( request, portletId, layout.getPlid(), PortletRequest.RENDER_PHASE); renderURL.setWindowState(WindowState.NORMAL); renderURL.setPortletMode(PortletMode.VIEW); break; } } } catch (Exception e) { e.printStackTrace(); } return renderURL; }
protected void initNewLayoutPermissions( long companyId, long groupId, long userId, Layout layout, Layout importedLayout, boolean privateLayout) throws Exception { boolean addGroupPermissions = true; Group group = importedLayout.getGroup(); if (privateLayout && group.isUser()) { addGroupPermissions = false; } boolean addGuestPermissions = false; if (!privateLayout || layout.isTypeControlPanel()) { addGuestPermissions = true; } _resourceLocalService.addResources( companyId, groupId, userId, Layout.class.getName(), importedLayout.getPlid(), false, addGroupPermissions, addGuestPermissions); }
public void onAfterRemove(Layout layout) throws ModelListenerException { try { removeEntries(layout.getPlid()); } catch (Exception e) { throw new ModelListenerException(e); } }
protected Group addScopeGroup() throws Exception { Group group = GroupTestUtil.addGroup(); Layout layout = LayoutTestUtil.addLayout(group.getGroupId(), ServiceTestUtil.randomString()); String name = ServiceTestUtil.randomString(); ServiceContext serviceContext = ServiceTestUtil.getServiceContext(group.getGroupId()); Group scopeGroup = GroupLocalServiceUtil.addGroup( TestPropsValues.getUserId(), group.getParentGroupId(), Layout.class.getName(), layout.getPlid(), GroupConstants.DEFAULT_LIVE_GROUP_ID, name, ServiceTestUtil.randomString(), GroupConstants.TYPE_SITE_OPEN, true, GroupConstants.DEFAULT_MEMBERSHIP_RESTRICTION, StringPool.SLASH + FriendlyURLNormalizerUtil.normalize(name), false, true, serviceContext); return scopeGroup; }
protected void assertLinksToLayouts(String content, Layout layout, long groupId) { StringBundler sb = new StringBundler(); sb.append(StringPool.OPEN_BRACKET); sb.append(layout.getLayoutId()); sb.append(CharPool.AT); Group group = GroupLocalServiceUtil.fetchGroup(groupId); if (layout.isPrivateLayout()) { if (group == null) { sb.append("private"); } else if (group.isUser()) { sb.append("private-user"); } else { sb.append("private-group"); } } else { sb.append("public"); } sb.append(CharPool.AT); sb.append(layout.getPlid()); if (group != null) { sb.append(CharPool.AT); sb.append(String.valueOf(groupId)); } sb.append(StringPool.CLOSE_BRACKET); Assert.assertTrue(content.contains(sb.toString())); }
protected void updateTypeSettings(Layout importedLayout, Layout layout) throws PortalException { long groupId = layout.getGroupId(); try { LayoutTypePortlet importedLayoutType = (LayoutTypePortlet) importedLayout.getLayoutType(); List<String> importedPortletIds = importedLayoutType.getPortletIds(); layout.setGroupId(importedLayout.getGroupId()); LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType(); importedPortletIds.removeAll(layoutTypePortlet.getPortletIds()); if (!importedPortletIds.isEmpty()) { _portletLocalService.deletePortlets( importedLayout.getCompanyId(), importedPortletIds.toArray(new String[importedPortletIds.size()]), importedLayout.getPlid()); } importedLayout.setTypeSettingsProperties(layoutTypePortlet.getTypeSettingsProperties()); } finally { layout.setGroupId(groupId); } }
@Override public void movePortletId(long userId, String portletId, String columnId, int columnPos) throws PortalException { if (!hasPortletId(portletId)) { return; } _enablePortletLayoutListener = false; try { removePortletId(userId, portletId, false); addPortletId(userId, portletId, columnId, columnPos, false, true); } finally { _enablePortletLayoutListener = true; } Layout layout = getLayout(); try { Portlet portlet = PortletLocalServiceUtil.getPortletById(layout.getCompanyId(), portletId); if (portlet != null) { PortletLayoutListener portletLayoutListener = portlet.getPortletLayoutListenerInstance(); if (portletLayoutListener != null) { portletLayoutListener.onMoveInLayout(portletId, layout.getPlid()); } } } catch (Exception e) { _log.error("Unable to fire portlet layout listener event", e); } }
protected void exportJournalArticle( PortletDataContext portletDataContext, Layout layout, Element layoutElement) throws Exception { UnicodeProperties typeSettingsProperties = layout.getTypeSettingsProperties(); String articleId = typeSettingsProperties.getProperty("article-id", StringPool.BLANK); long articleGroupId = layout.getGroupId(); if (Validator.isNull(articleId)) { if (_log.isWarnEnabled()) { _log.warn("No article id found in typeSettings of layout " + layout.getPlid()); } } JournalArticle article = null; try { article = JournalArticleLocalServiceUtil.getLatestArticle( articleGroupId, articleId, WorkflowConstants.STATUS_APPROVED); } catch (NoSuchArticleException nsae) { if (_log.isWarnEnabled()) { _log.warn( "No approved article found with group id " + articleGroupId + " and article id " + articleId); } } if (article == null) { return; } String path = JournalPortletDataHandlerImpl.getArticlePath(portletDataContext, article); Element articleElement = layoutElement.addElement("article"); articleElement.addAttribute("path", path); Element dlFileEntryTypesElement = layoutElement.addElement("dl-file-entry-types"); Element dlFoldersElement = layoutElement.addElement("dl-folders"); Element dlFilesElement = layoutElement.addElement("dl-file-entries"); Element dlFileRanksElement = layoutElement.addElement("dl-file-ranks"); JournalPortletDataHandlerImpl.exportArticle( portletDataContext, layoutElement, layoutElement, layoutElement, dlFileEntryTypesElement, dlFoldersElement, dlFilesElement, dlFileRanksElement, article, false); }
protected void addDependentLayoutFriendlyURLs( Map<String, List<StagedModel>> dependentStagedModelsMap, Layout layout) throws Exception { List<LayoutFriendlyURL> layoutFriendlyURLs = LayoutFriendlyURLLocalServiceUtil.getLayoutFriendlyURLs(layout.getPlid()); for (LayoutFriendlyURL layoutFriendlyURL : layoutFriendlyURLs) { addDependentStagedModel(dependentStagedModelsMap, LayoutFriendlyURL.class, layoutFriendlyURL); } }
public long getParentPlid() throws PortalException, SystemException { if (getParentLayoutId() == LayoutConstants.DEFAULT_PARENT_LAYOUT_ID) { return 0; } Layout layout = LayoutLocalServiceUtil.getLayout(getGroupId(), isPrivateLayout(), getParentLayoutId()); return layout.getPlid(); }
protected String getUniqueFriendlyURL( PortletDataContext portletDataContext, Layout existingLayout, String friendlyURL) { for (int i = 1; ; i++) { Layout duplicateFriendlyURLLayout = _layoutLocalService.fetchLayoutByFriendlyURL( portletDataContext.getGroupId(), portletDataContext.isPrivateLayout(), friendlyURL); if ((duplicateFriendlyURLLayout == null) || (duplicateFriendlyURLLayout.getPlid() == existingLayout.getPlid())) { break; } friendlyURL = friendlyURL + i; } return friendlyURL; }
@Override public boolean hasPortletId(String portletId, boolean strict) throws PortalException { List<String> columns = getColumns(); for (String columnId : columns) { if (hasNonstaticPortletId(columnId, portletId)) { return true; } if (hasStaticPortletId(columnId, portletId)) { return true; } } Layout layout = getLayout(); if (layout.isTypeControlPanel()) { return false; } if (isCustomizable() && isCustomizedView()) { LayoutTypePortletImpl defaultLayoutTypePortletImpl = getDefaultLayoutTypePortletImpl(); if (defaultLayoutTypePortletImpl.hasNonstaticPortletId(portletId)) { return false; } } if (!strict && ((PortletPreferencesLocalServiceUtil.getPortletPreferencesCount( PortletKeys.PREFS_OWNER_TYPE_LAYOUT, layout.getPlid(), portletId) > 0) || (PortletPreferencesLocalServiceUtil.getPortletPreferencesCount( PortletKeys.PREFS_OWNER_TYPE_USER, layout.getPlid(), portletId) > 0))) { return true; } return false; }
@Test public void testGetSelectedLayoutsJSONSelectChildLayout() throws Exception { Layout layout = LayoutTestUtil.addLayout(_stagingGroup); Layout childLayout = LayoutTestUtil.addLayout(_stagingGroup, layout.getPlid()); long[] selectedLayoutIds = new long[] {childLayout.getLayoutId()}; String selectedLayoutsJSON = ExportImportHelperUtil.getSelectedLayoutsJSON( _stagingGroup.getGroupId(), false, StringUtil.merge(selectedLayoutIds)); JSONArray selectedLayoutsJSONArray = JSONFactoryUtil.createJSONArray(selectedLayoutsJSON); Assert.assertEquals(1, selectedLayoutsJSONArray.length()); JSONObject layoutJSONObject = selectedLayoutsJSONArray.getJSONObject(0); Assert.assertTrue(layoutJSONObject.getBoolean("includeChildren")); Assert.assertEquals(childLayout.getPlid(), layoutJSONObject.getLong("plid")); }
public boolean isSelected(boolean selectable, Layout layout, long ancestorPlid) { if (selectable) { long plid = getPlid(); if ((plid == layout.getPlid()) || (plid == ancestorPlid)) { return true; } } return false; }
public void resetUserPreferences() { if (hasUserPreferences()) { Layout layout = getLayout(); long plid = layout.getPlid(); _portalPreferences.resetValues(CustomizedPages.namespacePlid(plid)); _portalPreferences.setValue( CustomizedPages.namespacePlid(plid), _MODIFIED_DATE, _dateFormat.format(new Date())); } }
public static String getColumnUserPrefs(String namespace, ThemeDisplay themeDisplay) { StringBundler sb = new StringBundler(3); sb.append(_COLUMN_USER_PREFS); sb.append(namespace); Layout layout = themeDisplay.getLayout(); sb.append(layout.getPlid()); return sb.toString(); }
@Ignore @Test public void testImportLinksToLayoutsIdsReplacement() throws Exception { LayoutTestUtil.addLayout(_liveGroup, true); LayoutTestUtil.addLayout(_liveGroup, false); exportImportLayouts(true); exportImportLayouts(false); Layout importedPrivateLayout = LayoutLocalServiceUtil.fetchLayoutByUuidAndGroupId( _stagingPrivateLayout.getUuid(), _liveGroup.getGroupId(), true); Layout importedPublicLayout = LayoutLocalServiceUtil.fetchLayoutByUuidAndGroupId( _stagingPublicLayout.getUuid(), _liveGroup.getGroupId(), false); Map<Long, Long> layoutPlids = (Map<Long, Long>) _portletDataContextImport.getNewPrimaryKeysMap(Layout.class); layoutPlids.put(_stagingPrivateLayout.getPlid(), importedPrivateLayout.getPlid()); layoutPlids.put(_stagingPublicLayout.getPlid(), importedPublicLayout.getPlid()); String content = getContent("layout_links_ids_replacement.txt"); String expectedContent = replaceLinksToLayoutsParameters(content, importedPrivateLayout, importedPublicLayout); content = replaceLinksToLayoutsParameters(content, _stagingPrivateLayout, _stagingPublicLayout); content = ExportImportHelperUtil.replaceExportContentReferences( _portletDataContextExport, _referrerStagedModel, content, true); String importedContent = ExportImportHelperUtil.replaceImportContentReferences( _portletDataContextImport, _referrerStagedModel, content); Assert.assertEquals(expectedContent, importedContent); }
protected String getLayoutIconPath( PortletDataContext portletDataContext, Layout layout, Image image) { StringBundler sb = new StringBundler(5); sb.append(ExportImportPathUtil.getLayoutPath(portletDataContext, layout.getPlid())); sb.append("/icons/"); sb.append(image.getImageId()); sb.append(StringPool.PERIOD); sb.append(image.getType()); return sb.toString(); }
protected LayoutRevision getLayoutRevision() throws Exception { Layout layout = LayoutTestUtil.addLayout(_group, false); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(); LayoutSetBranch layoutSetBranch = LayoutSetBranchLocalServiceUtil.addLayoutSetBranch( TestPropsValues.getUserId(), _group.getGroupId(), false, RandomTestUtil.randomString(), RandomTestUtil.randomString(), true, 0, serviceContext); LayoutBranch layoutBranch = LayoutBranchLocalServiceUtil.getMasterLayoutBranch( layoutSetBranch.getLayoutSetBranchId(), layout.getPlid()); return LayoutRevisionLocalServiceUtil.getLayoutRevision( layoutSetBranch.getLayoutSetBranchId(), layoutBranch.getLayoutBranchId(), layout.getPlid()); }
@Test public void testGetSelectedLayoutsJSONSelectNoLayouts() throws Exception { Layout layout = LayoutTestUtil.addLayout(_stagingGroup); LayoutTestUtil.addLayout(_stagingGroup, layout.getPlid()); String selectedLayoutsJSON = ExportImportHelperUtil.getSelectedLayoutsJSON( _stagingGroup.getGroupId(), false, StringUtil.merge(new long[0])); JSONArray selectedLayoutsJSONArray = JSONFactoryUtil.createJSONArray(selectedLayoutsJSON); Assert.assertEquals(0, selectedLayoutsJSONArray.length()); }
protected PortletPreferences getPortletInstancePortletPreferences( Layout layout, String portletId) { long ownerId = PortletKeys.PREFS_OWNER_ID_DEFAULT; int ownerType = PortletKeys.PREFS_OWNER_TYPE_LAYOUT; if (PortletConstants.hasUserId(portletId)) { ownerId = PortletConstants.getUserId(portletId); ownerType = PortletKeys.PREFS_OWNER_TYPE_USER; } return PortletPreferencesLocalServiceUtil.getStrictPreferences( layout.getCompanyId(), ownerId, ownerType, layout.getPlid(), portletId); }
@Override protected StagedModel addStagedModel( Group group, Map<String, List<StagedModel>> dependentStagedModelsMap) throws Exception { List<StagedModel> dependentStagedModels = dependentStagedModelsMap.get(Layout.class.getSimpleName()); Layout parentLayout = (Layout) dependentStagedModels.get(0); Layout layout = LayoutTestUtil.addLayout(group, parentLayout.getPlid()); addDependentLayoutFriendlyURLs(dependentStagedModelsMap, layout); return layout; }