001
014
015 package com.liferay.portal.service.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.model.Phone;
020 import com.liferay.portal.model.User;
021 import com.liferay.portal.security.permission.ActionKeys;
022 import com.liferay.portal.service.ServiceContext;
023 import com.liferay.portal.service.base.PhoneServiceBaseImpl;
024 import com.liferay.portal.service.permission.CommonPermissionUtil;
025
026 import java.util.List;
027
028
031 public class PhoneServiceImpl extends PhoneServiceBaseImpl {
032
033
037 @Override
038 public Phone addPhone(
039 String className, long classPK, String number, String extension,
040 int typeId, boolean primary)
041 throws PortalException, SystemException {
042
043 CommonPermissionUtil.check(
044 getPermissionChecker(), className, classPK, ActionKeys.UPDATE);
045
046 return phoneLocalService.addPhone(
047 getUserId(), className, classPK, number, extension, typeId,
048 primary);
049 }
050
051 @Override
052 public Phone addPhone(
053 String className, long classPK, String number, String extension,
054 int typeId, boolean primary, ServiceContext serviceContext)
055 throws PortalException, SystemException {
056
057 CommonPermissionUtil.check(
058 getPermissionChecker(), className, classPK, ActionKeys.UPDATE);
059
060 return phoneLocalService.addPhone(
061 getUserId(), className, classPK, number, extension, typeId, primary,
062 serviceContext);
063 }
064
065 @Override
066 public void deletePhone(long phoneId)
067 throws PortalException, SystemException {
068
069 Phone phone = phonePersistence.findByPrimaryKey(phoneId);
070
071 CommonPermissionUtil.check(
072 getPermissionChecker(), phone.getClassNameId(), phone.getClassPK(),
073 ActionKeys.UPDATE);
074
075 phoneLocalService.deletePhone(phoneId);
076 }
077
078 @Override
079 public Phone getPhone(long phoneId)
080 throws PortalException, SystemException {
081
082 Phone phone = phonePersistence.findByPrimaryKey(phoneId);
083
084 CommonPermissionUtil.check(
085 getPermissionChecker(), phone.getClassNameId(), phone.getClassPK(),
086 ActionKeys.VIEW);
087
088 return phone;
089 }
090
091 @Override
092 public List<Phone> getPhones(String className, long classPK)
093 throws PortalException, SystemException {
094
095 CommonPermissionUtil.check(
096 getPermissionChecker(), className, classPK, ActionKeys.VIEW);
097
098 User user = getUser();
099
100 return phoneLocalService.getPhones(
101 user.getCompanyId(), className, classPK);
102 }
103
104 @Override
105 public Phone updatePhone(
106 long phoneId, String number, String extension, int typeId,
107 boolean primary)
108 throws PortalException, SystemException {
109
110 Phone phone = phonePersistence.findByPrimaryKey(phoneId);
111
112 CommonPermissionUtil.check(
113 getPermissionChecker(), phone.getClassNameId(), phone.getClassPK(),
114 ActionKeys.UPDATE);
115
116 return phoneLocalService.updatePhone(
117 phoneId, number, extension, typeId, primary);
118 }
119
120 }