- Renamed former rootPrototype property to hrefRootProperty,
since it defines the root object only as far as href() function is concerned - Add rootPrototype and userPrototype properties that allow to set the prototypes for the root and user objects, respectively - Implement Application.getRootPrototype() and Application.getRootId() that allow to get the prototype and id of the app's root node
This commit is contained in:
parent
fc9120d77f
commit
022bc2a2d8
2 changed files with 39 additions and 20 deletions
|
@ -126,8 +126,15 @@ public final class Application implements IPathElement, Runnable {
|
||||||
|
|
||||||
// the URL-prefix to use for links into this application
|
// the URL-prefix to use for links into this application
|
||||||
private String baseURI;
|
private String baseURI;
|
||||||
|
// the name of the root prototype as far as href() is concerned
|
||||||
|
private String hrefRootPrototype;
|
||||||
|
|
||||||
|
// the id of the object to use as root object
|
||||||
|
String rootId = "0";
|
||||||
// the name of the root prototype
|
// the name of the root prototype
|
||||||
private String rootPrototype;
|
private String rootPrototype;
|
||||||
|
// the name of the user prototype
|
||||||
|
private String userPrototype;
|
||||||
|
|
||||||
// Db mappings for some standard prototypes
|
// Db mappings for some standard prototypes
|
||||||
private DbMapping rootMapping;
|
private DbMapping rootMapping;
|
||||||
|
@ -349,8 +356,8 @@ public final class Application implements IPathElement, Runnable {
|
||||||
// create the skin manager
|
// create the skin manager
|
||||||
skinmgr = new SkinManager(this);
|
skinmgr = new SkinManager(this);
|
||||||
|
|
||||||
rootMapping = getDbMapping("root");
|
rootMapping = getDbMapping(rootPrototype);
|
||||||
userMapping = getDbMapping("user");
|
userMapping = getDbMapping(userPrototype);
|
||||||
|
|
||||||
// The whole user/userroot handling is basically old
|
// The whole user/userroot handling is basically old
|
||||||
// ugly obsolete crap. Don't bother.
|
// ugly obsolete crap. Don't bother.
|
||||||
|
@ -361,7 +368,7 @@ public final class Application implements IPathElement, Runnable {
|
||||||
usernameField = "name";
|
usernameField = "name";
|
||||||
}
|
}
|
||||||
|
|
||||||
p.put("_children", "collection(user)");
|
p.put("_children", "collection(" + userPrototype + ")");
|
||||||
p.put("_children.accessname", usernameField);
|
p.put("_children.accessname", usernameField);
|
||||||
userRootMapping = new DbMapping(this, "__userroot__", p);
|
userRootMapping = new DbMapping(this, "__userroot__", p);
|
||||||
userRootMapping.update();
|
userRootMapping.update();
|
||||||
|
@ -754,16 +761,22 @@ public final class Application implements IPathElement, Runnable {
|
||||||
}
|
}
|
||||||
// no custom root object is defined - use standard helma objectmodel
|
// no custom root object is defined - use standard helma objectmodel
|
||||||
else {
|
else {
|
||||||
String rootId = props.getProperty("rootid", "0");
|
return nmgr.safe.getNode(rootId, rootMapping);
|
||||||
Node rootNode = nmgr.safe.getNode(rootId, rootMapping);
|
|
||||||
// set the root node's prototype, if requested by rootPrototype property
|
|
||||||
String rootProto = props.getProperty("rootprototype");
|
|
||||||
if (rootProto != null && !rootProto.equals(rootNode.getPrototype())) {
|
|
||||||
rootNode.setPrototype(rootProto);
|
|
||||||
rootNode.setDbMapping(getDbMapping(rootProto));
|
|
||||||
}
|
}
|
||||||
return rootNode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the prototype of the object to be used as this application's root object
|
||||||
|
*/
|
||||||
|
public String getRootPrototype() {
|
||||||
|
return rootPrototype;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the id of the object to be used as this application's root object
|
||||||
|
*/
|
||||||
|
public String getRootId() {
|
||||||
|
return rootId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -959,7 +972,7 @@ public final class Application implements IPathElement, Runnable {
|
||||||
unode = new Node(uname, "user", nmgr.safe);
|
unode = new Node(uname, "user", nmgr.safe);
|
||||||
users.setNode(uname, unode);
|
users.setNode(uname, unode);
|
||||||
|
|
||||||
String usernameField = userMapping.getNameField();
|
String usernameField = (userMapping != null) ? userMapping.getNameField() : null;
|
||||||
String usernameProp = null;
|
String usernameProp = null;
|
||||||
|
|
||||||
if (usernameField != null) {
|
if (usernameField != null) {
|
||||||
|
@ -1068,7 +1081,8 @@ public final class Application implements IPathElement, Runnable {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((rootPrototype != null) && rootPrototype.equals(getPrototypeName(elem))) {
|
if ((hrefRootPrototype != null) &&
|
||||||
|
hrefRootPrototype.equals(getPrototypeName(elem))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1122,8 +1136,8 @@ public final class Application implements IPathElement, Runnable {
|
||||||
/**
|
/**
|
||||||
* Returns the prototype name that Hrefs in this application should start with.
|
* Returns the prototype name that Hrefs in this application should start with.
|
||||||
*/
|
*/
|
||||||
public String getRootPrototype() {
|
public String getHrefRootPrototype() {
|
||||||
return rootPrototype;
|
return hrefRootPrototype;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1699,7 +1713,12 @@ public final class Application implements IPathElement, Runnable {
|
||||||
baseURI = "/";
|
baseURI = "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
rootPrototype = props.getProperty("rootprototype");
|
// read in root id, root prototype, user prototype
|
||||||
|
rootId = props.getProperty("rootid", "0");
|
||||||
|
rootPrototype = props.getProperty("rootprototype", "root");
|
||||||
|
userPrototype = props.getProperty("userprototype", "user");
|
||||||
|
|
||||||
|
hrefRootPrototype = props.getProperty("hrefrootprototype");
|
||||||
|
|
||||||
// update the XML-RPC access list, containting prototype.method
|
// update the XML-RPC access list, containting prototype.method
|
||||||
// entries of functions that may be called via XML-RPC
|
// entries of functions that may be called via XML-RPC
|
||||||
|
|
|
@ -112,10 +112,10 @@ public class RequestPath {
|
||||||
StringBuffer buffer = new StringBuffer(app.getBaseURI());
|
StringBuffer buffer = new StringBuffer(app.getBaseURI());
|
||||||
|
|
||||||
int start = 1;
|
int start = 1;
|
||||||
String rootPrototype = app.getRootPrototype();
|
String hrefRootPrototype = app.getHrefRootPrototype();
|
||||||
|
|
||||||
if (rootPrototype != null) {
|
if (hrefRootPrototype != null) {
|
||||||
Object rootObject = getByPrototypeName(rootPrototype);
|
Object rootObject = getByPrototypeName(hrefRootPrototype);
|
||||||
|
|
||||||
if (rootObject != null) {
|
if (rootObject != null) {
|
||||||
start = objects.indexOf(rootObject) + 1;
|
start = objects.indexOf(rootObject) + 1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue