Remove IntentStore access in IntentUpdate subclasses
Change-Id: I923c62f1d34dc2c911323f11990de5c9788bf655
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/IntentManager.java b/core/net/src/main/java/org/onosproject/net/intent/impl/IntentManager.java
index 2ebc518..fb772fd 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/IntentManager.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/IntentManager.java
@@ -489,19 +489,16 @@
}
private IntentUpdate createIntentUpdate(IntentData intentData) {
+ IntentData current = store.getIntentData(intentData.key());
switch (intentData.state()) {
case INSTALL_REQ:
- return new InstallRequest(this, intentData);
+ return new InstallRequest(this, intentData, Optional.ofNullable(current));
case WITHDRAW_REQ:
- return new WithdrawRequest(this, intentData);
- // fallthrough
- case COMPILING:
- case INSTALLING:
- case INSTALLED:
- case RECOMPILING:
- case WITHDRAWING:
- case WITHDRAWN:
- case FAILED:
+ if (current == null) {
+ return new Withdrawn(current, WITHDRAWN);
+ } else {
+ return new WithdrawRequest(this, intentData, current);
+ }
default:
// illegal state
return new CompilingFailed(intentData);