@Override @Asynchronous public void addInstallation(Variant variant, Installation entity) { // does it already exist ? Installation installation = this.findInstallationForVariantByDeviceToken(variant.getVariantID(), entity.getDeviceToken()); // Needed for the Admin UI Only. Help for setting up Routes entity.setPlatform(variant.getType().getTypeName()); // new device/client ? if (installation == null) { logger.trace("Performing new device/client registration"); // store the installation: storeInstallationAndSetReferences(variant, entity); } else { // We only update the metadata, if the device is enabled: if (installation.isEnabled()) { logger.trace("Updating received metadata for an 'enabled' installation"); // fix variant property of installation object installation.setVariant(variant); // update the entity: this.updateInstallation(installation, entity); } } }
@Override public void updateInstallation(Installation installationToUpdate, Installation postedInstallation) { // copy the "updateable" values: mergeCategories(installationToUpdate, postedInstallation.getCategories()); installationToUpdate.setDeviceToken(postedInstallation.getDeviceToken()); installationToUpdate.setAlias(postedInstallation.getAlias()); installationToUpdate.setDeviceType(postedInstallation.getDeviceType()); installationToUpdate.setOperatingSystem(postedInstallation .getOperatingSystem()); installationToUpdate.setOsVersion(postedInstallation.getOsVersion()); installationToUpdate.setEnabled(postedInstallation.isEnabled()); installationToUpdate.setPlatform(postedInstallation.getPlatform()); // update it: updateInstallation(installationToUpdate); // unsubscribe Android devices from topics that device should no longer be subscribed to if (installationToUpdate.getVariant().getType() == VariantType.ANDROID) { unsubscribeOldTopics(installationToUpdate); } }