001    /**
002     * Copyright (c) 2000-2012 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.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.model.Contact;
020    import com.liferay.portal.service.base.ContactLocalServiceBaseImpl;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public class ContactLocalServiceImpl extends ContactLocalServiceBaseImpl {
026    
027            @Override
028            public void deleteContact(Contact contact) throws SystemException {
029    
030                    // Addresses
031    
032                    addressLocalService.deleteAddresses(
033                            contact.getCompanyId(), Contact.class.getName(),
034                            contact.getContactId());
035    
036                    // Email addresses
037    
038                    emailAddressLocalService.deleteEmailAddresses(
039                            contact.getCompanyId(), Contact.class.getName(),
040                            contact.getContactId());
041    
042                    // Phone
043    
044                    phoneLocalService.deletePhones(
045                            contact.getCompanyId(), Contact.class.getName(),
046                            contact.getContactId());
047    
048                    // Website
049    
050                    websiteLocalService.deleteWebsites(
051                            contact.getCompanyId(), Contact.class.getName(),
052                            contact.getContactId());
053    
054                    // Contact
055    
056                    contactPersistence.remove(contact);
057            }
058    
059            @Override
060            public void deleteContact(long contactId) throws SystemException {
061                    Contact contact = contactPersistence.fetchByPrimaryKey(contactId);
062    
063                    if (contact != null) {
064                            deleteContact(contact);
065                    }
066            }
067    
068            @Override
069            public Contact getContact(long contactId)
070                    throws PortalException, SystemException {
071    
072                    return contactPersistence.findByPrimaryKey(contactId);
073            }
074    
075    }