1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
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  /**
27   * <a href="PhoneServiceImpl.java.html"><b><i>View Source</i></b></a>
28   *
29   * @author Brian Wing Shun Chan
30   */
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  }