add dependency check for security rule's group update(), not just add()
[neutron.git] / transcriber / src / main / java / org / opendaylight / neutron / transcriber / AbstractTranscriberInterface.java
index 987d4781682cc1b4a08e09f42c3c84adef687523..5419ec08c6aac84fd64103944c4662eea3a45a59 100644 (file)
@@ -520,7 +520,11 @@ public abstract class AbstractTranscriberInterface<
         while (retries-- >= 0) {
             final ReadWriteTransaction tx = getDataBroker().newReadWriteTransaction();
             try {
-                return update(uuid, delta, tx);
+                if (areAllDependenciesAvailable(tx, delta)) {
+                    return update(uuid, delta, tx);
+                } else {
+                    return Result.DependencyMissing;
+                }
             } catch (InterruptedException | ExecutionException e) {
                 if (e.getCause() instanceof OptimisticLockFailedException) {
                     LOG.warn("Got OptimisticLockFailedException - {} {} {}", uuid, delta, retries);
@@ -543,7 +547,9 @@ public abstract class AbstractTranscriberInterface<
      * {@link #exists(String, ReadTransaction)} method on ANOTHER transcriber with it.
      *
      * <p>Implementations should chain {@link #ifNonNull(Object, Function)}, or perform null safe comparisons otherwise,
-     * for any optional non-mandatory {@link NeutronObject} properties which may well be null.
+     * for both optional non-mandatory {@link NeutronObject} as well as mandatory properties which may well be null.
+     * Both must mandatory and non-mandatory must be guarded, because modify (update) operation are allowed to contain
+     * partial neutron objects with missing fields.
      *
      * @param tx the transaction within which to perform reads to check for dependencies
      * @param neutronObject the incoming main neutron object in which there may be references to dependencies