本文整理汇总了Java中com.liferay.portal.kernel.security.permission.PermissionChecker类的典型用法代码示例。如果您正苦于以下问题:Java PermissionChecker类的具体用法?Java PermissionChecker怎么用?Java PermissionChecker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PermissionChecker类属于com.liferay.portal.kernel.security.permission包,在下文中一共展示了PermissionChecker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFileEntryTypes
import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
@Override
public Map<DLFileEntryType, List<DDMTemplate>> getFileEntryTypes(PermissionChecker permissionChecker, long groupId) throws PortalException {
List<DLFileEntryType> fileEntryTypes = this.dlFileEntryTypeService.getFileEntryTypes(this.portal.getCurrentAndAncestorSiteGroupIds(groupId));
HashMap<DLFileEntryType, List<DDMTemplate>> fileEntryTypeTemplateMapping = new HashMap<>(fileEntryTypes.size());
Map<Group, List<DDMTemplate>> templatesByGroup = this.getDLFileEntryTypeTemplates(permissionChecker, groupId);
List<DDMTemplate> templates = new ArrayList<>();
for(List<DDMTemplate> groupTemplates : templatesByGroup.values()) {
templates.addAll(groupTemplates);
}
// Put the default file entry type in there (because getFileEntryTypes won't do it)
fileEntryTypeTemplateMapping.put(this.dlFileEntryTypeService.getDLFileEntryType(DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_BASIC_DOCUMENT), templates);
for(DLFileEntryType fileEntryType : fileEntryTypes) {
fileEntryTypeTemplateMapping.put(fileEntryType, templates);
}
return fileEntryTypeTemplateMapping;
}
示例2: processLifecycleEvent
import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
@Override
public void processLifecycleEvent(LifecycleEvent lifecycleEvent) throws ActionException {
User user;
try {
user = PortalUtil.getUser(lifecycleEvent.getRequest());
PrincipalThreadLocal.setName(user.getUserId());
PermissionChecker permissionChecker;
permissionChecker = PermissionCheckerFactoryUtil.create(user);
PermissionThreadLocal.setPermissionChecker(permissionChecker);
String friendlyUrl = user.getSiteGroups().get(0).getFriendlyURL();
lifecycleEvent.getResponse().sendRedirect("/group" + friendlyUrl);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例3: updateFile
import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
public static FileEntry updateFile(long userId, long companyId, long groupId, long fileEntryId,
InputStream inputStream, String fileName, String fileType, long fileSize, String destination, String desc,
ServiceContext serviceContext) throws Exception {
FileEntry fileEntry = null;
if (inputStream != null && fileSize > 0 && Validator.isNotNull(fileName)) {
serviceContext.setAddGroupPermissions(true);
serviceContext.setAddGuestPermissions(true);
User user = UserLocalServiceUtil.getUser(serviceContext.getUserId());
PermissionChecker checker = PermissionCheckerFactoryUtil.create(user);
PermissionThreadLocal.setPermissionChecker(checker);
DLAppLocalServiceUtil.updateFileEntry(userId, fileEntryId, fileName, fileType,
System.currentTimeMillis() + StringPool.DASH + fileName, desc, StringPool.BLANK, true, inputStream,
fileSize, serviceContext);
}
return fileEntry;
}
示例4: hasPermissions
import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
@Override
protected boolean hasPermissions(PermissionChecker permissionChecker, SocialActivity activity, String actionId,
ServiceContext serviceContext) throws Exception {
TaskRecord taskRecord = _taskRecordLocalService.getTaskRecord(activity.getClassPK());
return TaskRecordPermission.contains(permissionChecker, taskRecord.getTaskRecordId(), actionId);
}
示例5: check
import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
public static void check(PermissionChecker permissionChecker, long groupId, String actionId)
throws PortalException {
if (!contains(permissionChecker, groupId, actionId)) {
throw new PrincipalException();
}
}
示例6: check
import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
public static void check(PermissionChecker permissionChecker, TaskRecord taskRecord, String actionId)
throws PortalException {
if (!contains(permissionChecker, taskRecord, actionId)) {
throw new PrincipalException();
}
}
示例7: contains
import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
public static boolean contains(PermissionChecker permissionChecker, TaskRecord taskRecord, String actionId) {
if (permissionChecker.hasOwnerPermission(taskRecord.getCompanyId(), TaskRecord.class.getName(),
taskRecord.getTaskRecordId(), taskRecord.getUserId(), actionId)) {
return true;
}
return permissionChecker.hasPermission(taskRecord.getGroupId(), TaskRecord.class.getName(),
String.valueOf(taskRecord.getTaskRecordId()), actionId);
}
示例8: getApplicationDisplayTemplates
import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
/**
* Returns the DL File Entry types templates
*
* @param permissionChecker The current context's permission checker
* @param groupId The current site ID
* @param classNameId The template's classNameId
* @return A list of templates indexed by file entry types
*
* @throws PortalException If an error occurs while searching templates
*/
private Map<Group, List<DDMTemplate>> getApplicationDisplayTemplates(PermissionChecker permissionChecker, long groupId, long classNameId) throws PortalException {
HashMap<Group, List<DDMTemplate>> adts = new HashMap<>();
long[] currentGroupIds = this.portal.getCurrentAndAncestorSiteGroupIds(groupId);
long userId = permissionChecker.getUserId();
for(long currentGroupId : currentGroupIds) {
List<DDMTemplate> groupTemplates = this.ddmTemplateService.getTemplates(currentGroupId, classNameId)
.stream()
.filter(template -> {
// See DDMTemplatePermission.java in Liferay's source code for the inspirational stuff
String modelResourceName = DDMTemplate.class.getName();
long companyId = template.getCompanyId();
long templateId = template.getTemplateId();
String actionKey = ActionKeys.VIEW;
return (
permissionChecker.hasOwnerPermission(companyId, modelResourceName, templateId, userId, actionKey) ||
permissionChecker.hasPermission(companyId, modelResourceName, templateId, actionKey)
);
})
.collect(Collectors.toList());
// If we have templates to show, put it in the map
if(!groupTemplates.isEmpty()) {
Group group = this.groupService.getGroup(currentGroupId);
adts.put(group, groupTemplates);
}
}
return adts;
}
示例9: hasPermissions
import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
@Override
protected boolean hasPermissions(PermissionChecker permissionChecker, SocialActivity activity, String actionId,
ServiceContext serviceContext) throws Exception {
Contact contact = _contactLocalService.getContact(activity.getClassPK());
return ContactPermission.contains(permissionChecker, contact.getContactId(), actionId);
}
示例10: check
import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
public static void check(PermissionChecker permissionChecker, Contact contact, String actionId)
throws PrincipalException {
if (!contains(permissionChecker, contact, actionId)) {
throw new PrincipalException();
}
}
示例11: contains
import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
public static boolean contains(PermissionChecker permissionChecker, long contactId, String actionId) {
Contact contact;
try {
contact = ContactLocalServiceUtil.getContact(contactId);
return contains(permissionChecker, contact, actionId);
} catch (PortalException e) {
_log.error(e);
}
return false;
}
示例12: check
import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
public static void check(PermissionChecker permissionChecker, long groupId, String actionId)
throws PrincipalException {
if (!contains(permissionChecker, groupId, actionId)) {
throw new PrincipalException();
}
}
示例13: addFolder
import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
public static DLFolder addFolder(
long userId, long groupId, long repositoryId, boolean mountPoint,
long parentFolderId, String name, String description, boolean hidden,
ServiceContext serviceContext) {
DLFolder dlFolder = null;
try {
if (hasFolder(groupId, parentFolderId, name)) {
dlFolder = DLFolderLocalServiceUtil.getFolder(
groupId, parentFolderId, name);
setFolderPermissions(dlFolder);
}
else {
User user =
UserLocalServiceUtil.getUser(serviceContext.getUserId());
PermissionChecker checker =
PermissionCheckerFactoryUtil.create(user);
PermissionThreadLocal.setPermissionChecker(checker);
//serviceContext.setAddGroupPermissions(true);
//serviceContext.setAddGuestPermissions(true);
dlFolder = DLFolderLocalServiceUtil.addFolder(
userId, groupId, repositoryId, mountPoint, parentFolderId,
name, description, hidden, serviceContext);
setFolderPermissions(dlFolder);
}
}
catch (Exception e) {
_log.info(e);
}
return dlFolder;
}
示例14: cloneFile
import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
public static FileEntry cloneFile(long userId, long groupId, long fileEntryId,
String destination, ServiceContext serviceContext)
throws Exception {
FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(fileEntryId);
serviceContext.setAddGroupPermissions(true);
serviceContext.setAddGuestPermissions(true);
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
if(Validator.isNull(destination)) {
destination = StringPool.BLANK;
} else if(destination.indexOf(StringPool.SLASH) < 0) {
destination += StringPool.SLASH;
}
destination += calendar.get(Calendar.YEAR) + StringPool.SLASH;
destination += calendar.get(Calendar.MONTH) + StringPool.SLASH;
destination += calendar.get(Calendar.DAY_OF_MONTH);
DLFolder dlFolder = DLFolderUtil.getTargetFolder(userId, groupId, groupId, false, 0, destination,
StringPool.BLANK, false, serviceContext);
User user = UserLocalServiceUtil.getUser(serviceContext.getUserId());
PermissionChecker checker = PermissionCheckerFactoryUtil.create(user);
PermissionThreadLocal.setPermissionChecker(checker);
String title = getFileName(fileEntry.getTitle());
return DLAppLocalServiceUtil.addFileEntry(userId, groupId, dlFolder.getFolderId(), title,
fileEntry.getMimeType(), System.currentTimeMillis() + StringPool.DASH + title, title,
StringPool.BLANK, fileEntry.getContentStream(), fileEntry.getSize(), serviceContext);
}
示例15: check
import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
public static void check(PermissionChecker permissionChecker, Measurement taskRecord, String actionId)
throws PortalException {
if (!contains(permissionChecker, taskRecord, actionId)) {
throw new PrincipalException();
}
}