List of usage examples for com.liferay.portal.kernel.security.permission ActionKeys VIEW
String VIEW
To view the source code for com.liferay.portal.kernel.security.permission ActionKeys VIEW.
Click Source Link
From source file:com.liferay.layout.page.template.service.impl.LayoutPageTemplateEntryServiceImpl.java
License:Open Source License
@Override public LayoutPageTemplateEntry fetchLayoutPageTemplateEntry(long layoutPageTemplateEntryId) throws PortalException { LayoutPageTemplateEntry layoutPageTemplateEntry = layoutPageTemplateEntryLocalService .fetchLayoutPageTemplateEntry(layoutPageTemplateEntryId); if (layoutPageTemplateEntry != null) { _layoutPageTemplateEntryModelResourcePermission.check(getPermissionChecker(), layoutPageTemplateEntry, ActionKeys.VIEW); }//from w w w .ja va 2 s .c o m return layoutPageTemplateEntry; }
From source file:com.liferay.message.boards.comment.internal.MBDiscussionPermissionImpl.java
License:Open Source License
@Override public boolean hasViewPermission(long companyId, long groupId, String className, long classPK) { return MBDiscussionPermission.contains(_permissionChecker, companyId, groupId, className, classPK, ActionKeys.VIEW); }
From source file:com.liferay.message.boards.internal.search.MBMessageIndexer.java
License:Open Source License
@Override public boolean hasPermission(PermissionChecker permissionChecker, String entryClassName, long entryClassPK, String actionId) throws Exception { MBMessage message = mbMessageLocalService.getMessage(entryClassPK); if (message.isDiscussion()) { Indexer<?> indexer = IndexerRegistryUtil.getIndexer(message.getClassName()); return indexer.hasPermission(permissionChecker, message.getClassName(), message.getClassPK(), ActionKeys.VIEW); }//w w w . ja v a2 s.c o m return MBMessagePermission.contains(permissionChecker, entryClassPK, ActionKeys.VIEW); }
From source file:com.liferay.message.boards.internal.service.permission.MBCategoryPermission.java
License:Open Source License
private boolean _contains(PermissionChecker permissionChecker, long groupId, long categoryId, String actionId) throws PortalException { if (_mbBanLocalService.hasBan(groupId, permissionChecker.getUserId())) { return false; }// w w w .j ava 2 s . co m if ((categoryId == MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) || (categoryId == MBCategoryConstants.DISCUSSION_CATEGORY_ID)) { return MBPermission.contains(permissionChecker, groupId, actionId); } MBCategory category = _mbCategoryLocalService.getCategory(categoryId); if (actionId.equals(ActionKeys.ADD_CATEGORY)) { actionId = ActionKeys.ADD_SUBCATEGORY; } String portletId = PortletProviderUtil.getPortletId(MBCategory.class.getName(), PortletProvider.Action.EDIT); Boolean hasPermission = _stagingPermission.hasPermission(permissionChecker, category.getGroupId(), MBCategory.class.getName(), category.getCategoryId(), portletId, actionId); if (hasPermission != null) { return hasPermission.booleanValue(); } if (actionId.equals(ActionKeys.VIEW) && PropsValues.PERMISSIONS_VIEW_DYNAMIC_INHERITANCE) { try { while (categoryId != MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) { category = _mbCategoryLocalService.getCategory(categoryId); if (!_hasPermission(permissionChecker, category, actionId)) { return false; } categoryId = category.getParentCategoryId(); } } catch (NoSuchCategoryException nsce) { if (!category.isInTrash()) { throw nsce; } } return MBPermission.contains(permissionChecker, category.getGroupId(), actionId); } return _hasPermission(permissionChecker, category, actionId); }
From source file:com.liferay.message.boards.internal.service.permission.MBMessagePermission.java
License:Open Source License
private boolean _contains(PermissionChecker permissionChecker, MBMessage message, String actionId) throws PortalException { if (_mbBanLocalService.hasBan(message.getGroupId(), permissionChecker.getUserId())) { return false; }// w w w.jav a 2 s. c om String portletId = PortletProviderUtil.getPortletId(MBMessage.class.getName(), PortletProvider.Action.EDIT); Boolean hasPermission = _stagingPermission.hasPermission(permissionChecker, message.getGroupId(), MBMessage.class.getName(), message.getMessageId(), portletId, actionId); if (hasPermission != null) { return hasPermission.booleanValue(); } if (message.isDraft() || message.isScheduled()) { if (actionId.equals(ActionKeys.VIEW) && !_contains(permissionChecker, message, ActionKeys.UPDATE)) { return false; } } else if (message.isPending()) { hasPermission = WorkflowPermissionUtil.hasPermission(permissionChecker, message.getGroupId(), message.getWorkflowClassName(), message.getMessageId(), actionId); if (hasPermission != null) { return hasPermission.booleanValue(); } } if (actionId.equals(ActionKeys.VIEW) && PropsValues.PERMISSIONS_VIEW_DYNAMIC_INHERITANCE) { long categoryId = message.getCategoryId(); if ((categoryId == MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) || (categoryId == MBCategoryConstants.DISCUSSION_CATEGORY_ID)) { if (!MBPermission.contains(permissionChecker, message.getGroupId(), actionId)) { return false; } } else { try { MBCategory category = _mbCategoryLocalService.getCategory(categoryId); if (!MBCategoryPermission.contains(permissionChecker, category, actionId)) { return false; } } catch (NoSuchCategoryException nsce) { if (!message.isInTrash()) { throw nsce; } } } } if (permissionChecker.hasOwnerPermission(message.getCompanyId(), MBMessage.class.getName(), message.getRootMessageId(), message.getUserId(), actionId)) { return true; } if (!permissionChecker.hasPermission(message.getGroupId(), MBMessage.class.getName(), message.getMessageId(), actionId)) { return false; } if (message.isRoot() || !actionId.equals(ActionKeys.VIEW)) { return true; } return _contains(permissionChecker, _mbMessageLocalService.getMessage(message.getParentMessageId()), actionId); }
From source file:com.liferay.message.boards.permission.test.MBCategoryPermissionCheckerTest.java
License:Open Source License
@Test public void testContains() throws Exception { Assert.assertTrue(MBCategoryPermission.contains(permissionChecker, _category, ActionKeys.VIEW)); Assert.assertTrue(MBCategoryPermission.contains(permissionChecker, _subcategory, ActionKeys.VIEW)); removePortletModelViewPermission();//from ww w. jav a 2 s. c o m Assert.assertFalse(MBCategoryPermission.contains(permissionChecker, _category, ActionKeys.VIEW)); Assert.assertFalse(MBCategoryPermission.contains(permissionChecker, _subcategory, ActionKeys.VIEW)); }
From source file:com.liferay.message.boards.permission.test.MBMessagePermissionCheckerTest.java
License:Open Source License
@Test public void testContains() throws Exception { Assert.assertTrue(MBMessagePermission.contains(permissionChecker, _message, ActionKeys.VIEW)); Assert.assertTrue(MBMessagePermission.contains(permissionChecker, _submessage, ActionKeys.VIEW)); removePortletModelViewPermission();/*from w w w .j av a2s. c o m*/ Assert.assertFalse(MBMessagePermission.contains(permissionChecker, _message, ActionKeys.VIEW)); Assert.assertFalse(MBMessagePermission.contains(permissionChecker, _submessage, ActionKeys.VIEW)); }
From source file:com.liferay.message.boards.service.permission.MBDiscussionPermission.java
License:Open Source License
public static boolean contains(PermissionChecker permissionChecker, MBMessage message, String actionId) throws PortalException { String className = message.getClassName(); if (className.equals(WorkflowInstance.class.getName())) { return permissionChecker.hasPermission(message.getGroupId(), PortletKeys.WORKFLOW_DEFINITION, message.getGroupId(), ActionKeys.VIEW); }//from w ww . j a v a2 s . co m if (PropsValues.DISCUSSION_COMMENTS_ALWAYS_EDITABLE_BY_OWNER && (permissionChecker.getUserId() == message.getUserId())) { return true; } if (message.isPending()) { Boolean hasPermission = WorkflowPermissionUtil.hasPermission(permissionChecker, message.getGroupId(), message.getWorkflowClassName(), message.getMessageId(), actionId); if (hasPermission != null) { return hasPermission.booleanValue(); } } return contains(permissionChecker, message.getCompanyId(), message.getGroupId(), className, message.getClassPK(), actionId); }
From source file:com.liferay.message.boards.service.test.MBMessageServiceTest.java
License:Open Source License
@Before public void setUp() throws Exception { String name = "Test Category"; String description = "This is a test category."; String displayStyle = MBCategoryConstants.DEFAULT_DISPLAY_STYLE; String emailAddress = null;/* ww w . j a v a 2s . c o m*/ String inProtocol = null; String inServerName = null; int inServerPort = 0; boolean inUseSSL = false; String inUserName = null; String inPassword = null; int inReadInterval = 0; String outEmailAddress = null; boolean outCustom = false; String outServerName = null; int outServerPort = 0; boolean outUseSSL = false; String outUserName = null; String outPassword = null; boolean allowAnonymous = false; boolean mailingListActive = false; _group = GroupTestUtil.addGroup(); for (int i = 0; i < ServiceTestUtil.THREAD_COUNT; i++) { UserTestUtil.addUser(_group.getGroupId()); } ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId()); serviceContext.setGroupPermissions(new String[] { ActionKeys.ADD_MESSAGE, ActionKeys.VIEW }); serviceContext.setGuestPermissions(new String[] { ActionKeys.ADD_MESSAGE, ActionKeys.VIEW }); _category = MBCategoryServiceUtil.addCategory(MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, name, description, displayStyle, emailAddress, inProtocol, inServerName, inServerPort, inUseSSL, inUserName, inPassword, inReadInterval, outEmailAddress, outCustom, outServerName, outServerPort, outUseSSL, outUserName, outPassword, allowAnonymous, mailingListActive, serviceContext); _userIds = UserLocalServiceUtil.getGroupUserIds(_group.getGroupId()); }
From source file:com.liferay.message.boards.subscription.test.MBSubscriptionBaseModelTest.java
License:Open Source License
@Override protected void removeContainerModelResourceViewPermission() throws Exception { RoleTestUtil.removeResourcePermission(RoleConstants.GUEST, MBCategory.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, String.valueOf(_category.getCategoryId()), ActionKeys.VIEW); RoleTestUtil.removeResourcePermission(RoleConstants.SITE_MEMBER, MBCategory.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, String.valueOf(_category.getCategoryId()), ActionKeys.VIEW); }