public String[] scanForDeletions(Device device, Date lastScanTimestamp) { String[] returnValue = null; List<String> ids = deleteHistory.get(device.getIdentifier()); if(ids != null) { returnValue = ids.toArray(new String[0]); deleteHistory.get(device.getIdentifier()).clear(); } return returnValue; } //-------------------------------------------------------------------------------------------------------
public String[] scanForUpdates(Device device, Date lastScanTimestamp) { String[] returnValue = null; List<String> ids = updateHistory.get(device.getIdentifier()); if(ids != null) { returnValue = ids.toArray(new String[0]); updateHistory.get(device.getIdentifier()).clear(); } return returnValue; }
public String[] scanForNew(Device device, Date lastScanTimestamp) { String[] returnValue = null; List<String> ids = addHistory.get(device.getIdentifier()); if(ids != null) { returnValue = ids.toArray(new String[0]); addHistory.get(device.getIdentifier()).clear(); if(returnValue.length > 0) { log.info("Pushing New Email--------------------------------------------------"); for(String newId:returnValue) { log.info("Email UID: "+newId); } log.info("-------------------------------------------------------------------"); } } return returnValue; }
public static Notification createDeviceManagementNotification(Device device, String action) { if(action == null || action.trim().length()==0) { new IllegalArgumentException("Action cannot be null"); } Notification notification = new Notification(NotificationType.DM); notification.setMetaData(Constants.device, device.getIdentifier()); notification.setMetaData(Constants.action,action); return notification; }
notification.setMetaData(Constants.device, device.getIdentifier()); notification.setMetaData(Constants.d2dMessage, d2dMessage);
public static Notification createPushNotification(Device device, String message, Map<String,String> extras) { if(extras == null || extras.isEmpty()) { new IllegalArgumentException("Extras cannot be null"); } Notification notification = new Notification(NotificationType.PUSH); notification.setMetaData(Constants.device, device.getIdentifier()); notification.setMetaData(Constants.message,message); notification.setMetaData(Constants.extras,extras); return notification; }
public static Notification createSyncNotification(Device device, String service) { Notification syncNotification = new Notification(NotificationType.SYNC); syncNotification.setMetaData(Constants.device, device.getIdentifier()); syncNotification.setMetaData(Constants.service, service); return syncNotification; }
public static Notification createPushRPCNotification(Device device, String service) { Notification notification = new Notification(NotificationType.RPC); notification.setMetaData(Constants.device, device.getIdentifier()); notification.setMetaData(Constants.service, service); return notification; }
private LastScanTimestamp findScanTimestamp(Device device) throws Exception { LastScanTimestamp scanTimestamp = null; scanTimestamp = this.read(this.channelRegistration.getUri(),device.getIdentifier()); if(scanTimestamp == null) { scanTimestamp = new LastScanTimestamp(); scanTimestamp.setTimestamp(new Date()); scanTimestamp.setChannel(this.channelRegistration.getUri()); scanTimestamp.setClientId(device.getIdentifier()); } return scanTimestamp; }
@Override public void onEvent(Event event) { Device device = (Device)event.getAttribute("new-device"); if(device != null) { log.debug("***************************************************************"); log.debug("Updating the device cache with a new device: "+this.channelRegistration.getUri()); log.debug("***************************************************************"); //add this device to the cache device = this.deviceController.read(device.getIdentifier()); this.allDevices.add(device); } else { //Check for a device-cache-invalidation event Boolean invalidateDeviceCache = (Boolean)event.getAttribute("invalidate-device-cache"); if(invalidateDeviceCache != null) { //A device cache invalidation event received log.debug("***************************************************************"); log.debug("Invalidating the device cache: "+this.channelRegistration.getUri()); log.debug("***************************************************************"); this.loadDevices(); } } }
private void addSession(Device device) { CometSession session = this.findCometSession(device.getIdentifier()); if(session != null) { //Checking to make sure multiple device sessions are not created //resulting in multiple Bus infrastructure for each device return; } Subscription subscription = new Subscription(); subscription.setClientId(device.getIdentifier()); subscription.setConfigValue("identity", device.getIdentity().getPrincipal()); CometSession deviceSession = CometSession.createInstance(subscription); deviceSession.start(); this.cometSessions.add(deviceSession); } //---------------------------------------------------------------------------------------------------------
if(!device.getIdentifier().equals(destination_deviceid))
this.lastScanTimestamps.put(device.getIdentifier(), lastScanTimestamp);
try pushDevice = pushNotificationManager.getDevice(device.getIdentifier()); pushNotificationManager.addDevice(device.getIdentifier(), device.getDeviceToken()); pushDevice = pushNotificationManager.getDevice(device.getIdentifier());
String deviceId = device.getIdentifier();
for(Device local:allDevices) String myDeviceId = local.getIdentifier();
pushApp.setAppId(appId); pushApp.setChannels(storedChannels); pushApp.addDevice(device.getIdentifier()); pushApp.addDevice(device.getIdentifier());
LastScanTimestamp lastScanTimestamp = ChannelDaemon.this.lastScanTimestamps.get(device.getIdentifier()); if(lastScanTimestamp == null) lastScanTimestamp.setTimestamp(timestamp); lastScanTimestamp.setChannel(this.channelRegistration.getUri()); lastScanTimestamp.setClientId(device.getIdentifier()); cour.setChannel(this.channelRegistration.getUri()); cour.setBeanId(beanId); cour.setDeviceId(device.getIdentifier()); cour.setUpdateType(ChannelUpdateType.ADD); cour.setPrincipal(identity.getPrincipal()); cour.setChannel(this.channelRegistration.getUri()); cour.setBeanId(beanId); cour.setDeviceId(device.getIdentifier()); cour.setUpdateType(ChannelUpdateType.REPLACE); cour.setPrincipal(identity.getPrincipal()); cour.setChannel(this.channelRegistration.getUri()); cour.setBeanId(beanId); cour.setDeviceId(device.getIdentifier()); cour.setUpdateType(ChannelUpdateType.DELETE); cour.setPrincipal(identity.getPrincipal()); ChannelDaemon.this.lastScanTimestamps.put(device.getIdentifier(), lastScanTimestamp); Exception ex = new Exception("Device:"+device.getIdentifier()+ ",Identity:"+device.getIdentity().getPrincipal()+"Channel: "+this.channelRegistration.getUri()+