Initial implementation of CORRUPT state (ONOS-1060)

- Added CORRUPT state to state machine and event type
- Simplified phases using new request field
- Improved null-safety by using Optionals

Change-Id: I1d576b719765b5664aef73477ee04593e8acc4fd
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/phase/IntentProcessPhase.java b/core/net/src/main/java/org/onosproject/net/intent/impl/phase/IntentProcessPhase.java
index ea5a590..1ed42fd 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/phase/IntentProcessPhase.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/phase/IntentProcessPhase.java
@@ -20,8 +20,6 @@
 
 import java.util.Optional;
 
-import static org.onlab.util.Tools.isNullOrEmpty;
-
 /**
  * Represents a phase of processing an intent.
  */
@@ -46,20 +44,16 @@
      */
     static IntentProcessPhase newInitialPhase(IntentProcessor processor,
                                               IntentData data, IntentData current) {
-        switch (data.state()) {
+        switch (data.request()) {
             case INSTALL_REQ:
                 return new InstallRequest(processor, data, Optional.ofNullable(current));
             case WITHDRAW_REQ:
-                if (current == null || isNullOrEmpty(current.installables())) {
-                    return new Withdrawn(data);
-                } else {
-                    return new WithdrawRequest(processor, data, current);
-                }
+                return new WithdrawRequest(processor, data, Optional.ofNullable(current));
             case PURGE_REQ:
                 return new PurgeRequest(data, current);
             default:
                 // illegal state
-                return new CompileFailed(data);
+                return new Failed(data);
         }
     }