propagate datastore exceptions all the way to northbound
[neutron.git] / neutron-spi / src / main / java / org / opendaylight / neutron / spi / INeutronCRUD.java
index 2d3eddf07351010fd249e7bdae1a2db1e5fe7763..616d5caa1a49bc968985946b4bac4811fecfaa06 100644 (file)
@@ -9,6 +9,8 @@ package org.opendaylight.neutron.spi;
 
 import java.util.List;
 import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.yangtools.yang.common.OperationFailedException;
 
 /**
  * This interface defines the methods for CRUD of NB neutron objects.
@@ -22,8 +24,9 @@ public interface INeutronCRUD<T extends INeutronObject<T>> {
      * @param uuid UUID of the Neutron object
      * @param tx   the ReadTransaction within which to perform the check
      * @return boolean
+     * @throws ReadFailedException if the read failed
      */
-    boolean exists(String uuid, ReadTransaction tx);
+    boolean exists(String uuid, ReadTransaction tx) throws ReadFailedException;
 
     /**
      * Applications call this interface method to return if a particular
@@ -33,15 +36,17 @@ public interface INeutronCRUD<T extends INeutronObject<T>> {
      *            UUID of the Neutron object
      * @return {@link org.opendaylight.neutron.spi.INeutronObject}
      *          OpenStack Neutron class
+     * @throws ReadFailedException if the read failed
      */
-    T get(String uuid);
+    T get(String uuid) throws ReadFailedException;
 
     /**
      * Applications call this interface method to return all Neutron objects.
      *
      * @return List of OpenStackNeutrons objects
+     * @throws ReadFailedRuntimeException if the read failed
      */
-    List<T> getAll();
+    List<T> getAll() throws ReadFailedRuntimeException;
 
     /**
      * Applications call this interface method to add a Neutron object to the
@@ -50,8 +55,9 @@ public interface INeutronCRUD<T extends INeutronObject<T>> {
      * @param input
      *            OpenStackNeutron object
      * @return result with indication on whether the object was added or not and if so why
+     * @throws OperationFailedException if the write (or a required implicit read) failed
      */
-    Result add(T input);
+    Result add(T input) throws OperationFailedException;
 
     /**
      * Applications call this interface method to remove a Neutron object to the
@@ -60,8 +66,9 @@ public interface INeutronCRUD<T extends INeutronObject<T>> {
      * @param uuid
      *            identifier for the neutron object
      * @return boolean on whether the object was removed or not
+     * @throws OperationFailedException if the remove (or a required implicit read) failed
      */
-    boolean remove(String uuid);
+    boolean remove(String uuid) throws OperationFailedException;
 
     /**
      * Applications call this interface method to edit a Neutron object.
@@ -71,10 +78,10 @@ public interface INeutronCRUD<T extends INeutronObject<T>> {
      * @param delta
      *            OpenStackNeutron object containing changes to apply
      * @return boolean on whether the object was updated or not
+     * @throws OperationFailedException if the update (or a required implicit read) failed
      */
-    Result update(String uuid, T delta);
+    Result update(String uuid, T delta) throws OperationFailedException;
 
-    enum Result { Success, AlreadyExists, DoesNotExist, DependencyMissing, Exception }
-    // TODO The Result "Exception" should eventually be replaced by propagating exceptions, and removed
+    enum Result { Success, AlreadyExists, DoesNotExist, DependencyMissing }
 
 }