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.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.util.OrderByComparator;
020    import com.liferay.portal.model.Contact;
021    import com.liferay.portal.security.permission.ActionKeys;
022    import com.liferay.portal.service.base.ContactServiceBaseImpl;
023    import com.liferay.portal.service.permission.CommonPermissionUtil;
024    
025    import java.util.List;
026    
027    /**
028     * @author Brian Wing Shun Chan
029     * @author Vilmos Papp
030     */
031    public class ContactServiceImpl extends ContactServiceBaseImpl {
032    
033            @Override
034            public Contact getContact(long contactId)
035                    throws PortalException, SystemException {
036    
037                    Contact contact = contactPersistence.findByPrimaryKey(contactId);
038    
039                    CommonPermissionUtil.check(
040                            getPermissionChecker(), contact.getClassNameId(),
041                            contact.getClassPK(), ActionKeys.VIEW);
042    
043                    return contact;
044            }
045    
046            @Override
047            public List<Contact> getContacts(
048                            long classNameId, long classPK, int start, int end,
049                            OrderByComparator orderByComparator)
050                    throws PortalException, SystemException {
051    
052                    CommonPermissionUtil.check(
053                            getPermissionChecker(), classNameId, classPK, ActionKeys.VIEW);
054    
055                    return contactPersistence.findByC_C(
056                            classNameId, classPK, start, end, orderByComparator);
057            }
058    
059            @Override
060            public int getContactsCount(long classNameId, long classPK)
061                    throws PortalException, SystemException {
062    
063                    CommonPermissionUtil.check(
064                            getPermissionChecker(), classNameId, classPK, ActionKeys.VIEW);
065    
066                    return contactPersistence.countByC_C(classNameId, classPK);
067            }
068    
069    }