1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.service.impl;
21  
22  import com.liferay.portal.PortalException;
23  import com.liferay.portal.SystemException;
24  import com.liferay.portal.model.Phone;
25  import com.liferay.portal.security.permission.ActionKeys;
26  import com.liferay.portal.service.base.PhoneServiceBaseImpl;
27  import com.liferay.portal.service.permission.CommonPermissionUtil;
28  
29  import java.util.List;
30  
31  /**
32   * <a href="PhoneServiceImpl.java.html"><b><i>View Source</i></b></a>
33   *
34   * @author Brian Wing Shun Chan
35   *
36   */
37  public class PhoneServiceImpl extends PhoneServiceBaseImpl {
38  
39      public Phone addPhone(
40              String className, long classPK, String number, String extension,
41              int typeId, boolean primary)
42          throws PortalException, SystemException {
43  
44          CommonPermissionUtil.check(
45              getPermissionChecker(), className, classPK, ActionKeys.UPDATE);
46  
47          return phoneLocalService.addPhone(
48              getUserId(), className, classPK, number, extension, typeId,
49              primary);
50      }
51  
52      public void deletePhone(long phoneId)
53          throws PortalException, SystemException {
54  
55          Phone phone = phonePersistence.findByPrimaryKey(phoneId);
56  
57          CommonPermissionUtil.check(
58              getPermissionChecker(), phone.getClassNameId(), phone.getClassPK(),
59              ActionKeys.UPDATE);
60  
61          phoneLocalService.deletePhone(phoneId);
62      }
63  
64      public Phone getPhone(long phoneId)
65          throws PortalException, SystemException {
66  
67          Phone phone = phonePersistence.findByPrimaryKey(phoneId);
68  
69          CommonPermissionUtil.check(
70              getPermissionChecker(), phone.getClassNameId(), phone.getClassPK(),
71              ActionKeys.VIEW);
72  
73          return phone;
74      }
75  
76      public List<Phone> getPhones(String className, long classPK)
77          throws PortalException, SystemException {
78  
79          CommonPermissionUtil.check(
80              getPermissionChecker(), className, classPK, ActionKeys.VIEW);
81  
82          return phoneLocalService.getPhones(
83              getUser().getCompanyId(), className, classPK);
84      }
85  
86      public Phone updatePhone(
87              long phoneId, String number, String extension, int typeId,
88              boolean primary)
89          throws PortalException, SystemException {
90  
91          Phone phone = phonePersistence.findByPrimaryKey(phoneId);
92  
93          CommonPermissionUtil.check(
94              getPermissionChecker(), phone.getClassNameId(), phone.getClassPK(),
95              ActionKeys.UPDATE);
96  
97          return phoneLocalService.updatePhone(
98              phoneId, number, extension, typeId, primary);
99      }
100 
101 }