and for now use it in add(T input), later remove() & update().
A future follow-up change will extend INeutronCRUD.Result with a 4th
additional enum value to signal "DependencyMissing" to callers.
JIRA: NEUTRON-158
Change-Id: I5f312008b899862e4957c0ab950b4939fd5b7369
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
*
* @param input
* OpenStackNeutron object
*
* @param input
* OpenStackNeutron object
- * @return boolean on whether the object was added or not
+ * @return result with indication on whether the object was added or not and if so why
/**
* Applications call this interface method to remove a Neutron object to the
/**
* Applications call this interface method to remove a Neutron object to the
* @return boolean on whether the object was updated or not
*/
boolean update(String uuid, T delta);
* @return boolean on whether the object was updated or not
*/
boolean update(String uuid, T delta);
+
+ // TODO The Exception Result should eventually be replaced by propagating exceptions, and removed
+ enum Result { Success, AlreadyExists, Exception }
+
- private boolean add(S input, ReadWriteTransaction tx) throws InterruptedException, ExecutionException {
+ private Result add(S input, ReadWriteTransaction tx) throws InterruptedException, ExecutionException {
Preconditions.checkNotNull(tx);
if (exists(input.getID(), tx)) {
tx.cancel();
Preconditions.checkNotNull(tx);
if (exists(input.getID(), tx)) {
tx.cancel();
+ return Result.AlreadyExists;
- public boolean add(S input) {
+ public Result add(S input) {
int retries = RETRY_MAX;
while (retries-- >= 0) {
final ReadWriteTransaction tx = getDataBroker().newReadWriteTransaction();
int retries = RETRY_MAX;
while (retries-- >= 0) {
final ReadWriteTransaction tx = getDataBroker().newReadWriteTransaction();
+ // TODO remove when re-throwing, and remove Result.Exception completely
+ return Result.Exception;
}
private boolean remove(String uuid, ReadWriteTransaction tx) throws InterruptedException, ExecutionException {
}
private boolean remove(String uuid, ReadWriteTransaction tx) throws InterruptedException, ExecutionException {