diff options
author | 2016-04-14 15:22:06 +0200 | |
---|---|---|
committer | 2016-04-15 10:56:42 +0200 | |
commit | 3de41b2429269dd3c79d286d136da667f2f143bc (patch) | |
tree | c0f9e3b0eae02ca195b0efb6cc8028b2c1482724 /v3po/translate-impl/src/main/java | |
parent | 036a3589cfc1a62eddb49dc9cf09b7949c313f9b (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')
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); } } } |