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.notifications;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    
019    import java.util.Collection;
020    import java.util.List;
021    
022    /**
023     * @author Edward Han
024     */
025    public class ChannelHubManagerUtil {
026    
027            public static void confirmDelivery(
028                            long companyId, long userId,
029                            Collection<String> notificationEventUuids)
030                    throws ChannelException {
031    
032                    getChannelHubManager().confirmDelivery(
033                            companyId, userId, notificationEventUuids);
034            }
035    
036            public static void confirmDelivery(
037                            long companyId, long userId,
038                            Collection<String> notificationEventUuids, boolean archived)
039                    throws ChannelException {
040    
041                    getChannelHubManager().confirmDelivery(
042                            companyId, userId, notificationEventUuids, archived);
043            }
044    
045            public static void confirmDelivery(
046                            long companyId, long userId, String notificationEventUuid)
047                    throws ChannelException {
048    
049                    getChannelHubManager().confirmDelivery(
050                            companyId, userId, notificationEventUuid);
051            }
052    
053            public static void confirmDelivery(
054                            long companyId, long userId, String notificationEventUuid,
055                            boolean archived)
056                    throws ChannelException {
057    
058                    getChannelHubManager().confirmDelivery(
059                            companyId, userId, notificationEventUuid, archived);
060            }
061    
062            public static Channel createChannel(long companyId, long userId)
063                    throws ChannelException {
064    
065                    return getChannelHubManager().createChannel(companyId, userId);
066            }
067    
068            public static ChannelHub createChannelHub(long companyId)
069                    throws ChannelException {
070    
071                    return getChannelHubManager().createChannelHub(companyId);
072            }
073    
074            public static void deleteUserNotificiationEvent(
075                            long companyId, long userId, String notificationEventUuid)
076                    throws ChannelException {
077    
078                    getChannelHubManager().deleteUserNotificiationEvent(
079                            companyId, userId, notificationEventUuid);
080            }
081    
082            public static void deleteUserNotificiationEvents(
083                            long companyId, long userId,
084                            Collection<String> notificationEventUuids)
085                    throws ChannelException {
086    
087                    getChannelHubManager().deleteUserNotificiationEvents(
088                            companyId, userId, notificationEventUuids);
089            }
090    
091            public static void destroyChannel(long companyId, long userId)
092                    throws ChannelException {
093    
094                    getChannelHubManager().destroyChannel(companyId, userId);
095            }
096    
097            public static void destroyChannelHub(long companyId)
098                    throws ChannelException {
099    
100                    getChannelHubManager().destroyChannelHub(companyId);
101            }
102    
103            public static void destroyClusterChannel(long companyId, long userId)
104                    throws ChannelException {
105    
106                    getChannelHubManager().destroyClusterChannel(companyId, userId);
107            }
108    
109            public static ChannelHub fetchChannelHub(long companyId)
110                    throws ChannelException {
111    
112                    return getChannelHubManager().fetchChannelHub(companyId);
113            }
114    
115            public static ChannelHub fetchChannelHub(
116                            long companyId, boolean createIfAbsent)
117                    throws ChannelException {
118    
119                    return getChannelHubManager().fetchChannelHub(
120                            companyId, createIfAbsent);
121            }
122    
123            public static List<NotificationEvent> fetchNotificationEvents(
124                            long companyId, long userId, boolean flush)
125                    throws ChannelException {
126    
127                    return getChannelHubManager().fetchNotificationEvents(
128                            companyId, userId, flush);
129            }
130    
131            public static void flush() throws ChannelException {
132                    getChannelHubManager().flush();
133            }
134    
135            public static void flush(long companyId) throws ChannelException {
136                    getChannelHubManager().flush(companyId);
137            }
138    
139            public static void flush(long companyId, long userId, long timestamp)
140                    throws ChannelException {
141    
142                    getChannelHubManager().flush(companyId, userId, timestamp);
143            }
144    
145            public static Channel getChannel(long companyId, long userId)
146                    throws ChannelException {
147    
148                    return getChannelHubManager().getChannel(companyId, userId);
149            }
150    
151            public static Channel getChannel(
152                            long companyId, long userId, boolean createIfAbsent)
153                    throws ChannelException {
154    
155                    return getChannelHubManager().getChannel(
156                            companyId, userId, createIfAbsent);
157            }
158    
159            public static ChannelHub getChannelHub(long companyId)
160                    throws ChannelException {
161    
162                    return getChannelHubManager().getChannelHub(companyId);
163            }
164    
165            public static ChannelHub getChannelHub(
166                            long companyId, boolean createIfAbsent)
167                    throws ChannelException {
168    
169                    return getChannelHubManager().getChannelHub(companyId, createIfAbsent);
170            }
171    
172            public static ChannelHubManager getChannelHubManager() {
173                    PortalRuntimePermission.checkGetBeanProperty(
174                            ChannelHubManagerUtil.class);
175    
176                    return _channelHubManager;
177            }
178    
179            public static List<NotificationEvent> getNotificationEvents(
180                            long companyId, long userId)
181                    throws ChannelException {
182    
183                    return getChannelHubManager().getNotificationEvents(companyId, userId);
184            }
185    
186            public static List<NotificationEvent> getNotificationEvents(
187                            long companyId, long userId, boolean flush)
188                    throws ChannelException {
189    
190                    return getChannelHubManager().getNotificationEvents(
191                            companyId, userId, flush);
192            }
193    
194            public static Collection<Long> getUserIds(long companyId)
195                    throws ChannelException {
196    
197                    return getChannelHubManager().getUserIds(companyId);
198            }
199    
200            public static void registerChannelListener(
201                            long companyId, long userId, ChannelListener channelListener)
202                    throws ChannelException {
203    
204                    getChannelHubManager().registerChannelListener(
205                            companyId, userId, channelListener);
206            }
207    
208            public static void removeTransientNotificationEvents(
209                            long companyId, long userId,
210                            Collection<NotificationEvent> notificationEvents)
211                    throws ChannelException {
212    
213                    getChannelHubManager().removeTransientNotificationEvents(
214                            companyId, userId, notificationEvents);
215            }
216    
217            public static void removeTransientNotificationEventsByUuid(
218                            long companyId, long userId,
219                            Collection<String> notificationEventUuids)
220                    throws ChannelException {
221    
222                    getChannelHubManager().removeTransientNotificationEventsByUuid(
223                            companyId, userId, notificationEventUuids);
224            }
225    
226            public static void sendClusterNotificationEvent(
227                            long companyId, long userId, NotificationEvent notificationEvent)
228                    throws ChannelException {
229    
230                    getChannelHubManager().sendClusterNotificationEvent(
231                            companyId, userId, notificationEvent);
232            }
233    
234            public static void sendNotificationEvent(
235                            long companyId, long userId, NotificationEvent notificationEvent)
236                    throws ChannelException {
237    
238                    getChannelHubManager().sendNotificationEvent(
239                            companyId, userId, notificationEvent);
240            }
241    
242            public static void sendNotificationEvents(
243                            long companyId, long userId,
244                            Collection<NotificationEvent> notificationEvents)
245                    throws ChannelException {
246    
247                    getChannelHubManager().sendNotificationEvents(
248                            companyId, userId, notificationEvents);
249            }
250    
251            public static void storeNotificationEvent(
252                            long companyId, long userId, NotificationEvent notificationEvent)
253                    throws ChannelException {
254    
255                    getChannelHubManager().storeNotificationEvent(
256                            companyId, userId, notificationEvent);
257            }
258    
259            public static void unregisterChannelListener(
260                            long companyId, long userId, ChannelListener channelListener)
261                    throws ChannelException {
262    
263                    getChannelHubManager().unregisterChannelListener(
264                            companyId, userId, channelListener);
265            }
266    
267            public void setChannelHubManager(ChannelHubManager channelHubManager) {
268                    PortalRuntimePermission.checkSetBeanProperty(getClass());
269    
270                    _channelHubManager = channelHubManager;
271            }
272    
273            private static ChannelHubManager _channelHubManager;
274    
275    }