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
This commit is contained in:
parent
4def8eed1e
commit
70ea9f7aa3
3 changed files with 20 additions and 10 deletions
|
@ -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");
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue