@Override
public void processData(String id, IdentifiableMessage<String, UnitConfig, UnitConfig.Builder> entry, ProtoBufMessageMap<String, UnitConfig, UnitConfig.Builder> entryMap, ProtoBufRegistry<String, UnitConfig, UnitConfig.Builder> registry) throws CouldNotPerformException, EntryModification {
UnitConfig deviceUnitConfig = entry.getMessage();
DeviceConfig deviceConfig = deviceUnitConfig.getDeviceConfig();
if (!oldInventoryStateMap.get(registry.isSandbox()).containsKey(deviceUnitConfig.getId())) {
oldInventoryStateMap.get(registry.isSandbox()).put(deviceUnitConfig.getId(), deviceConfig.getInventoryState().getValue());
}
if (!deviceConfig.hasInventoryState()) {
throw new NotAvailableException("deviceConfig.inventoryState");
}
if (!deviceConfig.getInventoryState().hasValue()) {
throw new NotAvailableException("deviceConfig.inventoryState.value");
}
if (deviceConfig.getInventoryState().getValue() != InventoryState.State.INSTALLED) {
if (deviceUnitConfig.getEnablingState().getValue() == EnablingState.State.ENABLED) {
EnablingState disabled = EnablingState.newBuilder().setValue(EnablingState.State.DISABLED).build();
throw new EntryModification(entry.setMessage(deviceUnitConfig.toBuilder().setEnablingState(disabled)), this);
}
}
if (oldInventoryStateMap.get(registry.isSandbox()).get(deviceUnitConfig.getId()) != deviceConfig.getInventoryState().getValue()) {
oldInventoryStateMap.get(registry.isSandbox()).put(deviceUnitConfig.getId(), deviceConfig.getInventoryState().getValue());
if (deviceConfig.getInventoryState().getValue() == InventoryState.State.INSTALLED) {
EnablingState enabled = EnablingState.newBuilder().setValue(EnablingState.State.ENABLED).build();
throw new EntryModification(entry.setMessage(deviceUnitConfig.toBuilder().setEnablingState(enabled)), this);
}
}
}