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.comment;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
019    import com.liferay.portal.kernel.util.Function;
020    import com.liferay.portal.security.permission.PermissionChecker;
021    import com.liferay.portal.service.ServiceContext;
022    
023    /**
024     * @author Adolfo P??rez
025     */
026    public class CommentManagerUtil {
027    
028            public static void addComment(
029                            long userId, long groupId, String className, long classPK,
030                            String body,
031                            Function<String, ServiceContext> serviceContextFunction)
032                    throws PortalException {
033    
034                    getCommentManager().addComment(
035                            userId, groupId, className, classPK, body, serviceContextFunction);
036            }
037    
038            public static long addComment(
039                            long userId, long groupId, String className, long classPK,
040                            String userName, String subject, String body,
041                            Function<String, ServiceContext> serviceContextFunction)
042                    throws PortalException {
043    
044                    return getCommentManager().addComment(
045                            userId, groupId, className, classPK, userName, subject, body,
046                            serviceContextFunction);
047            }
048    
049            public static long addComment(
050                            long userId, String className, long classPK, String userName,
051                            long parentCommentId, String subject, String body,
052                            Function<String, ServiceContext> serviceContextFunction)
053                    throws PortalException {
054    
055                    return getCommentManager().addComment(
056                            userId, className, classPK, userName, parentCommentId, subject,
057                            body, serviceContextFunction);
058            }
059    
060            public static void addDiscussion(
061                            long userId, long groupId, String className, long classPK,
062                            String userName)
063                    throws PortalException {
064    
065                    getCommentManager().addDiscussion(
066                            userId, groupId, className, classPK, userName);
067            }
068    
069            public static void deleteComment(long commentId) throws PortalException {
070                    getCommentManager().deleteComment(commentId);
071            }
072    
073            public static void deleteDiscussion(String className, long classPK)
074                    throws PortalException {
075    
076                    getCommentManager().deleteDiscussion(className, classPK);
077            }
078    
079            public static CommentManager getCommentManager() {
080                    PortalRuntimePermission.checkGetBeanProperty(CommentManagerUtil.class);
081    
082                    return _commentManager;
083            }
084    
085            public static int getCommentsCount(String className, long classPK) {
086                    return getCommentManager().getCommentsCount(className, classPK);
087            }
088    
089            public static Discussion getDiscussion(
090                            long userId, long groupId, String className, long classPK,
091                            Function<String, ServiceContext> serviceContextFunction)
092                    throws PortalException {
093    
094                    return getCommentManager().getDiscussion(
095                            userId, groupId, className, classPK, serviceContextFunction);
096            }
097    
098            public static DiscussionPermission getDiscussionPermission(
099                    PermissionChecker permissionChecker) {
100    
101                    return getCommentManager().getDiscussionPermission(permissionChecker);
102            }
103    
104            public static boolean hasDiscussion(String className, long classPK)
105                    throws PortalException {
106    
107                    return getCommentManager().hasDiscussion(className, classPK);
108            }
109    
110            public static void subscribeDiscussion(
111                            long userId, long groupId, String className, long classPK)
112                    throws PortalException {
113    
114                    getCommentManager().subscribeDiscussion(
115                            userId, groupId, className, classPK);
116            }
117    
118            public static void unsubscribeDiscussion(
119                            long userId, String className, long classPK)
120                    throws PortalException {
121    
122                    getCommentManager().unsubscribeDiscussion(userId, className, classPK);
123            }
124    
125            public static long updateComment(
126                            long userId, String className, long classPK, long commentId,
127                            String subject, String body,
128                            Function<String, ServiceContext> serviceContextFunction)
129                    throws PortalException {
130    
131                    return getCommentManager().updateComment(
132                            userId, className, classPK, commentId, subject, body,
133                            serviceContextFunction);
134            }
135    
136            public void setCommentManager(CommentManager commentManager) {
137                    PortalRuntimePermission.checkSetBeanProperty(getClass());
138    
139                    _commentManager = commentManager;
140            }
141    
142            private static CommentManager _commentManager;
143    
144    }