From 70ea9f7aa3c4f9e1437862486169446699e6eef9 Mon Sep 17 00:00:00 2001 From: hns Date: Fri, 13 May 2005 15:20:16 +0000 Subject: [PATCH] Application.java: - Update rootMapping and userMapping in updateProperties() - Replace getRootPrototype() with getRootMapping() DbMapping(): - Implement static areStorageCompatible() method to check two DbMappings, both of which may be null NodeManager: - Update to use new methods --- src/helma/framework/core/Application.java | 9 ++++----- src/helma/objectmodel/db/DbMapping.java | 16 ++++++++++++++-- src/helma/objectmodel/db/NodeManager.java | 5 ++--- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/helma/framework/core/Application.java b/src/helma/framework/core/Application.java index fde1f8ea..8bda67af 100644 --- a/src/helma/framework/core/Application.java +++ b/src/helma/framework/core/Application.java @@ -356,9 +356,6 @@ public final class Application implements IPathElement, Runnable { // create the skin manager skinmgr = new SkinManager(this); - rootMapping = getDbMapping(rootPrototype); - userMapping = getDbMapping(userPrototype); - // The whole user/userroot handling is basically old // ugly obsolete crap. Don't bother. ResourceProperties p = new ResourceProperties(); @@ -768,8 +765,8 @@ public final class Application implements IPathElement, Runnable { /** * Return the prototype of the object to be used as this application's root object */ - public String getRootPrototype() { - return rootPrototype; + public DbMapping getRootMapping() { + return rootMapping; } /** @@ -1717,6 +1714,8 @@ public final class Application implements IPathElement, Runnable { rootId = props.getProperty("rootid", "0"); rootPrototype = props.getProperty("rootprototype", "root"); userPrototype = props.getProperty("userprototype", "user"); + rootMapping = getDbMapping(rootPrototype); + userMapping = getDbMapping(userPrototype); hrefRootPrototype = props.getProperty("hrefrootprototype"); diff --git a/src/helma/objectmodel/db/DbMapping.java b/src/helma/objectmodel/db/DbMapping.java index f6e5b02d..36b540c9 100644 --- a/src/helma/objectmodel/db/DbMapping.java +++ b/src/helma/objectmodel/db/DbMapping.java @@ -1296,8 +1296,20 @@ public final class DbMapping { } /** - * Tell if another DbMapping is storage-compatible to this one, i.e. it is stored in the same table or - * embedded database. + * Static utility method to check whether two DbMappings use the same storage. + * + * @return true if both use the embedded database or the same relational table. + */ + public static boolean areStorageCompatible(DbMapping dbm1, DbMapping dbm2) { + if (dbm1 == null) + return dbm2 == null || !dbm2.isRelational(); + return dbm1.isStorageCompatible(dbm2); + } + + /** + * Tell if this DbMapping uses the same storage as the given DbMapping. + * + * @return true if both use the embedded database or the same relational table. */ public boolean isStorageCompatible(DbMapping other) { if (other == null) { diff --git a/src/helma/objectmodel/db/NodeManager.java b/src/helma/objectmodel/db/NodeManager.java index d47dc24e..a8babbbe 100644 --- a/src/helma/objectmodel/db/NodeManager.java +++ b/src/helma/objectmodel/db/NodeManager.java @@ -101,8 +101,7 @@ public final class NodeManager { * Gets the application's root node. */ public Node getRootNode() throws Exception { - DbMapping dbmap = getDbMapping(app.getRootPrototype()); - DbKey key = new DbKey(dbmap, app.getRootId()); + DbKey key = new DbKey(app.getRootMapping(), app.getRootId()); return getNode(key); } /** @@ -110,7 +109,7 @@ public final class NodeManager { */ public boolean isRootNode(Node node) { return app.getRootId().equals(node.getID()) && - app.getRootPrototype().equals(node.getPrototype()); + DbMapping.areStorageCompatible(app.getRootMapping(), node.getDbMapping()); } /**