/** * Updates the group's type settings. * * @param groupId the primary key of the group * @param typeSettings the group's new type settings (optionally <code>null</code>) * @return the group * @throws PortalException if a portal exception occurred */ @Override public Group updateGroup(long groupId, String typeSettings) throws PortalException { Group group = groupPersistence.findByPrimaryKey(groupId); GroupPermissionUtil.check(getPermissionChecker(), group, ActionKeys.UPDATE); if (group.isSite()) { Group oldGroup = group; UnicodeProperties oldTypeSettingsProperties = oldGroup.getTypeSettingsProperties(); group = groupLocalService.updateGroup(groupId, typeSettings); RatingsDataTransformerUtil.transformGroupRatingsData( groupId, oldTypeSettingsProperties, group.getTypeSettingsProperties()); SiteMembershipPolicyUtil.verifyPolicy( group, oldGroup, null, null, null, oldTypeSettingsProperties); return group; } else { return groupLocalService.updateGroup(groupId, typeSettings); } }
public void updateConfiguration(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException { try { ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); long scopeGroupId = serviceContext.getScopeGroupId(); Group scopeGroup = GroupLocalServiceUtil.getGroup(scopeGroupId); if (scopeGroup.isStagingGroup()) { scopeGroup = scopeGroup.getLiveGroup(); } UnicodeProperties typeSettingsProperties = scopeGroup.getTypeSettingsProperties(); UnicodeProperties properties = PropertiesParamUtil.getProperties(actionRequest, "settings--"); typeSettingsProperties.putAll(properties); GroupServiceUtil.updateGroup(scopeGroup.getGroupId(), scopeGroup.getTypeSettings()); } catch (Exception e) { SessionErrors.add(actionRequest, e.getClass().getName()); } }
public int getMaxAge(Group group) throws PortalException, SystemException { if (group.isLayout()) { group = group.getParentGroup(); } int trashEntriesMaxAge = PrefsPropsUtil.getInteger( group.getCompanyId(), PropsKeys.TRASH_ENTRIES_MAX_AGE, GetterUtil.getInteger(PropsUtil.get(PropsKeys.TRASH_ENTRIES_MAX_AGE))); UnicodeProperties typeSettingsProperties = group.getTypeSettingsProperties(); return GetterUtil.getInteger( typeSettingsProperties.getProperty("trashEntriesMaxAge"), trashEntriesMaxAge); }
@Override public void updateStagedPortlets(long groupId, Map<String, String> stagedPortletIds) throws PortalException { Group group = groupPersistence.findByPrimaryKey(groupId); GroupPermissionUtil.check(getPermissionChecker(), group, ActionKeys.UPDATE); UnicodeProperties typeSettingsProperties = group.getTypeSettingsProperties(); for (String stagedPortletId : stagedPortletIds.keySet()) { typeSettingsProperties.setProperty( StagingUtil.getStagedPortletId(stagedPortletId), stagedPortletIds.get(stagedPortletId)); } groupLocalService.updateGroup(group); }
@Override public UnicodeProperties getParentLiveGroupTypeSettingsProperties() { try { if (isLayout()) { Group parentGroup = GroupLocalServiceUtil.getGroup(getParentGroupId()); return parentGroup.getParentLiveGroupTypeSettingsProperties(); } if (isStagingGroup()) { Group liveGroup = getLiveGroup(); return liveGroup.getTypeSettingsProperties(); } } catch (Exception e) { } return getTypeSettingsProperties(); }
private ObjectValuePair<Map<String, Locale>, Map<String, Locale>> _createGroupLocales( long groupId) { String[] languageIds = PropsValues.LOCALES_ENABLED; try { Group group = GroupLocalServiceUtil.getGroup(groupId); UnicodeProperties typeSettingsProperties = group.getTypeSettingsProperties(); languageIds = StringUtil.split(typeSettingsProperties.getProperty(PropsKeys.LOCALES)); } catch (Exception e) { } Map<String, Locale> groupLanguageCodeLocalesMap = new HashMap<>(); Map<String, Locale> groupLanguageIdLocalesMap = new HashMap<>(); for (String languageId : languageIds) { Locale locale = LocaleUtil.fromLanguageId(languageId, false); String languageCode = languageId; int pos = languageId.indexOf(CharPool.UNDERLINE); if (pos > 0) { languageCode = languageId.substring(0, pos); } if (!groupLanguageCodeLocalesMap.containsKey(languageCode)) { groupLanguageCodeLocalesMap.put(languageCode, locale); } groupLanguageIdLocalesMap.put(languageId, locale); } _groupLanguageCodeLocalesMapMap.put(groupId, groupLanguageCodeLocalesMap); _groupLanguageIdLocalesMap.put(groupId, groupLanguageIdLocalesMap); return new ObjectValuePair<>(groupLanguageCodeLocalesMap, groupLanguageIdLocalesMap); }
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, GroupConstants.DEFAULT_LIVE_GROUP_ID, 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); typeSettingsProperties.setProperty( "defaultSiteRoleIds", ListUtil.toString(getRoles(actionRequest), Role.ROLE_ID_ACCESSOR, StringPool.COMMA)); typeSettingsProperties.setProperty( "defaultTeamIds", ListUtil.toString(getTeams(actionRequest), Team.TEAM_ID_ACCESSOR, StringPool.COMMA)); String[] analyticsTypes = PrefsPropsUtil.getStringArray( themeDisplay.getCompanyId(), PropsKeys.ADMIN_ANALYTICS_TYPES, StringPool.NEW_LINE); for (String analyticsType : analyticsTypes) { if (analyticsType.equalsIgnoreCase("google")) { String googleAnalyticsId = ParamUtil.getString( actionRequest, "googleAnalyticsId", typeSettingsProperties.getProperty("googleAnalyticsId")); typeSettingsProperties.setProperty("googleAnalyticsId", googleAnalyticsId); } else { String analyticsScript = ParamUtil.getString( actionRequest, SitesUtil.ANALYTICS_PREFIX + analyticsType, typeSettingsProperties.getProperty(analyticsType)); typeSettingsProperties.setProperty( SitesUtil.ANALYTICS_PREFIX + analyticsType, analyticsScript); } } 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); int trashEnabled = ParamUtil.getInteger( actionRequest, "trashEnabled", GetterUtil.getInteger(typeSettingsProperties.getProperty("trashEnabled"))); typeSettingsProperties.setProperty("trashEnabled", String.valueOf(trashEnabled)); int trashEntriesMaxAgeCompany = PrefsPropsUtil.getInteger(themeDisplay.getCompanyId(), PropsKeys.TRASH_ENTRIES_MAX_AGE); int defaultTrashEntriesMaxAgeGroup = GetterUtil.getInteger( typeSettingsProperties.getProperty("trashEntriesMaxAge"), trashEntriesMaxAgeCompany); int trashEntriesMaxAgeGroup = ParamUtil.getInteger(actionRequest, "trashEntriesMaxAge", defaultTrashEntriesMaxAgeGroup); if (trashEntriesMaxAgeGroup != trashEntriesMaxAgeCompany) { typeSettingsProperties.setProperty( "trashEntriesMaxAge", String.valueOf(trashEntriesMaxAgeGroup)); } else { typeSettingsProperties.remove("trashEntriesMaxAge"); } // 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"); long publicLayoutSetPrototypeId = ParamUtil.getLong(actionRequest, "publicLayoutSetPrototypeId"); 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}; }