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.base.PhoneServiceBaseImpl;
023 import com.liferay.portal.service.permission.CommonPermissionUtil;
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 int typeId, boolean primary)
036 throws PortalException, SystemException {
037
038 CommonPermissionUtil.check(
039 getPermissionChecker(), className, classPK, ActionKeys.UPDATE);
040
041 return phoneLocalService.addPhone(
042 getUserId(), className, classPK, number, extension, typeId,
043 primary);
044 }
045
046 @Override
047 public void deletePhone(long phoneId)
048 throws PortalException, SystemException {
049
050 Phone phone = phonePersistence.findByPrimaryKey(phoneId);
051
052 CommonPermissionUtil.check(
053 getPermissionChecker(), phone.getClassNameId(), phone.getClassPK(),
054 ActionKeys.UPDATE);
055
056 phoneLocalService.deletePhone(phoneId);
057 }
058
059 @Override
060 public Phone getPhone(long phoneId)
061 throws PortalException, SystemException {
062
063 Phone phone = phonePersistence.findByPrimaryKey(phoneId);
064
065 CommonPermissionUtil.check(
066 getPermissionChecker(), phone.getClassNameId(), phone.getClassPK(),
067 ActionKeys.VIEW);
068
069 return phone;
070 }
071
072 @Override
073 public List<Phone> getPhones(String className, long classPK)
074 throws PortalException, SystemException {
075
076 CommonPermissionUtil.check(
077 getPermissionChecker(), className, classPK, ActionKeys.VIEW);
078
079 User user = getUser();
080
081 return phoneLocalService.getPhones(
082 user.getCompanyId(), className, classPK);
083 }
084
085 @Override
086 public Phone updatePhone(
087 long phoneId, String number, String extension, int typeId,
088 boolean primary)
089 throws PortalException, SystemException {
090
091 Phone phone = phonePersistence.findByPrimaryKey(phoneId);
092
093 CommonPermissionUtil.check(
094 getPermissionChecker(), phone.getClassNameId(), phone.getClassPK(),
095 ActionKeys.UPDATE);
096
097 return phoneLocalService.updatePhone(
098 phoneId, number, extension, typeId, primary);
099 }
100
101 }