X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fmodification%2FDeleteModification.java;h=2c553571612b81ee6bd751c7a741ce8ba95aad8d;hb=cac7138ddd81d1cc801d4b6cd9bc4372e0a8ddd3;hp=593f458afa314f458ad314e6af22701160810c35;hpb=0eb621d29daaf08979c356e2148e99c48458e169;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java index 593f458afa..2c55357161 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java @@ -8,33 +8,77 @@ package org.opendaylight.controller.cluster.datastore.modification; -import org.opendaylight.controller.cluster.datastore.utils.InstanceIdentifierUtils; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import org.opendaylight.controller.cluster.datastore.DataStoreVersions; +import org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils; +import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils; import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages; import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification; /** * DeleteModification store all the parameters required to delete a path from the data tree */ public class DeleteModification extends AbstractModification { - public DeleteModification(YangInstanceIdentifier path) { - super(path); - } + private static final long serialVersionUID = 1L; - @Override - public void apply(DOMStoreWriteTransaction transaction) { - transaction.delete(path); - } + public DeleteModification() { + this(DataStoreVersions.CURRENT_VERSION); + } + + public DeleteModification(short version) { + super(version); + } + + public DeleteModification(YangInstanceIdentifier path) { + super(path); + } + + @Override + public void apply(DOMStoreWriteTransaction transaction) { + transaction.delete(getPath()); + } + + @Override + public void apply(DataTreeModification transaction) { + transaction.delete(getPath()); + } - @Override public Object toSerializable() { - return PersistentMessages.Modification.newBuilder() - .setType(this.getClass().toString()) - .setPath(InstanceIdentifierUtils.toSerializable(this.path)) - .build(); + @Override + public byte getType() { + return DELETE; } - public static DeleteModification fromSerializable(Object serializable){ + @Override + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + setPath(SerializationUtils.deserializePath(in)); + } + + @Override + public void writeExternal(ObjectOutput out) throws IOException { + SerializationUtils.serializePath(getPath(), out); + } + + @Override + @Deprecated + public Object toSerializable() { + return PersistentMessages.Modification.newBuilder().setType(this.getClass().toString()) + .setPath(InstanceIdentifierUtils.toSerializable(getPath())).build(); + } + + @Deprecated + public static DeleteModification fromSerializable(Object serializable) { PersistentMessages.Modification o = (PersistentMessages.Modification) serializable; return new DeleteModification(InstanceIdentifierUtils.fromSerializable(o.getPath())); } + + public static DeleteModification fromStream(ObjectInput in, short version) + throws ClassNotFoundException, IOException { + DeleteModification mod = new DeleteModification(version); + mod.readExternal(in); + return mod; + } }