List of usage examples for com.liferay.portal.kernel.util UnicodeProperties remove
@Override
public String remove(Object key)
From source file:com.liferay.exportimport.staging.StagingImpl.java
License:Open Source License
@Override public void deleteLastImportSettings(Group liveGroup, boolean privateLayout) throws PortalException { List<Layout> layouts = _layoutLocalService.getLayouts(liveGroup.getGroupId(), privateLayout); for (Layout layout : layouts) { UnicodeProperties typeSettingsProperties = layout.getTypeSettingsProperties(); Set<String> keys = new HashSet<>(); for (String key : typeSettingsProperties.keySet()) { if (key.startsWith("last-import-")) { keys.add(key);// w w w .ja va 2s. c om } } if (keys.isEmpty()) { continue; } for (String key : keys) { typeSettingsProperties.remove(key); } _layoutLocalService.updateLayout(layout.getGroupId(), layout.getPrivateLayout(), layout.getLayoutId(), typeSettingsProperties.toString()); } }
From source file:com.liferay.layout.admin.web.internal.upgrade.v_1_0_0.UpgradeLayout.java
License:Open Source License
protected void updateLayout(long plid, String typeSettings) throws Exception { if (Validator.isNull(typeSettings)) { return;//from ww w. j ava2 s .c om } UnicodeProperties typeSettingsProperties = new UnicodeProperties(true); typeSettingsProperties.load(typeSettings); typeSettingsProperties.setProperty("embeddedLayoutURL", typeSettingsProperties.getProperty("url")); typeSettingsProperties.remove("url"); updateTypeSettings(plid, typeSettingsProperties.toString()); }
From source file:com.liferay.layout.internal.exportimport.data.handler.StagedLayoutSetStagedModelDataHandler.java
License:Open Source License
protected void doExportStagedModel(PortletDataContext portletDataContext, StagedLayoutSet stagedLayoutSet) throws Exception { exportLayouts(portletDataContext, stagedLayoutSet); exportLogo(portletDataContext, stagedLayoutSet); exportTheme(portletDataContext, stagedLayoutSet); // Layout set prototype settings boolean layoutSetPrototypeSettings = MapUtil.getBoolean(portletDataContext.getParameterMap(), PortletDataHandlerKeys.LAYOUT_SET_PROTOTYPE_SETTINGS); if (!layoutSetPrototypeSettings) { stagedLayoutSet.setLayoutSetPrototypeUuid(StringPool.BLANK); stagedLayoutSet.setLayoutSetPrototypeLinkEnabled(false); }//from www.j ava 2 s . c o m // Layout set settings boolean layoutSetSettings = MapUtil.getBoolean(portletDataContext.getParameterMap(), PortletDataHandlerKeys.LAYOUT_SET_SETTINGS); if (!layoutSetSettings) { stagedLayoutSet.setSettings(StringPool.BLANK); } // Serialization Element stagedLayoutSetElement = portletDataContext.getExportDataElement(stagedLayoutSet); // Last publish date must not be exported UnicodeProperties settingsProperties = stagedLayoutSet.getSettingsProperties(); settingsProperties.remove("last-publish-date"); // Page versioning stagedLayoutSet = unwrapLayoutSetStagingHandler(stagedLayoutSet); portletDataContext.addClassedModel(stagedLayoutSetElement, ExportImportPathUtil.getModelPath(stagedLayoutSet), stagedLayoutSet); // Last publish date boolean updateLastPublishDate = MapUtil.getBoolean(portletDataContext.getParameterMap(), PortletDataHandlerKeys.UPDATE_LAST_PUBLISH_DATE); if (ExportImportThreadLocal.isStagingInProcess() && updateLastPublishDate) { _exportImportProcessCallbackRegistry.registerCallback(portletDataContext.getExportImportProcessId(), new UpdateLayoutSetLastPublishDateCallable(portletDataContext.getDateRange(), portletDataContext.getGroupId(), portletDataContext.isPrivateLayout())); } }
From source file:com.liferay.portlet.documentlibrary.service.impl.DLFileEntryLocalServiceImpl.java
License:Open Source License
protected void convertExtraSettings(UnicodeProperties extraSettingsProperties, ExpandoBridge expandoBridge, String[] keys) {/* w ww .ja va 2 s . c om*/ for (String key : keys) { String value = extraSettingsProperties.remove(key); if (Validator.isNull(value)) { continue; } int type = expandoBridge.getAttributeType(key); Serializable serializable = ExpandoColumnConstants.getSerializable(type, value); expandoBridge.setAttribute(key, serializable); } }
From source file:com.liferay.portlet.portalsettings.action.EditLDAPServerAction.java
License:Open Source License
protected UnicodeProperties addLDAPServer(long companyId, UnicodeProperties properties) throws Exception { String defaultPostfix = LDAPSettingsUtil.getPropertyPostfix(0); String[] defaultKeys = new String[_KEYS.length]; for (int i = 0; i < _KEYS.length; i++) { defaultKeys[i] = _KEYS[i] + defaultPostfix; }//www . j a v a 2 s. c om long ldapServerId = CounterLocalServiceUtil.increment(); String postfix = LDAPSettingsUtil.getPropertyPostfix(ldapServerId); String[] keys = properties.keySet().toArray(new String[0]); for (String key : keys) { if (ArrayUtil.contains(defaultKeys, key)) { String value = properties.remove(key); if (key.equals(PropsKeys.LDAP_SECURITY_CREDENTIALS + defaultPostfix) && value.equals(Portal.TEMP_OBFUSCATION_VALUE)) { value = PrefsPropsUtil.getString(PropsKeys.LDAP_SECURITY_CREDENTIALS); } properties.setProperty(key.replace(defaultPostfix, postfix), value); } } PortletPreferences preferences = PrefsPropsUtil.getPreferences(companyId); String ldapServerIds = preferences.getValue("ldap.server.ids", StringPool.BLANK); ldapServerIds = StringUtil.add(ldapServerIds, String.valueOf(ldapServerId)); properties.setProperty("ldap.server.ids", ldapServerIds); return properties; }
From source file:com.liferay.site.admin.web.internal.portlet.SiteAdminPortlet.java
License:Open Source License
protected Group updateGroup(ActionRequest actionRequest) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long userId = portal.getUserId(actionRequest); long liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId"); long parentGroupId = ParamUtil.getLong(actionRequest, "parentGroupSearchContainerPrimaryKeys", GroupConstants.DEFAULT_PARENT_GROUP_ID); Map<Locale, String> nameMap = null; Map<Locale, String> descriptionMap = null; int type = 0; String friendlyURL = null;//from w ww. j a v a 2s. c o m boolean inheritContent = false; boolean active = false; boolean manualMembership = true; int membershipRestriction = GroupConstants.DEFAULT_MEMBERSHIP_RESTRICTION; boolean actionRequestMembershipRestriction = ParamUtil.getBoolean(actionRequest, "membershipRestriction"); if (actionRequestMembershipRestriction && (parentGroupId != GroupConstants.DEFAULT_PARENT_GROUP_ID)) { membershipRestriction = GroupConstants.MEMBERSHIP_RESTRICTION_TO_PARENT_SITE_MEMBERS; } ServiceContext serviceContext = ServiceContextFactory.getInstance(Group.class.getName(), actionRequest); ServiceContextThreadLocal.pushServiceContext(serviceContext); Group liveGroup = null; if (liveGroupId <= 0) { // Add group nameMap = LocalizationUtil.getLocalizationMap(actionRequest, "name"); descriptionMap = LocalizationUtil.getLocalizationMap(actionRequest, "description"); type = ParamUtil.getInteger(actionRequest, "type"); friendlyURL = ParamUtil.getString(actionRequest, "friendlyURL"); manualMembership = ParamUtil.getBoolean(actionRequest, "manualMembership"); inheritContent = ParamUtil.getBoolean(actionRequest, "inheritContent"); active = ParamUtil.getBoolean(actionRequest, "active"); liveGroup = groupService.addGroup(parentGroupId, GroupConstants.DEFAULT_LIVE_GROUP_ID, nameMap, descriptionMap, type, manualMembership, membershipRestriction, friendlyURL, true, inheritContent, active, serviceContext); LiveUsers.joinGroup(themeDisplay.getCompanyId(), liveGroup.getGroupId(), userId); } else { // Update group liveGroup = groupLocalService.getGroup(liveGroupId); nameMap = LocalizationUtil.getLocalizationMap(actionRequest, "name", liveGroup.getNameMap()); descriptionMap = LocalizationUtil.getLocalizationMap(actionRequest, "description", liveGroup.getDescriptionMap()); type = ParamUtil.getInteger(actionRequest, "type", liveGroup.getType()); manualMembership = ParamUtil.getBoolean(actionRequest, "manualMembership", liveGroup.isManualMembership()); friendlyURL = ParamUtil.getString(actionRequest, "friendlyURL", liveGroup.getFriendlyURL()); inheritContent = ParamUtil.getBoolean(actionRequest, "inheritContent", liveGroup.getInheritContent()); active = ParamUtil.getBoolean(actionRequest, "active", liveGroup.getActive()); liveGroup = groupService.updateGroup(liveGroupId, parentGroupId, nameMap, descriptionMap, type, manualMembership, membershipRestriction, friendlyURL, inheritContent, active, serviceContext); if (type == GroupConstants.TYPE_SITE_OPEN) { List<MembershipRequest> membershipRequests = membershipRequestLocalService.search(liveGroupId, MembershipRequestConstants.STATUS_PENDING, QueryUtil.ALL_POS, QueryUtil.ALL_POS); for (MembershipRequest membershipRequest : membershipRequests) { membershipRequestService.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 (StringUtil.equalsIgnoreCase(analyticsType, "google")) { String googleAnalyticsId = ParamUtil.getString(actionRequest, "googleAnalyticsId", typeSettingsProperties.getProperty("googleAnalyticsId")); typeSettingsProperties.setProperty("googleAnalyticsId", googleAnalyticsId); } else { String analyticsScript = ParamUtil.getString(actionRequest, Sites.ANALYTICS_PREFIX + analyticsType, typeSettingsProperties.getProperty(analyticsType)); typeSettingsProperties.setProperty(Sites.ANALYTICS_PREFIX + analyticsType, analyticsScript); } } boolean trashEnabled = ParamUtil.getBoolean(actionRequest, "trashEnabled", GetterUtil.getBoolean(typeSettingsProperties.getProperty("trashEnabled"), true)); typeSettingsProperties.setProperty("trashEnabled", String.valueOf(trashEnabled)); int trashEntriesMaxAgeCompany = PrefsPropsUtil.getInteger(themeDisplay.getCompanyId(), PropsKeys.TRASH_ENTRIES_MAX_AGE); int trashEntriesMaxAgeGroup = ParamUtil.getInteger(actionRequest, "trashEntriesMaxAge"); if (trashEntriesMaxAgeGroup <= 0) { trashEntriesMaxAgeGroup = GetterUtil.getInteger( typeSettingsProperties.getProperty("trashEntriesMaxAge"), trashEntriesMaxAgeCompany); } if (trashEntriesMaxAgeGroup != trashEntriesMaxAgeCompany) { typeSettingsProperties.setProperty("trashEntriesMaxAge", String.valueOf(GetterUtil.getInteger(trashEntriesMaxAgeGroup))); } else { typeSettingsProperties.remove("trashEntriesMaxAge"); } int contentSharingWithChildrenEnabled = ParamUtil.getInteger(actionRequest, "contentSharingWithChildrenEnabled", GetterUtil.getInteger(typeSettingsProperties.getProperty("contentSharingWithChildrenEnabled"), Sites.CONTENT_SHARING_WITH_CHILDREN_DEFAULT_VALUE)); typeSettingsProperties.setProperty("contentSharingWithChildrenEnabled", String.valueOf(contentSharingWithChildrenEnabled)); UnicodeProperties formTypeSettingsProperties = PropertiesParamUtil.getProperties(actionRequest, "TypeSettingsProperties--"); typeSettingsProperties.putAll(formTypeSettingsProperties); // Virtual hosts LayoutSet publicLayoutSet = liveGroup.getPublicLayoutSet(); String publicVirtualHost = ParamUtil.getString(actionRequest, "publicVirtualHost", publicLayoutSet.getVirtualHostname()); layoutSetService.updateVirtualHost(liveGroup.getGroupId(), false, publicVirtualHost); LayoutSet privateLayoutSet = liveGroup.getPrivateLayoutSet(); String privateVirtualHost = ParamUtil.getString(actionRequest, "privateVirtualHost", privateLayoutSet.getVirtualHostname()); layoutSetService.updateVirtualHost(liveGroup.getGroupId(), true, privateVirtualHost); // Staging if (liveGroup.hasStagingGroup()) { Group stagingGroup = liveGroup.getStagingGroup(); friendlyURL = ParamUtil.getString(actionRequest, "stagingFriendlyURL", stagingGroup.getFriendlyURL()); groupService.updateFriendlyURL(stagingGroup.getGroupId(), friendlyURL); LayoutSet stagingPublicLayoutSet = stagingGroup.getPublicLayoutSet(); publicVirtualHost = ParamUtil.getString(actionRequest, "stagingPublicVirtualHost", stagingPublicLayoutSet.getVirtualHostname()); layoutSetService.updateVirtualHost(stagingGroup.getGroupId(), false, publicVirtualHost); LayoutSet stagingPrivateLayoutSet = stagingGroup.getPrivateLayoutSet(); privateVirtualHost = ParamUtil.getString(actionRequest, "stagingPrivateVirtualHost", stagingPrivateLayoutSet.getVirtualHostname()); layoutSetService.updateVirtualHost(stagingGroup.getGroupId(), true, privateVirtualHost); UnicodeProperties stagedGroupTypeSettingsProperties = stagingGroup.getTypeSettingsProperties(); stagedGroupTypeSettingsProperties.putAll(formTypeSettingsProperties); groupService.updateGroup(stagingGroup.getGroupId(), stagedGroupTypeSettingsProperties.toString()); } liveGroup = groupService.updateGroup(liveGroup.getGroupId(), typeSettingsProperties.toString()); // Layout set prototypes 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; } } if (!liveGroup.isStaged() || liveGroup.isStagedRemotely()) { SitesUtil.updateLayoutSetPrototypesLinks(liveGroup, publicLayoutSetPrototypeId, privateLayoutSetPrototypeId, publicLayoutSetPrototypeLinkEnabled, privateLayoutSetPrototypeLinkEnabled); } else { SitesUtil.updateLayoutSetPrototypesLinks(liveGroup.getStagingGroup(), publicLayoutSetPrototypeId, privateLayoutSetPrototypeId, publicLayoutSetPrototypeLinkEnabled, privateLayoutSetPrototypeLinkEnabled); } themeDisplay.setSiteGroupId(liveGroup.getGroupId()); return liveGroup; }
From source file:com.liferay.so.hook.listeners.UserListener.java
License:Open Source License
protected void updateUserLayoutSets(long userId) throws Exception { User user = UserLocalServiceUtil.getUser(userId); Group group = user.getGroup(); ServiceContext serviceContext = new ServiceContext(); LayoutSetLocalServiceUtil.deleteLayoutSet(group.getGroupId(), false, serviceContext); LayoutSetLocalServiceUtil.deleteLayoutSet(group.getGroupId(), true, serviceContext); LayoutSetLocalServiceUtil.addLayoutSet(group.getGroupId(), false); LayoutSetLocalServiceUtil.addLayoutSet(group.getGroupId(), true); UnicodeProperties typeSettingsProperties = group.getTypeSettingsProperties(); typeSettingsProperties.remove("customJspServletContextName"); GroupLocalServiceUtil.updateGroup(group.getGroupId(), typeSettingsProperties.toString()); }
From source file:com.liferay.so.messaging.SODeployListenerMessageListener.java
License:Open Source License
protected void updateGroups(long companyId) throws PortalException { ActionableDynamicQuery actionableDynamicQuery = new GroupActionableDynamicQuery() { @Override//from w w w.j a v a 2 s. co m protected void performAction(Object object) throws PortalException { Group group = (Group) object; if (!group.isRegularSite()) { return; } if (!SocialOfficeServiceUtil.isSocialOfficeGroup(group.getGroupId())) { return; } if (group.hasPrivateLayouts()) { updateLayoutSetPrototype(group.getGroupId(), true); } if (group.hasPublicLayouts()) { updateLayoutSetPrototype(group.getGroupId(), false); } UnicodeProperties typeSettingsProperties = group.getTypeSettingsProperties(); typeSettingsProperties.remove("customJspServletContextName"); GroupLocalServiceUtil.updateGroup(group.getGroupId(), typeSettingsProperties.toString()); } }; actionableDynamicQuery.setCompanyId(companyId); actionableDynamicQuery.performActions(); }
From source file:com.liferay.so.messaging.SODeployListenerMessageListener.java
License:Open Source License
protected void updateLayoutSetPrototype(long groupId, boolean privateLayout) throws PortalException { // Layout// ww w. jav a 2s . c o m 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); }
From source file:com.liferay.so.util.LayoutSetPrototypeUtil.java
License:Open Source License
public static void removeLayoutSetPrototype(Group group, boolean privateLayout, String layoutSetPrototypeKey) throws PortalException { LayoutSet layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(group.getGroupId(), privateLayout); UnicodeProperties settingsProperties = layoutSet.getSettingsProperties(); settingsProperties.remove("last-merge-time"); layoutSet.setSettingsProperties(settingsProperties); layoutSet.setLayoutSetPrototypeUuid(StringPool.BLANK); layoutSet.setLayoutSetPrototypeLinkEnabled(false); LayoutSetLocalServiceUtil.updateLayoutSet(layoutSet); LayoutSetLocalServiceUtil.updateLookAndFeel(group.getGroupId(), null, null, StringPool.BLANK, false); LayoutSetPrototype layoutSetPrototype = fetchLayoutSetPrototype(group.getCompanyId(), layoutSetPrototypeKey);/* ww w. j a v a 2 s . c o m*/ Group layoutSetPrototypeGroup = layoutSetPrototype.getGroup(); List<Layout> layouts = LayoutLocalServiceUtil.getLayouts(layoutSetPrototypeGroup.getGroupId(), true); String[] layoutUuids = new String[layouts.size()]; for (int i = 0; i < layouts.size(); i++) { Layout layout = layouts.get(i); layoutUuids[i] = layout.getUuid(); } layouts = LayoutLocalServiceUtil.getLayouts(group.getGroupId(), privateLayout); layouts = ListUtil.sort(layouts, new LayoutPriorityComparator(false)); for (Layout layout : layouts) { if (ArrayUtil.contains(layoutUuids, layout.getSourcePrototypeLayoutUuid())) { LayoutLocalServiceUtil.deleteLayout(layout.getGroupId(), privateLayout, layout.getLayoutId(), new ServiceContext()); } } }