1 /** 2 * Copyright 2011 The Kuali Foundation Licensed under the 3 * Educational Community License, Version 2.0 (the "License"); you may 4 * not use this file except in compliance with the License. You may 5 * obtain a copy of the License at 6 * 7 * http://www.osedu.org/licenses/ECL-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, 10 * software distributed under the License is distributed on an "AS IS" 11 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 * or implied. See the License for the specific language governing 13 * permissions and limitations under the License. 14 */ 15 16 package org.kuali.mobility.push.service; 17 18 import org.kuali.mobility.push.entity.Device; 19 import org.kuali.mobility.push.entity.Push; 20 import org.kuali.mobility.push.entity.PushDeviceTuple; 21 22 import java.util.List; 23 24 /** 25 * Interface for sending and persisting <code>Push</code> messages to 26 * <code>Device</code>. 27 * 28 * Implementations of this service will typically persist <code>Push</code> 29 * messages from a database, retrieve devices from a service, and send the 30 * message to the devices using an implementatin of the <code>SendService</code> 31 * interface. 32 * 33 * @author Kuali Mobility Team (mobility.dev@kuali.org) 34 * @since 2.0.0 35 */ 36 public interface PushService { 37 38 /** 39 * Persists a <code>Push</code> message. 40 * 41 * @param push 42 * Push message to persist. 43 */ 44 void savePush(Push push); 45 46 /** 47 * Removes a <code>Push</code> message. 48 * 49 * @param push 50 * Push message to persist. 51 */ 52 boolean removePush(Push push); 53 54 /** 55 * Persists a push messages that should be sent to many devices 56 * 57 * @param push 58 * Push message to be sent. 59 * @param Devices 60 * Devices the Push message should be sent to. 61 */ 62 void savePush(Push push, List<Device> Devices); 63 64 /** 65 * Returns the number of <code>Push</code> messages persisted. 66 * 67 * @return number of <code>Push</code> messages persisted. 68 */ 69 int countPushes(); 70 71 /** 72 * Finds a <code>Push</code> by its ID. 73 * 74 * @param id 75 * ID of the <code>Push</code> to find. 76 * @return The <code>Push</code> that has the specified ID. 77 */ 78 Push findPushById(Long id); 79 80 /** 81 * Returns a list of <b>ALL</b> the <code>Push</code> messages that are 82 * persisted.<br> 83 * <b>WARNING: This method can return A LOT of data</b> 84 * 85 * @return A lsit of all the persisted <code>Push</code> messages. 86 */ 87 List<Push> findAllPush(); 88 89 /** 90 * Returns a list of <b>ALL</b> the <code>Push</code> messages per page number that are 91 * persisted.<br> 92 * The number of records per page is fetched from property file.<br> 93 * <b>WARNING: This method can return A LOT of data</b> 94 * 95 * @return A lsit of all the persisted <code>Push</code> messages. 96 */ 97 List<Push> findAllPushByPageNumber(Integer pageNum); 98 99 /** 100 * Finds a list of <code>Devices</code> that was linked to a 101 * <code>Push</code>. 102 * 103 * @param push 104 * <code>Push</code> to find devices of</code>. 105 * @return List of <code>Devices</code> that was linked. 106 */ 107 List<Device> findDevicesForPush(Push push); 108 109 /** 110 * Finds a list of unsent <code>PushDeviceTuple</code>. 111 * 112 * @return List of unsent <code>PushDeviceTuple</code>. 113 */ 114 List<PushDeviceTuple> findUnsentPushTuples(); 115 116 /** 117 * Sends a <code>Push</code> message to the specified <code>Device</code> 118 * without persisting the message. 119 * 120 * @param push 121 * Push message to send. 122 * @param device 123 * Device to send the message to. 124 */ 125 int sendPush(Push push, Device device); 126 127 /** 128 * Sends a <code>Push</code< message to the specified list of devices 129 * without persisting the message. 130 * 131 * @param push 132 * Push message to send. 133 * @param devices 134 * Devices to send the message to. 135 */ 136 int sendPush(Push push, List<Device> devices); 137 138 /** 139 * Sends a 140 * <code>Push</code< message to the specified list of username. All devices for those users will be searched 141 * for, and messages will be sent to each device without persisting the message. 142 * 143 * @param push 144 * Push message to send. 145 * @param usernames 146 * List of usernames to send push notifications too. 147 */ 148 int sendPushToUsers(Push push, List<String> usernames); 149 150 /** 151 * Attempts to send <code>PushDeviceTuple</code> 152 * 153 * @param tuples 154 * List of <code>PushDeviceTuple</code> to send. 155 * @return 156 */ 157 int sendPush(List<PushDeviceTuple> tuples); 158 159 /** 160 * Find User details by push ID. 161 * 162 * @param pushId 163 * ID of the <code>Push</code>. 164 * @return the user details having specified ID. 165 */ 166 String getUserDetails(String pushId); 167 168 }