You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by st...@apache.org on 2005/02/02 11:27:49 UTC
svn commit: r149506 - in
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core:
ItemImpl.java NodeImpl.java PropertyImpl.java SessionImpl.java
WorkspaceImpl.java
Author: stefan
Date: Wed Feb 2 02:27:46 2005
New Revision: 149506
URL: http://svn.apache.org/viewcvs?view=rev&rev=149506
Log:
fixed checking checked-out status according to spec
Modified:
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SessionImpl.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/WorkspaceImpl.java
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java?view=diff&r1=149505&r2=149506
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java Wed Feb 2 02:27:46 2005
@@ -1110,8 +1110,8 @@
NodeImpl parentNode = (NodeImpl) getParent();
- // check if versioning allows write (only cheap call)
- if (!parentNode.isCheckedOut(false)) {
+ // verify that parent node is checked-out
+ if (!parentNode.internalIsCheckedOut()) {
String msg = parentNode.safeGetJCRPath() + ": cannot remove a child of a checked-in node";
log.error(msg);
throw new VersionException(msg);
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java?view=diff&r1=149505&r2=149506
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java Wed Feb 2 02:27:46 2005
@@ -1,6 +1,6 @@
/*
* Copyright 2004-2005 The Apache Software Foundation or its licensors,
- * as applicable.
+ * as applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -348,8 +348,8 @@
log.error(msg);
throw new RepositoryException(msg);
}
- // check if versioning allows write (only cheap call)
- if (!isCheckedOut(false)) {
+ // make sure this node is checked-out
+ if (!internalIsCheckedOut()) {
String msg = "Cannot set the value of a property of a checked-in node " + safeGetJCRPath() + "/" + name.toString();
log.error(msg);
throw new VersionException(msg);
@@ -830,6 +830,41 @@
}
/**
+ * Same as {@link Node#isNodeType(String)}, but takes a <code>QName</code>
+ * instad of a <code>String</code>.
+ * @param ntName name of node type
+ * @return <code>true</code> if this node is of the specified node type;
+ * otherwise <code>false</code>
+ */
+ public boolean isNodeType(QName ntName) throws RepositoryException {
+ // no need to perform sanity check; assume this has
+ // already been done by calling method
+
+ if (ntName.equals(nodeType.getQName())) {
+ return true;
+ }
+
+ if (nodeType.isDerivedFrom(ntName)) {
+ return true;
+ }
+
+ // check mixin types
+ Set mixinNames = ((NodeState) state).getMixinTypeNames();
+ if (mixinNames.isEmpty()) {
+ return false;
+ }
+ NodeTypeRegistry ntReg = session.getNodeTypeManager().getNodeTypeRegistry();
+ try {
+ EffectiveNodeType ent = ntReg.getEffectiveNodeType((QName[]) mixinNames.toArray(new QName[mixinNames.size()]));
+ return ent.includesNodeType(ntName);
+ } catch (NodeTypeConflictException ntce) {
+ String msg = "internal error: invalid mixin node type(s)";
+ log.error(msg, ntce);
+ throw new RepositoryException(msg, ntce);
+ }
+ }
+
+ /**
* Returns the (internal) uuid of this node.
* @return the uuid of this node
*/
@@ -1278,8 +1313,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write (only cheap call)
- if (!isCheckedOut(false)) {
+ // make sure this node is checked-out
+ if (!internalIsCheckedOut()) {
String msg = safeGetJCRPath() + ": cannot add a child to a checked-in node";
log.error(msg);
throw new VersionException(msg);
@@ -1298,8 +1333,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write (only cheap call)
- if (!isCheckedOut(false)) {
+ // make sure this node is checked-out
+ if (!internalIsCheckedOut()) {
String msg = safeGetJCRPath() + ": cannot add a child to a checked-in node";
log.error(msg);
throw new VersionException(msg);
@@ -1366,8 +1401,8 @@
throw new ItemNotFoundException(safeGetJCRPath() + " has no child node with name " + destName);
}
- // check if versioning allows write (only cheap call)
- if (!isCheckedOut(false)) {
+ // make sure this node is checked-out
+ if (!internalIsCheckedOut()) {
String msg = safeGetJCRPath() + ": cannot change child node ordering of a checked-in node";
log.error(msg);
throw new VersionException(msg);
@@ -1461,8 +1496,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write (only cheap call)
- if (!isCheckedOut(false)) {
+ // make sure this node is checked-out
+ if (!internalIsCheckedOut()) {
String msg = safeGetJCRPath() + ": cannot set property of a checked-in node";
log.error(msg);
throw new VersionException(msg);
@@ -1501,8 +1536,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write (only cheap call)
- if (!isCheckedOut(false)) {
+ // make sure this node is checked-out
+ if (!internalIsCheckedOut()) {
String msg = safeGetJCRPath() + ": cannot set property of a checked-in node";
log.error(msg);
throw new VersionException(msg);
@@ -1532,8 +1567,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write (only cheap call)
- if (!isCheckedOut(false)) {
+ // make sure this node is checked-out
+ if (!internalIsCheckedOut()) {
String msg = safeGetJCRPath() + ": cannot set property of a checked-in node";
log.error(msg);
throw new VersionException(msg);
@@ -1563,8 +1598,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write (only cheap call)
- if (!isCheckedOut(false)) {
+ // make sure this node is checked-out
+ if (!internalIsCheckedOut()) {
String msg = safeGetJCRPath() + ": cannot set property of a checked-in node";
log.error(msg);
throw new VersionException(msg);
@@ -1596,8 +1631,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write (only cheap call)
- if (!isCheckedOut(false)) {
+ // make sure this node is checked-out
+ if (!internalIsCheckedOut()) {
String msg = safeGetJCRPath() + ": cannot set property of a checked-in node";
log.error(msg);
throw new VersionException(msg);
@@ -1627,8 +1662,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write (only cheap call)
- if (!isCheckedOut(false)) {
+ // make sure this node is checked-out
+ if (!internalIsCheckedOut()) {
String msg = safeGetJCRPath() + ": cannot set property of a checked-in node";
log.error(msg);
throw new VersionException(msg);
@@ -1658,8 +1693,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write (only cheap call)
- if (!isCheckedOut(false)) {
+ // make sure this node is checked-out
+ if (!internalIsCheckedOut()) {
String msg = safeGetJCRPath() + ": cannot set property of a checked-in node";
log.error(msg);
throw new VersionException(msg);
@@ -1689,8 +1724,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write (only cheap call)
- if (!isCheckedOut(false)) {
+ // make sure this node is checked-out
+ if (!internalIsCheckedOut()) {
String msg = safeGetJCRPath() + ": cannot set property of a checked-in node";
log.error(msg);
throw new VersionException(msg);
@@ -1720,8 +1755,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write (only cheap call)
- if (!isCheckedOut(false)) {
+ // make sure this node is checked-out
+ if (!internalIsCheckedOut()) {
String msg = safeGetJCRPath() + ": cannot set property of a checked-in node";
log.error(msg);
throw new VersionException(msg);
@@ -1751,8 +1786,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write (only cheap call)
- if (!isCheckedOut(false)) {
+ // make sure this node is checked-out
+ if (!internalIsCheckedOut()) {
String msg = safeGetJCRPath() + ": cannot set property of a checked-in node";
log.error(msg);
throw new VersionException(msg);
@@ -1974,38 +2009,6 @@
}
/**
- * @see Node#isNodeType(String)
- */
- public boolean isNodeType(QName ntName) throws RepositoryException {
- // check state of this instance
- sanityCheck();
-
- if (ntName.equals(nodeType.getQName())) {
- return true;
- }
-
- if (nodeType.isDerivedFrom(ntName)) {
- return true;
- }
-
- // check mixin types
- Set mixinNames = ((NodeState) state).getMixinTypeNames();
- if (mixinNames.isEmpty()) {
- return false;
- }
- NodeTypeRegistry ntReg = session.getNodeTypeManager().getNodeTypeRegistry();
- try {
- EffectiveNodeType ent = ntReg.getEffectiveNodeType((QName[]) mixinNames.toArray(new QName[mixinNames.size()]));
- return ent.includesNodeType(ntName);
- } catch (NodeTypeConflictException ntce) {
- String msg = "internal error: invalid mixin node type(s)";
- log.error(msg, ntce);
- throw new RepositoryException(msg, ntce);
- }
- }
-
-
- /**
* @see Node#getPrimaryNodeType()
*/
public NodeType getPrimaryNodeType() throws RepositoryException {
@@ -2038,8 +2041,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write
- if (!isCheckedOut(true)) {
+ // make sure this node is checked-out
+ if (!internalIsCheckedOut()) {
String msg = safeGetJCRPath() + ": cannot add a mixin node type to a checked-in node";
log.error(msg);
throw new VersionException(msg);
@@ -2147,8 +2150,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write
- if (!isCheckedOut(true)) {
+ // make sure this node is checked-out
+ if (!internalIsCheckedOut()) {
String msg = safeGetJCRPath() + ": cannot remove a mixin node type from a checked-in node";
log.error(msg);
throw new VersionException(msg);
@@ -2264,8 +2267,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write
- if (!isCheckedOut(true)) {
+ // check checked-out status
+ if (!internalIsCheckedOut()) {
return false;
}
@@ -2544,8 +2547,8 @@
// check if versionable
checkVersionable();
- // check if already checked out
- if (isCheckedOut(false)) {
+ // check checked-out status
+ if (internalIsCheckedOut()) {
String msg = safeGetJCRPath() + ": Node is already checked-out. ignoring.";
log.debug(msg);
return;
@@ -2701,7 +2704,7 @@
// check state of this instance
sanityCheck();
- return isCheckedOut(true);
+ return internalIsCheckedOut();
}
/**
@@ -2980,18 +2983,20 @@
}
/**
- * Same as {@link Node#isCheckedOut()} but if <code>inherit</code>
- * is <code>true</code>, a non-versionable node will return the checked out
- * state of its parent.
- *
- * @param inherit
+ * Determines the checked-out status of this node.
+ * @return a boolean
* @see Node#isCheckedOut()
*/
- protected boolean isCheckedOut(boolean inherit) throws RepositoryException {
+ protected boolean internalIsCheckedOut() throws RepositoryException {
// search nearest ancestor that is versionable
+ /**
+ * FIXME should not only rely on existence of jcr:isCheckedOut property
+ * but also verify that node.isNodeType("mix:versionable")==true;
+ * this would have a negative impact on performance though...
+ */
NodeImpl node = this;
while (!node.hasProperty(VersionManager.PROPNAME_IS_CHECKED_OUT)) {
- if (!inherit || node.isRepositoryRoot()) {
+ if (node.isRepositoryRoot()) {
return true;
}
node = (NodeImpl) node.getParent();
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java?view=diff&r1=149505&r2=149506
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java Wed Feb 2 02:27:46 2005
@@ -182,8 +182,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write
- if (!((NodeImpl) getParent()).isCheckedOut(false)) { // only cheap call yet
+ // verify that parent node is checked-out
+ if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
throw new VersionException("cannot set the value of a property of a checked-in node " + safeGetJCRPath());
}
@@ -235,8 +235,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write
- if (!((NodeImpl) getParent()).isCheckedOut(false)) { // only cheap call yet
+ // verify that parent node is checked-out
+ if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
throw new VersionException("cannot set the value of a property of a checked-in node " + safeGetJCRPath());
}
@@ -527,8 +527,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write
- if (!((NodeImpl) getParent()).isCheckedOut(false)) { // only cheap call yet
+ // verify that parent node is checked-out
+ if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
throw new VersionException("cannot set the value of a property of a checked-in node " + safeGetJCRPath());
}
@@ -574,8 +574,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write
- if (!((NodeImpl) getParent()).isCheckedOut(false)) { // only cheap call yet
+ // verify that parent node is checked-out
+ if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
throw new VersionException("cannot set the value of a property of a checked-in node " + safeGetJCRPath());
}
@@ -616,8 +616,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write
- if (!((NodeImpl) getParent()).isCheckedOut(false)) { // only cheap call yet
+ // verify that parent node is checked-out
+ if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
throw new VersionException("cannot set the value of a property of a checked-in node " + safeGetJCRPath());
}
@@ -669,8 +669,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write
- if (!((NodeImpl) getParent()).isCheckedOut(false)) { // only cheap call yet
+ // verify that parent node is checked-out
+ if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
throw new VersionException("cannot set the value of a property of a checked-in node " + safeGetJCRPath());
}
@@ -715,8 +715,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write
- if (!((NodeImpl) getParent()).isCheckedOut(false)) { // only cheap call yet
+ // verify that parent node is checked-out
+ if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
throw new VersionException("cannot set the value of a property of a checked-in node " + safeGetJCRPath());
}
@@ -768,8 +768,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write
- if (!((NodeImpl) getParent()).isCheckedOut(false)) { // only cheap call yet
+ // verify that parent node is checked-out
+ if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
throw new VersionException("cannot set the value of a property of a checked-in node " + safeGetJCRPath());
}
@@ -810,8 +810,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write
- if (!((NodeImpl) getParent()).isCheckedOut(false)) { // only cheap call yet
+ // verify that parent node is checked-out
+ if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
throw new VersionException("cannot set the value of a property of a checked-in node " + safeGetJCRPath());
}
@@ -864,8 +864,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write
- if (!((NodeImpl) getParent()).isCheckedOut(false)) { // only cheap call yet
+ // verify that parent node is checked-out
+ if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
throw new VersionException("cannot set the value of a property of a checked-in node " + safeGetJCRPath());
}
@@ -906,8 +906,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write
- if (!((NodeImpl) getParent()).isCheckedOut(false)) { // only cheap call yet
+ // verify that parent node is checked-out
+ if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
String msg = "cannot set the value of a property of a checked-in node " + safeGetJCRPath();
log.error(msg);
throw new VersionException(msg);
@@ -954,8 +954,8 @@
// check state of this instance
sanityCheck();
- // check if versioning allows write
- if (!((NodeImpl) getParent()).isCheckedOut(false)) { // only cheap call yet
+ // verify that parent node is checked-out
+ if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
throw new VersionException("cannot set the value of a property of a checked-in node " + safeGetJCRPath());
}
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SessionImpl.java?view=diff&r1=149505&r2=149506
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SessionImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SessionImpl.java Wed Feb 2 02:27:46 2005
@@ -829,8 +829,8 @@
}
NodeImpl parent = (NodeImpl) item;
- // check if versioning allows write (only cheap call)
- if (!parent.isCheckedOut(false)) {
+ // verify that parent node is checked-out
+ if (!parent.internalIsCheckedOut()) {
String msg = parentAbsPath + ": cannot add a child to a checked-in node";
log.error(msg);
throw new VersionException(msg);
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/WorkspaceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/WorkspaceImpl.java?view=diff&r1=149505&r2=149506
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/WorkspaceImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/WorkspaceImpl.java Wed Feb 2 02:27:46 2005
@@ -112,7 +112,7 @@
return rep;
}
- public LocalItemStateManager getItemStateManager() {
+ LocalItemStateManager getItemStateManager() {
return stateMgr;
}