1
22
23 package com.liferay.portlet.softwarecatalog.service.permission;
24
25 import com.liferay.portal.PortalException;
26 import com.liferay.portal.SystemException;
27 import com.liferay.portal.security.auth.PrincipalException;
28 import com.liferay.portal.security.permission.PermissionChecker;
29 import com.liferay.portlet.softwarecatalog.model.SCProductEntry;
30 import com.liferay.portlet.softwarecatalog.service.SCProductEntryLocalServiceUtil;
31
32
39 public class SCProductEntryPermission {
40
41 public static void check(
42 PermissionChecker permissionChecker, long productEntryId,
43 String actionId)
44 throws PortalException, SystemException {
45
46 if (!contains(permissionChecker, productEntryId, actionId)) {
47 throw new PrincipalException();
48 }
49 }
50
51 public static void check(
52 PermissionChecker permissionChecker, SCProductEntry productEntry,
53 String actionId)
54 throws PortalException, SystemException {
55
56 if (!contains(permissionChecker, productEntry, actionId)) {
57 throw new PrincipalException();
58 }
59 }
60
61 public static boolean contains(
62 PermissionChecker permissionChecker, long productEntryId,
63 String actionId)
64 throws PortalException, SystemException {
65
66 SCProductEntry productEntry =
67 SCProductEntryLocalServiceUtil.getProductEntry(productEntryId);
68
69 return contains(permissionChecker, productEntry, actionId);
70 }
71
72 public static boolean contains(
73 PermissionChecker permissionChecker, SCProductEntry productEntry,
74 String actionId)
75 throws PortalException, SystemException {
76
77 return permissionChecker.hasPermission(
78 productEntry.getGroupId(), SCProductEntry.class.getName(),
79 productEntry.getProductEntryId(), actionId);
80 }
81
82 }