Updated bmclickatell pom file
[bm-groupware-server.git] / bm-webconfig / webconfig-webapp / src / main / java / net / bionicmessage / funambol / configuration / NotificationUtils.java
blob40a3e19c819ec16204d52017e618b7f5d9d685fd
1 /*
2 * WebConfig - a web administration interface for the Funambol DS Server.
3 * Copyright (C) 2008 Mathew McBride
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.bionicmessage.funambol.configuration;
20 import com.funambol.framework.core.*;
21 import com.funambol.framework.notification.NotificationException;
22 import com.funambol.server.config.Configuration;
23 import com.funambol.server.notification.NotificationEngineImpl;
24 import java.util.ArrayList;
26 /**
27 * Methods for sending Funambol push notifications
28 * @author matt
30 public class NotificationUtils {
32 /**
33 * Copied from InboxListenerManager.java in Funambol
34 * Send notification to the device corresponding to the given
35 * principal for the kinds of item in sourcesToNotify
37 * @param username user to notify
38 * @param syncSourceEmail string
39 * @param contentTypeEmail string
41 public static void notifyUser(String username,
42 String deviceId,
43 String syncSource,
44 String contentType) throws NotificationException {
46 ArrayList<Alert> alerts = new ArrayList<Alert>();
48 Target target = new Target(syncSource);
49 Meta meta = new Meta();
50 meta.setType(contentType);
51 Item item = new Item(null, target, meta, null, false);
53 Alert alert = new Alert(new CmdID(0), false, null, 206, new Item[]{item});
55 alerts.add(alert);
57 Alert[] alertArray = (Alert[]) alerts.toArray(new Alert[alerts.size()]);
59 Configuration conf = Configuration.getConfiguration();
60 NotificationEngineImpl nei =
61 new NotificationEngineImpl(conf);
62 nei.sendNotificationMessage(username, deviceId, alertArray, 1);