001    /**
002     * Copyright (c) 2000-present 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.kernel.social;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
019    import com.liferay.portal.model.ClassedModel;
020    import com.liferay.portal.model.GroupedModel;
021    
022    import java.util.Date;
023    
024    /**
025     * @author Adolfo P??rez
026     */
027    public class SocialActivityManagerUtil {
028    
029            public static <T extends ClassedModel & GroupedModel> void addActivity(
030                            long userId, T classedModel, int type, String extraData,
031                            long receiverUserId)
032                    throws PortalException {
033    
034                    getSocialActivityManager().addActivity(
035                            userId, classedModel, type, extraData, receiverUserId);
036            }
037    
038            public static <T extends ClassedModel & GroupedModel>
039                            void addUniqueActivity(
040                                    long userId, Date createDate, T classedModel, int type,
041                                    String extraData, long receiverUserId)
042                    throws PortalException {
043    
044                    getSocialActivityManager().addUniqueActivity(
045                            userId, createDate, classedModel, type, extraData, receiverUserId);
046            }
047    
048            public static <T extends ClassedModel & GroupedModel>
049                            void addUniqueActivity(
050                                    long userId, T classedModel, int type, String extraData,
051                                    long receiverUserId)
052                    throws PortalException {
053    
054                    getSocialActivityManager().addUniqueActivity(
055                            userId, classedModel, type, extraData, receiverUserId);
056            }
057    
058            public static <T extends ClassedModel & GroupedModel> void deleteActivities(
059                            T classedModel)
060                    throws PortalException {
061    
062                    getSocialActivityManager().deleteActivities(classedModel);
063            }
064    
065            public static <T extends ClassedModel & GroupedModel>
066                    SocialActivityManager<T> getSocialActivityManager() {
067    
068                    PortalRuntimePermission.checkGetBeanProperty(
069                            SocialActivityManagerUtil.class);
070    
071                    return (SocialActivityManager<T>)_socialActivityManager;
072            }
073    
074            public static <T extends ClassedModel & GroupedModel>
075                            void updateLastSocialActivity(
076                                    long userId, T classedModel, int type, Date createDate)
077                    throws PortalException {
078    
079                    getSocialActivityManager().updateLastSocialActivity(
080                            userId, classedModel, type, createDate);
081            }
082    
083            public <T extends ClassedModel & GroupedModel>
084                    void setSocialActivityManager(
085                            SocialActivityManager<T> socialActivityManager) {
086    
087                    PortalRuntimePermission.checkSetBeanProperty(getClass());
088    
089                    _socialActivityManager = socialActivityManager;
090            }
091    
092            private static SocialActivityManager<?> _socialActivityManager;
093    
094    }