001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.service.impl;
016    
017    import com.liferay.portal.kernel.exception.SystemException;
018    import com.liferay.portal.model.Contact;
019    import com.liferay.portal.service.base.ContactLocalServiceBaseImpl;
020    
021    /**
022     * @author Brian Wing Shun Chan
023     */
024    public class ContactLocalServiceImpl extends ContactLocalServiceBaseImpl {
025    
026            @Override
027            public Contact deleteContact(Contact contact) throws SystemException {
028    
029                    // Addresses
030    
031                    addressLocalService.deleteAddresses(
032                            contact.getCompanyId(), Contact.class.getName(),
033                            contact.getContactId());
034    
035                    // Email addresses
036    
037                    emailAddressLocalService.deleteEmailAddresses(
038                            contact.getCompanyId(), Contact.class.getName(),
039                            contact.getContactId());
040    
041                    // Phone
042    
043                    phoneLocalService.deletePhones(
044                            contact.getCompanyId(), Contact.class.getName(),
045                            contact.getContactId());
046    
047                    // Website
048    
049                    websiteLocalService.deleteWebsites(
050                            contact.getCompanyId(), Contact.class.getName(),
051                            contact.getContactId());
052    
053                    // Contact
054    
055                    return contactPersistence.remove(contact);
056            }
057    
058            @Override
059            public Contact deleteContact(long contactId) throws SystemException {
060                    Contact contact = contactPersistence.fetchByPrimaryKey(contactId);
061    
062                    if (contact != null) {
063                            deleteContact(contact);
064                    }
065    
066                    return contact;
067            }
068    
069    }