diff --git a/src/helma/objectmodel/db/Node.java b/src/helma/objectmodel/db/Node.java index 1b963042..da43745e 100644 --- a/src/helma/objectmodel/db/Node.java +++ b/src/helma/objectmodel/db/Node.java @@ -44,17 +44,20 @@ public final class Node implements INode, Serializable { // anonymous node in a subnode collection? protected boolean anonymous = false; + // the serialization version this object was read from (see readObject()) + protected short version = 0; + private void readObject (ObjectInputStream in) throws IOException { try { // as a general rule of thumb, if a string can bu null use read/writeObject, // if not it's save to use read/writeUTF. // version indicates the serialization version - int version = in.readShort (); + version = in.readShort (); + String rawParentID = null; id = in.readUTF (); name = in.readUTF (); if (version < 5) - throw new IOException ("Unsupported Data Format (pre 1.2)"); - // parentHandle = new NodeHandle (new Key (null, (String) in.readObject ())); + rawParentID = (String) in.readObject (); else parentHandle = (NodeHandle) in.readObject (); created = in.readLong (); @@ -73,6 +76,29 @@ public final class Node implements INode, Serializable { 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