List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getUserId
public long getUserId()
From source file:com.liferay.journal.content.web.internal.display.context.JournalContentDisplayContext.java
License:Open Source License
public long[] getSelectedGroupIds() throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) _portletRequest.getAttribute(WebKeys.THEME_DISPLAY); Group scopeGroup = themeDisplay.getScopeGroup(); if (scopeGroup.isStagingGroup() && !scopeGroup.isInStagingPortlet(JournalPortletKeys.JOURNAL)) { return new long[] { scopeGroup.getLiveGroupId() }; }//from w w w. j a v a 2s. c o m if (themeDisplay.getScopeGroupId() == themeDisplay.getSiteGroupId()) { return PortalUtil.getSharedContentSiteGroupIds(themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId(), themeDisplay.getUserId()); } return new long[] { themeDisplay.getScopeGroupId() }; }
From source file:com.liferay.journal.search.JournalOpenSearchImpl.java
License:Open Source License
protected String getLayoutURL(ThemeDisplay themeDisplay, String articleId) throws Exception { PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); List<JournalContentSearch> contentSearches = _journalContentSearchLocalService .getArticleContentSearches(articleId); for (JournalContentSearch contentSearch : contentSearches) { if (LayoutPermissionUtil.contains(permissionChecker, contentSearch.getGroupId(), contentSearch.isPrivateLayout(), contentSearch.getLayoutId(), ActionKeys.VIEW)) { if (contentSearch.isPrivateLayout()) { if (!_groupLocalService.hasUserGroup(themeDisplay.getUserId(), contentSearch.getGroupId())) { continue; }//from w ww .ja v a 2s . c o m } Layout hitLayout = _layoutLocalService.getLayout(contentSearch.getGroupId(), contentSearch.isPrivateLayout(), contentSearch.getLayoutId()); return _portal.getLayoutURL(hitLayout, themeDisplay); } } return null; }
From source file:com.liferay.journal.web.internal.display.context.JournalDisplayContext.java
License:Open Source License
public SearchContainer getSearchContainer(boolean showVersions) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); SearchContainer articleSearchContainer = new SearchContainer(_liferayPortletRequest, getPortletURL(), null, null);//from w w w .j a v a 2 s .c o m if (!isSearch()) { articleSearchContainer .setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn"); } else { articleSearchContainer.setSearch(true); } OrderByComparator<JournalArticle> orderByComparator = JournalPortletUtil .getArticleOrderByComparator(getOrderByCol(), getOrderByType()); articleSearchContainer.setOrderByCol(getOrderByCol()); articleSearchContainer.setOrderByComparator(orderByComparator); articleSearchContainer.setOrderByType(getOrderByType()); EntriesChecker entriesChecker = new EntriesChecker(_liferayPortletRequest, _liferayPortletResponse); entriesChecker.setCssClass("entry-selector"); entriesChecker.setRememberCheckBoxStateURLRegex( "^(?!.*" + _liferayPortletResponse.getNamespace() + "redirect).*(folderId=" + getFolderId() + ")"); articleSearchContainer.setRowChecker(entriesChecker); EntriesMover entriesMover = new EntriesMover(themeDisplay.getScopeGroupId()); articleSearchContainer.setRowMover(entriesMover); if (isNavigationMine() || isNavigationRecent()) { boolean includeOwner = true; if (isNavigationMine()) { includeOwner = false; } if (isNavigationRecent()) { articleSearchContainer.setOrderByCol("create-date"); articleSearchContainer.setOrderByType(getOrderByType()); } int total = JournalArticleServiceUtil.getGroupArticlesCount(themeDisplay.getScopeGroupId(), themeDisplay.getUserId(), getFolderId(), getStatus(), includeOwner); articleSearchContainer.setTotal(total); List results = JournalArticleServiceUtil.getGroupArticles(themeDisplay.getScopeGroupId(), themeDisplay.getUserId(), getFolderId(), getStatus(), includeOwner, articleSearchContainer.getStart(), articleSearchContainer.getEnd(), articleSearchContainer.getOrderByComparator()); articleSearchContainer.setResults(results); } else if (Validator.isNotNull(getDDMStructureKey())) { int total = JournalArticleServiceUtil.getArticlesCountByStructureId(themeDisplay.getScopeGroupId(), getDDMStructureKey(), getStatus()); articleSearchContainer.setTotal(total); List results = JournalArticleServiceUtil.getArticlesByStructureId(themeDisplay.getScopeGroupId(), getDDMStructureKey(), getStatus(), articleSearchContainer.getStart(), articleSearchContainer.getEnd(), articleSearchContainer.getOrderByComparator()); articleSearchContainer.setResults(results); } else if (Validator.isNotNull(getDDMTemplateKey())) { List<Long> folderIds = new ArrayList<>(1); if (getFolderId() != JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) { folderIds.add(getFolderId()); } int total = JournalArticleServiceUtil.searchCount(themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId(), folderIds, JournalArticleConstants.CLASSNAME_ID_DEFAULT, getKeywords(), -1.0, getDDMStructureKey(), getDDMTemplateKey(), null, null, getStatus(), null); articleSearchContainer.setTotal(total); List results = JournalArticleServiceUtil.search(themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId(), folderIds, JournalArticleConstants.CLASSNAME_ID_DEFAULT, getKeywords(), -1.0, getDDMStructureKey(), getDDMTemplateKey(), null, null, getStatus(), null, articleSearchContainer.getStart(), articleSearchContainer.getEnd(), articleSearchContainer.getOrderByComparator()); articleSearchContainer.setResults(results); } else if (isSearch()) { List<Long> folderIds = new ArrayList<>(1); if (getFolderId() != JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) { folderIds.add(getFolderId()); } JournalWebConfiguration journalWebConfiguration = (JournalWebConfiguration) _request .getAttribute(JournalWebConfiguration.class.getName()); if (journalWebConfiguration.journalArticlesSearchWithIndex()) { boolean orderByAsc = false; if (Objects.equals(getOrderByType(), "asc")) { orderByAsc = true; } Sort sort = null; if (Objects.equals(getOrderByCol(), "display-date")) { sort = new Sort("displayDate", Sort.LONG_TYPE, orderByAsc); } else if (Objects.equals(getOrderByCol(), "id")) { sort = new Sort(DocumentImpl.getSortableFieldName(Field.ARTICLE_ID), Sort.STRING_TYPE, !orderByAsc); } else if (Objects.equals(getOrderByCol(), "modified-date")) { sort = new Sort(Field.MODIFIED_DATE, Sort.LONG_TYPE, orderByAsc); } else if (Objects.equals(getOrderByCol(), "title")) { sort = new Sort("title", Sort.STRING_TYPE, !orderByAsc); } LinkedHashMap<String, Object> params = new LinkedHashMap<>(); params.put("expandoAttributes", getKeywords()); Indexer indexer = JournalSearcher.getInstance(); SearchContext searchContext = buildSearchContext(themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId(), folderIds, JournalArticleConstants.CLASSNAME_ID_DEFAULT, getDDMStructureKey(), getDDMTemplateKey(), getKeywords(), params, articleSearchContainer.getStart(), articleSearchContainer.getEnd(), sort, showVersions); Hits hits = indexer.search(searchContext); int total = hits.getLength(); articleSearchContainer.setTotal(total); List results = new ArrayList<>(); Document[] documents = hits.getDocs(); for (int i = 0; i < documents.length; i++) { Document document = documents[i]; JournalArticle article = null; JournalFolder folder = null; String className = document.get(Field.ENTRY_CLASS_NAME); long classPK = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK)); if (className.equals(JournalArticle.class.getName())) { if (!showVersions) { article = JournalArticleLocalServiceUtil.fetchLatestArticle(classPK, WorkflowConstants.STATUS_ANY, false); } else { String articleId = document.get(Field.ARTICLE_ID); long groupId = GetterUtil.getLong(document.get(Field.GROUP_ID)); double version = GetterUtil.getDouble(document.get(Field.VERSION)); article = JournalArticleLocalServiceUtil.fetchArticle(groupId, articleId, version); } results.add(article); } else if (className.equals(JournalFolder.class.getName())) { folder = JournalFolderLocalServiceUtil.getFolder(classPK); results.add(folder); } } articleSearchContainer.setResults(results); } else { int total = JournalArticleServiceUtil.searchCount(themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId(), folderIds, JournalArticleConstants.CLASSNAME_ID_DEFAULT, getKeywords(), -1.0, getDDMStructureKey(), getDDMTemplateKey(), null, null, getStatus(), null); articleSearchContainer.setTotal(total); List results = JournalArticleServiceUtil.search(themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId(), folderIds, JournalArticleConstants.CLASSNAME_ID_DEFAULT, getKeywords(), -1.0, getDDMStructureKey(), getDDMTemplateKey(), null, null, getStatus(), null, articleSearchContainer.getStart(), articleSearchContainer.getEnd(), articleSearchContainer.getOrderByComparator()); articleSearchContainer.setResults(results); } } else { int total = JournalFolderServiceUtil.getFoldersAndArticlesCount(themeDisplay.getScopeGroupId(), 0, getFolderId(), getStatus()); articleSearchContainer.setTotal(total); OrderByComparator<Object> folderOrderByComparator = null; boolean orderByAsc = false; if (Objects.equals(getOrderByType(), "asc")) { orderByAsc = true; } if (Objects.equals(getOrderByCol(), "display-date")) { folderOrderByComparator = new FolderArticleDisplayDateComparator(orderByAsc); } else if (Objects.equals(getOrderByCol(), "id")) { folderOrderByComparator = new FolderArticleArticleIdComparator(orderByAsc); } else if (Objects.equals(getOrderByCol(), "modified-date")) { folderOrderByComparator = new FolderArticleModifiedDateComparator(orderByAsc); } else if (Objects.equals(getOrderByCol(), "title")) { folderOrderByComparator = new FolderArticleTitleComparator(orderByAsc); } List results = JournalFolderServiceUtil.getFoldersAndArticles(themeDisplay.getScopeGroupId(), 0, getFolderId(), getStatus(), themeDisplay.getLocale(), articleSearchContainer.getStart(), articleSearchContainer.getEnd(), folderOrderByComparator); articleSearchContainer.setResults(results); } return articleSearchContainer; }
From source file:com.liferay.journal.web.internal.portlet.JournalPortlet.java
License:Open Source License
public void subscribeStructure(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long ddmStructureId = ParamUtil.getLong(actionRequest, "ddmStructureId"); _journalArticleService.subscribeStructure(themeDisplay.getScopeGroupId(), themeDisplay.getUserId(), ddmStructureId);/*from ww w . ja va 2 s . c o m*/ sendEditArticleRedirect(actionRequest, actionResponse); }
From source file:com.liferay.journal.web.internal.portlet.JournalPortlet.java
License:Open Source License
public void unsubscribeStructure(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long ddmStructureId = ParamUtil.getLong(actionRequest, "ddmStructureId"); _journalArticleService.unsubscribeStructure(themeDisplay.getScopeGroupId(), themeDisplay.getUserId(), ddmStructureId);//from ww w. j a v a 2 s . co m sendEditArticleRedirect(actionRequest, actionResponse); }
From source file:com.liferay.journal.web.internal.upload.ImageJournalUploadFileEntryHandler.java
License:Open Source License
@Override public FileEntry upload(UploadPortletRequest uploadPortletRequest) throws IOException, PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) uploadPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); _checkPermission(themeDisplay.getScopeGroupId(), themeDisplay.getPermissionChecker()); String fileName = uploadPortletRequest.getFileName(_PARAMETER_NAME); long size = uploadPortletRequest.getSize(_PARAMETER_NAME); _validateFile(fileName, size);// www .j a v a 2 s . c om String contentType = uploadPortletRequest.getContentType(_PARAMETER_NAME); try (InputStream inputStream = uploadPortletRequest.getFileAsStream(_PARAMETER_NAME)) { String uniqueFileName = _uniqueFileNameProvider.provide(fileName, curFileName -> _exists(themeDisplay, curFileName)); return TempFileEntryUtil.addTempFileEntry(themeDisplay.getScopeGroupId(), themeDisplay.getUserId(), _TEMP_FOLDER_NAME, uniqueFileName, inputStream, contentType); } }
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 w ww .ja va 2 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.AddSimpleLayoutMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { 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(actionRequest, "parentLayoutId"); String name = ParamUtil.getString(actionRequest, "name"); String type = ParamUtil.getString(actionRequest, "type"); Map<Locale, String> nameMap = new HashMap<>(); nameMap.put(themeDisplay.getLocale(), name); ServiceContext serviceContext = ServiceContextFactory.getInstance(Layout.class.getName(), actionRequest); UnicodeProperties typeSettingsProperties = PropertiesParamUtil.getProperties(actionRequest, "TypeSettingsProperties--"); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); try {// w w w . j a v a 2 s . c o m Layout layout = _layoutService.addLayout(groupId, privateLayout, parentLayoutId, nameMap, new HashMap<Locale, String>(), new HashMap<Locale, String>(), new HashMap<Locale, String>(), new HashMap<Locale, String>(), type, typeSettingsProperties.toString(), false, new HashMap<Locale, String>(), serviceContext); LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType(); layoutTypePortlet.setLayoutTemplateId(themeDisplay.getUserId(), PropsValues.DEFAULT_LAYOUT_TEMPLATE_ID); _layoutService.updateLayout(groupId, privateLayout, layout.getLayoutId(), layout.getTypeSettings()); _actionUtil.updateLookAndFeel(actionRequest, themeDisplay.getCompanyId(), liveGroupId, stagingGroupId, privateLayout, layout.getLayoutId(), layout.getTypeSettingsProperties()); jsonObject.put("redirectURL", getRedirectURL(actionResponse)); JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject); } catch (PortalException pe) { if (_log.isDebugEnabled()) { _log.debug(pe, pe); } ResourceBundle resourceBundle = _resourceBundleLoader.loadResourceBundle(themeDisplay.getLocale()); jsonObject.put("error", LanguageUtil.get(resourceBundle, "an-unexpected-error-occurred")); JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject); } }
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 a2 s . com*/ 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.mentions.web.internal.portlet.MentionsPortlet.java
License:Open Source License
protected JSONArray getJSONArray(HttpServletRequest request) throws PortalException { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); SocialInteractionsConfiguration socialInteractionsConfiguration = SocialInteractionsConfigurationUtil .getSocialInteractionsConfiguration(themeDisplay.getCompanyId(), MentionsPortletKeys.MENTIONS); String query = ParamUtil.getString(request, "query"); List<User> users = _mentionsUserFinder.getUsers(themeDisplay.getCompanyId(), themeDisplay.getUserId(), query, socialInteractionsConfiguration); for (User user : users) { if (user.isDefaultUser() || (themeDisplay.getUserId() == user.getUserId())) { continue; }// ww w. ja v a 2s . c o m JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); jsonObject.put("fullName", user.getFullName()); String mention = "@" + user.getScreenName(); String profileURL = user.getDisplayURL(themeDisplay); if (Validator.isNotNull(profileURL)) { mention = StringBundler.concat("<a href=\"", profileURL, "\">@", user.getScreenName(), "</a>"); } jsonObject.put("mention", mention); jsonObject.put("portraitURL", user.getPortraitURL(themeDisplay)); jsonObject.put("screenName", user.getScreenName()); jsonArray.put(jsonObject); } return jsonArray; }