Revert back to revision 1.133 (except for improved comments and removed obsolete code)
This commit is contained in:
parent
b173eb0200
commit
7a727927a9
1 changed files with 20 additions and 44 deletions
|
@ -113,7 +113,7 @@ public final class Node implements INode, Serializable {
|
||||||
*/
|
*/
|
||||||
public Node(Node home, String propname, WrappedNodeManager nmgr, String prototype) {
|
public Node(Node home, String propname, WrappedNodeManager nmgr, String prototype) {
|
||||||
this.nmgr = nmgr;
|
this.nmgr = nmgr;
|
||||||
setParentHandle(home.getHandle());
|
setParent(home);
|
||||||
|
|
||||||
// this.dbmap = null;
|
// this.dbmap = null;
|
||||||
// generate a key for the virtual node that can't be mistaken for a Database Key
|
// generate a key for the virtual node that can't be mistaken for a Database Key
|
||||||
|
@ -624,31 +624,14 @@ public final class Node implements INode, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a node as parent of the present node. This performs a check
|
* Set this node's parent node.
|
||||||
* to prevent cyclic parent paths. If the argument is accepted as parent,
|
|
||||||
* the method returns true. Otherwise, false is returned.
|
|
||||||
*/
|
*/
|
||||||
protected boolean setParent(Node parent) {
|
protected void setParent(Node parent) {
|
||||||
// walk down parent node to see if we are in its parent chain.
|
|
||||||
// this is to prevent cyclic parent chains.
|
|
||||||
Node p = parent;
|
|
||||||
while (p != null) {
|
|
||||||
p = p.parentHandle == null ? null : p.parentHandle.getNode(nmgr);
|
|
||||||
if (p == this) {
|
|
||||||
// we found ourself in the argument node's parent chain -
|
|
||||||
// ignore request to make it our parent.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
parentHandle = (parent == null) ? null : parent.getHandle();
|
parentHandle = (parent == null) ? null : parent.getHandle();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the parent handle which can be used to get the actual parent node.
|
* Set this node's parent node to the node referred to by the NodeHandle.
|
||||||
* In contrast to <code>getParent()</code> this does not perform any
|
|
||||||
* cyclic parent chain checks, so it should only be used when one is sure
|
|
||||||
* the argument handle doesn't refer to a Node we are a parent of.
|
|
||||||
*/
|
*/
|
||||||
public void setParentHandle(NodeHandle parent) {
|
public void setParentHandle(NodeHandle parent) {
|
||||||
parentHandle = parent;
|
parentHandle = parent;
|
||||||
|
@ -658,8 +641,6 @@ public final class Node implements INode, Serializable {
|
||||||
* This version of setParent additionally marks the node as anonymous or non-anonymous,
|
* This version of setParent additionally marks the node as anonymous or non-anonymous,
|
||||||
* depending on the string argument. This is the version called from the scripting framework,
|
* depending on the string argument. This is the version called from the scripting framework,
|
||||||
* while the one argument version is called from within the objectmodel classes only.
|
* while the one argument version is called from within the objectmodel classes only.
|
||||||
*
|
|
||||||
* @deprecated use Helma _parent mapping instead
|
|
||||||
*/
|
*/
|
||||||
public void setParent(Node parent, String propertyName) {
|
public void setParent(Node parent, String propertyName) {
|
||||||
// we only do that for relational nodes.
|
// we only do that for relational nodes.
|
||||||
|
@ -730,6 +711,7 @@ public final class Node implements INode, Serializable {
|
||||||
// if not, try to get one that does.
|
// if not, try to get one that does.
|
||||||
if (parentInfo != null) {
|
if (parentInfo != null) {
|
||||||
for (int i = 0; i < parentInfo.length; i++) {
|
for (int i = 0; i < parentInfo.length; i++) {
|
||||||
|
|
||||||
ParentInfo pinfo = parentInfo[i];
|
ParentInfo pinfo = parentInfo[i];
|
||||||
Node pn = null;
|
Node pn = null;
|
||||||
|
|
||||||
|
@ -767,7 +749,7 @@ public final class Node implements INode, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pn != null && pn.isParentOf(this)) {
|
if (pn != null && pn.isParentOf(this)) {
|
||||||
setParentHandle(pn.getHandle());
|
setParent(pn);
|
||||||
lastParentSet = System.currentTimeMillis();
|
lastParentSet = System.currentTimeMillis();
|
||||||
|
|
||||||
return pn;
|
return pn;
|
||||||
|
@ -932,9 +914,8 @@ public final class Node implements INode, Serializable {
|
||||||
// transient while we are persistent, make this the nodes new parent.
|
// transient while we are persistent, make this the nodes new parent.
|
||||||
if ((nparent == null) ||
|
if ((nparent == null) ||
|
||||||
((state != TRANSIENT) && (nparent.getState() == TRANSIENT))) {
|
((state != TRANSIENT) && (nparent.getState() == TRANSIENT))) {
|
||||||
if (node.setParent(this)) {
|
node.setParent(this);
|
||||||
node.anonymous = true;
|
node.anonymous = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1100,12 +1081,10 @@ public final class Node implements INode, Serializable {
|
||||||
// This would be an alternative way to do it, without loading the subnodes:
|
// This would be an alternative way to do it, without loading the subnodes:
|
||||||
// if (dbmap != null && dbmap.getSubnodeRelation () != null)
|
// if (dbmap != null && dbmap.getSubnodeRelation () != null)
|
||||||
// retval = nmgr.getNode (this, subid, dbmap.getSubnodeRelation ());
|
// retval = nmgr.getNode (this, subid, dbmap.getSubnodeRelation ());
|
||||||
|
|
||||||
if ((retval != null) && (retval.parentHandle == null) &&
|
if ((retval != null) && (retval.parentHandle == null) &&
|
||||||
!"root".equalsIgnoreCase(retval.getPrototype())) {
|
!"root".equalsIgnoreCase(retval.getPrototype())) {
|
||||||
if (retval.setParent(this)) {
|
retval.setParent(this);
|
||||||
retval.anonymous = true;
|
retval.anonymous = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1134,9 +1113,8 @@ public final class Node implements INode, Serializable {
|
||||||
|
|
||||||
if ((retval != null) && (retval.parentHandle == null) &&
|
if ((retval != null) && (retval.parentHandle == null) &&
|
||||||
!"root".equalsIgnoreCase(retval.getPrototype())) {
|
!"root".equalsIgnoreCase(retval.getPrototype())) {
|
||||||
if (retval.setParent(this)) {
|
retval.setParent(this);
|
||||||
retval.anonymous = true;
|
retval.anonymous = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1330,7 +1308,7 @@ public final class Node implements INode, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
// mark the node as deleted
|
// mark the node as deleted
|
||||||
setParentHandle(null);
|
setParent(null);
|
||||||
markAs(DELETED);
|
markAs(DELETED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1658,7 +1636,7 @@ public final class Node implements INode, Serializable {
|
||||||
// consulting the NodeManager about it.
|
// consulting the NodeManager about it.
|
||||||
Node n = new Node(propname, rel.getPrototype(), nmgr);
|
Node n = new Node(propname, rel.getPrototype(), nmgr);
|
||||||
n.setDbMapping(rel.getVirtualMapping());
|
n.setDbMapping(rel.getVirtualMapping());
|
||||||
n.setParentHandle(this.getHandle());
|
n.setParent(this);
|
||||||
setNode(propname, n);
|
setNode(propname, n);
|
||||||
return (Property) propMap.get(propname.toLowerCase());
|
return (Property) propMap.get(propname.toLowerCase());
|
||||||
}
|
}
|
||||||
|
@ -1671,10 +1649,9 @@ public final class Node implements INode, Serializable {
|
||||||
if (n != null) {
|
if (n != null) {
|
||||||
if ((n.parentHandle == null) &&
|
if ((n.parentHandle == null) &&
|
||||||
!"root".equalsIgnoreCase(n.getPrototype())) {
|
!"root".equalsIgnoreCase(n.getPrototype())) {
|
||||||
if (n.setParent(this)) {
|
n.setParent(this);
|
||||||
n.name = propname;
|
n.name = propname;
|
||||||
n.anonymous = false;
|
n.anonymous = false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return new Property(propname, this, n);
|
return new Property(propname, this, n);
|
||||||
}
|
}
|
||||||
|
@ -2186,10 +2163,9 @@ public final class Node implements INode, Serializable {
|
||||||
// transient while we are persistent, make this the nodes new parent.
|
// transient while we are persistent, make this the nodes new parent.
|
||||||
if ((nparent == null) ||
|
if ((nparent == null) ||
|
||||||
((state != TRANSIENT) && (nparent.getState() == TRANSIENT))) {
|
((state != TRANSIENT) && (nparent.getState() == TRANSIENT))) {
|
||||||
if (n.setParent(this)) {
|
n.setParent(this);
|
||||||
n.setName(propname);
|
n.name = propname;
|
||||||
n.anonymous = false;
|
n.anonymous = false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue