Merge "Fix for Bug 2290."
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / CreateTransactionReply.java
index 4faf9d370d56a4dc4bb3edf97de469fb33f95362..14620f15d98ffece07905a73cdd7d18222e9c023 100644 (file)
@@ -8,16 +8,51 @@
 
 package org.opendaylight.controller.cluster.datastore.messages;
 
-import akka.actor.ActorPath;
+import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
 
-public class CreateTransactionReply {
-  private final ActorPath transactionPath;
+public class CreateTransactionReply implements SerializableMessage {
 
-  public CreateTransactionReply(ActorPath transactionPath) {
-    this.transactionPath = transactionPath;
-  }
+    public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.CreateTransactionReply.class;
+    private final String transactionPath;
+    private final String transactionId;
+    private final int version;
+
+    public CreateTransactionReply(String transactionPath,
+        String transactionId) {
+        this(transactionPath, transactionId, CreateTransaction.CURRENT_VERSION);
+    }
+
+    public CreateTransactionReply(String transactionPath,
+                                  String transactionId, int version) {
+        this.transactionPath = transactionPath;
+        this.transactionId = transactionId;
+        this.version = version;
+    }
+
+
+    public String getTransactionPath() {
+        return transactionPath;
+    }
+
+    public String getTransactionId() {
+        return transactionId;
+    }
+
+    public int getVersion() {
+        return version;
+    }
+
+    public Object toSerializable(){
+        return ShardTransactionMessages.CreateTransactionReply.newBuilder()
+            .setTransactionActorPath(transactionPath)
+            .setTransactionId(transactionId)
+            .setMessageVersion(version)
+            .build();
+    }
+
+    public static CreateTransactionReply fromSerializable(Object serializable){
+        ShardTransactionMessages.CreateTransactionReply o = (ShardTransactionMessages.CreateTransactionReply) serializable;
+        return new CreateTransactionReply(o.getTransactionActorPath(), o.getTransactionId(), o.getMessageVersion());
+    }
 
-  public ActorPath getTransactionPath() {
-    return transactionPath;
-  }
 }