View Javadoc

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 java.util.List;
19  import java.util.Map;
20  
21  import org.kuali.mobility.push.entity.Device;
22  
23  /**
24   * Interface for managing <code>Device</code> instances.
25   * 
26   * @author Kuali Mobility Team (mobility.dev@kuali.org)
27   * @since 2.0.0
28   */
29  public interface DeviceService {
30  
31  	/**
32  	 * Persists a <code>Device</code> instance
33  	 * @param device The device to persist
34  	 */
35  	void saveDevice(Device device);
36  
37  	/**
38  	 * Persists a <code>Device</code> instance
39  	 * @param device The device to persist
40  	 * @deprecated This method is misleading as it does not register a device
41  	 * but persists the state of a device. Rather use {@link #saveDevice(Device)}.
42  	 * This method will be removed in version 3.0
43  	 */
44  	@Deprecated
45  	void registerDevice(Device device);
46  
47  	/**
48  	 * Removes a <code>Device</code> instance from persistence.
49  	 * @param device The device to remove.
50  	 * @return
51  	 */
52  	boolean removeDevice(Device device); 
53  
54  
55  	/**
56  	 * Counts the number of all registered devices.
57  	 * This can included devices that does not have a Registration ID and Username.
58  	 * @return
59  	 */
60  	Long countDevices();
61  
62  
63  	/**
64  	 * Counts the number of devices by device type.
65  	 * This can included devices that does not have a Registration ID and Username.
66  	 * @return
67  	 */
68  	Long countDevices(String deviceType);
69  
70  
71  	/**
72  	 * Returns a count of all devices that does not have a username
73  	 * @return
74  	 */
75  	Long countDevicesWithoutUsername();
76  
77  
78  	/**
79  	 * Find all devices that are registered.
80  	 * This can included devices that does not have a Registration ID and Username
81  	 * @return
82  	 */
83  	List<Device> findAllDevices();
84  
85  
86  	/**
87  	 * Returns a list of device types that are set up.
88  	 * This list will be dictated by the SenderService implemenations that was
89  	 * set up with the <code>SendServiceDelegator</code>.
90  	 * Device types returns in this list are expected to have SendService implementations
91  	 * configured.
92  	 * This method will call the <code>SendServiceDelegator</code> to find supported device types.
93  	 * @return A list of supported device types.
94  	 */
95  	List<String> getSupportedDeviceTypes();
96  
97  
98  	/**
99  	 * Finds all devices of a specific type.
100 	 * This can included devices that does not have a Registration ID and Username
101 	 * @param deviceType 
102 	 * @return
103 	 */
104 	List<Device> findAllDevices(String deviceType);
105 
106 
107 	/**
108 	 * Gets a map of all registerd devices in a mapping between device type
109 	 * and a list of the devices for that type.
110 	 * 
111 	 * @return
112 	 */
113 	Map<String, List<Device>> findDevicesMap();
114 
115 
116 	/**
117 	 * Return tue if there is a username for the specifed deviceId
118 	 * @param deviceid
119 	 * @return
120 	 */
121 	boolean doesDeviceHaveUsername(String deviceid);
122 
123 
124 	/**
125 	 * Returns a list of devices registed by a username.
126 	 * @param username
127 	 * @return
128 	 */
129 	List<Device> findDevicesByUsername(String username);
130 
131 
132 	/**
133 	 * Finds all device that does not have a username
134 	 * @return
135 	 */
136 	List<Device> findDevicesWithoutUsername();
137 
138 
139 	/**
140 	 * Finds devices with the specified device id.
141 	 * In theory, this should only return on <code>Device</code>
142 	 * @param deviceid
143 	 * @return
144 	 */
145 	List<Device> findDevicesByDeviceId(String deviceid);
146 
147 	/**
148 	 * Finds devices with the specified reg id.
149 	 * In theory, this should only return on <code>Device</code>
150 	 * @param deviceid
151 	 * @return
152 	 */
153 	Device findDeviceByRegId(String regid);
154 	
155 
156 	/**
157 	 * Finds a device with the specified device ID
158 	 * @param deviceid
159 	 * @return
160 	 */
161 	Device findDeviceByDeviceId(String deviceid);
162 
163 
164 	/**
165 	 * Finds a <code>Device</code> by the Object ID for the <code>Device</code>
166 	 * @param id If of the <code>Device</code> to find. 
167 	 * @return
168 	 */
169 	Device findDeviceById(Long id);
170 
171 	/**
172 	 * Finds a List of <code>Device</code> based on the specified keyword.
173 	 * @param keyword
174 	 * @return Device List. 
175 	 */
176 	List<Device> findDevicesByKeyword(String keyword);
177 	
178 
179 	/**
180 	 * This returns a list of devices with Long id. Id should be unique, therefore should not return a list. 
181 	 * TODO is this used anywhere? what is it suppose to do?
182 	 * @param id
183 	 * @return
184 	 */
185 	@Deprecated
186 	List<Device> findDevicesById(String id);
187 
188 	
189 	/**
190 	 * CXF method for search for devices by keyword. 
191 	 * @param keyword
192 	 * @return
193 	 */
194 	String devicesByKeyword(String keyword); 
195 	
196 	/**
197 	 * CXF method for retrieving devices for a given username.
198 	 * @param username
199 	 * @return
200 	 */
201     String devicesFromUsername(String username);
202 	
203     /**
204      * CXF method for retrieving a username for a given device. 
205      * @param id
206      * @return
207      */
208     String usernameFromDeviceId(String id);
209 	
210 }