public LinkedHashMap<String, Object> getGroupParams() throws PortalException { if (_groupParams != null) { return _groupParams; } long groupId = ParamUtil.getLong(_request, "groupId"); boolean includeCurrentGroup = ParamUtil.getBoolean(_request, "includeCurrentGroup", true); String type = getType(); ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); User user = themeDisplay.getUser(); boolean filterManageableGroups = true; if (permissionChecker.isCompanyAdmin()) { filterManageableGroups = false; } _groupParams = new LinkedHashMap<>(); _groupParams.put("active", Boolean.TRUE); if (isManualMembership()) { _groupParams.put("manualMembership", Boolean.TRUE); } if (type.equals("child-sites")) { Group parentGroup = GroupLocalServiceUtil.getGroup(groupId); List<Group> parentGroups = new ArrayList<>(); parentGroups.add(parentGroup); _groupParams.put("groupsTree", parentGroups); } else if (filterManageableGroups) { _groupParams.put("usersGroups", user.getUserId()); } _groupParams.put("site", Boolean.TRUE); if (!includeCurrentGroup && (groupId > 0)) { List<Long> excludedGroupIds = new ArrayList<>(); Group group = GroupLocalServiceUtil.getGroup(groupId); if (group.isStagingGroup()) { excludedGroupIds.add(group.getLiveGroupId()); } else { excludedGroupIds.add(groupId); } _groupParams.put("excludedGroupIds", excludedGroupIds); } return _groupParams; }
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); } } }
protected void checkEditPermissionsJSP(PortletRequest request) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String modelResource = ParamUtil.getString(request, "modelResource"); long resourceGroupId = ParamUtil.getLong(request, "resourceGroupId", themeDisplay.getScopeGroupId()); if (Validator.isNotNull(modelResource)) { String resourcePrimKey = ParamUtil.getString(request, "resourcePrimKey"); _permissionService.checkPermission(resourceGroupId, modelResource, resourcePrimKey); return; } String portletResource = ParamUtil.getString(request, "portletResource"); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); Layout layout = PortletConfigurationLayoutUtil.getLayout(themeDisplay); _portletPermission.check( permissionChecker, resourceGroupId, layout, portletResource, ActionKeys.PERMISSIONS); }
protected String getGroupURL( Group group, PortletRequest portletRequest, boolean includeStagingGroup) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); String groupDisplayURL = group.getDisplayURL(themeDisplay, false); if (Validator.isNotNull(groupDisplayURL)) { return HttpUtil.removeParameter(groupDisplayURL, "p_p_id"); } groupDisplayURL = group.getDisplayURL(themeDisplay, true); if (Validator.isNotNull(groupDisplayURL)) { return HttpUtil.removeParameter(groupDisplayURL, "p_p_id"); } if (includeStagingGroup && group.hasStagingGroup()) { try { if (GroupPermissionUtil.contains( themeDisplay.getPermissionChecker(), group, ActionKeys.VIEW_STAGING)) { return getGroupURL(group.getStagingGroup(), portletRequest); } } catch (PortalException pe) { _log.error("Unable to check permission on group " + group.getGroupId(), pe); } } return getGroupAdministrationURL(group, portletRequest); }
@Override public boolean isShow(PortletRequest portletRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); return ShoppingPermission.contains( themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), ActionKeys.PERMISSIONS); }
public EntriesChecker( LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse) { super(liferayPortletResponse); _liferayPortletResponse = liferayPortletResponse; ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); _permissionChecker = themeDisplay.getPermissionChecker(); }
@Override public PortletURL getViewContentURL(HttpServletRequest request, String className, long classPK) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String portletId = PortletProviderUtil.getPortletId(TrashEntry.class.getName(), PortletProvider.Action.VIEW); if (!themeDisplay.isSignedIn() || !isTrashEnabled(themeDisplay.getScopeGroupId()) || !PortletPermissionUtil.hasControlPanelAccessPermission( themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), portletId)) { 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; } PortletURL portletURL = PortalUtil.getControlPanelPortletURL(request, portletId, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcPath", "/view_content.jsp"); 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("showAssetMetadata", Boolean.TRUE.toString()); return portletURL; }
@Override public boolean isShow(PortletRequest portletRequest) { try { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); UserGroup userGroup = ActionUtil.getUserGroup(portletRequest); if (UserGroupPermissionUtil.contains( themeDisplay.getPermissionChecker(), userGroup.getUserGroupId(), ActionKeys.UPDATE) && UserGroupPermissionUtil.contains( themeDisplay.getPermissionChecker(), userGroup.getUserGroupId(), ActionKeys.VIEW)) { return true; } return false; } catch (Exception e) { } return false; }
public static void doTag( String portletProviderClassName, PortletProvider.Action portletProviderAction, String instanceId, String queryString, String defaultPreferences, boolean persistSettings, PageContext pageContext, HttpServletRequest request, HttpServletResponse response) throws Exception { String portletId = PortletProviderUtil.getPortletId(portletProviderClassName, portletProviderAction); if (Validator.isNotNull(portletId)) { doTag( portletId, instanceId, queryString, _SETTINGS_SCOPE_DEFAULT, defaultPreferences, persistSettings, pageContext, request, response); } else { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); if (!layout.isTypeControlPanel() && !LayoutPermissionUtil.contains( themeDisplay.getPermissionChecker(), layout, ActionKeys.UPDATE)) { return; } String errorMessage = LanguageUtil.format( request, "an-app-that-can-x-x-belongs-here", new Object[] {portletProviderAction.name(), portletProviderClassName}, false); request.setAttribute("liferay-portlet:runtime:errorMessage", errorMessage); PortalIncludeUtil.include(pageContext, _ERROR_PAGE); } }
protected boolean isFilterManageableGroups(PortletRequest portletRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); if (permissionChecker.isCompanyAdmin()) { return false; } if (GroupPermissionUtil.contains(permissionChecker, ActionKeys.VIEW)) { return false; } return true; }
@Override public boolean isShow(PortletRequest portletRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); KBTemplate kbTemplate = (KBTemplate) portletRequest.getAttribute(KBWebKeys.KNOWLEDGE_BASE_KB_TEMPLATE); if (KBTemplatePermission.contains(permissionChecker, kbTemplate, KBActionKeys.UPDATE)) { return true; } return false; }
@Override public boolean isShow(PortletRequest portletRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); try { MBMessage message = ActionUtil.getMessage(portletRequest); return MBCategoryPermission.contains( themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), message.getCategoryId(), ActionKeys.LOCK_THREAD); } catch (Exception e) { } return false; }
public void setLayoutAssetEntry(AssetEntry assetEntry) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); String defaultAssetPublisherPortletId = AssetUtil.getDefaultAssetPublisherId(themeDisplay.getLayout()); if (isDefaultAssetPublisher() || Validator.isNull(defaultAssetPublisherPortletId) || !PortletPermissionUtil.contains( themeDisplay.getPermissionChecker(), themeDisplay.getLayout(), defaultAssetPublisherPortletId, ActionKeys.VIEW)) { _request.setAttribute(WebKeys.LAYOUT_ASSET_ENTRY, assetEntry); } }
protected boolean hasViewPermission() throws PortalException { if (_hasViewPermission != null) { return _hasViewPermission; } _hasViewPermission = true; DDLRecordSet recordSet = getRecordSet(); if (recordSet != null) { ThemeDisplay themeDisplay = getThemeDisplay(); _hasViewPermission = DDLRecordSetPermission.contains( themeDisplay.getPermissionChecker(), recordSet, ActionKeys.VIEW); } return _hasViewPermission; }
@Override protected boolean isProcessPortletRequest(PortletRequest portletRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); if (permissionChecker.isCompanyAdmin()) { return true; } Group group = themeDisplay.getScopeGroup(); if (group.isSite() && permissionChecker.isGroupAdmin(themeDisplay.getScopeGroupId())) { return true; } return false; }
@Override public boolean isShow(PortletRequest portletRequest) { try { MBCategory category = ActionUtil.getCategory(portletRequest); ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); if (MBCategoryPermission.contains( themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), getCategoryId(category), ActionKeys.MOVE_THREAD)) { return true; } } catch (Exception e) { } return false; }
public int getStatus() { if (_status != null) { return _status; } ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); int defaultStatus = WorkflowConstants.STATUS_APPROVED; PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); if (permissionChecker.isContentReviewer( themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId()) || isNavigationMine()) { defaultStatus = WorkflowConstants.STATUS_ANY; } _status = ParamUtil.getInteger(_request, "status", defaultStatus); return _status; }
@Override public boolean isShow(PortletRequest portletRequest) { try { BookmarksFolder folder = ActionUtil.getFolder(portletRequest); if (folder.getFolderId() == BookmarksFolderConstants.DEFAULT_PARENT_FOLDER_ID) { return false; } ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); if (BookmarksFolderPermissionChecker.contains( themeDisplay.getPermissionChecker(), folder, ActionKeys.UPDATE)) { return true; } } catch (Exception e) { } return false; }
public boolean isShowConfigurationIcon() throws PortalException { if (_showConfigurationIcon != null) { return _showConfigurationIcon; } if (isPreview() || (isSharedURL() && isFormShared())) { _showConfigurationIcon = false; return _showConfigurationIcon; } ThemeDisplay themeDisplay = getThemeDisplay(); _showConfigurationIcon = PortletPermissionUtil.contains( themeDisplay.getPermissionChecker(), themeDisplay.getLayout(), getPortletId(), ActionKeys.CONFIGURATION); return _showConfigurationIcon; }
public String getGroupAdministrationURL(Group group, PortletRequest portletRequest) { PanelCategoryHelper panelCategoryHelper = new PanelCategoryHelper(_panelAppRegistry, _panelCategoryRegistry); ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); String portletId = panelCategoryHelper.getFirstPortletId( PanelCategoryKeys.SITE_ADMINISTRATION, themeDisplay.getPermissionChecker(), group); if (Validator.isNotNull(portletId)) { PortletURL groupAdministrationURL = _portal.getControlPanelPortletURL( portletRequest, group, portletId, 0, 0, PortletRequest.RENDER_PHASE); if (groupAdministrationURL != null) { return groupAdministrationURL.toString(); } } return null; }
@Override public PortletURL getViewURL(HttpServletRequest request) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String portletId = PortletProviderUtil.getPortletId(TrashEntry.class.getName(), PortletProvider.Action.VIEW); if (!themeDisplay.isSignedIn() || !isTrashEnabled(themeDisplay.getScopeGroupId()) || !PortletPermissionUtil.hasControlPanelAccessPermission( themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), portletId)) { return null; } PortletURL portletURL = PortalUtil.getControlPanelPortletURL(request, portletId, PortletRequest.RENDER_PHASE); portletURL.setParameter("redirect", themeDisplay.getURLCurrent()); return portletURL; }
public void resetCustomizationView(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); if (!LayoutPermissionUtil.contains( themeDisplay.getPermissionChecker(), themeDisplay.getLayout(), ActionKeys.CUSTOMIZE)) { throw new PrincipalException(); } LayoutTypePortlet layoutTypePortlet = themeDisplay.getLayoutTypePortlet(); if ((layoutTypePortlet != null) && layoutTypePortlet.isCustomizable() && layoutTypePortlet.isCustomizedView()) { layoutTypePortlet.resetUserPreferences(); } MultiSessionMessages.add( actionRequest, PortalUtil.getPortletId(actionRequest) + "requestProcessed"); }
@Override public boolean isShow(PortletRequest portletRequest) { try { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); long roleId = _getRoleId(portletRequest); Role role = _roleService.fetchRole(roleId); String roleName = role.getName(); if (!roleName.equals(RoleConstants.OWNER) && RolePermissionUtil.contains( themeDisplay.getPermissionChecker(), roleId, ActionKeys.PERMISSIONS)) { return true; } return false; } catch (Exception e) { } return false; }
protected LinkedHashMap<String, Object> getGroupParams( PortletRequest portletRequest, GroupSearchTerms searchTerms, long parentGroupId) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); LinkedHashMap<String, Object> groupParams = new LinkedHashMap<>(); groupParams.put("site", Boolean.TRUE); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); User user = themeDisplay.getUser(); if (searchTerms.hasSearchTerms()) { if (isFilterManageableGroups(portletRequest)) { groupParams.put("groupsTree", getAllGroups(portletRequest)); } else if (parentGroupId > 0) { List<Group> groupsTree = new ArrayList<>(); Group parentGroup = _groupLocalService.getGroup(parentGroupId); groupsTree.add(parentGroup); groupParams.put("groupsTree", groupsTree); } if (!permissionChecker.isCompanyAdmin() && !GroupPermissionUtil.contains(permissionChecker, ActionKeys.VIEW)) { groupParams.put("usersGroups", Long.valueOf(user.getUserId())); } } return groupParams; }
protected MBMessage updateMessage(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long messageId = ParamUtil.getLong(actionRequest, "messageId"); long groupId = themeDisplay.getScopeGroupId(); long categoryId = ParamUtil.getLong(actionRequest, "mbCategoryId"); long threadId = ParamUtil.getLong(actionRequest, "threadId"); long parentMessageId = ParamUtil.getLong(actionRequest, "parentMessageId"); String subject = ParamUtil.getString(actionRequest, "subject"); String body = ParamUtil.getString(actionRequest, "body"); MBGroupServiceSettings mbGroupServiceSettings = MBGroupServiceSettings.getInstance(groupId); List<ObjectValuePair<String, InputStream>> inputStreamOVPs = new ArrayList<>(5); try { UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest); for (int i = 1; i <= 5; i++) { String fileName = uploadPortletRequest.getFileName("msgFile" + i); InputStream inputStream = uploadPortletRequest.getFileAsStream("msgFile" + i); if ((inputStream == null) || Validator.isNull(fileName)) { continue; } ObjectValuePair<String, InputStream> inputStreamOVP = new ObjectValuePair<>(fileName, inputStream); inputStreamOVPs.add(inputStreamOVP); } boolean question = ParamUtil.getBoolean(actionRequest, "question"); boolean anonymous = ParamUtil.getBoolean(actionRequest, "anonymous"); double priority = ParamUtil.getDouble(actionRequest, "priority"); boolean allowPingbacks = ParamUtil.getBoolean(actionRequest, "allowPingbacks"); ServiceContext serviceContext = ServiceContextFactory.getInstance(MBMessage.class.getName(), actionRequest); boolean preview = ParamUtil.getBoolean(actionRequest, "preview"); serviceContext.setAttribute("preview", preview); MBMessage message = null; if (messageId <= 0) { if (PropsValues.CAPTCHA_CHECK_PORTLET_MESSAGE_BOARDS_EDIT_MESSAGE) { CaptchaUtil.check(actionRequest); } if (threadId <= 0) { // Post new thread message = _mbMessageService.addMessage( groupId, categoryId, subject, body, mbGroupServiceSettings.getMessageFormat(), inputStreamOVPs, anonymous, priority, allowPingbacks, serviceContext); if (question) { _mbThreadLocalService.updateQuestion(message.getThreadId(), true); } } else { // Post reply message = _mbMessageService.addMessage( parentMessageId, subject, body, mbGroupServiceSettings.getMessageFormat(), inputStreamOVPs, anonymous, priority, allowPingbacks, serviceContext); } } else { List<String> existingFiles = new ArrayList<>(); for (int i = 1; i <= 5; i++) { String path = ParamUtil.getString(actionRequest, "existingPath" + i); if (Validator.isNotNull(path)) { existingFiles.add(path); } } // Update message message = _mbMessageService.updateMessage( messageId, subject, body, inputStreamOVPs, existingFiles, priority, allowPingbacks, serviceContext); if (message.isRoot()) { _mbThreadLocalService.updateQuestion(message.getThreadId(), question); } } PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); boolean subscribe = ParamUtil.getBoolean(actionRequest, "subscribe"); if (!preview && subscribe && MBMessagePermission.contains(permissionChecker, message, ActionKeys.SUBSCRIBE)) { _mbMessageService.subscribeMessage(message.getMessageId()); } return message; } finally { for (ObjectValuePair<String, InputStream> inputStreamOVP : inputStreamOVPs) { InputStream inputStream = inputStreamOVP.getValue(); StreamUtil.cleanUp(inputStream); } } }