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.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
020    import com.liferay.portal.model.UserNotificationEvent;
021    import com.liferay.portal.service.ServiceContext;
022    
023    import java.util.Map;
024    
025    /**
026     * @author Jonathan Lee
027     */
028    public class UserNotificationManagerUtil {
029    
030            public static void addUserNotificationDefinition(
031                    String portletId,
032                    UserNotificationDefinition userNotificationDefinition) {
033    
034                    getUserNotificationManager().addUserNotificationDefinition(
035                            portletId, userNotificationDefinition);
036            }
037    
038            public static void addUserNotificationHandler(
039                    UserNotificationHandler userNotificationHandler) {
040    
041                    getUserNotificationManager().addUserNotificationHandler(
042                            userNotificationHandler);
043            }
044    
045            public static void deleteUserNotificationDefinitions(String portletId) {
046                    getUserNotificationManager().deleteUserNotificationDefinitions(
047                            portletId);
048            }
049    
050            public static void deleteUserNotificationHandler(
051                    UserNotificationHandler userNotificationHandler) {
052    
053                    getUserNotificationManager().deleteUserNotificationHandler(
054                            userNotificationHandler);
055            }
056    
057            public static UserNotificationDefinition fetchUserNotificationDefinition(
058                    String portletId, long classNameId, int notificationType) {
059    
060                    return getUserNotificationManager().fetchUserNotificationDefinition(
061                            portletId, classNameId, notificationType);
062            }
063    
064            public static Map<String, Map<String, UserNotificationHandler>>
065                    getUserNotificationHandlers() {
066    
067                    return getUserNotificationManager().getUserNotificationHandlers();
068            }
069    
070            public static UserNotificationManager getUserNotificationManager() {
071                    PortalRuntimePermission.checkGetBeanProperty(
072                            UserNotificationManagerUtil.class);
073    
074                    return _userNotificationManager;
075            }
076    
077            public static UserNotificationFeedEntry interpret(
078                            String selector, UserNotificationEvent userNotificationEvent,
079                            ServiceContext serviceContext)
080                    throws PortalException {
081    
082                    return getUserNotificationManager().interpret(
083                            selector, userNotificationEvent, serviceContext);
084            }
085    
086            public static boolean isDeliver(
087                            long userId, String portletId, long classNameId,
088                            int notificationType, int deliveryType)
089                    throws PortalException, SystemException {
090    
091                    return getUserNotificationManager().isDeliver(
092                            userId, portletId, classNameId, notificationType, deliveryType);
093            }
094    
095            public static boolean isDeliver(
096                            long userId, String selector, String portletId, long classNameId,
097                            int notificationType, int deliveryType,
098                            ServiceContext serviceContext)
099                    throws PortalException, SystemException {
100    
101                    return getUserNotificationManager().isDeliver(
102                            userId, selector, portletId, classNameId, notificationType,
103                            deliveryType, serviceContext);
104            }
105    
106            public void setUserNotificationManager(
107                    UserNotificationManager userNotificationManager) {
108    
109                    PortalRuntimePermission.checkSetBeanProperty(getClass());
110    
111                    _userNotificationManager = userNotificationManager;
112            }
113    
114            private static UserNotificationManager _userNotificationManager;
115    
116    }