1
+ /**
2
+ * SPDX-FileCopyrightText: (c) 2025 Liferay, Inc. https://liferay.com
3
+ * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
4
+ */
5
+
6
+ package com .liferay .calendar .internal .security .permission .resource ;
7
+
8
+ import com .liferay .calendar .model .CalendarNotificationTemplate ;
9
+ import com .liferay .calendar .service .CalendarNotificationTemplateLocalService ;
10
+ import com .liferay .portal .kernel .exception .PortalException ;
11
+ import com .liferay .portal .kernel .security .auth .PrincipalException ;
12
+ import com .liferay .portal .kernel .security .permission .PermissionChecker ;
13
+ import com .liferay .portal .kernel .security .permission .resource .ModelResourcePermission ;
14
+ import com .liferay .portal .kernel .security .permission .resource .PortletResourcePermission ;
15
+
16
+ import org .osgi .service .component .annotations .Component ;
17
+ import org .osgi .service .component .annotations .Reference ;
18
+
19
+ /**
20
+ * @author Feliphe Marinho
21
+ */
22
+ @ Component (
23
+ property = "model.class.name=com.liferay.calendar.model.CalendarNotificationTemplate" ,
24
+ service = ModelResourcePermission .class
25
+ )
26
+ public class CalendarNotificationTemplateModelResourcePermission
27
+ implements ModelResourcePermission <CalendarNotificationTemplate > {
28
+
29
+ @ Override
30
+ public void check (
31
+ PermissionChecker permissionChecker ,
32
+ CalendarNotificationTemplate calendarNotificationTemplate ,
33
+ String actionId )
34
+ throws PortalException {
35
+
36
+ if (!contains (
37
+ permissionChecker , calendarNotificationTemplate , actionId )) {
38
+
39
+ throw new PrincipalException .MustHavePermission (
40
+ permissionChecker , CalendarNotificationTemplate .class .getName (),
41
+ calendarNotificationTemplate .getPrimaryKey (), actionId );
42
+ }
43
+ }
44
+
45
+ @ Override
46
+ public void check (
47
+ PermissionChecker permissionChecker ,
48
+ long calendarNotificationTemplateId , String actionId )
49
+ throws PortalException {
50
+
51
+ if (!contains (
52
+ permissionChecker , calendarNotificationTemplateId , actionId )) {
53
+
54
+ throw new PrincipalException .MustHavePermission (
55
+ permissionChecker , CalendarNotificationTemplate .class .getName (),
56
+ calendarNotificationTemplateId , actionId );
57
+ }
58
+ }
59
+
60
+ @ Override
61
+ public boolean contains (
62
+ PermissionChecker permissionChecker ,
63
+ CalendarNotificationTemplate calendarNotificationTemplate ,
64
+ String actionId )
65
+ throws PortalException {
66
+
67
+ if (permissionChecker .hasPermission (
68
+ null , CalendarNotificationTemplate .class .getName (),
69
+ calendarNotificationTemplate .getPrimaryKey (), actionId )) {
70
+
71
+ return true ;
72
+ }
73
+
74
+ return false ;
75
+ }
76
+
77
+ @ Override
78
+ public boolean contains (
79
+ PermissionChecker permissionChecker ,
80
+ long calendarNotificationTemplateId , String actionId )
81
+ throws PortalException {
82
+
83
+ return contains (
84
+ permissionChecker ,
85
+ _calendarNotificationTemplateLocalService .
86
+ getCalendarNotificationTemplate (calendarNotificationTemplateId ),
87
+ actionId );
88
+ }
89
+
90
+ @ Override
91
+ public String getModelName () {
92
+ return CalendarNotificationTemplate .class .getName ();
93
+ }
94
+
95
+ @ Override
96
+ public PortletResourcePermission getPortletResourcePermission () {
97
+ return null ;
98
+ }
99
+
100
+ @ Reference
101
+ private CalendarNotificationTemplateLocalService
102
+ _calendarNotificationTemplateLocalService ;
103
+
104
+ }
0 commit comments