You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by mr...@apache.org on 2004/11/15 15:01:58 UTC
svn commit: rev 71503 - in incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core: . observation
Author: mreutegg
Date: Mon Nov 15 06:01:56 2004
New Revision: 71503
Modified:
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/Path.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/observation/EventConsumer.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/observation/EventImpl.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/observation/EventState.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
Log:
- ObservationManager failed to return correct paths for same name siblings (-> SelectClauseTest.testSameNameSibling() failed)
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/Path.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/Path.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/Path.java Mon Nov 15 06:01:56 2004
@@ -166,6 +166,26 @@
}
}
+ /**
+ * Creates a relative path based on a {@link QName} and an index.
+ * @param name single {@link QName} for this relative path.
+ * @param index index of the sinlge name element.
+ * @return the relative path created from <code>name</code>.
+ * @exception IllegalArgumentException if <code>index</code> is negative.
+ */
+ public static Path create(QName name, int index) {
+ if (index < 0) {
+ throw new IllegalArgumentException("index must not be negative: " + index);
+ }
+ PathElement elem;
+ if (index < 1) {
+ elem = new PathElement(name);
+ } else {
+ elem = new PathElement(name, index);
+ }
+ return new Path(new PathElement[]{elem});
+ }
+
//------------------------------------------------------< utility methods >
/**
* Checks if <code>jcrPath</code> is a valid JCR-style absolute or relative
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/observation/EventConsumer.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/observation/EventConsumer.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/observation/EventConsumer.java Mon Nov 15 06:01:56 2004
@@ -141,7 +141,7 @@
ItemId targetId;
if (state.getChildUUID() == null) {
// target is a property
- targetId = new PropertyId(state.getParentUUID(), state.getChildItemQName());
+ targetId = new PropertyId(state.getParentUUID(), state.getChildRelPath().getElements()[0].getName());
} else {
// target is a node
targetId = new NodeId(state.getChildUUID());
@@ -176,7 +176,7 @@
ItemId targetId;
if (state.getChildUUID() == null) {
// target is a property
- targetId = new PropertyId(state.getParentUUID(), state.getChildItemQName());
+ targetId = new PropertyId(state.getParentUUID(), state.getChildRelPath().getElements()[0].getName());
} else {
// target is a node
targetId = new NodeId(state.getChildUUID());
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/observation/EventImpl.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/observation/EventImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/observation/EventImpl.java Mon Nov 15 06:01:56 2004
@@ -80,7 +80,7 @@
*/
public String getPath() throws RepositoryException {
try {
- Path p = Path.create(eventState.getParentPath(), eventState.getChildItemQName(), false);
+ Path p = Path.create(eventState.getParentPath(), eventState.getChildRelPath(), false);
return p.toJCRPath(session.getNamespaceResolver());
} catch (MalformedPathException e) {
String msg = "internal error: malformed path for event";
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/observation/EventState.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/observation/EventState.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/observation/EventState.java Mon Nov 15 06:01:56 2004
@@ -16,7 +16,6 @@
package org.apache.jackrabbit.core.observation;
import org.apache.jackrabbit.core.Path;
-import org.apache.jackrabbit.core.QName;
import org.apache.jackrabbit.core.nodetype.NodeTypeImpl;
import javax.jcr.Session;
@@ -51,9 +50,10 @@
private final String childUUID;
/**
- * The qualified name of the child item associated with this event.
+ * The relative path of the child item associated with this event.
+ * This is basically the name of the item with an optional index.
*/
- private final QName childName;
+ private final Path childRelPath;
/**
* The node type of the parent node.
@@ -87,7 +87,7 @@
* If the event type is one of: <code>PROPERTY_ADDED</code>,
* <code>PROPERTY_CHANGED</code> or <code>PROPERTY_REMOVED</code>
* this parameter must be <code>null</code>.
- * @param childName the qualified name of the child item associated with
+ * @param childPath the relative path of the child item associated with
* this event.
* @param nodeType the node type of the parent node.
* @param session the {@link javax.jcr.Session} that caused this event.
@@ -96,7 +96,7 @@
String parentUUID,
Path parentPath,
String childUUID,
- QName childName,
+ Path childPath,
NodeTypeImpl nodeType,
Session session) {
int mask = (Event.PROPERTY_ADDED | Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED);
@@ -113,7 +113,7 @@
this.parentUUID = parentUUID;
this.parentPath = parentPath;
this.childUUID = childUUID;
- this.childName = childName;
+ this.childRelPath = childPath;
this.nodeType = nodeType;
this.session = session;
}
@@ -129,7 +129,7 @@
* @param parentPath the path of the parent node associated with
* this <code>EventState</code>.
* @param childUUID the uuid of the child node associated with this event.
- * @param childName the qualified name of the child node that was added.
+ * @param childPath the relative path of the child node that was added.
* @param nodeType the node type of the parent node.
* @param session the session that added the node.
* @return an <code>EventState</code> instance.
@@ -137,14 +137,14 @@
public static EventState childNodeAdded(String parentUUID,
Path parentPath,
String childUUID,
- QName childName,
+ Path childPath,
NodeTypeImpl nodeType,
Session session) {
return new EventState(Event.NODE_ADDED,
parentUUID,
parentPath,
childUUID,
- childName,
+ childPath,
nodeType,
session);
}
@@ -158,7 +158,7 @@
* @param parentPath the path of the parent node associated with
* this <code>EventState</code>.
* @param childUUID the uuid of the child node associated with this event.
- * @param childName the qualified name of the child node that was removed.
+ * @param childPath the relative path of the child node that was removed.
* @param nodeType the node type of the parent node.
* @param session the session that removed the node.
* @return an <code>EventState</code> instance.
@@ -166,14 +166,14 @@
public static EventState childNodeRemoved(String parentUUID,
Path parentPath,
String childUUID,
- QName childName,
+ Path childPath,
NodeTypeImpl nodeType,
Session session) {
return new EventState(Event.NODE_REMOVED,
parentUUID,
parentPath,
childUUID,
- childName,
+ childPath,
nodeType,
session);
}
@@ -186,21 +186,21 @@
* this <code>EventState</code>.
* @param parentPath the path of the parent node associated with
* this <code>EventState</code>.
- * @param childName the qualified name of the property that was added.
+ * @param childPath the relative path of the property that was added.
* @param nodeType the node type of the parent node.
* @param session the session that added the property.
* @return an <code>EventState</code> instance.
*/
public static EventState propertyAdded(String parentUUID,
Path parentPath,
- QName childName,
+ Path childPath,
NodeTypeImpl nodeType,
Session session) {
return new EventState(Event.PROPERTY_ADDED,
parentUUID,
parentPath,
null,
- childName,
+ childPath,
nodeType,
session);
}
@@ -213,21 +213,21 @@
* this <code>EventState</code>.
* @param parentPath the path of the parent node associated with
* this <code>EventState</code>.
- * @param childName the qualified name of the property that was removed.
+ * @param childPath the relative path of the property that was removed.
* @param nodeType the node type of the parent node.
* @param session the session that removed the property.
* @return an <code>EventState</code> instance.
*/
public static EventState propertyRemoved(String parentUUID,
Path parentPath,
- QName childName,
+ Path childPath,
NodeTypeImpl nodeType,
Session session) {
return new EventState(Event.PROPERTY_REMOVED,
parentUUID,
parentPath,
null,
- childName,
+ childPath,
nodeType,
session);
}
@@ -240,21 +240,21 @@
* this <code>EventState</code>.
* @param parentPath the path of the parent node associated with
* this <code>EventState</code>.
- * @param childName the qualified name of the property that changed.
+ * @param childPath the relative path of the property that changed.
* @param nodeType the node type of the parent node.
* @param session the session that changed the property.
* @return an <code>EventState</code> instance.
*/
public static EventState propertyChanged(String parentUUID,
Path parentPath,
- QName childName,
+ Path childPath,
NodeTypeImpl nodeType,
Session session) {
return new EventState(Event.PROPERTY_CHANGED,
parentUUID,
parentPath,
null,
- childName,
+ childPath,
nodeType,
session);
}
@@ -296,13 +296,13 @@
}
/**
- * Returns the {@link QName} of the
+ * Returns the relative {@link Path} of the child
* {@link javax.jcr.Item} associated with this event.
*
- * @return the <code>QName</code> associated with this event.
+ * @return the <code>Path</code> associated with this event.
*/
- public QName getChildItemQName() {
- return childName;
+ public Path getChildRelPath() {
+ return childRelPath;
}
/**
@@ -342,7 +342,7 @@
StringBuffer sb = new StringBuffer();
sb.append("EventState: ").append(valueOf(type));
sb.append(", Parent: ").append(parentUUID);
- sb.append(", Child: ").append(childName);
+ sb.append(", Child: ").append(childRelPath);
sb.append(", UserId: ").append(session.getUserId());
stringValue = sb.toString();
}
@@ -360,7 +360,7 @@
h = 37;
h = 37 * h + (int) type;
h = 37 * h + parentUUID.hashCode();
- h = 37 * h + childName.hashCode();
+ h = 37 * h + childRelPath.hashCode();
h = 37 * h + session.hashCode();
hashCode = h;
}
@@ -383,7 +383,7 @@
EventState other = (EventState) obj;
return this.type == other.type
&& this.parentUUID.equals(other.parentUUID)
- && this.childName.equals(other.childName)
+ && this.childRelPath.equals(other.childRelPath)
&& this.session.equals(other.session);
}
return false;
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/observation/EventStateCollection.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/observation/EventStateCollection.java Mon Nov 15 06:01:56 2004
@@ -120,7 +120,7 @@
NodeState.PropertyEntry prop = (NodeState.PropertyEntry) it.next();
events.add(EventState.propertyAdded(currentNode.getUUID(),
parentPath,
- prop.getName(),
+ Path.create(prop.getName(), 0),
nodeType,
session));
}
@@ -131,7 +131,7 @@
NodeState.PropertyEntry prop = (NodeState.PropertyEntry) it.next();
events.add(EventState.propertyRemoved(currentNode.getUUID(),
parentPath,
- prop.getName(),
+ Path.create(prop.getName(), 0),
nodeType,
session));
}
@@ -143,7 +143,7 @@
events.add(EventState.childNodeAdded(currentNode.getUUID(),
parentPath,
child.getUUID(),
- child.getName(),
+ Path.create(child.getName(), child.getIndex()),
nodeType,
session));
}
@@ -155,7 +155,7 @@
events.add(EventState.childNodeRemoved(currentNode.getUUID(),
parentPath,
child.getUUID(),
- child.getName(),
+ Path.create(child.getName(), child.getIndex()),
nodeType,
session));
}
@@ -168,7 +168,7 @@
Path parentPath = hmgr.getPath(parentId);
events.add(EventState.propertyChanged(state.getParentUUID(),
parentPath,
- ((PropertyState) state).getName(),
+ Path.create(((PropertyState) state).getName(), 0),
session.getNodeTypeManager().getNodeType(parentState.getNodeTypeName()),
session));
} catch (ItemStateException e) {
@@ -194,7 +194,7 @@
events.add(EventState.childNodeRemoved(currentNode.getUUID(),
parentPaths[i],
child.getUUID(),
- child.getName(),
+ Path.create(child.getName(), child.getIndex()),
nodeType,
session));
}