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 void updateLayoutSetPrototype(long groupId, boolean privateLayout) throws PortalException { // Layout LayoutSet layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(groupId, privateLayout); LayoutSetPrototype layoutSetPrototype = LayoutSetPrototypeLocalServiceUtil.getLayoutSetPrototype( layoutSet.getLayoutSetPrototypeId()); Group layoutSetPrototypeGroup = layoutSetPrototype.getGroup(); List<Layout> layoutSetPrototypeLayouts = LayoutLocalServiceUtil.getLayouts(layoutSetPrototypeGroup.getGroupId(), true); String[] layoutSetPrototypeLayoutUuids = new String[layoutSetPrototypeLayouts.size()]; for (int i = 0; i < layoutSetPrototypeLayouts.size(); i++) { Layout layout = layoutSetPrototypeLayouts.get(i); layoutSetPrototypeLayoutUuids[i] = layout.getUuid(); } List<Layout> layouts = LayoutLocalServiceUtil.getLayouts(groupId, privateLayout); for (Layout layout : layouts) { if (ArrayUtil.contains( layoutSetPrototypeLayoutUuids, layout.getSourcePrototypeLayoutUuid())) { layout.setLayoutPrototypeUuid(StringPool.BLANK); layout.setLayoutPrototypeLinkEnabled(false); layout.setSourcePrototypeLayoutUuid(StringPool.BLANK); LayoutLocalServiceUtil.updateLayout(layout); } } // Layout set UnicodeProperties settingsProperties = layoutSet.getSettingsProperties(); settingsProperties.remove("last-merge-time"); layoutSet.setSettingsProperties(settingsProperties); layoutSet.setLayoutSetPrototypeUuid(StringPool.BLANK); layoutSet.setLayoutSetPrototypeLinkEnabled(false); LayoutSetLocalServiceUtil.updateLayoutSet(layoutSet); LayoutSetLocalServiceUtil.updateLookAndFeel( layoutSet.getGroupId(), null, null, StringPool.BLANK, false); }
protected Object[] updateGroup(ActionRequest actionRequest) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long userId = PortalUtil.getUserId(actionRequest); long liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId"); long parentGroupId = ParamUtil.getLong( actionRequest, "parentGroupSearchContainerPrimaryKeys", GroupConstants.DEFAULT_PARENT_GROUP_ID); String name = null; String description = null; int type = 0; String friendlyURL = null; boolean active = false; ServiceContext serviceContext = ServiceContextFactory.getInstance(Group.class.getName(), actionRequest); Group liveGroup = null; String oldFriendlyURL = null; String oldStagingFriendlyURL = null; if (liveGroupId <= 0) { // Add group name = ParamUtil.getString(actionRequest, "name"); description = ParamUtil.getString(actionRequest, "description"); type = ParamUtil.getInteger(actionRequest, "type"); friendlyURL = ParamUtil.getString(actionRequest, "friendlyURL"); active = ParamUtil.getBoolean(actionRequest, "active"); liveGroup = GroupServiceUtil.addGroup( parentGroupId, name, description, type, friendlyURL, true, active, serviceContext); LiveUsers.joinGroup(themeDisplay.getCompanyId(), liveGroup.getGroupId(), userId); } else { // Update group liveGroup = GroupLocalServiceUtil.getGroup(liveGroupId); oldFriendlyURL = liveGroup.getFriendlyURL(); name = ParamUtil.getString(actionRequest, "name", liveGroup.getName()); description = ParamUtil.getString(actionRequest, "description", liveGroup.getDescription()); type = ParamUtil.getInteger(actionRequest, "type", liveGroup.getType()); friendlyURL = ParamUtil.getString(actionRequest, "friendlyURL", liveGroup.getFriendlyURL()); active = ParamUtil.getBoolean(actionRequest, "active", liveGroup.getActive()); liveGroup = GroupServiceUtil.updateGroup( liveGroupId, parentGroupId, name, description, type, friendlyURL, active, serviceContext); if (type == GroupConstants.TYPE_SITE_OPEN) { List<MembershipRequest> membershipRequests = MembershipRequestLocalServiceUtil.search( liveGroupId, MembershipRequestConstants.STATUS_PENDING, QueryUtil.ALL_POS, QueryUtil.ALL_POS); for (MembershipRequest membershipRequest : membershipRequests) { MembershipRequestServiceUtil.updateStatus( membershipRequest.getMembershipRequestId(), themeDisplay.translate("your-membership-has-been-approved"), MembershipRequestConstants.STATUS_APPROVED, serviceContext); LiveUsers.joinGroup( themeDisplay.getCompanyId(), membershipRequest.getGroupId(), new long[] {membershipRequest.getUserId()}); } } } // Settings UnicodeProperties typeSettingsProperties = liveGroup.getTypeSettingsProperties(); String customJspServletContextName = ParamUtil.getString( actionRequest, "customJspServletContextName", typeSettingsProperties.getProperty("customJspServletContextName")); typeSettingsProperties.setProperty("customJspServletContextName", customJspServletContextName); String googleAnalyticsId = ParamUtil.getString( actionRequest, "googleAnalyticsId", typeSettingsProperties.getProperty("googleAnalyticsId")); typeSettingsProperties.setProperty("googleAnalyticsId", googleAnalyticsId); String publicRobots = ParamUtil.getString( actionRequest, "publicRobots", liveGroup.getTypeSettingsProperty("false-robots.txt")); String privateRobots = ParamUtil.getString( actionRequest, "privateRobots", liveGroup.getTypeSettingsProperty("true-robots.txt")); typeSettingsProperties.setProperty("false-robots.txt", publicRobots); typeSettingsProperties.setProperty("true-robots.txt", privateRobots); // Virtual hosts LayoutSet publicLayoutSet = liveGroup.getPublicLayoutSet(); String publicVirtualHost = ParamUtil.getString( actionRequest, "publicVirtualHost", publicLayoutSet.getVirtualHostname()); LayoutSetServiceUtil.updateVirtualHost(liveGroup.getGroupId(), false, publicVirtualHost); LayoutSet privateLayoutSet = liveGroup.getPrivateLayoutSet(); String privateVirtualHost = ParamUtil.getString( actionRequest, "privateVirtualHost", privateLayoutSet.getVirtualHostname()); LayoutSetServiceUtil.updateVirtualHost(liveGroup.getGroupId(), true, privateVirtualHost); // Staging if (liveGroup.hasStagingGroup()) { Group stagingGroup = liveGroup.getStagingGroup(); oldStagingFriendlyURL = stagingGroup.getFriendlyURL(); friendlyURL = ParamUtil.getString(actionRequest, "stagingFriendlyURL", stagingGroup.getFriendlyURL()); GroupServiceUtil.updateFriendlyURL(stagingGroup.getGroupId(), friendlyURL); LayoutSet stagingPublicLayoutSet = stagingGroup.getPublicLayoutSet(); publicVirtualHost = ParamUtil.getString( actionRequest, "stagingPublicVirtualHost", stagingPublicLayoutSet.getVirtualHostname()); LayoutSetServiceUtil.updateVirtualHost(stagingGroup.getGroupId(), false, publicVirtualHost); LayoutSet stagingPrivateLayoutSet = stagingGroup.getPrivateLayoutSet(); privateVirtualHost = ParamUtil.getString( actionRequest, "stagingPrivateVirtualHost", stagingPrivateLayoutSet.getVirtualHostname()); LayoutSetServiceUtil.updateVirtualHost(stagingGroup.getGroupId(), true, privateVirtualHost); } liveGroup = GroupServiceUtil.updateGroup(liveGroup.getGroupId(), typeSettingsProperties.toString()); // Layout set prototypes if (!liveGroup.isStaged()) { long privateLayoutSetPrototypeId = ParamUtil.getLong( actionRequest, "privateLayoutSetPrototypeId", privateLayoutSet.getLayoutSetPrototypeId()); long publicLayoutSetPrototypeId = ParamUtil.getLong( actionRequest, "publicLayoutSetPrototypeId", publicLayoutSet.getLayoutSetPrototypeId()); boolean privateLayoutSetPrototypeLinkEnabled = ParamUtil.getBoolean( actionRequest, "privateLayoutSetPrototypeLinkEnabled", privateLayoutSet.isLayoutSetPrototypeLinkEnabled()); boolean publicLayoutSetPrototypeLinkEnabled = ParamUtil.getBoolean( actionRequest, "publicLayoutSetPrototypeLinkEnabled", publicLayoutSet.isLayoutSetPrototypeLinkEnabled()); if ((privateLayoutSetPrototypeId == 0) && (publicLayoutSetPrototypeId == 0) && !privateLayoutSetPrototypeLinkEnabled && !publicLayoutSetPrototypeLinkEnabled) { long layoutSetPrototypeId = ParamUtil.getLong(actionRequest, "layoutSetPrototypeId"); int layoutSetVisibility = ParamUtil.getInteger(actionRequest, "layoutSetVisibility"); boolean layoutSetPrototypeLinkEnabled = ParamUtil.getBoolean( actionRequest, "layoutSetPrototypeLinkEnabled", (layoutSetPrototypeId > 0)); if (layoutSetVisibility == _LAYOUT_SET_VISIBILITY_PRIVATE) { privateLayoutSetPrototypeId = layoutSetPrototypeId; privateLayoutSetPrototypeLinkEnabled = layoutSetPrototypeLinkEnabled; } else { publicLayoutSetPrototypeId = layoutSetPrototypeId; publicLayoutSetPrototypeLinkEnabled = layoutSetPrototypeLinkEnabled; } } SitesUtil.updateLayoutSetPrototypesLinks( liveGroup, publicLayoutSetPrototypeId, privateLayoutSetPrototypeId, publicLayoutSetPrototypeLinkEnabled, privateLayoutSetPrototypeLinkEnabled); } // Staging String redirect = ParamUtil.getString(actionRequest, "redirect"); long refererPlid = GetterUtil.getLong(HttpUtil.getParameter(redirect, "refererPlid", false)); if (!privateLayoutSet.isLayoutSetPrototypeLinkActive() && !publicLayoutSet.isLayoutSetPrototypeLinkActive()) { if ((refererPlid > 0) && liveGroup.hasStagingGroup() && (themeDisplay.getScopeGroupId() != liveGroup.getGroupId())) { Layout firstLayout = LayoutLocalServiceUtil.fetchFirstLayout( liveGroup.getGroupId(), false, LayoutConstants.DEFAULT_PARENT_LAYOUT_ID); if (firstLayout == null) { firstLayout = LayoutLocalServiceUtil.fetchFirstLayout( liveGroup.getGroupId(), true, LayoutConstants.DEFAULT_PARENT_LAYOUT_ID); } if (firstLayout != null) { refererPlid = firstLayout.getPlid(); } else { refererPlid = 0; } } StagingUtil.updateStaging(actionRequest, liveGroup); } return new Object[] {liveGroup, oldFriendlyURL, oldStagingFriendlyURL, refererPlid}; }