*
* @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
*/
- boolean add(T input);
+ Result add(T input);
/**
* 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);
+
+ // 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();
- return false;
+ return Result.AlreadyExists;
}
addMd(input, tx);
- return true;
+ return Result.Success;
}
@Override
- public boolean add(S input) {
+ public Result add(S input) {
int retries = RETRY_MAX;
while (retries-- >= 0) {
final ReadWriteTransaction tx = getDataBroker().newReadWriteTransaction();
}
break;
}
- return false;
+ // TODO remove when re-throwing, and remove Result.Exception completely
+ return Result.Exception;
}
private boolean remove(String uuid, ReadWriteTransaction tx) throws InterruptedException, ExecutionException {