001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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    }