- private void process(final DataObjectModification<Device> deviceMod) {
- Device before = deviceMod.getDataBefore();
- Device after = deviceMod.getDataAfter();
-
- if (before == null) {
- putDevice(after);
- } else if (after == null) {
- // Delete
- removeDevice(before);
- } else {
- if (!Objects.equal(before.getSshHostKey(), after.getSshHostKey())) {
- // key changed // we should remove previous key.
- removeDevice(before);
+ private void deleteDevice(final Device dataBefore) {
+ if (dataBefore != null) {
+ final String publicKey = dataBefore.getSshHostKey();
+ if (publicKey != null) {
+ LOG.debug("Removing device {}", dataBefore.getUniqueId());
+ removeDevice(publicKey, dataBefore);
+ } else {
+ LOG.debug("Ignoring removal of device {}, no host key present", dataBefore.getUniqueId());