Some minor changes in getNodeHref() and getDataRoot()
This commit is contained in:
parent
4757fa93a8
commit
452cf28676
1 changed files with 16 additions and 22 deletions
|
@ -512,7 +512,6 @@ public final class Application implements IPathElement, Runnable {
|
||||||
nmgr.clearCache ();
|
nmgr.clearCache ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of elements in the NodeManager's cache
|
* Returns the number of elements in the NodeManager's cache
|
||||||
*/
|
*/
|
||||||
|
@ -533,10 +532,7 @@ public final class Application implements IPathElement, Runnable {
|
||||||
* This method returns the root object of this application's object tree.
|
* This method returns the root object of this application's object tree.
|
||||||
*/
|
*/
|
||||||
public Object getDataRoot () {
|
public Object getDataRoot () {
|
||||||
// if rootObject is set, immediately return it.
|
// check if we have a custom root object class
|
||||||
if (rootObject != null)
|
|
||||||
return rootObject;
|
|
||||||
// check if we ought to create a rootObject from its class name
|
|
||||||
if (rootObjectClass != null) {
|
if (rootObjectClass != null) {
|
||||||
// create custom root element.
|
// create custom root element.
|
||||||
if (rootObject == null) {
|
if (rootObject == null) {
|
||||||
|
@ -556,9 +552,13 @@ public final class Application implements IPathElement, Runnable {
|
||||||
return rootObject;
|
return rootObject;
|
||||||
}
|
}
|
||||||
// no custom root object is defined - use standard helma objectmodel
|
// no custom root object is defined - use standard helma objectmodel
|
||||||
INode root = nmgr.safe.getNode ("0", rootMapping);
|
else {
|
||||||
root.setDbMapping (rootMapping);
|
// INode root = nmgr.safe.getNode ("0", rootMapping);
|
||||||
return root;
|
// root.setDbMapping (rootMapping);
|
||||||
|
// rootObject = root;
|
||||||
|
rootObject = nmgr.safe.getNode ("0", rootMapping);
|
||||||
|
return rootObject;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -831,34 +831,28 @@ public final class Application implements IPathElement, Runnable {
|
||||||
return pwfile.authenticate (uname, password);
|
return pwfile.authenticate (uname, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the href to the root of this application.
|
|
||||||
*/
|
|
||||||
public String getRootHref () {
|
|
||||||
return getNodeHref (getDataRoot(), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a path to be used in a URL pointing to the given element and action
|
* Return a path to be used in a URL pointing to the given element and action
|
||||||
*/
|
*/
|
||||||
public String getNodeHref (Object elem, String actionName) {
|
public String getNodeHref (Object elem, String actionName) {
|
||||||
Object root = getDataRoot ();
|
// Object root = getDataRoot ();
|
||||||
|
|
||||||
// check optional root prototype from app.properties
|
// check optional root prototype from app.properties
|
||||||
String rootproto = props.getProperty ("rootPrototype");
|
String rootProto = props.getProperty ("rootPrototype");
|
||||||
|
|
||||||
String divider = "/";
|
String divider = "/";
|
||||||
StringBuffer b = new StringBuffer ();
|
StringBuffer b = new StringBuffer ();
|
||||||
Object p = elem;
|
Object parent = null;
|
||||||
int loopWatch = 0;
|
int loopWatch = 0;
|
||||||
|
|
||||||
while (p != null && getParentElement (p) != null && p != root) {
|
while (elem != null && (parent = getParentElement (elem)) != null && elem != rootObject) {
|
||||||
|
|
||||||
if (rootproto != null && rootproto.equals (getPrototypeName (p)))
|
if (rootProto != null && rootProto.equals (getPrototypeName (elem)))
|
||||||
break;
|
break;
|
||||||
b.insert (0, divider);
|
b.insert (0, divider);
|
||||||
b.insert (0, UrlEncoded.encode (getElementName (p)));
|
b.insert (0, UrlEncoded.encode (getElementName (elem)));
|
||||||
p = getParentElement (p);
|
// move down to the element's parent
|
||||||
|
elem = parent;
|
||||||
|
|
||||||
if (loopWatch++ > 20)
|
if (loopWatch++ > 20)
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue