List of usage examples for com.liferay.portal.kernel.util UnicodeProperties put
@Override
public String put(String key, String value)
From source file:com.liferay.calendar.portlet.CalendarPortlet.java
License:Open Source License
protected String getNotificationTypeSettings(ActionRequest actionRequest, NotificationType notificationType) { UnicodeProperties notificationTypeSettingsProperties = new UnicodeProperties(true); if (notificationType == NotificationType.EMAIL) { String fromAddress = ParamUtil.getString(actionRequest, "fromAddress"); String fromName = ParamUtil.getString(actionRequest, "fromName"); notificationTypeSettingsProperties.put(CalendarNotificationTemplateConstants.PROPERTY_FROM_ADDRESS, fromAddress);//from w w w . ja va 2 s . co m notificationTypeSettingsProperties.put(CalendarNotificationTemplateConstants.PROPERTY_FROM_NAME, fromName); } return notificationTypeSettingsProperties.toString(); }
From source file:com.liferay.calendar.test.util.CalendarNotificationTemplateTestUtil.java
License:Open Source License
public static CalendarNotificationTemplate addCalendarNotificationTemplate(Calendar calendar, NotificationTemplateType notificationTemplateType, String fromAddress, String fromName, String subject, String body) throws PortalException { UnicodeProperties notificationTypeSettingsProperties = new UnicodeProperties(true); notificationTypeSettingsProperties.put(CalendarNotificationTemplateConstants.PROPERTY_FROM_ADDRESS, fromAddress);/* w w w .jav a2s.co m*/ notificationTypeSettingsProperties.put(CalendarNotificationTemplateConstants.PROPERTY_FROM_NAME, fromName); User user = UserLocalServiceUtil.getUser(calendar.getUserId()); return CalendarNotificationTemplateLocalServiceUtil.addCalendarNotificationTemplate(calendar.getUserId(), calendar.getCalendarId(), NotificationType.EMAIL, notificationTypeSettingsProperties.toString(), notificationTemplateType, subject, body, createServiceContext(user)); }
From source file:com.liferay.content.targeting.service.test.util.GroupTestUtil.java
License:Open Source License
public static Group updateDisplaySettings(long groupId, Locale[] availableLocales, Locale defaultLocale) throws Exception { UnicodeProperties typeSettingsProperties = new UnicodeProperties(); boolean inheritLocales = false; if ((availableLocales == null) && (defaultLocale == null)) { inheritLocales = true;/*from w ww. j a va 2s . co m*/ } typeSettingsProperties.put("inheritLocales", String.valueOf(inheritLocales)); if (availableLocales != null) { typeSettingsProperties.put(PropsKeys.LOCALES, StringUtil.merge(LocaleUtil.toLanguageIds(availableLocales))); } if (defaultLocale != null) { typeSettingsProperties.put("languageId", LocaleUtil.toLanguageId(defaultLocale)); } Group group = GroupLocalServiceUtil.updateGroup(groupId, typeSettingsProperties.toString()); ThreadLocalCacheManager.clearAll(Lifecycle.REQUEST); return group; }
From source file:com.liferay.exportimport.test.LayoutSetPrototypePropagationTest.java
License:Open Source License
protected Layout setLayoutUpdateable(Layout layout, boolean layoutUpdateable) throws Exception { UnicodeProperties typeSettingsProperties = layout.getTypeSettingsProperties(); typeSettingsProperties.put(Sites.LAYOUT_UPDATEABLE, String.valueOf(layoutUpdateable)); layout.setTypeSettingsProperties(typeSettingsProperties); return LayoutLocalServiceUtil.updateLayout(layout); }
From source file:com.liferay.grow.layout.helper.service.impl.LayoutHelperServiceImpl.java
License:Open Source License
@Override public void updateProfilePages() { if (_log.isInfoEnabled()) { _log.info("Updating Profile Pages..."); }/*from www . ja v a 2 s. c om*/ List<User> users = _userLocalService.getUsers(QueryUtil.ALL_POS, QueryUtil.ALL_POS); for (User user : users) { try { if (user.isDefaultUser()) { continue; } List<Layout> layouts = _layoutLocalService.getLayouts(user.getGroupId(), false); if (layouts.size() != 1) { if (_log.isInfoEnabled()) { _log.info("User: " + user.getScreenName() + " has " + layouts.size() + " public layout"); } } if (layouts.isEmpty()) { continue; } Layout layout = layouts.get(0); LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType(); // Update Theme layout.setThemeId("frontenduserprofilegrow_WAR_growthemeuserprofile"); layout.setColorSchemeId("01"); UnicodeProperties properties = layoutTypePortlet.getTypeSettingsProperties(); properties.put("layoutUpdateable", Boolean.TRUE.toString()); properties.put("sitemap-changefreq", "daily"); properties.put("sitemap-include", "1"); // Remove OWXPSubscribePortlet String owxpSubscribePortletId = "com_liferay_owxp_subscribe_portlet_OWXPSubscribePortlet"; List<String> portletIds = layoutTypePortlet.getPortletIds(); for (String portletId : portletIds) { if (portletId.startsWith(owxpSubscribePortletId)) { layoutTypePortlet.removePortletId(user.getUserId(), portletId); break; } } _layoutLocalService.updateLayout(layout); // Remove the Guest role's View permission from the Profile // Pages Role guestRole = _roleLocalService.getRole(layout.getCompanyId(), RoleConstants.GUEST); _resourcePermissionLocalService.setResourcePermissions(layout.getCompanyId(), Layout.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, String.valueOf(layout.getPlid()), guestRole.getRoleId(), new String[0]); } catch (Exception e) { _log.error("Cannot remove View permission for " + user.getScreenName(), e); } } if (_log.isInfoEnabled()) { _log.info("Profile Pages have been updated"); } }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
/** * Moves the latest version of the web content article matching the group * and article ID to the recycle bin./*from w ww . j av a2s . c om*/ * * @param userId the primary key of the user updating the web content * article * @param article the web content article * @return the updated web content article, which was moved to the Recycle * Bin */ @Indexable(type = IndexableType.REINDEX) @Override public JournalArticle moveArticleToTrash(long userId, JournalArticle article) throws PortalException { // Article if (article.isInTrash()) { throw new TrashEntryException(); } int oldStatus = article.getStatus(); if (oldStatus == WorkflowConstants.STATUS_PENDING) { article.setStatus(WorkflowConstants.STATUS_DRAFT); } journalArticlePersistence.update(article); List<JournalArticle> articleVersions = journalArticlePersistence.findByG_A(article.getGroupId(), article.getArticleId()); articleVersions = ListUtil.sort(articleVersions, new ArticleVersionComparator()); List<ObjectValuePair<Long, Integer>> articleVersionStatusOVPs = new ArrayList<>(); if ((articleVersions != null) && !articleVersions.isEmpty()) { articleVersionStatusOVPs = getArticleVersionStatuses(articleVersions); } article = updateStatus(userId, article.getId(), WorkflowConstants.STATUS_IN_TRASH, new HashMap<String, Serializable>(), new ServiceContext()); // Trash JournalArticleResource articleResource = journalArticleResourceLocalService .getArticleResource(article.getResourcePrimKey()); UnicodeProperties typeSettingsProperties = new UnicodeProperties(); typeSettingsProperties.put("title", article.getArticleId()); TrashEntry trashEntry = trashEntryLocalService.addTrashEntry(userId, article.getGroupId(), JournalArticle.class.getName(), article.getResourcePrimKey(), articleResource.getUuid(), null, oldStatus, articleVersionStatusOVPs, typeSettingsProperties); String trashArticleId = TrashUtil.getTrashTitle(trashEntry.getEntryId()); for (JournalArticle articleVersion : articleVersions) { articleVersion.setArticleId(trashArticleId); articleVersion.setStatus(WorkflowConstants.STATUS_IN_TRASH); journalArticlePersistence.update(articleVersion); } articleResource.setArticleId(trashArticleId); journalArticleResourcePersistence.update(articleResource); article.setArticleId(trashArticleId); article = journalArticlePersistence.update(article); // Asset assetEntryLocalService.updateVisible(JournalArticle.class.getName(), article.getResourcePrimKey(), false); // Attachments for (FileEntry fileEntry : article.getImagesFileEntries()) { PortletFileRepositoryUtil.movePortletFileEntryToTrash(userId, fileEntry.getFileEntryId()); } // Comment if (isArticleCommentsEnabled(article.getCompanyId())) { CommentManagerUtil.moveDiscussionToTrash(JournalArticle.class.getName(), article.getResourcePrimKey()); } // Social JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); extraDataJSONObject.put("title", article.getTitleMapAsXML()); SocialActivityManagerUtil.addActivity(userId, article, SocialActivityConstants.TYPE_MOVE_TO_TRASH, extraDataJSONObject.toString(), 0); if (oldStatus == WorkflowConstants.STATUS_PENDING) { workflowInstanceLinkLocalService.deleteWorkflowInstanceLink(article.getCompanyId(), article.getGroupId(), JournalArticle.class.getName(), article.getId()); } return article; }
From source file:com.liferay.journal.service.impl.JournalFolderLocalServiceImpl.java
License:Open Source License
@Indexable(type = IndexableType.REINDEX) @Override//from w w w. ja v a2s .c o m public JournalFolder moveFolderToTrash(long userId, long folderId) throws PortalException { // Folder JournalFolder folder = journalFolderPersistence.findByPrimaryKey(folderId); if (folder.isInTrash()) { throw new TrashEntryException(); } String title = folder.getName(); folder = updateStatus(userId, folder, WorkflowConstants.STATUS_IN_TRASH); // Trash UnicodeProperties typeSettingsProperties = new UnicodeProperties(); typeSettingsProperties.put("title", folder.getName()); TrashEntry trashEntry = trashEntryLocalService.addTrashEntry(userId, folder.getGroupId(), JournalFolder.class.getName(), folder.getFolderId(), folder.getUuid(), null, WorkflowConstants.STATUS_APPROVED, null, typeSettingsProperties); folder.setName(TrashUtil.getTrashTitle(trashEntry.getEntryId())); journalFolderPersistence.update(folder); // Folders and articles List<Object> foldersAndArticles = journalFolderLocalService.getFoldersAndArticles(folder.getGroupId(), folder.getFolderId()); moveDependentsToTrash(foldersAndArticles, trashEntry.getEntryId()); // Social JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); extraDataJSONObject.put("title", title); SocialActivityManagerUtil.addActivity(userId, folder, SocialActivityConstants.TYPE_MOVE_TO_TRASH, extraDataJSONObject.toString(), 0); return folder; }
From source file:com.liferay.layout.admin.web.internal.portlet.action.AddLayoutMVCActionCommand.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 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"); Map<Locale, String> friendlyURLMap = LocalizationUtil.getLocalizationMap(actionRequest, "friendlyURL"); long layoutPrototypeId = ParamUtil.getLong(uploadPortletRequest, "layoutPrototypeId"); ServiceContext serviceContext = ServiceContextFactory.getInstance(Layout.class.getName(), actionRequest); Layout layout = null;/*from www .j a va2 s. co m*/ boolean inheritFromParentLayoutId = ParamUtil.getBoolean(uploadPortletRequest, "inheritFromParentLayoutId"); UnicodeProperties typeSettingsProperties = PropertiesParamUtil.getProperties(actionRequest, "TypeSettingsProperties--"); String linkToLayoutUuid = ParamUtil.getString(actionRequest, "linkToLayoutUuid"); if (Validator.isNotNull(linkToLayoutUuid)) { Layout linkToLayout = _layoutLocalService.getLayoutByUuidAndGroupId(linkToLayoutUuid, groupId, privateLayout); typeSettingsProperties.put("linkToLayoutId", String.valueOf(linkToLayout.getLayoutId())); } if (inheritFromParentLayoutId && (parentLayoutId > 0)) { Layout parentLayout = _layoutLocalService.getLayout(groupId, privateLayout, parentLayoutId); layout = _layoutService.addLayout(groupId, privateLayout, parentLayoutId, nameMap, titleMap, parentLayout.getDescriptionMap(), parentLayout.getKeywordsMap(), parentLayout.getRobotsMap(), parentLayout.getType(), parentLayout.getTypeSettings(), hidden, friendlyURLMap, serviceContext); inheritMobileRuleGroups(layout, serviceContext); if (parentLayout.isTypePortlet()) { com.liferay.portlet.sites.action.ActionUtil.copyPreferences(actionRequest, layout, parentLayout); SitesUtil.copyLookAndFeel(layout, parentLayout); } } else if (layoutPrototypeId > 0) { LayoutPrototype layoutPrototype = _layoutPrototypeService.getLayoutPrototype(layoutPrototypeId); boolean layoutPrototypeLinkEnabled = ParamUtil.getBoolean(uploadPortletRequest, "layoutPrototypeLinkEnabled" + layoutPrototype.getUuid()); serviceContext.setAttribute("layoutPrototypeLinkEnabled", layoutPrototypeLinkEnabled); serviceContext.setAttribute("layoutPrototypeUuid", layoutPrototype.getUuid()); layout = _layoutService.addLayout(groupId, privateLayout, parentLayoutId, nameMap, titleMap, descriptionMap, keywordsMap, robotsMap, LayoutConstants.TYPE_PORTLET, typeSettingsProperties.toString(), hidden, friendlyURLMap, serviceContext); // Force propagation from page template to page. See LPS-48430. SitesUtil.mergeLayoutPrototypeLayout(layout.getGroup(), layout); } else { long copyLayoutId = ParamUtil.getLong(uploadPortletRequest, "copyLayoutId"); Layout copyLayout = null; String layoutTemplateId = ParamUtil.getString(uploadPortletRequest, "layoutTemplateId", PropsValues.DEFAULT_LAYOUT_TEMPLATE_ID); if (copyLayoutId > 0) { copyLayout = _layoutLocalService.fetchLayout(groupId, privateLayout, copyLayoutId); if ((copyLayout != null) && copyLayout.isTypePortlet()) { LayoutTypePortlet copyLayoutTypePortlet = (LayoutTypePortlet) copyLayout.getLayoutType(); layoutTemplateId = copyLayoutTypePortlet.getLayoutTemplateId(); typeSettingsProperties = copyLayout.getTypeSettingsProperties(); } } layout = _layoutService.addLayout(groupId, privateLayout, parentLayoutId, nameMap, titleMap, descriptionMap, keywordsMap, robotsMap, type, typeSettingsProperties.toString(), hidden, friendlyURLMap, serviceContext); LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType(); layoutTypePortlet.setLayoutTemplateId(themeDisplay.getUserId(), layoutTemplateId); _layoutService.updateLayout(groupId, privateLayout, layout.getLayoutId(), layout.getTypeSettings()); if ((copyLayout != null) && copyLayout.isTypePortlet()) { com.liferay.portlet.sites.action.ActionUtil.copyPreferences(actionRequest, layout, copyLayout); SitesUtil.copyLookAndFeel(layout, copyLayout); } } _actionUtil.updateLookAndFeel(actionRequest, themeDisplay.getCompanyId(), liveGroupId, stagingGroupId, privateLayout, layout.getLayoutId(), layout.getTypeSettingsProperties()); String portletResource = ParamUtil.getString(uploadPortletRequest, "portletResource"); MultiSessionMessages.add(actionRequest, portletResource + "layoutAdded", layout); String redirect = ParamUtil.getString(actionRequest, "redirect"); if (Validator.isNull(redirect)) { redirect = _portal.getLayoutFullURL(layout, themeDisplay); if (layout.isTypeURL()) { redirect = _portal.getGroupFriendlyURL(layout.getLayoutSet(), themeDisplay); } } actionRequest.setAttribute(WebKeys.REDIRECT, redirect); }
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 www . j av a 2s .c o 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.upgrade.v_1_0_1.UpgradeLayoutType.java
License:Open Source License
protected String getTypeSettings(String portletId) { UnicodeProperties newTypeSettings = new UnicodeProperties(true); newTypeSettings.put("column-1", portletId); newTypeSettings.put(LayoutTypePortletConstants.LAYOUT_TEMPLATE_ID, "1_column"); return newTypeSettings.toString(); }