| ContactLocalServiceImpl.java |
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.Contact;
25 import com.liferay.portal.service.base.ContactLocalServiceBaseImpl;
26
27 /**
28 * <a href="ContactLocalServiceImpl.java.html"><b><i>View Source</i></b></a>
29 *
30 * @author Brian Wing Shun Chan
31 *
32 */
33 public class ContactLocalServiceImpl extends ContactLocalServiceBaseImpl {
34
35 public Contact getContact(long contactId)
36 throws PortalException, SystemException {
37
38 return contactPersistence.findByPrimaryKey(contactId);
39 }
40
41 public void deleteContact(long contactId) throws SystemException {
42 Contact contact = contactPersistence.fetchByPrimaryKey(contactId);
43
44 if (contact != null) {
45 deleteContact(contact);
46 }
47 }
48
49 public void deleteContact(Contact contact) throws SystemException {
50
51 // Addresses
52
53 addressLocalService.deleteAddresses(
54 contact.getCompanyId(), Contact.class.getName(),
55 contact.getContactId());
56
57 // Email addresses
58
59 emailAddressLocalService.deleteEmailAddresses(
60 contact.getCompanyId(), Contact.class.getName(),
61 contact.getContactId());
62
63 // Phone
64
65 phoneLocalService.deletePhones(
66 contact.getCompanyId(), Contact.class.getName(),
67 contact.getContactId());
68
69 // Website
70
71 websiteLocalService.deleteWebsites(
72 contact.getCompanyId(), Contact.class.getName(),
73 contact.getContactId());
74
75 // Contact
76
77 contactPersistence.remove(contact);
78 }
79
80 }