1
14
15 package com.liferay.portal.service.impl;
16
17 import com.liferay.portal.PortalException;
18 import com.liferay.portal.SystemException;
19 import com.liferay.portal.model.Phone;
20 import com.liferay.portal.security.permission.ActionKeys;
21 import com.liferay.portal.service.base.PhoneServiceBaseImpl;
22 import com.liferay.portal.service.permission.CommonPermissionUtil;
23
24 import java.util.List;
25
26
31 public class PhoneServiceImpl extends PhoneServiceBaseImpl {
32
33 public Phone addPhone(
34 String className, long classPK, String number, String extension,
35 int typeId, boolean primary)
36 throws PortalException, SystemException {
37
38 CommonPermissionUtil.check(
39 getPermissionChecker(), className, classPK, ActionKeys.UPDATE);
40
41 return phoneLocalService.addPhone(
42 getUserId(), className, classPK, number, extension, typeId,
43 primary);
44 }
45
46 public void deletePhone(long phoneId)
47 throws PortalException, SystemException {
48
49 Phone phone = phonePersistence.findByPrimaryKey(phoneId);
50
51 CommonPermissionUtil.check(
52 getPermissionChecker(), phone.getClassNameId(), phone.getClassPK(),
53 ActionKeys.UPDATE);
54
55 phoneLocalService.deletePhone(phoneId);
56 }
57
58 public Phone getPhone(long phoneId)
59 throws PortalException, SystemException {
60
61 Phone phone = phonePersistence.findByPrimaryKey(phoneId);
62
63 CommonPermissionUtil.check(
64 getPermissionChecker(), phone.getClassNameId(), phone.getClassPK(),
65 ActionKeys.VIEW);
66
67 return phone;
68 }
69
70 public List<Phone> getPhones(String className, long classPK)
71 throws PortalException, SystemException {
72
73 CommonPermissionUtil.check(
74 getPermissionChecker(), className, classPK, ActionKeys.VIEW);
75
76 return phoneLocalService.getPhones(
77 getUser().getCompanyId(), className, classPK);
78 }
79
80 public Phone updatePhone(
81 long phoneId, String number, String extension, int typeId,
82 boolean primary)
83 throws PortalException, SystemException {
84
85 Phone phone = phonePersistence.findByPrimaryKey(phoneId);
86
87 CommonPermissionUtil.check(
88 getPermissionChecker(), phone.getClassNameId(), phone.getClassPK(),
89 ActionKeys.UPDATE);
90
91 return phoneLocalService.updatePhone(
92 phoneId, number, extension, typeId, primary);
93 }
94
95 }