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.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 ChannelHub fetchChannelHub(long companyId)
104                    throws ChannelException {
105    
106                    return getChannelHubManager().fetchChannelHub(companyId);
107            }
108    
109            public static ChannelHub fetchChannelHub(
110                            long companyId, boolean createIfAbsent)
111                    throws ChannelException {
112    
113                    return getChannelHubManager().fetchChannelHub(
114                            companyId, createIfAbsent);
115            }
116    
117            public static List<NotificationEvent> fetchNotificationEvents(
118                            long companyId, long userId, boolean flush)
119                    throws ChannelException {
120    
121                    return getChannelHubManager().fetchNotificationEvents(
122                            companyId, userId, flush);
123            }
124    
125            public static void flush() throws ChannelException {
126                    getChannelHubManager().flush();
127            }
128    
129            public static void flush(long companyId) throws ChannelException {
130                    getChannelHubManager().flush(companyId);
131            }
132    
133            public static void flush(long companyId, long userId, long timestamp)
134                    throws ChannelException {
135    
136                    getChannelHubManager().flush(companyId, userId, timestamp);
137            }
138    
139            public static Channel getChannel(long companyId, long userId)
140                    throws ChannelException {
141    
142                    return getChannelHubManager().getChannel(companyId, userId);
143            }
144    
145            public static Channel getChannel(
146                            long companyId, long userId, boolean createIfAbsent)
147                    throws ChannelException {
148    
149                    return getChannelHubManager().getChannel(
150                            companyId, userId, createIfAbsent);
151            }
152    
153            public static ChannelHub getChannelHub(long companyId)
154                    throws ChannelException {
155    
156                    return getChannelHubManager().getChannelHub(companyId);
157            }
158    
159            public static ChannelHub getChannelHub(
160                            long companyId, boolean createIfAbsent)
161                    throws ChannelException {
162    
163                    return getChannelHubManager().getChannelHub(companyId, createIfAbsent);
164            }
165    
166            public static ChannelHubManager getChannelHubManager() {
167                    PortalRuntimePermission.checkGetBeanProperty(
168                            ChannelHubManagerUtil.class);
169    
170                    return _channelHubManager;
171            }
172    
173            public static List<NotificationEvent> getNotificationEvents(
174                            long companyId, long userId)
175                    throws ChannelException {
176    
177                    return getChannelHubManager().getNotificationEvents(companyId, userId);
178            }
179    
180            public static List<NotificationEvent> getNotificationEvents(
181                            long companyId, long userId, boolean flush)
182                    throws ChannelException {
183    
184                    return getChannelHubManager().getNotificationEvents(
185                            companyId, userId, flush);
186            }
187    
188            public static Collection<Long> getUserIds(long companyId)
189                    throws ChannelException {
190    
191                    return getChannelHubManager().getUserIds(companyId);
192            }
193    
194            public static void registerChannelListener(
195                            long companyId, long userId, ChannelListener channelListener)
196                    throws ChannelException {
197    
198                    getChannelHubManager().registerChannelListener(
199                            companyId, userId, channelListener);
200            }
201    
202            public static void removeTransientNotificationEvents(
203                            long companyId, long userId,
204                            Collection<NotificationEvent> notificationEvents)
205                    throws ChannelException {
206    
207                    getChannelHubManager().removeTransientNotificationEvents(
208                            companyId, userId, notificationEvents);
209            }
210    
211            public static void removeTransientNotificationEventsByUuid(
212                            long companyId, long userId,
213                            Collection<String> notificationEventUuids)
214                    throws ChannelException {
215    
216                    getChannelHubManager().removeTransientNotificationEventsByUuid(
217                            companyId, userId, notificationEventUuids);
218            }
219    
220            public static void sendNotificationEvent(
221                            long companyId, long userId, NotificationEvent notificationEvent)
222                    throws ChannelException {
223    
224                    getChannelHubManager().sendNotificationEvent(
225                            companyId, userId, notificationEvent);
226            }
227    
228            public static void sendNotificationEvents(
229                            long companyId, long userId,
230                            Collection<NotificationEvent> notificationEvents)
231                    throws ChannelException {
232    
233                    getChannelHubManager().sendNotificationEvents(
234                            companyId, userId, notificationEvents);
235            }
236    
237            public static void unregisterChannelListener(
238                            long companyId, long userId, ChannelListener channelListener)
239                    throws ChannelException {
240    
241                    getChannelHubManager().unregisterChannelListener(
242                            companyId, userId, channelListener);
243            }
244    
245            public void setChannelHubManager(ChannelHubManager channelHubManager) {
246                    PortalRuntimePermission.checkSetBeanProperty(getClass());
247    
248                    _channelHubManager = channelHubManager;
249            }
250    
251            private static ChannelHubManager _channelHubManager;
252    
253    }