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