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(long contactId) throws SystemException {
029                    Contact contact = contactPersistence.fetchByPrimaryKey(contactId);
030    
031                    if (contact != null) {
032                            deleteContact(contact);
033                    }
034            }
035    
036            @Override
037            public void deleteContact(Contact contact) throws SystemException {
038    
039                    // Addresses
040    
041                    addressLocalService.deleteAddresses(
042                            contact.getCompanyId(), Contact.class.getName(),
043                            contact.getContactId());
044    
045                    // Email addresses
046    
047                    emailAddressLocalService.deleteEmailAddresses(
048                            contact.getCompanyId(), Contact.class.getName(),
049                            contact.getContactId());
050    
051                    // Phone
052    
053                    phoneLocalService.deletePhones(
054                            contact.getCompanyId(), Contact.class.getName(),
055                            contact.getContactId());
056    
057                    // Website
058    
059                    websiteLocalService.deleteWebsites(
060                            contact.getCompanyId(), Contact.class.getName(),
061                            contact.getContactId());
062    
063                    // Contact
064    
065                    contactPersistence.remove(contact);
066            }
067    
068            @Override
069            public Contact getContact(long contactId)
070                    throws PortalException, SystemException {
071    
072                    return contactPersistence.findByPrimaryKey(contactId);
073            }
074    
075    }