1
22
23 package com.liferay.portal.service.impl;
24
25 import com.liferay.portal.PortalException;
26 import com.liferay.portal.SystemException;
27 import com.liferay.portal.kernel.security.permission.ActionKeys;
28 import com.liferay.portal.model.OrgLabor;
29 import com.liferay.portal.model.Organization;
30 import com.liferay.portal.service.OrgLaborLocalServiceUtil;
31 import com.liferay.portal.service.OrgLaborService;
32 import com.liferay.portal.service.permission.LocationPermissionUtil;
33 import com.liferay.portal.service.permission.OrganizationPermissionUtil;
34 import com.liferay.portal.service.persistence.OrgLaborUtil;
35 import com.liferay.portal.service.persistence.OrganizationUtil;
36
37 import java.util.List;
38
39
45 public class OrgLaborServiceImpl
46 extends PrincipalBean implements OrgLaborService {
47
48 public OrgLabor addOrgLabor(
49 long organizationId, int typeId, int sunOpen, int sunClose,
50 int monOpen, int monClose, int tueOpen, int tueClose, int wedOpen,
51 int wedClose, int thuOpen, int thuClose, int friOpen, int friClose,
52 int satOpen, int satClose)
53 throws PortalException, SystemException {
54
55 checkPermission(organizationId, ActionKeys.UPDATE);
56
57 return OrgLaborLocalServiceUtil.addOrgLabor(
58 organizationId, typeId, sunOpen, sunClose, monOpen, monClose,
59 tueOpen, tueClose, wedOpen, wedClose, thuOpen, thuClose, friOpen,
60 friClose, satOpen, satClose);
61 }
62
63 public void deleteOrgLabor(long orgLaborId)
64 throws PortalException, SystemException {
65
66 OrgLabor orgLabor = OrgLaborUtil.findByPrimaryKey(orgLaborId);
67
68 checkPermission(orgLabor.getOrganizationId(), ActionKeys.UPDATE);
69
70 OrgLaborLocalServiceUtil.deleteOrgLabor(orgLaborId);
71 }
72
73 public OrgLabor getOrgLabor(long orgLaborId)
74 throws PortalException, SystemException {
75
76 OrgLabor orgLabor = OrgLaborUtil.findByPrimaryKey(orgLaborId);
77
78 checkPermission(orgLabor.getOrganizationId(), ActionKeys.VIEW);
79
80 return orgLabor;
81 }
82
83 public List getOrgLabors(long organizationId)
84 throws PortalException, SystemException {
85
86 checkPermission(organizationId, ActionKeys.VIEW);
87
88 return OrgLaborLocalServiceUtil.getOrgLabors(organizationId);
89 }
90
91 public OrgLabor updateOrgLabor(
92 long orgLaborId, int sunOpen, int sunClose, int monOpen,
93 int monClose, int tueOpen, int tueClose, int wedOpen, int wedClose,
94 int thuOpen, int thuClose, int friOpen, int friClose, int satOpen,
95 int satClose)
96 throws PortalException, SystemException {
97
98 OrgLabor orgLabor = OrgLaborUtil.findByPrimaryKey(orgLaborId);
99
100 checkPermission(orgLabor.getOrganizationId(), ActionKeys.UPDATE);
101
102 return OrgLaborLocalServiceUtil.updateOrgLabor(
103 orgLaborId, sunOpen, sunClose, monOpen, monClose, tueOpen, tueClose,
104 wedOpen, wedClose, thuOpen, thuClose, friOpen, friClose, satOpen,
105 satClose);
106 }
107
108 protected void checkPermission(long organizationId, String actionId)
109 throws PortalException, SystemException {
110
111 Organization organization =
112 OrganizationUtil.findByPrimaryKey(organizationId);
113
114 if (!organization.isLocation()) {
115 OrganizationPermissionUtil.check(
116 getPermissionChecker(), organizationId, actionId);
117 }
118 else {
119 LocationPermissionUtil.check(
120 getPermissionChecker(), organizationId, actionId);
121 }
122 }
123
124 }