01: /**
02: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
03: *
04: * Permission is hereby granted, free of charge, to any person obtaining a copy
05: * of this software and associated documentation files (the "Software"), to deal
06: * in the Software without restriction, including without limitation the rights
07: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
08: * copies of the Software, and to permit persons to whom the Software is
09: * furnished to do so, subject to the following conditions:
10: *
11: * The above copyright notice and this permission notice shall be included in
12: * all copies or substantial portions of the Software.
13: *
14: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20: * SOFTWARE.
21: */package com.liferay.portal.service.impl;
22:
23: import com.liferay.portal.PortalException;
24: import com.liferay.portal.SystemException;
25: import com.liferay.portal.kernel.security.permission.ActionKeys;
26: import com.liferay.portal.model.Phone;
27: import com.liferay.portal.service.base.PhoneServiceBaseImpl;
28: import com.liferay.portal.service.permission.CommonPermissionUtil;
29:
30: import java.util.List;
31:
32: /**
33: * <a href="PhoneServiceImpl.java.html"><b><i>View Source</i></b></a>
34: *
35: * @author Brian Wing Shun Chan
36: *
37: */
38: public class PhoneServiceImpl extends PhoneServiceBaseImpl {
39:
40: public Phone addPhone(String className, long classPK,
41: String number, String extension, int typeId, boolean primary)
42: throws PortalException, SystemException {
43:
44: CommonPermissionUtil.check(getPermissionChecker(), className,
45: classPK, ActionKeys.UPDATE);
46:
47: return phoneLocalService.addPhone(getUserId(), className,
48: classPK, number, extension, typeId, primary);
49: }
50:
51: public void deletePhone(long phoneId) throws PortalException,
52: SystemException {
53:
54: Phone phone = phonePersistence.findByPrimaryKey(phoneId);
55:
56: CommonPermissionUtil.check(getPermissionChecker(), phone
57: .getClassNameId(), phone.getClassPK(),
58: ActionKeys.UPDATE);
59:
60: phoneLocalService.deletePhone(phoneId);
61: }
62:
63: public Phone getPhone(long phoneId) throws PortalException,
64: SystemException {
65:
66: Phone phone = phonePersistence.findByPrimaryKey(phoneId);
67:
68: CommonPermissionUtil.check(getPermissionChecker(), phone
69: .getClassNameId(), phone.getClassPK(), ActionKeys.VIEW);
70:
71: return phone;
72: }
73:
74: public List getPhones(String className, long classPK)
75: throws PortalException, SystemException {
76:
77: CommonPermissionUtil.check(getPermissionChecker(), className,
78: classPK, ActionKeys.VIEW);
79:
80: return phoneLocalService.getPhones(getUser().getCompanyId(),
81: className, classPK);
82: }
83:
84: public Phone updatePhone(long phoneId, String number,
85: String extension, int typeId, boolean primary)
86: throws PortalException, SystemException {
87:
88: Phone phone = phonePersistence.findByPrimaryKey(phoneId);
89:
90: CommonPermissionUtil.check(getPermissionChecker(), phone
91: .getClassNameId(), phone.getClassPK(),
92: ActionKeys.UPDATE);
93:
94: return phoneLocalService.updatePhone(phoneId, number,
95: extension, typeId, primary);
96: }
97:
98: }
|