protected SocialActivityFeedEntry doInterpret(SocialActivity activity, ThemeDisplay themeDisplay) throws Exception { PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); if (!CalEventPermission.contains(permissionChecker, activity.getClassPK(), ActionKeys.VIEW)) { return null; } String groupName = StringPool.BLANK; if (activity.getGroupId() != themeDisplay.getScopeGroupId()) { groupName = getGroupName(activity.getGroupId(), themeDisplay); } String creatorUserName = getUserName(activity.getUserId(), themeDisplay); int activityType = activity.getType(); // Link CalEvent event = CalEventLocalServiceUtil.getEvent(activity.getClassPK()); String link = themeDisplay.getPortalURL() + themeDisplay.getPathMain() + "/calendar/find_event?redirect=" + themeDisplay.getURLCurrent() + "&eventId=" + activity.getClassPK(); // Title String titlePattern = null; if (activityType == CalendarActivityKeys.ADD_EVENT) { titlePattern = "activity-calendar-add-event"; } else if (activityType == CalendarActivityKeys.UPDATE_EVENT) { titlePattern = "activity-calendar-update-event"; } if (Validator.isNotNull(groupName)) { titlePattern += "-in"; } String eventTitle = wrapLink(link, HtmlUtil.escape(cleanContent(event.getTitle()))); Object[] titleArguments = new Object[] {groupName, creatorUserName, eventTitle}; String title = themeDisplay.translate(titlePattern, titleArguments); // Body String body = StringPool.BLANK; return new SocialActivityFeedEntry(link, title, body); }
@Override public PortletURL getURLAdd( LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse) throws PortalException, SystemException { ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); if (!AdminPermission.contains( themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), ActionKeys.ADD_KB_ARTICLE)) { return null; } PortletURL portletURL = PortletURLFactoryUtil.create( liferayPortletRequest, PortletKeys.KNOWLEDGE_BASE_ADMIN, getControlPanelPlid(themeDisplay), PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcPath", "/admin/edit_article.jsp"); return portletURL; }
public static void getFolder(HttpServletRequest request) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); long folderId = ParamUtil.getLong(request, "folderId"); Folder folder = null; if ((folderId > 0) && (folderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID)) { folder = DLAppServiceUtil.getFolder(folderId); if (folder.getModel() instanceof DLFolder) { DLFolder dlFolder = (DLFolder) folder.getModel(); if (dlFolder.isInTrash() || dlFolder.isInTrashContainer()) { throw new NoSuchFolderException(); } } } else { DLPermission.check( themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), ActionKeys.VIEW); } request.setAttribute(WebKeys.DOCUMENT_LIBRARY_FOLDER, folder); }
protected long getResourcePrimKey(RenderRequest renderRequest) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletPreferences preferences = renderRequest.getPreferences(); long defaultValue = GetterUtil.getLong(preferences.getValue("resourcePrimKey", null)); String mvcPath = ParamUtil.getString(renderRequest, "mvcPath"); if (((defaultValue == 0) && mvcPath.equals(viewTemplate)) || mvcPath.equals("/display/select_configuration_article.jsp")) { return 0; } long resourcePrimKey = ParamUtil.getLong(renderRequest, "resourcePrimKey", defaultValue); if ((resourcePrimKey == 0) || (resourcePrimKey != defaultValue)) { return resourcePrimKey; } PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); if (!KBArticlePermission.contains(permissionChecker, defaultValue, ActionKeys.VIEW)) { return 0; } return defaultValue; }
protected int getStatus(RenderRequest renderRequest) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); if (!themeDisplay.isSignedIn()) { return WorkflowConstants.STATUS_APPROVED; } String value = renderRequest.getParameter("status"); int status = GetterUtil.getInteger(value); if ((value != null) && (status == WorkflowConstants.STATUS_APPROVED)) { return WorkflowConstants.STATUS_APPROVED; } long resourcePrimKey = getResourcePrimKey(renderRequest); if (resourcePrimKey == 0) { return WorkflowConstants.STATUS_APPROVED; } PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); if (KBArticlePermission.contains(permissionChecker, resourcePrimKey, ActionKeys.UPDATE)) { return ParamUtil.getInteger(renderRequest, "status", WorkflowConstants.STATUS_ANY); } return WorkflowConstants.STATUS_APPROVED; }
protected void deleteImages(ActionRequest actionRequest) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long[] deleteFileEntryIds = null; long fileEntryId = ParamUtil.getLong(actionRequest, "fileEntryId"); if (fileEntryId > 0) { deleteFileEntryIds = new long[] {fileEntryId}; } else { deleteFileEntryIds = StringUtil.split(ParamUtil.getString(actionRequest, "deleteFileEntryIds"), 0L); } Folder folder = _blogsEntryLocalService.addAttachmentsFolder( themeDisplay.getUserId(), themeDisplay.getScopeGroupId()); for (long deleteFileEntryId : deleteFileEntryIds) { FileEntry fileEntry = PortletFileRepositoryUtil.getPortletFileEntry(deleteFileEntryId); if (fileEntry.getFolderId() != folder.getFolderId()) { continue; } if ((fileEntry.getUserId() == themeDisplay.getUserId()) || BlogsPermission.contains( themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), ActionKeys.UPDATE)) { PortletFileRepositoryUtil.deletePortletFileEntry(deleteFileEntryId); } } }
private void _init( HttpServletRequest request, DLFileEntryType dlFileEntryType, FileEntry fileEntry) throws PortalException { _request = request; _dlFileEntryType = dlFileEntryType; _fileEntry = fileEntry; ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); _dlPortletInstanceSettings = DLPortletInstanceSettings.getInstance(themeDisplay.getLayout(), portletDisplay.getId()); _fileEntryDisplayContextHelper = new FileEntryDisplayContextHelper(themeDisplay.getPermissionChecker(), _fileEntry); if ((_dlFileEntryType == null) && (_fileEntry != null)) { _dlFileEntryType = _fileEntryDisplayContextHelper.getDLFileEntryType(); } if (fileEntry != null) { _fileVersion = fileEntry.getFileVersion(); } _fileVersionDisplayContextHelper = new FileVersionDisplayContextHelper(_fileVersion); }
protected SocialActivityFeedEntry doInterpret( SocialActivity activity, ServiceContext serviceContext) throws Exception { ThemeDisplay themeDisplay = serviceContext.getThemeDisplay(); SocialActivityFeedEntry socialActivityFeedEntry = doInterpret(activity, themeDisplay); if (socialActivityFeedEntry != _deprecatedMarkerSocialActivityFeedEntry) { return socialActivityFeedEntry; } PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); if (!hasPermissions(permissionChecker, activity, ActionKeys.VIEW, serviceContext)) { return null; } String link = getLink(activity, serviceContext); String title = getTitle(activity, serviceContext); if (Validator.isNull(title)) { return null; } String body = getBody(activity, serviceContext); return new SocialActivityFeedEntry(link, title, body); }
public static boolean isViewableMessage( ThemeDisplay themeDisplay, MBMessage message, MBMessage parentMessage) throws Exception { PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); if (!MBMessagePermission.contains(permissionChecker, parentMessage, ActionKeys.VIEW)) { return false; } if ((message.getMessageId() != parentMessage.getMessageId()) && !MBMessagePermission.contains(permissionChecker, message, ActionKeys.VIEW)) { return false; } if (!message.isApproved() && !Validator.equals(message.getUserId(), themeDisplay.getUserId()) && !permissionChecker.isGroupAdmin(themeDisplay.getScopeGroupId())) { return false; } return true; }
@Override protected SocialActivityFeedEntry doInterpret(SocialActivity activity, ThemeDisplay themeDisplay) throws Exception { PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); if (!WikiPagePermission.contains(permissionChecker, activity.getClassPK(), ActionKeys.VIEW)) { return null; } String groupName = StringPool.BLANK; if (activity.getGroupId() != themeDisplay.getScopeGroupId()) { groupName = getGroupName(activity.getGroupId(), themeDisplay); } String creatorUserName = getUserName(activity.getUserId(), themeDisplay); int activityType = activity.getType(); // Link WikiPageResource pageResource = WikiPageResourceLocalServiceUtil.getPageResource(activity.getClassPK()); String link = themeDisplay.getPortalURL() + themeDisplay.getPathMain() + "/wiki/find_page?pageResourcePrimKey=" + activity.getClassPK(); // Title String titlePattern = null; if (activityType == WikiActivityKeys.ADD_PAGE) { titlePattern = "activity-wiki-add-page"; } else if (activityType == WikiActivityKeys.UPDATE_PAGE) { titlePattern = "activity-wiki-update-page"; } if (Validator.isNotNull(groupName)) { titlePattern += "-in"; } String pageTitle = wrapLink(link, HtmlUtil.escape(cleanContent(pageResource.getTitle()))); Object[] titleArguments = new Object[] {groupName, creatorUserName, pageTitle}; String title = themeDisplay.translate(titlePattern, titleArguments); // Body String body = StringPool.BLANK; return new SocialActivityFeedEntry(link, title, body); }
@Override public PortletURL getViewContentURL(HttpServletRequest request, String className, long classPK) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); if (!themeDisplay.isSignedIn() || !isTrashEnabled(themeDisplay.getScopeGroupId()) || !PortletPermissionUtil.hasControlPanelAccessPermission( themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), PortletKeys.TRASH)) { return null; } TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(className); if (trashHandler.isInTrashContainer(classPK)) { TrashEntry trashEntry = trashHandler.getTrashEntry(classPK); className = trashEntry.getClassName(); classPK = trashEntry.getClassPK(); trashHandler = TrashHandlerRegistryUtil.getTrashHandler(className); } TrashRenderer trashRenderer = trashHandler.getTrashRenderer(classPK); if (trashRenderer == null) { return null; } Layout layout = themeDisplay.getLayout(); PortletURL portletURL = PortalUtil.getControlPanelPortletURL( request, PortletKeys.TRASH, layout.getLayoutId(), PortletRequest.RENDER_PHASE); portletURL.setParameter("struts_action", "/trash/view_content"); portletURL.setParameter("redirect", themeDisplay.getURLCurrent()); TrashEntry trashEntry = TrashEntryLocalServiceUtil.getEntry(className, classPK); if (trashEntry.getRootEntry() != null) { portletURL.setParameter("className", className); portletURL.setParameter("classPK", String.valueOf(classPK)); } else { portletURL.setParameter("trashEntryId", String.valueOf(trashEntry.getEntryId())); } portletURL.setParameter("type", trashRenderer.getType()); portletURL.setParameter("showActions", Boolean.FALSE.toString()); portletURL.setParameter("showAssetMetadata", Boolean.TRUE.toString()); portletURL.setParameter("showEditURL", Boolean.FALSE.toString()); return portletURL; }
public String getViewContentURL(String className, long classPK, ThemeDisplay themeDisplay) throws PortalException, SystemException { if (!themeDisplay.isSignedIn() || !isTrashEnabled(themeDisplay.getScopeGroupId()) || !PortletPermissionUtil.hasControlPanelAccessPermission( themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), PortletKeys.TRASH)) { return null; } TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(className); if (trashHandler.isInTrashContainer(classPK)) { ContainerModel containerModel = trashHandler.getTrashContainer(classPK); className = containerModel.getModelClassName(); classPK = containerModel.getContainerModelId(); trashHandler = TrashHandlerRegistryUtil.getTrashHandler(className); } TrashRenderer trashRenderer = trashHandler.getTrashRenderer(classPK); if (trashRenderer == null) { return null; } String namespace = PortalUtil.getPortletNamespace(PortletKeys.TRASH); Map<String, String[]> params = new HashMap<String, String[]>(); params.put(namespace + "struts_action", new String[] {"/trash/view_content"}); params.put(namespace + "redirect", new String[] {themeDisplay.getURLCurrent()}); TrashEntry trashEntry = TrashEntryLocalServiceUtil.getEntry(className, classPK); if (trashEntry.getRootEntry() != null) { params.put(namespace + "className", new String[] {className}); params.put(namespace + "classPK", new String[] {String.valueOf(classPK)}); } else { params.put( namespace + "trashEntryId", new String[] {String.valueOf(trashEntry.getEntryId())}); } params.put(namespace + "type", new String[] {trashRenderer.getType()}); params.put(namespace + "showActions", new String[] {Boolean.FALSE.toString()}); params.put(namespace + "showAssetMetadata", new String[] {Boolean.TRUE.toString()}); params.put(namespace + "showEditURL", new String[] {Boolean.FALSE.toString()}); return PortalUtil.getControlPanelFullURL( themeDisplay.getScopeGroupId(), PortletKeys.TRASH, params); }
public EntriesChecker( LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse) { super(liferayPortletResponse); _liferayPortletResponse = liferayPortletResponse; ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); _permissionChecker = themeDisplay.getPermissionChecker(); }
public void deleteMeetupsEntry(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); if (!permissionChecker.isCompanyAdmin()) { return; } long meetupsEntryId = ParamUtil.getLong(actionRequest, "meetupsEntryId"); MeetupsEntryLocalServiceUtil.deleteMeetupsEntry(meetupsEntryId); }
public static void getRepository(HttpServletRequest request) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); long repositoryId = ParamUtil.getLong(request, "repositoryId"); Repository repository = null; if (repositoryId > 0) { repository = RepositoryServiceUtil.getRepository(repositoryId); } else { DLPermission.check( themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), ActionKeys.VIEW); } request.setAttribute(WebKeys.DOCUMENT_LIBRARY_REPOSITORY, repository); }
@Override public void checkControlPanelPortletPreferences(ThemeDisplay themeDisplay, Portlet portlet) throws PortalException { Layout layout = themeDisplay.getLayout(); Group group = layout.getGroup(); if (!group.isControlPanel()) { return; } String portletId = portlet.getPortletId(); boolean hasControlPanelAccessPermission = PortletPermissionUtil.hasControlPanelAccessPermission( themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), portletId); if (!hasControlPanelAccessPermission) { return; } PortletPreferences portletSetup = getStrictLayoutPortletSetup(layout, portletId); if (portletSetup instanceof StrictPortletPreferencesImpl) { getLayoutPortletSetup(layout, portletId); } if (portlet.isInstanceable()) { return; } PortletPreferencesIds portletPreferencesIds = getPortletPreferencesIds( themeDisplay.getScopeGroupId(), themeDisplay.getUserId(), layout, portletId, false); PortletPreferences portletPreferences = PortletPreferencesLocalServiceUtil.fetchPreferences(portletPreferencesIds); if (portletPreferences != null) { return; } PortletPreferencesLocalServiceUtil.getPreferences(portletPreferencesIds); }
protected int getStatus(RenderRequest renderRequest) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); if (!themeDisplay.isSignedIn()) { return WorkflowConstants.STATUS_APPROVED; } String statusString = renderRequest.getParameter("status"); int status = GetterUtil.getInteger(statusString); if ((statusString != null) && (status == WorkflowConstants.STATUS_APPROVED)) { return WorkflowConstants.STATUS_APPROVED; } Tuple resourceTuple = getResourceTuple(renderRequest); long resourcePrimKey = (Long) resourceTuple.getObject(1); if (resourcePrimKey == KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) { return WorkflowConstants.STATUS_APPROVED; } long resourceClassNameId = (Long) resourceTuple.getObject(0); long kbArticleClassNameId = PortalUtil.getClassNameId(KBArticleConstants.getClassName()); if (resourceClassNameId == kbArticleClassNameId) { KBArticle kbArticle = KBArticleServiceUtil.fetchLatestKBArticle(resourcePrimKey, WorkflowConstants.STATUS_ANY); if (kbArticle == null) { return WorkflowConstants.STATUS_APPROVED; } if (KBArticlePermission.contains( themeDisplay.getPermissionChecker(), resourcePrimKey, ActionKeys.UPDATE)) { return ParamUtil.getInteger(renderRequest, "status", WorkflowConstants.STATUS_ANY); } } return WorkflowConstants.STATUS_APPROVED; }
protected String getUsersCSV(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); if (!PortalPermissionUtil.contains(permissionChecker, ActionKeys.EXPORT_USER)) { return StringPool.BLANK; } String exportProgressId = ParamUtil.getString(actionRequest, "exportProgressId"); ProgressTracker progressTracker = new ProgressTracker(actionRequest, exportProgressId); progressTracker.start(); List<User> users = getUsers(actionRequest, actionResponse, themeDisplay); int percentage = 10; int total = users.size(); progressTracker.setPercent(percentage); if (total == 0) { return StringPool.BLANK; } StringBundler sb = new StringBundler(users.size()); for (int i = 0; i < users.size(); i++) { User user = users.get(i); sb.append(getUserCSV(user)); percentage = Math.min(10 + (i * 90) / total, 99); progressTracker.setPercent(percentage); } progressTracker.finish(); return sb.toString(); }
public static void getCategory(HttpServletRequest request) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); long categoryId = ParamUtil.getLong(request, "categoryId"); ShoppingCategory category = null; if ((categoryId > 0) && (categoryId != ShoppingCategoryConstants.DEFAULT_PARENT_CATEGORY_ID)) { category = ShoppingCategoryServiceUtil.getCategory(categoryId); } else { ShoppingPermission.check( themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), ActionKeys.VIEW); } request.setAttribute(WebKeys.SHOPPING_CATEGORY, category); }
protected List<MenuItem> getPortletTitleMenuItems(PortletRequest portletRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); if (!_resourcePermissionChecker.checkResource( themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), ActionKeys.ADD_ENTRY)) { return Collections.emptyList(); } List<MenuItem> menuItems = new ArrayList<>(); menuItems.add(getPortletTitleMenuItem(portletRequest, themeDisplay)); return menuItems; }
protected void addPortletTitleAddCategoryMenuItem( List<MenuItem> menuItems, long categoryId, ThemeDisplay themeDisplay, PortletRequest portletRequest) throws PortalException { if (!containsPermission( themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), categoryId, ActionKeys.ADD_CATEGORY)) { return; } URLMenuItem urlMenuItem = new URLMenuItem(); String key = "category[message-board]"; if (categoryId != MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) { key = "subcategory[message-board]"; } urlMenuItem.setLabel(LanguageUtil.get(PortalUtil.getHttpServletRequest(portletRequest), key)); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); PortletURL portletURL = PortletURLFactoryUtil.create( portletRequest, portletDisplay.getId(), themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "/message_boards/edit_category"); portletURL.setParameter("redirect", PortalUtil.getCurrentURL(portletRequest)); portletURL.setParameter("parentCategoryId", String.valueOf(categoryId)); urlMenuItem.setURL(portletURL.toString()); menuItems.add(urlMenuItem); }
public EntriesChecker( LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse) { super(liferayPortletResponse); _journalDisplayContext = new JournalDisplayContext( PortalUtil.getHttpServletRequest(liferayPortletRequest), liferayPortletRequest, liferayPortletResponse, liferayPortletRequest.getPreferences()); _liferayPortletResponse = liferayPortletResponse; ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); _permissionChecker = themeDisplay.getPermissionChecker(); }
public void updateRootKBFolderId(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException { long kbFolderId = ParamUtil.getLong(actionRequest, "rootKBFolderId"); if (kbFolderId == KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) { return; } KBFolder kbFolder = KBFolderServiceUtil.getKBFolder(kbFolderId); PortalPreferences portalPreferences = PortletPreferencesFactoryUtil.getPortalPreferences( PortalUtil.getLiferayPortletRequest(actionRequest)); portalPreferences.setValue( PortletKeys.KNOWLEDGE_BASE_DISPLAY, "preferredKBFolderURLTitle", kbFolder.getUrlTitle()); String urlTitle = ParamUtil.getString(actionRequest, "urlTitle"); if (Validator.isNull(urlTitle)) { return; } KBArticle kbArticle = KBArticleLocalServiceUtil.fetchKBArticleByUrlTitle( kbFolder.getGroupId(), kbFolder.getUrlTitle(), urlTitle); if (kbArticle == null) { return; } ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); if (!KBArticlePermission.contains( themeDisplay.getPermissionChecker(), kbArticle, ActionKeys.VIEW)) { return; } actionResponse.setRenderParameter("kbFolderUrlTitle", kbFolder.getUrlTitle()); actionResponse.setRenderParameter("urlTitle", urlTitle); }
@Override public String getJSON( ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String portletId = ParamUtil.getString(request, "portletId"); PortletPermissionUtil.check( themeDisplay.getPermissionChecker(), themeDisplay.getLayout(), portletId, ActionKeys.CONFIGURATION); PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.getStrictPortletSetup(themeDisplay.getLayout(), portletId); if (portletPreferences instanceof StrictPortletPreferencesImpl) { throw new PrincipalException(); } String color = ParamUtil.getString(request, "color"); String data = ParamUtil.getString(request, "data"); if (Validator.isNotNull(color)) { portletPreferences.setValue("color", color); } if (Validator.isNotNull(data)) { portletPreferences.setValue("data", data); } portletPreferences.store(); return null; }
public void updateSummary(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); if (!themeDisplay.isSignedIn()) { return; } Group group = _groupLocalService.getGroup(themeDisplay.getScopeGroupId()); User user = null; if (group.isUser()) { user = _userLocalService.getUserById(group.getClassPK()); } else { return; } if (!UserPermissionUtil.contains( themeDisplay.getPermissionChecker(), user.getUserId(), ActionKeys.UPDATE)) { return; } String jobTitle = ParamUtil.getString(actionRequest, "jobTitle"); _userLocalService.updateJobTitle(user.getUserId(), jobTitle); String aboutMe = ParamUtil.getString(actionRequest, "aboutMe"); _expandoValueLocalService.addValue( themeDisplay.getCompanyId(), User.class.getName(), "SN", "aboutMe", user.getUserId(), aboutMe); }
public String getJSON( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { HttpSession session = request.getSession(); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); String portletId = ParamUtil.getString(request, "portletId"); if (!PortletPermissionUtil.contains( permissionChecker, themeDisplay.getPlid(), portletId, ActionKeys.CONFIGURATION)) { return null; } String languageId = LanguageUtil.getLanguageId(request); String title = ParamUtil.getString(request, "title"); PortletPreferences portletSetup = PortletPreferencesFactoryUtil.getLayoutPortletSetup(layout, portletId); portletSetup.setValue("portlet-setup-title-" + languageId, title); portletSetup.setValue("portlet-setup-use-custom-title", "true"); portletSetup.store(); InvokerPortletImpl.clearResponse( session, layout.getPrimaryKey(), portletId, LanguageUtil.getLanguageId(request)); return null; }
@Override public void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); if (!permissionChecker.isCompanyAdmin()) { SessionErrors.add(actionRequest, PrincipalException.MustBeCompanyAdmin.class.getName()); actionResponse.setRenderParameter("mvcPath", "/error.jsp"); return; } invalidateSession(actionRequest); String redirect = ParamUtil.getString(actionRequest, "redirect"); sendRedirect(actionRequest, actionResponse, redirect); }
protected void addPortletTitleAddMessageMenuItem( List<MenuItem> menuItems, long categoryId, ThemeDisplay themeDisplay, PortletRequest portletRequest) throws PortalException { if (!containsPermission( themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), categoryId, ActionKeys.ADD_MESSAGE)) { return; } URLMenuItem urlMenuItem = new URLMenuItem(); urlMenuItem.setLabel( LanguageUtil.get(PortalUtil.getHttpServletRequest(portletRequest), "thread")); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); PortletURL portletURL = PortletURLFactoryUtil.create( portletRequest, portletDisplay.getId(), themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "/message_boards/edit_message"); portletURL.setParameter("redirect", PortalUtil.getCurrentURL(portletRequest)); portletURL.setParameter("mbCategoryId", String.valueOf(categoryId)); urlMenuItem.setURL(portletURL.toString()); menuItems.add(urlMenuItem); }
protected void processPrincipalException( Throwable t, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); User user = permissionChecker.getUser(); if ((user != null) && !user.isDefaultUser()) { PortalUtil.sendError(HttpServletResponse.SC_UNAUTHORIZED, (Exception) t, request, response); return; } String redirect = request.getContextPath() + Portal.PATH_MAIN + "/portal/login"; String currentURL = PortalUtil.getCurrentURL(request); redirect = HttpUtil.addParameter(redirect, "redirect", currentURL); response.sendRedirect(redirect); }
public static WikiNode getFirstNode(PortletRequest portletRequest) throws PortalException, SystemException { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); long groupId = themeDisplay.getScopeGroupId(); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); List<WikiNode> nodes = WikiNodeLocalServiceUtil.getNodes(groupId); PortletPreferences preferences = portletRequest.getPreferences(); String[] visibleNodeNames = StringUtil.split(preferences.getValue("visibleNodes", null)); nodes = orderNodes(nodes, visibleNodeNames); String[] hiddenNodes = StringUtil.split(preferences.getValue("hiddenNodes", StringPool.BLANK)); Arrays.sort(hiddenNodes); for (WikiNode node : nodes) { if ((Arrays.binarySearch(hiddenNodes, node.getName()) < 0) && (WikiNodePermission.contains(permissionChecker, node, ActionKeys.VIEW))) { return node; } } return null; }