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; } //-------------------------------------------------------------------------------------------------------
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); } //---------------------------------------------------------------------------------------------------------
public String getDeviceToken() { DeviceAttribute attr = this.readAttribute("device-token"); if(attr != null) { return attr.getValue(); } return null; } //-------------------------------------------------------------------------------------------------------
String deviceId = device.getIdentifier(); DeviceAttribute osAttribute = new DeviceAttribute("os",os); DeviceAttribute versionAttribute = new DeviceAttribute("version",version); toBeUpdated.updateAttribute(osAttribute); toBeUpdated.updateAttribute(versionAttribute);
try pushDevice = pushNotificationManager.getDevice(device.getIdentifier()); pushNotificationManager.addDevice(device.getIdentifier(), device.getDeviceToken()); pushDevice = pushNotificationManager.getDevice(device.getIdentifier());
if(device != null && device.getIdentity().isActive()) String storedNonce = device.readAttribute("nonce").getValue();
Device device = deviceController.read(deviceId); Identity identity = device.getIdentity(); if(identity == null) this.identityController.update(identity); device.updateAttribute(new DeviceAttribute("nonce", authenticationHash)); this.deviceController.update(device);
Device device = new Device(deviceIdentifier, registeredIdentity); device.addAttribute(new DeviceAttribute("nonce", registeredIdentity.getCredential())); device.setIdentity(registeredIdentity); device.updateAttribute(new DeviceAttribute("nonce", registeredIdentity.getCredential())); this.deviceController.update(device);
for(Device device:localCopy) if(!device.getIdentity().isActive())
pushApp.setAppId(appId); pushApp.setChannels(storedChannels); pushApp.addDevice(device.getIdentifier()); pushApp.addDevice(device.getIdentifier()); device.updateAttribute(tokenAttr); this.deviceController.update(device);
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; }
Identity registeredUser = device.getIdentity(); log.debug("User: "+registeredUser.getPrincipal()); for(Device local:allDevices) String myDeviceId = local.getIdentifier();
public String getOs() { DeviceAttribute osAttr = this.readAttribute("os"); if(osAttr != null) { return osAttr.getValue(); } return null; }
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; }
LastScanTimestamp lastScanTimestamp = ChannelDaemon.this.lastScanTimestamps.get(device.getIdentifier()); if(lastScanTimestamp == null) lastScanTimestamp.setTimestamp(timestamp); lastScanTimestamp.setChannel(this.channelRegistration.getUri()); lastScanTimestamp.setClientId(device.getIdentifier()); Identity identity = device.getIdentity(); 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);
String storedNonce = device.readAttribute("nonce").getValue();
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; }
String storedNonce = device.readAttribute("nonce").getValue();
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; }