Handle case gracefully where a node has a prototype set that does not exist anymore.
When reading from relational table, set _prototype to the name of the prototype we actually use. When JS-wrapping the object, also check its DbMapping to find out the prototype.
This commit is contained in:
parent
06685adbec
commit
e7e5467d8f
2 changed files with 18 additions and 3 deletions
|
@ -1683,6 +1683,7 @@ public final class NodeManager {
|
||||||
System.err.println("Warning: Invalid prototype name: " + protoName +
|
System.err.println("Warning: Invalid prototype name: " + protoName +
|
||||||
" - using default");
|
" - using default");
|
||||||
dbmap = dbm;
|
dbmap = dbm;
|
||||||
|
protoName = dbmap.getTypeName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ package helma.scripting.rhino;
|
||||||
import helma.scripting.rhino.extensions.*;
|
import helma.scripting.rhino.extensions.*;
|
||||||
import helma.framework.core.*;
|
import helma.framework.core.*;
|
||||||
import helma.objectmodel.*;
|
import helma.objectmodel.*;
|
||||||
|
import helma.objectmodel.db.DbMapping;
|
||||||
import helma.scripting.*;
|
import helma.scripting.*;
|
||||||
import helma.util.CacheMap;
|
import helma.util.CacheMap;
|
||||||
import helma.util.SystemMap;
|
import helma.util.SystemMap;
|
||||||
|
@ -611,10 +612,22 @@ public final class RhinoCore {
|
||||||
|
|
||||||
op = getValidPrototype(protoname);
|
op = getValidPrototype(protoname);
|
||||||
|
|
||||||
// no prototype found for this node?
|
// no prototype found for this node
|
||||||
|
if (op == null) {
|
||||||
|
// maybe this object has a prototype name that has been
|
||||||
|
// deleted, but the storage layer was able to set a
|
||||||
|
// DbMapping matching the relational table the object
|
||||||
|
// was fetched from.
|
||||||
|
DbMapping dbmap = n.getDbMapping();
|
||||||
|
if (dbmap != null && (protoname = dbmap.getTypeName()) != null) {
|
||||||
|
op = getValidPrototype(protoname);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if not found, fall back to HopObject prototype
|
||||||
if (op == null) {
|
if (op == null) {
|
||||||
op = getValidPrototype("HopObject");
|
|
||||||
protoname = "HopObject";
|
protoname = "HopObject";
|
||||||
|
op = getValidPrototype("HopObject");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
esn = new HopObject(protoname, op);
|
esn = new HopObject(protoname, op);
|
||||||
|
@ -800,6 +813,7 @@ public final class RhinoCore {
|
||||||
Scriptable op = type.objectPrototype;
|
Scriptable op = type.objectPrototype;
|
||||||
|
|
||||||
// do the update, evaluating the file
|
// do the update, evaluating the file
|
||||||
|
// Script script = cx.compileReader(reader, sourceName, firstline, null);
|
||||||
cx.evaluateReader(op, reader, sourceName, firstline, null);
|
cx.evaluateReader(op, reader, sourceName, firstline, null);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue