private void _buildParentGroupsBreadcrumb( LayoutSet layoutSet, PortletURL portletURL, ThemeDisplay themeDisplay, StringBundler sb) throws Exception { Group group = layoutSet.getGroup(); if (group.isOrganization()) { Organization organization = OrganizationLocalServiceUtil.getOrganization(group.getOrganizationId()); Organization parentOrganization = organization.getParentOrganization(); if (parentOrganization != null) { Group parentGroup = parentOrganization.getGroup(); LayoutSet parentLayoutSet = LayoutSetLocalServiceUtil.getLayoutSet( parentGroup.getGroupId(), layoutSet.isPrivateLayout()); _buildParentGroupsBreadcrumb(parentLayoutSet, portletURL, themeDisplay, sb); } } else if (group.isUser()) { User groupUser = UserLocalServiceUtil.getUser(group.getClassPK()); List<Organization> organizations = OrganizationLocalServiceUtil.getUserOrganizations(groupUser.getUserId(), true); if (!organizations.isEmpty()) { Organization organization = organizations.get(0); Group parentGroup = organization.getGroup(); LayoutSet parentLayoutSet = LayoutSetLocalServiceUtil.getLayoutSet( parentGroup.getGroupId(), layoutSet.isPrivateLayout()); _buildParentGroupsBreadcrumb(parentLayoutSet, portletURL, themeDisplay, sb); } } int layoutsPageCount = 0; if (layoutSet.isPrivateLayout()) { layoutsPageCount = group.getPrivateLayoutsPageCount(); } else { layoutsPageCount = group.getPublicLayoutsPageCount(); } if ((layoutsPageCount > 0) && !group.getName().equals(GroupConstants.GUEST)) { String layoutSetFriendlyURL = PortalUtil.getLayoutSetFriendlyURL(layoutSet, themeDisplay); sb.append("<li><span><a href=\""); sb.append(layoutSetFriendlyURL); sb.append("\">"); sb.append(HtmlUtil.escape(group.getDescriptiveName())); sb.append("</a></span></li>"); } }
protected LayoutSet toUnwrappedModel(LayoutSet layoutSet) { if (layoutSet instanceof LayoutSetImpl) { return layoutSet; } LayoutSetImpl layoutSetImpl = new LayoutSetImpl(); layoutSetImpl.setNew(layoutSet.isNew()); layoutSetImpl.setPrimaryKey(layoutSet.getPrimaryKey()); layoutSetImpl.setLayoutSetId(layoutSet.getLayoutSetId()); layoutSetImpl.setGroupId(layoutSet.getGroupId()); layoutSetImpl.setCompanyId(layoutSet.getCompanyId()); layoutSetImpl.setPrivateLayout(layoutSet.isPrivateLayout()); layoutSetImpl.setLogo(layoutSet.isLogo()); layoutSetImpl.setLogoId(layoutSet.getLogoId()); layoutSetImpl.setThemeId(layoutSet.getThemeId()); layoutSetImpl.setColorSchemeId(layoutSet.getColorSchemeId()); layoutSetImpl.setWapThemeId(layoutSet.getWapThemeId()); layoutSetImpl.setWapColorSchemeId(layoutSet.getWapColorSchemeId()); layoutSetImpl.setCss(layoutSet.getCss()); layoutSetImpl.setPageCount(layoutSet.getPageCount()); layoutSetImpl.setSettings(layoutSet.getSettings()); layoutSetImpl.setLayoutSetPrototypeId(layoutSet.getLayoutSetPrototypeId()); return layoutSetImpl; }
protected List<Layout> addUserGroupLayouts( Group group, LayoutSet layoutSet, List<Layout> layouts, long parentLayoutId) throws Exception { layouts = ListUtil.copy(layouts); List<UserGroup> userUserGroups = UserGroupLocalServiceUtil.getUserUserGroups(group.getClassPK()); for (UserGroup userGroup : userUserGroups) { Group userGroupGroup = userGroup.getGroup(); List<Layout> userGroupLayouts = LayoutLocalServiceUtil.getLayouts( userGroupGroup.getGroupId(), layoutSet.isPrivateLayout(), parentLayoutId); for (Layout userGroupLayout : userGroupLayouts) { Layout virtualLayout = new VirtualLayout(userGroupLayout, group); layouts.add(virtualLayout); } } return layouts; }
public static void updateLastPublishDate(LayoutSet layoutSet, long lastPublishDate) throws Exception { UnicodeProperties settingsProperties = layoutSet.getSettingsProperties(); if (lastPublishDate <= 0) { settingsProperties.remove("last-publish-date"); } else { settingsProperties.setProperty("last-publish-date", String.valueOf(lastPublishDate)); } LayoutSetLocalServiceUtil.updateSettings( layoutSet.getGroupId(), layoutSet.isPrivateLayout(), settingsProperties.toString()); }
protected String importTheme(LayoutSet layoutSet, InputStream themeZip) throws Exception { ThemeLoader themeLoader = ThemeLoaderFactory.getDefaultThemeLoader(); if (themeLoader == null) { _log.error("No theme loaders are deployed"); return null; } ZipReader zipReader = ZipReaderFactoryUtil.getZipReader(themeZip); String lookAndFeelXML = zipReader.getEntryAsString("liferay-look-and-feel.xml"); String themeId = String.valueOf(layoutSet.getGroupId()); if (layoutSet.isPrivateLayout()) { themeId += "-private"; } else { themeId += "-public"; } if (PropsValues.THEME_LOADER_NEW_THEME_ID_ON_IMPORT) { Date now = new Date(); themeId += "-" + Time.getShortTimestamp(now); } String themeName = themeId; lookAndFeelXML = StringUtil.replace( lookAndFeelXML, new String[] {"[$GROUP_ID$]", "[$THEME_ID$]", "[$THEME_NAME$]"}, new String[] {String.valueOf(layoutSet.getGroupId()), themeId, themeName}); FileUtil.deltree(themeLoader.getFileStorage() + StringPool.SLASH + themeId); List<String> zipEntries = zipReader.getEntries(); for (String zipEntry : zipEntries) { String key = zipEntry; if (key.equals("liferay-look-and-feel.xml")) { FileUtil.write( themeLoader.getFileStorage() + StringPool.SLASH + themeId + StringPool.SLASH + key, lookAndFeelXML.getBytes()); } else { InputStream is = zipReader.getEntryAsInputStream(zipEntry); FileUtil.write( themeLoader.getFileStorage() + StringPool.SLASH + themeId + StringPool.SLASH + key, is); } } themeLoader.loadThemes(); ClusterRequest clusterRequest = ClusterRequest.createMulticastRequest(_loadThemesMethodHandler, true); clusterRequest.setFireAndForget(true); ClusterExecutorUtil.execute(clusterRequest); themeId += PortletConstants.WAR_SEPARATOR + themeLoader.getServletContextName(); return PortalUtil.getJsSafePortletId(themeId); }