From 672153dbfeefbb9234d453a1e2251bd72ce7ccd4 Mon Sep 17 00:00:00 2001 From: hns Date: Tue, 8 Jul 2003 16:15:02 +0000 Subject: [PATCH] Include node state in serialization and refuse to read earlier serialization versions. --- src/helma/objectmodel/db/Node.java | 62 ++++---------------------- src/helma/objectmodel/db/Property.java | 16 +------ 2 files changed, 11 insertions(+), 67 deletions(-) diff --git a/src/helma/objectmodel/db/Node.java b/src/helma/objectmodel/db/Node.java index de9e9c34..472f8928 100644 --- a/src/helma/objectmodel/db/Node.java +++ b/src/helma/objectmodel/db/Node.java @@ -184,68 +184,23 @@ public final class Node implements INode, Serializable { String rawParentID = null; - if (version < 8) { - id = in.readUTF(); - name = in.readUTF(); - } else { - id = (String) in.readObject(); - name = (String) in.readObject(); - } - - if (version < 5) { - rawParentID = (String) in.readObject(); - } else { - parentHandle = (NodeHandle) in.readObject(); + if (version < 9) { + throw new IOException("Can't read pre 1.3.0 HopObject"); } + id = (String) in.readObject(); + name = (String) in.readObject(); + state = in.readInt(); + parentHandle = (NodeHandle) in.readObject(); created = in.readLong(); lastmodified = in.readLong(); - if (version < 4) { - // read away content and contentType, which were dropped - in.readObject(); - in.readObject(); - } - subnodes = (ExternalizableVector) in.readObject(); links = (ExternalizableVector) in.readObject(); - - if (version < 6) { - // read away obsolete proplinks list - in.readObject(); - } - propMap = (Hashtable) in.readObject(); anonymous = in.readBoolean(); + prototype = (String) in.readObject(); - if (version == 2) { - prototype = in.readUTF(); - } else if (version >= 3) { - prototype = (String) in.readObject(); - } - - // if the input version is < 5, we have to do some conversion to make this object work - if (version < 5) { - if (rawParentID != null) { - parentHandle = new NodeHandle(new DbKey(null, rawParentID)); - } - - if (subnodes != null) { - for (int i = 0; i < subnodes.size(); i++) { - String s = (String) subnodes.get(i); - - subnodes.set(i, new NodeHandle(new DbKey(null, s))); - } - } - - if (links != null) { - for (int i = 0; i < links.size(); i++) { - String s = (String) links.get(i); - - links.set(i, new NodeHandle(new DbKey(null, s))); - } - } - } } catch (ClassNotFoundException x) { throw new IOException(x.toString()); } @@ -255,9 +210,10 @@ public final class Node implements INode, Serializable { * Write out this instance to a stream */ private void writeObject(ObjectOutputStream out) throws IOException { - out.writeShort(8); // serialization version + out.writeShort(9); // serialization version out.writeObject(id); out.writeObject(name); + out.writeInt(state); out.writeObject(parentHandle); out.writeLong(created); out.writeLong(lastmodified); diff --git a/src/helma/objectmodel/db/Property.java b/src/helma/objectmodel/db/Property.java index 8e4f1ea3..8e949122 100644 --- a/src/helma/objectmodel/db/Property.java +++ b/src/helma/objectmodel/db/Property.java @@ -79,13 +79,7 @@ public final class Property implements IProperty, Serializable, Cloneable { switch (type) { case STRING: - - // try to convert from old format - if (node.version < 7) { - value = in.readUTF(); - } else { - value = in.readObject(); - } + value = in.readObject(); break; @@ -110,13 +104,7 @@ public final class Property implements IProperty, Serializable, Cloneable { break; case NODE: - - // try to convert from old format - if (node.version > 4) { - value = (NodeHandle) in.readObject(); - } else { - value = new NodeHandle(new DbKey(null, in.readUTF())); - } + value = (NodeHandle) in.readObject(); break;