List of usage examples for com.liferay.portal.kernel.util UnicodeProperties putAll
@Override
public void putAll(Map<? extends String, ? extends String> map)
From source file:com.liferay.layout.admin.web.internal.portlet.action.EditLayoutMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { UploadPortletRequest uploadPortletRequest = _portal.getUploadPortletRequest(actionRequest); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long groupId = ParamUtil.getLong(actionRequest, "groupId"); long liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId"); long stagingGroupId = ParamUtil.getLong(actionRequest, "stagingGroupId"); boolean privateLayout = ParamUtil.getBoolean(actionRequest, "privateLayout"); long layoutId = ParamUtil.getLong(actionRequest, "layoutId"); Map<Locale, String> nameMap = LocalizationUtil.getLocalizationMap(actionRequest, "name"); Map<Locale, String> titleMap = LocalizationUtil.getLocalizationMap(actionRequest, "title"); Map<Locale, String> descriptionMap = LocalizationUtil.getLocalizationMap(actionRequest, "description"); Map<Locale, String> keywordsMap = LocalizationUtil.getLocalizationMap(actionRequest, "keywords"); Map<Locale, String> robotsMap = LocalizationUtil.getLocalizationMap(actionRequest, "robots"); String type = ParamUtil.getString(uploadPortletRequest, "type"); boolean hidden = ParamUtil.getBoolean(uploadPortletRequest, "hidden"); Map<Locale, String> friendlyURLMap = LocalizationUtil.getLocalizationMap(actionRequest, "friendlyURL"); boolean deleteLogo = ParamUtil.getBoolean(actionRequest, "deleteLogo"); byte[] iconBytes = null; long fileEntryId = ParamUtil.getLong(uploadPortletRequest, "fileEntryId"); if (fileEntryId > 0) { FileEntry fileEntry = _dlAppLocalService.getFileEntry(fileEntryId); iconBytes = FileUtil.getBytes(fileEntry.getContentStream()); }/*from w w w .j a v a 2 s. co m*/ ServiceContext serviceContext = ServiceContextFactory.getInstance(Layout.class.getName(), actionRequest); Layout layout = _layoutLocalService.getLayout(groupId, privateLayout, layoutId); String currentType = layout.getType(); layout = _layoutService.updateLayout(groupId, privateLayout, layoutId, layout.getParentLayoutId(), nameMap, titleMap, descriptionMap, keywordsMap, robotsMap, type, hidden, friendlyURLMap, !deleteLogo, iconBytes, serviceContext); themeDisplay.clearLayoutFriendlyURL(layout); UnicodeProperties layoutTypeSettingsProperties = layout.getTypeSettingsProperties(); UnicodeProperties formTypeSettingsProperties = PropertiesParamUtil.getProperties(actionRequest, "TypeSettingsProperties--"); String linkToLayoutUuid = ParamUtil.getString(actionRequest, "linkToLayoutUuid"); if (Validator.isNotNull(linkToLayoutUuid)) { Layout linkToLayout = _layoutLocalService.getLayoutByUuidAndGroupId(linkToLayoutUuid, groupId, privateLayout); formTypeSettingsProperties.put("linkToLayoutId", String.valueOf(linkToLayout.getLayoutId())); } LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType(); if (type.equals(LayoutConstants.TYPE_PORTLET)) { String layoutTemplateId = ParamUtil.getString(uploadPortletRequest, "layoutTemplateId", PropsValues.DEFAULT_LAYOUT_TEMPLATE_ID); layoutTypePortlet.setLayoutTemplateId(themeDisplay.getUserId(), layoutTemplateId); layoutTypeSettingsProperties.putAll(formTypeSettingsProperties); boolean layoutCustomizable = GetterUtil .getBoolean(layoutTypeSettingsProperties.get(LayoutConstants.CUSTOMIZABLE_LAYOUT)); if (!layoutCustomizable) { layoutTypePortlet.removeCustomization(layoutTypeSettingsProperties); } layout = _layoutService.updateLayout(groupId, privateLayout, layoutId, layoutTypeSettingsProperties.toString()); if (!currentType.equals(LayoutConstants.TYPE_PORTLET)) { _portletPreferencesLocalService.deletePortletPreferences(0, PortletKeys.PREFS_OWNER_TYPE_LAYOUT, layout.getPlid()); } } else { layoutTypeSettingsProperties.putAll(formTypeSettingsProperties); layoutTypeSettingsProperties.putAll(layout.getTypeSettingsProperties()); layout = _layoutService.updateLayout(groupId, privateLayout, layoutId, layoutTypeSettingsProperties.toString()); } HttpServletResponse response = _portal.getHttpServletResponse(actionResponse); EventsProcessorUtil.process(PropsKeys.LAYOUT_CONFIGURATION_ACTION_UPDATE, layoutTypePortlet.getConfigurationActionUpdate(), uploadPortletRequest, response); _actionUtil.updateLookAndFeel(actionRequest, themeDisplay.getCompanyId(), liveGroupId, stagingGroupId, privateLayout, layout.getLayoutId(), layout.getTypeSettingsProperties()); String redirect = ParamUtil.getString(actionRequest, "redirect"); if (Validator.isNull(redirect)) { redirect = _portal.getLayoutFullURL(layout, themeDisplay); } String portletResource = ParamUtil.getString(actionRequest, "portletResource"); MultiSessionMessages.add(actionRequest, portletResource + "layoutUpdated", layout); actionRequest.setAttribute(WebKeys.REDIRECT, redirect); }
From source file:com.liferay.layout.admin.web.internal.portlet.action.EditLayoutSetMVCActionCommand.java
License:Open Source License
protected void updateSettings(ActionRequest actionRequest, long liveGroupId, long stagingGroupId, boolean privateLayout, UnicodeProperties settingsProperties) throws Exception { UnicodeProperties typeSettingsProperties = PropertiesParamUtil.getProperties(actionRequest, "TypeSettingsProperties--"); settingsProperties.putAll(typeSettingsProperties); long groupId = liveGroupId; if (stagingGroupId > 0) { groupId = stagingGroupId;/*from w w w .j a v a 2s . com*/ } _layoutSetService.updateSettings(groupId, privateLayout, settingsProperties.toString()); }
From source file:com.liferay.portlet.layoutsadmin.action.EditLayoutsAction.java
License:Open Source License
protected Object[] updateLayout(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String cmd = ParamUtil.getString(uploadPortletRequest, Constants.CMD); long groupId = ParamUtil.getLong(actionRequest, "groupId"); long liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId"); long stagingGroupId = ParamUtil.getLong(actionRequest, "stagingGroupId"); boolean privateLayout = ParamUtil.getBoolean(actionRequest, "privateLayout"); long layoutId = ParamUtil.getLong(actionRequest, "layoutId"); long parentLayoutId = ParamUtil.getLong(uploadPortletRequest, "parentLayoutId"); Map<Locale, String> nameMap = LocalizationUtil.getLocalizationMap(actionRequest, "name"); Map<Locale, String> titleMap = LocalizationUtil.getLocalizationMap(actionRequest, "title"); Map<Locale, String> descriptionMap = LocalizationUtil.getLocalizationMap(actionRequest, "description"); Map<Locale, String> keywordsMap = LocalizationUtil.getLocalizationMap(actionRequest, "keywords"); Map<Locale, String> robotsMap = LocalizationUtil.getLocalizationMap(actionRequest, "robots"); String type = ParamUtil.getString(uploadPortletRequest, "type"); boolean hidden = ParamUtil.getBoolean(uploadPortletRequest, "hidden"); String friendlyURL = ParamUtil.getString(uploadPortletRequest, "friendlyURL"); boolean iconImage = ParamUtil.getBoolean(uploadPortletRequest, "iconImage"); byte[] iconBytes = getIconBytes(uploadPortletRequest, "iconFileName"); long layoutPrototypeId = ParamUtil.getLong(uploadPortletRequest, "layoutPrototypeId"); ServiceContext serviceContext = ServiceContextFactory.getInstance(Layout.class.getName(), actionRequest); Layout layout = null;/*from w ww.j ava2 s. c om*/ UnicodeProperties layoutTypeSettingsProperties = null; String oldFriendlyURL = StringPool.BLANK; if (cmd.equals(Constants.ADD)) { // Add layout boolean inheritFromParentLayoutId = ParamUtil.getBoolean(uploadPortletRequest, "inheritFromParentLayoutId"); if (inheritFromParentLayoutId && (parentLayoutId > 0)) { Layout parentLayout = LayoutLocalServiceUtil.getLayout(groupId, privateLayout, parentLayoutId); layout = LayoutServiceUtil.addLayout(groupId, privateLayout, parentLayoutId, nameMap, titleMap, descriptionMap, keywordsMap, robotsMap, parentLayout.getType(), hidden, friendlyURL, serviceContext); LayoutServiceUtil.updateLayout(layout.getGroupId(), layout.isPrivateLayout(), layout.getLayoutId(), parentLayout.getTypeSettings()); if (parentLayout.isTypePortlet()) { ActionUtil.copyPreferences(actionRequest, layout, parentLayout); SitesUtil.copyLookAndFeel(layout, parentLayout); } } else if (layoutPrototypeId > 0) { LayoutPrototype layoutPrototype = LayoutPrototypeServiceUtil.getLayoutPrototype(layoutPrototypeId); String layoutPrototypeLinkEnabled = ParamUtil.getString(uploadPortletRequest, "layoutPrototypeLinkEnabled"); if (Validator.isNotNull(layoutPrototypeLinkEnabled)) { serviceContext.setAttribute("layoutPrototypeLinkEnabled", layoutPrototypeLinkEnabled); } serviceContext.setAttribute("layoutPrototypeUuid", layoutPrototype.getUuid()); layout = LayoutServiceUtil.addLayout(groupId, privateLayout, parentLayoutId, nameMap, titleMap, descriptionMap, keywordsMap, robotsMap, LayoutConstants.TYPE_PORTLET, hidden, friendlyURL, serviceContext); } else { layout = LayoutServiceUtil.addLayout(groupId, privateLayout, parentLayoutId, nameMap, titleMap, descriptionMap, keywordsMap, robotsMap, type, hidden, friendlyURL, serviceContext); } layoutTypeSettingsProperties = layout.getTypeSettingsProperties(); } else { // Update layout layout = LayoutLocalServiceUtil.getLayout(groupId, privateLayout, layoutId); oldFriendlyURL = layout.getFriendlyURL(); layout = LayoutServiceUtil.updateLayout(groupId, privateLayout, layoutId, layout.getParentLayoutId(), nameMap, titleMap, descriptionMap, keywordsMap, robotsMap, type, hidden, friendlyURL, Boolean.valueOf(iconImage), iconBytes, serviceContext); layoutTypeSettingsProperties = layout.getTypeSettingsProperties(); if (oldFriendlyURL.equals(layout.getFriendlyURL())) { oldFriendlyURL = StringPool.BLANK; } UnicodeProperties formTypeSettingsProperties = PropertiesParamUtil.getProperties(actionRequest, "TypeSettingsProperties--"); if (type.equals(LayoutConstants.TYPE_PORTLET)) { LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType(); String layoutTemplateId = ParamUtil.getString(uploadPortletRequest, "layoutTemplateId", PropsValues.DEFAULT_LAYOUT_TEMPLATE_ID); layoutTypePortlet.setLayoutTemplateId(themeDisplay.getUserId(), layoutTemplateId); long copyLayoutId = ParamUtil.getLong(uploadPortletRequest, "copyLayoutId"); if ((copyLayoutId > 0) && (copyLayoutId != layout.getLayoutId())) { try { Layout copyLayout = LayoutLocalServiceUtil.getLayout(groupId, privateLayout, copyLayoutId); if (copyLayout.isTypePortlet()) { layoutTypeSettingsProperties = copyLayout.getTypeSettingsProperties(); ActionUtil.copyPreferences(actionRequest, layout, copyLayout); SitesUtil.copyLookAndFeel(layout, copyLayout); } } catch (NoSuchLayoutException nsle) { } } else { layoutTypeSettingsProperties.putAll(formTypeSettingsProperties); LayoutServiceUtil.updateLayout(groupId, privateLayout, layoutId, layout.getTypeSettings()); } } else { layout.setTypeSettingsProperties(formTypeSettingsProperties); layoutTypeSettingsProperties.putAll(layout.getTypeSettingsProperties()); LayoutServiceUtil.updateLayout(groupId, privateLayout, layoutId, layout.getTypeSettings()); } HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse); LayoutSettings layoutSettings = LayoutSettings.getInstance(layout); EventsProcessorUtil.process(PropsKeys.LAYOUT_CONFIGURATION_ACTION_UPDATE, layoutSettings.getConfigurationActionUpdate(), uploadPortletRequest, response); } updateLookAndFeel(actionRequest, themeDisplay.getCompanyId(), liveGroupId, stagingGroupId, privateLayout, layout.getLayoutId(), layoutTypeSettingsProperties); updateCustomAttributes(themeDisplay.getCompanyId(), layout, uploadPortletRequest); return new Object[] { layout, oldFriendlyURL }; }
From source file:com.liferay.portlet.layoutsadmin.action.EditLayoutSetAction.java
License:Open Source License
protected void updateSettings(ActionRequest actionRequest, long liveGroupId, long stagingGroupId, boolean privateLayout, UnicodeProperties settingsProperties) throws Exception { UnicodeProperties typeSettingsProperties = PropertiesParamUtil.getProperties(actionRequest, "TypeSettingsProperties--"); settingsProperties.putAll(typeSettingsProperties); boolean showSiteName = ParamUtil.getBoolean(actionRequest, "showSiteName"); settingsProperties.put("showSiteName", Boolean.toString(showSiteName)); LayoutSetServiceUtil.updateSettings(liveGroupId, privateLayout, settingsProperties.toString()); if (stagingGroupId > 0) { LayoutSetServiceUtil.updateSettings(stagingGroupId, privateLayout, typeSettingsProperties.toString()); }/*from w w w .java 2 s.c om*/ }
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;/*w w w .j a v a2 s .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.sqli.liferay.imex.core.group.GroupImporter.java
License:Open Source License
public void doImport(long companyId, File groupDir, GroupImportOptions options, long classPK) throws Exception { SimpleXmlProcessor<ImExGroup> xmlProcessor = new SimpleXmlProcessor<ImExGroup>(ImExGroup.class, groupDir, FilesNames.GROUP);//from www . j a va2 s . c om ImExGroup g = xmlProcessor.read(); boolean site = g.isSite(); long userId = getDefaultAdmin(companyId).getUserId(); String className = g.getClassName(); String name = g.getName(); String description = g.getDescription(); int type = g.getType().getIntValue(); String friendlyURL = g.getFriendlyURL(); boolean active = g.isActive(); ServiceContext serviceContext = new ServiceContext(); UnicodeProperties unicodeProperties = new UnicodeProperties(); unicodeProperties.putAll(g.getTypeSettings()); String typeSettings = unicodeProperties.toString(); //Tentative de cration Group group = null; try { group = GroupLocalServiceUtil.addGroup(userId, className, classPK, name, description, type, friendlyURL, site, active, serviceContext); doImportLars(groupDir, options, userId, group); _log.info("[" + group.getFriendlyURL() + "] => [CREATE] ..."); } catch (DuplicateGroupException e) { //Chargement du group group = GroupLocalServiceUtil.getFriendlyURLGroup(companyId, friendlyURL); OnDuplicateMethodEnum method = options.getOnduplicateBehavior(group); if (!method.getValue().equals(OnDuplicateMethodEnum.SKIP.getValue())) { long groupId = group.getGroupId(); //Si le group existe if (method.getValue().equals(OnDuplicateMethodEnum.UPDATE.getValue())) { GroupLocalServiceUtil.updateGroup(groupId, name, description, type, friendlyURL, active, serviceContext); } else if (method.getValue().equals(OnDuplicateMethodEnum.REPLACE.getValue())) { //Suppression du Group GroupLocalServiceUtil.deleteGroup(group); //Cration du group group = GroupLocalServiceUtil.addGroup(userId, className, classPK, name, description, type, friendlyURL, site, active, serviceContext); } doImportLars(groupDir, options, userId, group); _log.info("[" + group.getFriendlyURL() + "] => [" + method.getValue() + "] ..."); } } }
From source file:fi.javaguru.socialcomments.portlet.SocialCommentsPortlet.java
License:Open Source License
public void updateConfiguration(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException { try {//from w w w .ja v a 2s. co m 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()); } }