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            public Contact getContact(long contactId)
034                    throws PortalException, SystemException {
035    
036                    Contact contact = contactPersistence.findByPrimaryKey(contactId);
037    
038                    CommonPermissionUtil.check(
039                            getPermissionChecker(), contact.getClassNameId(),
040                            contact.getClassPK(), ActionKeys.VIEW);
041    
042                    return contact;
043            }
044    
045            public List<Contact> getContacts(
046                            long classNameId, long classPK, int start, int end,
047                            OrderByComparator orderByComparator)
048                    throws PortalException, SystemException {
049    
050                    CommonPermissionUtil.check(
051                            getPermissionChecker(), classNameId, classPK, ActionKeys.VIEW);
052    
053                    return contactPersistence.findByC_C(
054                            classNameId, classPK, start, end, orderByComparator);
055            }
056    
057            public int getContactsCount(long classNameId, long classPK)
058                    throws PortalException, SystemException {
059    
060                    CommonPermissionUtil.check(
061                            getPermissionChecker(), classNameId, classPK, ActionKeys.VIEW);
062    
063                    return contactPersistence.countByC_C(classNameId, classPK);
064            }
065    
066    }