diff options
author | Maros Marsalek <mmarsale@cisco.com> | 2016-04-14 15:22:06 +0200 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2016-04-15 10:56:42 +0200 |
commit | 1e37dbc5e73141fb6927ab68304f4ef4671243c7 (patch) | |
tree | 129c15d0236563e6c8cc5bd20b3b314f0397a8a9 /v3po/translate-impl/src/main/java/io/fd/honeycomb | |
parent | 83a373b7cb6274e84281519d32417d6eda2a5145 (diff) |
HONEYCOMB-38: Fix vpp interface customizers
The order of execution was not correct
+ CompositeWriter ignored some changes
Change-Id: I53fd9fda4b7a0379e0fa8451fa894865f67ebace
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'v3po/translate-impl/src/main/java/io/fd/honeycomb')
3 files changed, 19 insertions, 9 deletions
diff --git a/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/read/CompositeListReader.java b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/read/CompositeListReader.java index de32ee723..4c84c3afe 100644 --- a/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/read/CompositeListReader.java +++ b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/read/CompositeListReader.java @@ -133,9 +133,11 @@ public final class CompositeListReader<C extends DataObject & Identifiable<K>, K RWUtils.getCurrentIdItem(id, key); final InstanceIdentifier<C> keyedId = RWUtils.replaceLastInId(id, currentBdItem); final Optional<C> read = readCurrent(keyedId, ctx); - final DataObject singleItem = read.get(); - checkArgument(getManagedDataObjectType().getTargetType().isAssignableFrom(singleItem.getClass())); - allEntries.add(getManagedDataObjectType().getTargetType().cast(singleItem)); + if(read.isPresent()) { + final DataObject singleItem = read.get(); + checkArgument(getManagedDataObjectType().getTargetType().isAssignableFrom(singleItem.getClass())); + allEntries.add(getManagedDataObjectType().getTargetType().cast(singleItem)); + } } return allEntries; } diff --git a/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/AbstractCompositeWriter.java b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/AbstractCompositeWriter.java index 1e4d1361a..603f2a868 100644 --- a/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/AbstractCompositeWriter.java +++ b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/AbstractCompositeWriter.java @@ -98,6 +98,7 @@ public abstract class AbstractCompositeWriter<D extends DataObject> implements W final WriteContext ctx) throws WriteFailedException { LOG.debug("{}: Updating current: {} dataBefore: {}, datAfter: {}", this, id, dataBefore, dataAfter); +/* FIXME: Equals does not work: LINK */ if (dataBefore.equals(dataAfter)) { LOG.debug("{}: Skipping current(no update): {}", this, id); // No change, ignore diff --git a/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeChildWriter.java b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeChildWriter.java index 512eb44d9..54a09f272 100644 --- a/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeChildWriter.java +++ b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeChildWriter.java @@ -95,12 +95,12 @@ public class CompositeChildWriter<D extends DataObject> extends AbstractComposit @Override public void deleteChild(@Nonnull final InstanceIdentifier<? extends DataObject> parentId, - @Nonnull final DataObject parentData, + @Nonnull final DataObject parentDataBefore, @Nonnull final WriteContext ctx) throws WriteFailedException { final InstanceIdentifier<D> currentId = RWUtils.appendTypeToId(parentId, getManagedDataObjectType()); - final Optional<D> currentData = customizer.extract(currentId, parentData); - if(currentData.isPresent()) { - deleteCurrent(currentId, currentData.get(), ctx); + final Optional<D> dataBefore = customizer.extract(currentId, parentDataBefore); + if(dataBefore.isPresent()) { + deleteCurrent(currentId, dataBefore.get(), ctx); } } @@ -111,8 +111,15 @@ public class CompositeChildWriter<D extends DataObject> extends AbstractComposit final InstanceIdentifier<D> currentId = RWUtils.appendTypeToId(parentId, getManagedDataObjectType()); final Optional<D> before = customizer.extract(currentId, parentDataBefore); final Optional<D> after = customizer.extract(currentId, parentDataAfter); - if(before.isPresent() && after.isPresent()) { - updateCurrent(currentId, before.get(), after.get(), ctx); + + if(before.isPresent()) { + if(after.isPresent()) { + updateCurrent(currentId, before.get(), after.get(), ctx); + } else { + deleteCurrent(currentId, before.get(), ctx); + } + } else if (after.isPresent()){ + writeCurrent(currentId, after.get(), ctx); } } } |