You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2008/09/24 01:36:07 UTC
svn commit: r698402 - in
/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core:
./ lock/ version/ xml/
Author: jukka
Date: Tue Sep 23 16:36:07 2008
New Revision: 698402
URL: http://svn.apache.org/viewvc?rev=698402&view=rev
Log:
JCR-1538: [patch] add toString for NodeImpl and PropertyImpl
Type-specific toString() on all ItemImpl descendants
Use the toString() method instead of safeGetPath() in diagnostics.
Modified:
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/XALockManager.java
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionImpl.java
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java?rev=698402&r1=698401&r2=698402&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java Tue Sep 23 16:36:07 2008
@@ -50,6 +50,7 @@
import javax.jcr.ItemVisitor;
import javax.jcr.Node;
import javax.jcr.PathNotFoundException;
+import javax.jcr.Property;
import javax.jcr.PropertyType;
import javax.jcr.ReferentialIntegrityException;
import javax.jcr.RepositoryException;
@@ -57,10 +58,10 @@
import javax.jcr.UnsupportedRepositoryOperationException;
import javax.jcr.lock.LockException;
import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.ItemDefinition;
import javax.jcr.nodetype.NoSuchNodeTypeException;
import javax.jcr.nodetype.NodeDefinition;
import javax.jcr.nodetype.NodeType;
-import javax.jcr.nodetype.PropertyDefinition;
import javax.jcr.version.VersionException;
import javax.jcr.version.VersionHistory;
import java.util.ArrayList;
@@ -232,7 +233,6 @@
while (iter.hasNext()) {
transientState = (ItemState) iter.next();
// fail-fast test: check status of transient state
- String msg;
switch (transientState.getStatus()) {
case ItemState.STATUS_NEW:
case ItemState.STATUS_EXISTING_MODIFIED:
@@ -241,25 +241,23 @@
break;
case ItemState.STATUS_STALE_MODIFIED:
- msg = transientState.getId()
- + ": the item cannot be saved because it has been modified externally.";
- log.debug(msg);
- throw new InvalidItemStateException(msg);
+ throw new InvalidItemStateException(
+ "Item cannot be saved because it has been"
+ + "modified externally: " + this);
case ItemState.STATUS_STALE_DESTROYED:
- msg = transientState.getId()
- + ": the item cannot be saved because it has been deleted externally.";
- log.debug(msg);
- throw new InvalidItemStateException(msg);
+ throw new InvalidItemStateException(
+ "Item cannot be saved because it has been"
+ + "deleted externally: " + this);
case ItemState.STATUS_UNDEFINED:
- msg = safeGetJCRPath()
- + ": the item cannot be saved; it seems to have been removed externally.";
- log.debug(msg);
- throw new InvalidItemStateException(msg);
+ throw new InvalidItemStateException(
+ "Item cannot be saved; it seems to have been"
+ + "removed externally: " + this);
default:
- log.debug("unexpected state status (" + transientState.getStatus() + ")");
+ log.warn("Unexpected item state status: "
+ + transientState.getStatus() + " of " + this);
// ignore
break;
}
@@ -276,30 +274,27 @@
break;
case ItemState.STATUS_NEW:
- msg = safeGetJCRPath() + ": cannot save a new item.";
- log.debug(msg);
- throw new RepositoryException(msg);
+ throw new RepositoryException(
+ "Cannot save a new item: " + this);
case ItemState.STATUS_STALE_MODIFIED:
- msg = safeGetJCRPath()
- + ": the item cannot be saved because it has been modified externally.";
- log.debug(msg);
- throw new InvalidItemStateException(msg);
+ throw new InvalidItemStateException(
+ "Item cannot be saved because it has been"
+ + " modified externally: " + this);
case ItemState.STATUS_STALE_DESTROYED:
- msg = safeGetJCRPath()
- + ": the item cannot be saved because it has been deleted externally.";
- log.debug(msg);
- throw new InvalidItemStateException(msg);
+ throw new InvalidItemStateException(
+ "Item cannot be saved because it has been"
+ + " deleted externally:" + this);
case ItemState.STATUS_UNDEFINED:
- msg = safeGetJCRPath()
- + ": the item cannot be saved; it seems to have been removed externally.";
- log.debug(msg);
- throw new InvalidItemStateException(msg);
+ throw new InvalidItemStateException(
+ "Item cannot be saved; it seems to have been"
+ + " removed externally: " + this);
default:
- log.debug("unexpected state status (" + state.getStatus() + ")");
+ log.warn("Unexpected item state status:"
+ + state.getStatus() + " of " + this);
// ignore
break;
}
@@ -781,58 +776,42 @@
// check state of this instance
sanityCheck();
- Path.Element thisName = getPrimaryPath().getNameElement();
-
- // check if protected
- if (isNode()) {
- NodeImpl node = (NodeImpl) this;
- // check if this is the root node
- if (node.getDepth() == 0) {
- String msg = safeGetJCRPath() + ": cannot remove root node";
- log.debug(msg);
- throw new RepositoryException(msg);
- }
-
- NodeDefinition def = node.getDefinition();
- // check protected flag
- if (!noChecks && def.isProtected()) {
- String msg = safeGetJCRPath() + ": cannot remove a protected node";
- log.debug(msg);
- throw new ConstraintViolationException(msg);
- }
- } else {
- PropertyImpl prop = (PropertyImpl) this;
- PropertyDefinition def = prop.getDefinition();
- // check protected flag
- if (!noChecks && def.isProtected()) {
- String msg = safeGetJCRPath() + ": cannot remove a protected property";
- log.debug(msg);
- throw new ConstraintViolationException(msg);
- }
+ // check if this is the root node
+ if (getDepth() == 0) {
+ throw new RepositoryException("Cannot remove the root node");
}
NodeImpl parentNode = (NodeImpl) getParent();
- // verify that parent node is checked-out
- if (!noChecks && !parentNode.internalIsCheckedOut()) {
- String msg = parentNode.safeGetJCRPath() + ": cannot remove a child of a checked-in node";
- log.debug(msg);
- throw new VersionException(msg);
- }
+ if (!noChecks) {
+ // check if protected
+ ItemDefinition definition;
+ if (isNode()) {
+ definition = ((Node) this).getDefinition();
+ } else {
+ definition = ((Property) this).getDefinition();
+ }
+ if (definition.isProtected()) {
+ throw new ConstraintViolationException(
+ "Cannot remove a protected item: " + this);
+ }
- // check protected flag of parent node
- if (!noChecks && parentNode.getDefinition().isProtected()) {
- String msg = parentNode.safeGetJCRPath() + ": cannot remove a child of a protected node";
- log.debug(msg);
- throw new ConstraintViolationException(msg);
- }
+ // verify that parent node is checked-out and not protected
+ if (!parentNode.internalIsCheckedOut()) {
+ throw new VersionException(
+ "Cannot remove a child of a checked-in node: " + this);
+ }
+ if (parentNode.getDefinition().isProtected()) {
+ throw new ConstraintViolationException(
+ "Cannot remove a child of a protected node: " + this);
+ }
- // check lock status
- if (!noChecks) {
+ // check lock status
parentNode.checkLock();
}
// delegate the removal of the child item to the parent node
+ Path.Element thisName = getPrimaryPath().getNameElement();
if (isNode()) {
parentNode.removeChildNode(thisName.getName(), thisName.getIndex());
} else {
@@ -1106,9 +1085,8 @@
} catch (StaleItemStateException e) {
throw new InvalidItemStateException(e.getMessage());
} catch (ItemStateException e) {
- String msg = safeGetJCRPath() + ": unable to update item.";
- log.debug(msg);
- throw new RepositoryException(msg, e);
+ throw new RepositoryException(
+ "Unable to update item: " + this, e);
} finally {
if (!succeeded) {
// update operation failed, cancel all modifications
@@ -1176,12 +1154,12 @@
break;
case ItemState.STATUS_NEW:
- String msg = safeGetJCRPath() + ": cannot refresh a new item.";
- log.debug(msg);
- throw new RepositoryException(msg);
+ throw new RepositoryException(
+ "Cannot refresh a new item: " + this);
default:
- log.debug("unexpected state status (" + transientState.getStatus() + ")");
+ log.warn("Unexpected item state status:"
+ + transientState.getStatus() + " of " + this);
// ignore
break;
}
@@ -1322,17 +1300,13 @@
//--------------------------------------------------------------< Object >
/**
- * Returns a string with the type and ({@link #safeGetJCRPath() safe}) path
- * of this item for use in diagnostic output.
+ * Returns the({@link #safeGetJCRPath() safe}) path of this item for use
+ * in diagnostic output.
*
- * @return item path
+ * @return "/path/to/item"
*/
public String toString() {
- if (isNode()) {
- return "node " + safeGetJCRPath();
- } else {
- return "property " + safeGetJCRPath();
- }
+ return safeGetJCRPath();
}
}
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?rev=698402&r1=698401&r2=698402&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java Tue Sep 23 16:36:07 2008
@@ -131,7 +131,7 @@
* e.g. 'flag' nodes that refer to non-registered node types
*/
log.warn("Fallback to nt:unstructured due to unknown node type '"
- + state.getNodeTypeName() + "' of node " + safeGetJCRPath());
+ + state.getNodeTypeName() + "' of " + this);
data.getNodeState().setNodeTypeName(NameConstants.NT_UNSTRUCTURED);
}
}
@@ -173,7 +173,7 @@
getPrimaryPath(), session.getQPath(relPath), true);
return session.getHierarchyManager().resolvePropertyPath(p);
} catch (NameException e) {
- String msg = "failed to resolve path " + relPath + " relative to " + safeGetJCRPath();
+ String msg = "failed to resolve path " + relPath + " relative to " + this;
log.debug(msg);
throw new RepositoryException(msg, e);
}
@@ -224,7 +224,7 @@
p = PathFactoryImpl.getInstance().create(getPrimaryPath(), p, true);
return session.getHierarchyManager().resolveNodePath(p);
} catch (NameException e) {
- String msg = "failed to resolve path " + relPath + " relative to " + safeGetJCRPath();
+ String msg = "failed to resolve path " + relPath + " relative to " + this;
log.debug(msg);
throw new RepositoryException(msg, e);
}
@@ -470,8 +470,7 @@
propState.setValues(defValues);
}
} catch (ItemStateException ise) {
- String msg = "failed to add property " + name + " to "
- + safeGetJCRPath();
+ String msg = "failed to add property " + name + " to " + this;
log.debug(msg);
throw new RepositoryException(msg, ise);
}
@@ -503,8 +502,7 @@
getNodeId(), ItemState.STATUS_NEW);
nodeState.setDefinitionId(def.unwrap().getId());
} catch (ItemStateException ise) {
- String msg = "failed to add child node " + name + " to "
- + safeGetJCRPath();
+ String msg = "failed to add child node " + name + " to " + this;
log.debug(msg);
throw new RepositoryException(msg, ise);
}
@@ -571,8 +569,7 @@
// remove the property entry
if (!thisState.removePropertyName(propName)) {
- String msg = "failed to remove property " + propName + " of "
- + safeGetJCRPath();
+ String msg = "failed to remove property " + propName + " of " + this;
log.debug(msg);
throw new RepositoryException(msg);
}
@@ -592,8 +589,7 @@
ChildNodeEntry entry =
thisState.getChildNodeEntry(nodeName, index);
if (entry == null) {
- String msg = "failed to remove child " + nodeName + " of "
- + safeGetJCRPath();
+ String msg = "failed to remove child " + nodeName + " of " + this;
log.debug(msg);
throw new RepositoryException(msg);
}
@@ -605,8 +601,7 @@
// remove the child node entry
if (!thisState.removeChildNodeEntry(nodeName, index)) {
- String msg = "failed to remove child " + nodeName + " of "
- + safeGetJCRPath();
+ String msg = "failed to remove child " + nodeName + " of " + this;
log.debug(msg);
throw new RepositoryException(msg);
}
@@ -701,8 +696,8 @@
nodeName = nodePath.getNameElement().getName();
parentPath = nodePath.getAncestor(1);
} catch (NameException e) {
- String msg = "failed to resolve path " + relPath + " relative to "
- + safeGetJCRPath();
+ String msg =
+ "failed to resolve path " + relPath + " relative to " + this;
log.debug(msg);
throw new RepositoryException(msg, e);
}
@@ -722,8 +717,7 @@
// make sure that parent node is checked-out
if (!parentNode.internalIsCheckedOut()) {
- String msg = safeGetJCRPath()
- + ": cannot add a child to a checked-in node";
+ String msg = this + ": cannot add a child to a checked-in node";
log.debug(msg);
throw new VersionException(msg);
}
@@ -751,7 +745,7 @@
nodePath = PathFactoryImpl.getInstance().create(getPrimaryPath(), nodeName, true);
} catch (MalformedPathException e) {
// should never happen
- String msg = "internal error: invalid path " + safeGetJCRPath();
+ String msg = "internal error: invalid path " + this;
log.debug(msg);
throw new RepositoryException(msg, e);
}
@@ -792,7 +786,7 @@
// check protected flag of parent (i.e. this) node
final NodeDefinition definition = data.getNodeDefinition();
if (definition.isProtected()) {
- String msg = safeGetJCRPath() + ": cannot add a child to a protected node";
+ String msg = this + ": cannot add a child to a protected node";
log.debug(msg);
throw new ConstraintViolationException(msg);
}
@@ -871,8 +865,7 @@
try {
return ntReg.getEffectiveNodeType(types);
} catch (NodeTypeConflictException ntce) {
- String msg = "internal error: failed to build effective node type for node "
- + safeGetJCRPath();
+ String msg = "Failed to build effective node type for " + this;
log.debug(msg);
throw new RepositoryException(msg, ntce);
}
@@ -936,7 +929,7 @@
protected void makePersistent() throws InvalidItemStateException {
if (!isTransient()) {
- log.debug(safeGetJCRPath() + " (" + id + "): there's no transient state to persist");
+ log.debug(this + " (" + id + "): there's no transient state to persist");
return;
}
@@ -951,8 +944,9 @@
synchronized (persistentState) {
// check staleness of transient state first
if (transientState.isStale()) {
- String msg = safeGetJCRPath()
- + ": the node cannot be saved because it has been modified externally.";
+ String msg =
+ this + ": the node cannot be saved because it has been"
+ + " modified externally.";
log.debug(msg);
throw new InvalidItemStateException(msg);
}
@@ -1020,7 +1014,7 @@
// make sure this node is checked-out
if (!internalIsCheckedOut()) {
- String msg = safeGetJCRPath() + ": cannot add a mixin node type to a checked-in node";
+ String msg = this + ": cannot add a mixin node type to a checked-in node";
log.debug(msg);
throw new VersionException(msg);
}
@@ -1028,7 +1022,7 @@
// check protected flag
final NodeDefinition definition = data.getNodeDefinition();
if (definition.isProtected()) {
- String msg = safeGetJCRPath() + ": cannot add a mixin node type to a protected node";
+ String msg = this + ": cannot add a mixin node type to a protected node";
log.debug(msg);
throw new ConstraintViolationException(msg);
}
@@ -1133,8 +1127,8 @@
// make sure this node is checked-out
if (!internalIsCheckedOut()) {
- String msg = safeGetJCRPath()
- + ": cannot remove a mixin node type from a checked-in node";
+ String msg =
+ this + ": cannot remove a mixin node type from a checked-in node";
log.debug(msg);
throw new VersionException(msg);
}
@@ -1142,8 +1136,8 @@
// check protected flag
NodeDefinition definition = data.getNodeDefinition();
if (definition.isProtected()) {
- String msg = safeGetJCRPath()
- + ": cannot remove a mixin node type from a protected node";
+ String msg =
+ this + ": cannot remove a mixin node type from a protected node";
log.debug(msg);
throw new ConstraintViolationException(msg);
}
@@ -1297,8 +1291,7 @@
throws VersionException, LockException, RepositoryException {
// make sure this node is checked-out
if (!internalIsCheckedOut()) {
- String msg = safeGetJCRPath()
- + ": cannot set property of a checked-in node";
+ String msg = this + ": cannot set property of a checked-in node";
log.debug(msg);
throw new VersionException(msg);
}
@@ -1563,7 +1556,7 @@
// make sure this node is checked-out
if (!internalIsCheckedOut()) {
- String msg = safeGetJCRPath() + ": cannot add node to a checked-in node";
+ String msg = this + ": cannot add node to a checked-in node";
log.debug(msg);
throw new VersionException(msg);
}
@@ -1761,8 +1754,7 @@
if (!getPrimaryNodeType().hasOrderableChildNodes()) {
throw new UnsupportedRepositoryOperationException(
- "child node ordering not supported on node "
- + safeGetJCRPath());
+ "child node ordering not supported on " + this);
}
// check arguments
@@ -1782,8 +1774,8 @@
} catch (NamespaceException e) {
name = srcName.toString();
}
- throw new ItemNotFoundException(safeGetJCRPath()
- + " has no child node with name " + name);
+ throw new ItemNotFoundException(
+ this + " has no child node with name " + name);
}
if (dstName != null && !hasNode(dstName.getName(), dstName.getIndex())) {
String name;
@@ -1795,14 +1787,14 @@
} catch (NamespaceException e) {
name = dstName.toString();
}
- throw new ItemNotFoundException(safeGetJCRPath()
- + " has no child node with name " + name);
+ throw new ItemNotFoundException(
+ this + " has no child node with name " + name);
}
// make sure this node is checked-out
if (!internalIsCheckedOut()) {
- String msg = safeGetJCRPath()
- + ": cannot change child node ordering of a checked-in node";
+ String msg =
+ this + ": cannot change child node ordering of a checked-in node";
log.debug(msg);
throw new VersionException(msg);
}
@@ -1810,8 +1802,8 @@
// check protected flag
final NodeDefinition definition = data.getNodeDefinition();
if (definition.isProtected()) {
- String msg = safeGetJCRPath()
- + ": cannot change child node ordering of a protected node";
+ String msg =
+ this + ": cannot change child node ordering of a protected node";
log.debug(msg);
throw new ConstraintViolationException(msg);
}
@@ -1912,8 +1904,8 @@
NodeState state = data.getNodeState();
ChildNodeEntry cneExisting = state.getChildNodeEntry(id);
if (cneExisting == null) {
- throw new ItemNotFoundException(safeGetJCRPath()
- + ": no child node entry with id " + id);
+ throw new ItemNotFoundException(
+ this + ": no child node entry with id " + id);
}
List cneList = new ArrayList(state.getChildNodeEntries());
@@ -1977,15 +1969,14 @@
nodePath = PathFactoryImpl.getInstance().create(getPrimaryPath(), name, true);
} catch (MalformedPathException e) {
// should never happen
- String msg = "internal error: invalid path " + safeGetJCRPath();
+ String msg = "internal error: invalid path " + this;
log.debug(msg);
throw new RepositoryException(msg, e);
}
// (1) make sure that parent node is checked-out
if (!internalIsCheckedOut()) {
- String msg = safeGetJCRPath()
- + ": cannot add a child to a checked-in node";
+ String msg = this + ": cannot add a child to a checked-in node";
log.debug(msg);
throw new VersionException(msg);
}
@@ -2020,7 +2011,7 @@
// (4) check protected flag of parent (i.e. this) node
final NodeDefinition definition = data.getNodeDefinition();
if (definition.isProtected()) {
- String msg = safeGetJCRPath() + ": cannot add a child to a protected node";
+ String msg = this + ": cannot add a child to a protected node";
log.debug(msg);
throw new ConstraintViolationException(msg);
}
@@ -2639,11 +2630,11 @@
try {
return itemMgr.getChildNodes((NodeId) id);
} catch (ItemNotFoundException infe) {
- String msg = "failed to list the child nodes of " + safeGetJCRPath();
+ String msg = "failed to list the child nodes of " + this;
log.debug(msg);
throw new RepositoryException(msg, infe);
} catch (AccessDeniedException ade) {
- String msg = "failed to list the child nodes of " + safeGetJCRPath();
+ String msg = "failed to list the child nodes of " + this;
log.debug(msg);
throw new RepositoryException(msg, ade);
}
@@ -2666,11 +2657,11 @@
try {
return itemMgr.getChildProperties((NodeId) id);
} catch (ItemNotFoundException infe) {
- String msg = "failed to list the child properties of " + safeGetJCRPath();
+ String msg = "failed to list the child properties of " + this;
log.debug(msg);
throw new RepositoryException(msg, infe);
} catch (AccessDeniedException ade) {
- String msg = "failed to list the child properties of " + safeGetJCRPath();
+ String msg = "failed to list the child properties of " + this;
log.debug(msg);
throw new RepositoryException(msg, ade);
}
@@ -3006,7 +2997,7 @@
if (m1.getDepth() == 0) {
// check existence
if (!srcSession.getItemManager().itemExists(getPrimaryPath())) {
- throw new ItemNotFoundException(safeGetJCRPath());
+ throw new ItemNotFoundException("Node not found: " + this);
} else {
return getPath();
}
@@ -3210,7 +3201,7 @@
void addShareParent(NodeId parentId) throws RepositoryException {
// verify that we're shareable
if (!isShareable()) {
- String msg = "Node at " + safeGetJCRPath() + " is not shareable.";
+ String msg = this + " is not shareable.";
log.debug(msg);
throw new RepositoryException(msg);
}
@@ -3291,14 +3282,14 @@
// check if checked out
if (!internalIsCheckedOut()) {
- String msg = safeGetJCRPath() + ": Node is already checked-in. ignoring.";
+ String msg = this + ": Node is already checked-in. ignoring.";
log.debug(msg);
return getBaseVersion();
}
// check for pending changes
if (hasPendingChanges()) {
- String msg = "Unable to checkin node. Node has pending changes: " + safeGetJCRPath();
+ String msg = "Unable to checkin node. Node has pending changes: " + this;
log.debug(msg);
throw new InvalidItemStateException(msg);
}
@@ -3328,7 +3319,7 @@
// check checked-out status
if (internalIsCheckedOut()) {
- String msg = safeGetJCRPath() + ": Node is already checked-out. ignoring.";
+ String msg = this + ": Node is already checked-out. ignoring.";
log.debug(msg);
return;
}
@@ -3562,7 +3553,9 @@
private void checkVersionable()
throws UnsupportedRepositoryOperationException, RepositoryException {
if (!isNodeType(NameConstants.MIX_VERSIONABLE)) {
- String msg = "Unable to perform versioning operation on non versionable node: " + safeGetJCRPath();
+ String msg =
+ "Unable to perform a versioning operation on"
+ + " a non versionable node: " + this;
log.debug(msg);
throw new UnsupportedRepositoryOperationException(msg);
}
@@ -3743,7 +3736,8 @@
failedIds.add(id);
return null;
} else {
- String msg = "Unable to merge nodes. Violating versions. " + safeGetJCRPath();
+ String msg =
+ "Unable to merge nodes. Violating versions. " + this;
log.debug(msg);
throw new MergeException(msg);
}
@@ -3761,7 +3755,8 @@
// check for pending changes
if (hasPendingChanges()) {
- String msg = "Unable to finish merge. Node has pending changes: " + safeGetJCRPath();
+ String msg =
+ "Unable to finish merge. Node has pending changes: " + this;
log.debug(msg);
throw new InvalidItemStateException(msg);
}
@@ -3774,7 +3769,7 @@
// check if checked out
if (!internalIsCheckedOut()) {
- String msg = "Unable to finish merge. Node is checked-in: " + safeGetJCRPath();
+ String msg = "Unable to finish merge. Node is checked-in: " + this;
log.error(msg);
throw new VersionException(msg);
}
@@ -3782,7 +3777,9 @@
// check if version is in mergeFailed list
Set failed = internalGetMergeFailed();
if (!failed.remove(version.getUUID())) {
- String msg = "Unable to finish merge. Specified version is not in jcr:mergeFailed property: " + safeGetJCRPath();
+ String msg =
+ "Unable to finish merge. Specified version is not in"
+ + " jcr:mergeFailed property: " + this;
log.error(msg);
throw new VersionException(msg);
}
@@ -4106,7 +4103,7 @@
} else if (replaceExisting) {
// node exists outside of this update tree, so continue there
} else {
- throw new ItemExistsException("Unable to update node: " + dstNode.safeGetJCRPath());
+ throw new ItemExistsException("Unable to update item: " + dstNode);
}
}
@@ -4223,14 +4220,14 @@
if (isNodeType(NameConstants.MIX_REFERENCEABLE)) {
UUID uuid = freeze.getFrozenUUID();
if (!internalGetUUID().equals(uuid)) {
- throw new ItemExistsException("Unable to restore version of " + safeGetJCRPath() + ". UUID changed.");
+ throw new ItemExistsException("Unable to restore version of " + this + ". UUID changed.");
}
}
// check primary type
if (!freeze.getFrozenPrimaryType().equals(data.getNodeState().getNodeTypeName())) {
// todo: check with spec what should happen here
- throw new ItemExistsException("Unable to restore version of " + safeGetJCRPath() + ". PrimaryType changed.");
+ throw new ItemExistsException("Unable to restore version of " + this + ". PrimaryType changed.");
}
// adjust mixins
@@ -4320,8 +4317,10 @@
} else {
// since we delete the OPV=Copy children beforehand, all
// found nodes must be outside of this tree
- throw new ItemExistsException("Unable to restore node, item already exists outside of restored tree: "
- + existing.safeGetJCRPath());
+ throw new ItemExistsException(
+ "Unable to restore node, item already"
+ + " exists outside of restored tree: "
+ + existing);
}
} catch (ItemNotFoundException e) {
// ignore, item with uuid does not exist
@@ -4352,8 +4351,9 @@
} else {
// since we delete the OPV=Copy children beforehand, all
// found nodes must be outside of this tree
- throw new ItemExistsException("Unable to restore node, item already exists outside of restored tree: "
- + n.safeGetJCRPath());
+ throw new ItemExistsException(
+ "Unable to restore node, item already exists"
+ + " outside of restored tree: " + n);
}
}
// get desired version from version selector
@@ -4384,8 +4384,8 @@
try {
restoredChild.internalRestore(v, vsel, removeExisting);
} catch (RepositoryException e) {
- log.error("Error while restoring node: " + e.toString());
- log.error(" child path: " + restoredChild.safeGetJCRPath());
+ log.error("Error while restoring node: " + e);
+ log.error(" child path: " + restoredChild);
log.error(" selected version: " + v.getName());
StringBuffer avail = new StringBuffer();
VersionIterator vi = history.getAllVersions();
@@ -4444,7 +4444,7 @@
// check for pending changes
if (hasPendingChanges()) {
- String msg = "Unable to lock node. Node has pending changes: " + safeGetJCRPath();
+ String msg = "Unable to lock node. Node has pending changes: " + this;
log.debug(msg);
throw new InvalidItemStateException(msg);
}
@@ -4492,7 +4492,7 @@
sanityCheck();
if (isNew()) {
- throw new LockException("Node not locked: " + safeGetJCRPath());
+ throw new LockException("New node can not be locked: " + this);
}
return session.getLockManager().getLock(this);
}
@@ -4509,7 +4509,7 @@
// check for pending changes
if (hasPendingChanges()) {
- String msg = "Unable to unlock node. Node has pending changes: " + safeGetJCRPath();
+ String msg = "Unable to unlock node. Node has pending changes: " + this;
log.debug(msg);
throw new InvalidItemStateException(msg);
}
@@ -4565,8 +4565,9 @@
*/
private void checkLockable() throws LockException, RepositoryException {
if (!isNodeType(NameConstants.MIX_LOCKABLE)) {
- String msg = "Unable to perform locking operation on non-lockable node: "
- + safeGetJCRPath();
+ String msg =
+ "Unable to perform a locking operation on"
+ + " a non-lockable node: " + this;
log.debug(msg);
throw new LockException(msg);
}
@@ -4733,14 +4734,14 @@
// make sure this node is checked-out
if (!internalIsCheckedOut()) {
- String msg = safeGetJCRPath() + ": cannot set primary type of a checked-in node";
+ String msg = this + ": cannot set primary type of a checked-in node";
log.debug(msg);
throw new VersionException(msg);
}
// check protected flag
if (data.getDefinition().isProtected()) {
- String msg = safeGetJCRPath() + ": cannot set primary type of a protected node";
+ String msg = this + ": cannot set primary type of a protected node";
log.debug(msg);
throw new ConstraintViolationException(msg);
}
@@ -4796,7 +4797,7 @@
NodeImpl parent = (NodeImpl) getParent();
defId = parent.getApplicableChildNodeDefinition(getQName(), ntName).unwrap().getId();
} catch (RepositoryException re) {
- String msg = safeGetJCRPath() + ": no applicable definition found in parent node's node type";
+ String msg = this + ": no applicable definition found in parent node's node type";
log.debug(msg);
throw new ConstraintViolationException(msg, re);
}
@@ -4954,4 +4955,16 @@
}
}
}
+
+ //--------------------------------------------------------------< Object >
+
+ /**
+ * Return a string representation of this node for diagnostic purposes.
+ *
+ * @return "node /path/to/item"
+ */
+ public String toString() {
+ return "node " + super.toString();
+ }
+
}
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java?rev=698402&r1=698401&r2=698402&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java Tue Sep 23 16:36:07 2008
@@ -110,7 +110,7 @@
protected void makePersistent() throws InvalidItemStateException {
if (!isTransient()) {
- log.debug(safeGetJCRPath() + " (" + id + "): there's no transient state to persist");
+ log.debug(this + " (" + id + "): there's no transient state to persist");
return;
}
@@ -124,8 +124,9 @@
synchronized (persistentState) {
// check staleness of transient state first
if (transientState.isStale()) {
- String msg = safeGetJCRPath()
- + ": the property cannot be saved because it has been modified externally.";
+ String msg =
+ this + ": the property cannot be saved because it has"
+ + " been modified externally.";
log.debug(msg);
throw new InvalidItemStateException(msg);
}
@@ -238,26 +239,28 @@
// verify that parent node is checked-out
if (!parent.internalIsCheckedOut()) {
- throw new VersionException("cannot set the value of a property of a checked-in node "
- + safeGetJCRPath());
+ throw new VersionException(
+ "Cannot set a property of a checked-in node: " + this);
}
// check protected flag
if (definition.isProtected()) {
- throw new ConstraintViolationException("cannot set the value of a protected property "
- + safeGetJCRPath());
+ throw new ConstraintViolationException(
+ "Cannot set the value of a protected property: " + this);
}
// check multi-value flag
if (multipleValues) {
if (!definition.isMultiple()) {
- throw new ValueFormatException(safeGetJCRPath()
- + " is not multi-valued");
+ throw new ValueFormatException(
+ "Single-valued property can not be set to"
+ + " an array of values: " + this);
}
} else {
if (definition.isMultiple()) {
- throw new ValueFormatException(safeGetJCRPath()
- + " is multi-valued and can therefore only be set to an array of values");
+ throw new ValueFormatException(
+ "Multivalued property can not be set to a single"
+ + " value (an array of lenght one is OK): " + this);
}
}
@@ -765,4 +768,15 @@
return (Node) itemMgr.getItem(getPropertyState().getParentId());
}
+ //--------------------------------------------------------------< Object >
+
+ /**
+ * Return a string representation of this property for diagnostic purposes.
+ *
+ * @return "property /path/to/item"
+ */
+ public String toString() {
+ return "property " + super.toString();
+ }
+
}
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java?rev=698402&r1=698401&r2=698402&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java Tue Sep 23 16:36:07 2008
@@ -1541,7 +1541,8 @@
// there's already a node with that name:
// check same-name sibling setting of existing node
if (!existing.getDefinition().allowsSameNameSiblings()) {
- throw new ItemExistsException(existing.safeGetJCRPath());
+ throw new ItemExistsException(
+ "Same name siblings are not allowed: " + existing);
}
} catch (AccessDeniedException ade) {
// FIXME by throwing ItemExistsException we're disclosing too much information
@@ -1567,7 +1568,8 @@
// existing node is not sufficient since same-name sibling nodes don't
// necessarily have identical definitions
if (existing != null && !newTargetDef.allowsSameNameSiblings()) {
- throw new ItemExistsException(existing.safeGetJCRPath());
+ throw new ItemExistsException(
+ "Same name siblings not allowed: " + existing);
}
// check protected flag of old & new parent
@@ -1621,7 +1623,7 @@
// change definition of target
targetNode.onRedefine(newTargetDef.unwrap().getId());
- return targetNode.safeGetJCRPath();
+ return targetNode.getPath();
}
//-------------------------------------------------------------< Dumpable >
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java?rev=698402&r1=698401&r2=698402&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java Tue Sep 23 16:36:07 2008
@@ -262,9 +262,10 @@
LockInfo other = (LockInfo) element.get();
if (other != null) {
if (element.hasPath(path)) {
- throw new LockException("Node already locked: " + node.safeGetJCRPath());
+ throw new LockException("Node already locked: " + node);
} else if (other.deep) {
- throw new LockException("Parent node has deep lock.");
+ throw new LockException(
+ "Parent node has a deep lock: " + node);
}
}
if (info.deep && element.hasPath(path)
@@ -315,17 +316,16 @@
SessionImpl session = (SessionImpl) node.getSession();
// check whether node is locked by this session
- PathMap.Element element = lockMap.map(
- getPath(node.getId()), true);
+ PathMap.Element element = lockMap.map(getPath(node.getId()), true);
if (element == null) {
- throw new LockException("Node not locked: " + node.safeGetJCRPath());
+ throw new LockException("Node not locked: " + node);
}
AbstractLockInfo info = (AbstractLockInfo) element.get();
if (info == null) {
- throw new LockException("Node not locked: " + node.safeGetJCRPath());
+ throw new LockException("Node not locked: " + node);
}
if (session != info.getLockHolder()) {
- throw new LockException("Node not locked by session: " + node.safeGetJCRPath());
+ throw new LockException("Node not locked by session: " + node);
}
session.removeLockToken(info.getLockToken(session), false);
@@ -421,17 +421,14 @@
PathMap.Element element = lockMap.map(path, false);
AbstractLockInfo info = (AbstractLockInfo) element.get();
- if (info == null) {
- throw new LockException("Node not locked: " + node.safeGetJCRPath());
- }
- if (element.hasPath(path) || info.deep) {
+ if (info != null && (element.hasPath(path) || info.deep)) {
Node lockHolder = (Node) session.getItemManager().getItem(info.getId());
return new LockImpl(info, lockHolder);
} else {
- throw new LockException("Node not locked: " + node.safeGetJCRPath());
+ throw new LockException("Node not locked: " + node);
}
} catch (ItemNotFoundException e) {
- throw new LockException("Node not locked: " + node.safeGetJCRPath());
+ throw new LockException("Node not locked: " + node);
} finally {
release();
}
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/XALockManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/XALockManager.java?rev=698402&r1=698401&r2=698402&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/XALockManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/XALockManager.java Tue Sep 23 16:36:07 2008
@@ -86,7 +86,7 @@
info = lockMgr.getLockInfo(node.getNodeId());
}
if (info == null) {
- throw new LockException("Node not locked: " + node.safeGetJCRPath());
+ throw new LockException("Node not locked: " + node);
}
SessionImpl session = (SessionImpl) node.getSession();
NodeImpl holder = (NodeImpl) session.getItemManager().getItem(info.getId());
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java?rev=698402&r1=698401&r2=698402&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java Tue Sep 23 16:36:07 2008
@@ -296,7 +296,7 @@
if (opv == OnParentVersionAction.ABORT) {
parent.reload();
- throw new VersionException("Checkin aborted due to OPV in " + prop.safeGetJCRPath());
+ throw new VersionException("Checkin aborted due to OPV in " + prop);
} else if (opv == OnParentVersionAction.VERSION
|| opv == OnParentVersionAction.COPY) {
// ignore frozen properties
@@ -320,7 +320,7 @@
}
if (opv == OnParentVersionAction.ABORT) {
- throw new VersionException("Checkin aborted due to OPV in " + child.safeGetJCRPath());
+ throw new VersionException("Checkin aborted due to OPV in " + child);
} else if (opv == OnParentVersionAction.VERSION) {
if (child.isNodeType(NameConstants.MIX_VERSIONABLE)) {
// create frozen versionable child
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java?rev=698402&r1=698401&r2=698402&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java Tue Sep 23 16:36:07 2008
@@ -269,7 +269,7 @@
* @throws javax.jcr.nodetype.ConstraintViolationException
*/
public void update(String srcWorkspaceName) throws ConstraintViolationException {
- String msg = "update operation not allowed on a version history node: " + safeGetJCRPath();
+ String msg = "update operation not allowed: " + this;
log.debug(msg);
throw new ConstraintViolationException(msg);
}
@@ -282,8 +282,21 @@
*/
public NodeIterator merge(String srcWorkspace, boolean bestEffort)
throws ConstraintViolationException {
- String msg = "merge operation not allowed on a version history node: " + safeGetJCRPath();
+ String msg = "merge operation not allowed: " + this;
log.debug(msg);
throw new ConstraintViolationException(msg);
}
+
+ //--------------------------------------------------------------< Object >
+
+ /**
+ * Return a string representation of this version history node
+ * for diagnostic purposes.
+ *
+ * @return "version history node /path/to/item"
+ */
+ public String toString() {
+ return "version history " + super.toString();
+ }
+
}
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionImpl.java?rev=698402&r1=698401&r2=698402&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionImpl.java Tue Sep 23 16:36:07 2008
@@ -169,7 +169,7 @@
* @throws javax.jcr.nodetype.ConstraintViolationException
*/
public void update(String srcWorkspaceName) throws ConstraintViolationException {
- String msg = "update operation not allowed on a version node: " + safeGetJCRPath();
+ String msg = "update operation not allowed: " + this;
log.debug(msg);
throw new ConstraintViolationException(msg);
}
@@ -182,9 +182,21 @@
*/
public NodeIterator merge(String srcWorkspace, boolean bestEffort)
throws ConstraintViolationException {
- String msg = "merge operation not allowed on a version node: " + safeGetJCRPath();
+ String msg = "merge operation not allowed: " + this;
log.debug(msg);
throw new ConstraintViolationException(msg);
}
+ //--------------------------------------------------------------< Object >
+
+ /**
+ * Return a string representation of this version node for diagnostic
+ * purposes.
+ *
+ * @return "version node /path/to/item"
+ */
+ public String toString() {
+ return "version " + super.toString();
+ }
+
}
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java?rev=698402&r1=698401&r2=698402&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java Tue Sep 23 16:36:07 2008
@@ -181,7 +181,7 @@
if (parent == null) {
// parent node was skipped, skip this child node too
parents.push(null); // push null onto stack for skipped node
- log.debug("skipping node " + nodeName);
+ log.debug("Skipping node: " + nodeName);
return;
}
if (parent.hasNode(nodeName)) {
@@ -194,7 +194,7 @@
if (def.isProtected() && existing.isNodeType(ntName)) {
// skip protected node
parents.push(null); // push null onto stack for skipped node
- log.debug("skipping protected node " + existing.safeGetJCRPath());
+ log.debug("Skipping protected node: " + existing);
return;
}
if (def.isAutoCreated() && existing.isNodeType(ntName)) {
@@ -206,7 +206,8 @@
if (!(existing.getId().equals(id)
&& (uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING
|| uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING))) {
- throw new ItemExistsException(existing.safeGetJCRPath());
+ throw new ItemExistsException(
+ "Node with the same UUID exists:" + existing);
}
// fall through
}