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