You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by tr...@apache.org on 2006/02/16 11:48:29 UTC
svn commit: r378221 [4/7] - in /incubator/jackrabbit/trunk: contrib/
contrib/bdb-persistence/
contrib/bdb-persistence/src/java/org/apache/jackrabbit/core/state/bdb/
contrib/jca/ contrib/jcr-server/ contrib/jcrtaglib/ contrib/nt-ns-util/
contrib/orm-per...
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/QueryHandlerContext.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/QueryHandlerContext.java?rev=378221&r1=378220&r2=378221&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/QueryHandlerContext.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/QueryHandlerContext.java Thu Feb 16 02:48:20 2006
@@ -19,6 +19,7 @@
import org.apache.jackrabbit.core.fs.FileSystem;
import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
import org.apache.jackrabbit.core.state.ItemStateManager;
+import org.apache.jackrabbit.core.NodeId;
/**
* Acts as an argument for the {@link QueryHandler} to keep the interface
@@ -43,9 +44,9 @@
private final NodeTypeRegistry ntRegistry;
/**
- * The UUID of the root node.
+ * The id of the root node.
*/
- private String rootUUID;
+ private NodeId rootId;
/**
* PropertyType registry to look up the type of a property with a given name.
@@ -58,9 +59,9 @@
private final QueryHandler parentHandler;
/**
- * UUID of the node that should be excluded from indexing.
+ * id of the node that should be excluded from indexing.
*/
- private final String excludedNodeUUID;
+ private final NodeId excludedNodeId;
/**
* Creates a new context instance.
@@ -70,27 +71,27 @@
* <code>FileSystem</code> has been configured
* <code>fs</code> is <code>null</code>.
* @param stateMgr provides persistent item states.
- * @param rootUUID the uuid of the root node.
+ * @param rootId the id of the root node.
* @param ntRegistry the node type registry.
* @param parentHandler the parent query handler or <code>null</code> it
* there is no parent handler.
- * @param excludedNodeUUID uuid of the node that should be excluded from
+ * @param excludedNodeId id of the node that should be excluded from
* indexing. Any descendant of that node is also
* excluded from indexing.
*/
public QueryHandlerContext(FileSystem fs,
ItemStateManager stateMgr,
- String rootUUID,
+ NodeId rootId,
NodeTypeRegistry ntRegistry,
QueryHandler parentHandler,
- String excludedNodeUUID) {
+ NodeId excludedNodeId) {
this.fs = fs;
this.stateMgr = stateMgr;
- this.rootUUID = rootUUID;
+ this.rootId = rootId;
this.ntRegistry = ntRegistry;
propRegistry = new PropertyTypeRegistry(ntRegistry);
this.parentHandler = parentHandler;
- this.excludedNodeUUID = excludedNodeUUID;
+ this.excludedNodeId = excludedNodeId;
ntRegistry.addListener(propRegistry);
}
@@ -118,11 +119,11 @@
}
/**
- * Returns the UUID of the root node.
- * @return the UUID of the root node.
+ * Returns the id of the root node.
+ * @return the idof the root node.
*/
- public String getRootUUID() {
- return rootUUID;
+ public NodeId getRootId() {
+ return rootId;
}
/**
@@ -150,13 +151,13 @@
}
/**
- * Returns the uuid of the node that should be excluded from indexing. Any
+ * Returns the id of the node that should be excluded from indexing. Any
* descendant of this node is also excluded from indexing.
*
* @return the uuid of the exluded node.
*/
- public String getExcludedNodeUUID() {
- return excludedNodeUUID;
+ public NodeId getExcludedNodeId() {
+ return excludedNodeId;
}
/**
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java?rev=378221&r1=378220&r2=378221&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java Thu Feb 16 02:48:20 2006
@@ -334,10 +334,10 @@
if (position != LocationStepQueryNode.NONE) {
for (int i = hits.nextSetBit(0); i >= 0; i = hits.nextSetBit(i + 1)) {
Document node = reader.document(i);
- String parentUUID = node.get(FieldNames.PARENT);
- String uuid = node.get(FieldNames.UUID);
+ NodeId parentId = NodeId.valueOf(node.get(FieldNames.PARENT));
+ NodeId id = NodeId.valueOf(node.get(FieldNames.UUID));
try {
- NodeState state = (NodeState) itemMgr.getItemState(new NodeId(parentUUID));
+ NodeState state = (NodeState) itemMgr.getItemState(parentId);
if (nameTest == null) {
// only select this node if it is the child at
// specified position
@@ -346,14 +346,14 @@
List childNodes = state.getChildNodeEntries();
if (childNodes.size() == 0
|| !((NodeState.ChildNodeEntry) childNodes.get(childNodes.size() - 1))
- .getUUID().equals(uuid)) {
+ .getId().equals(id)) {
hits.flip(i);
}
} else {
List childNodes = state.getChildNodeEntries();
if (position < 1
|| childNodes.size() < position
- || !((NodeState.ChildNodeEntry) childNodes.get(position - 1)).getUUID().equals(uuid)) {
+ || !((NodeState.ChildNodeEntry) childNodes.get(position - 1)).getId().equals(id)) {
hits.flip(i);
}
}
@@ -363,7 +363,7 @@
if (position == LocationStepQueryNode.LAST) {
// only select last
NodeState.ChildNodeEntry entry =
- state.getChildNodeEntry(uuid);
+ state.getChildNodeEntry(id);
if (entry == null) {
// no such child node, probably deleted meanwhile
hits.flip(i);
@@ -373,13 +373,13 @@
List childNodes = state.getChildNodeEntries(name);
if (childNodes.size() == 0
|| !((NodeState.ChildNodeEntry) childNodes.get(childNodes.size() - 1))
- .getUUID().equals(uuid)) {
+ .getId().equals(id)) {
hits.flip(i);
}
}
} else {
NodeState.ChildNodeEntry entry =
- state.getChildNodeEntry(uuid);
+ state.getChildNodeEntry(id);
if (entry == null) {
// no such child node, probably has been deleted meanwhile
hits.flip(i);
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java?rev=378221&r1=378220&r2=378221&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java Thu Feb 16 02:48:20 2006
@@ -161,7 +161,7 @@
}
Document d = reader.document(i);
String uuid = d.get(FieldNames.UUID);
- if (stateMgr.hasItemState(new NodeId(uuid))) {
+ if (stateMgr.hasItemState(NodeId.valueOf(uuid))) {
Document old = (Document) documents.put(uuid, d);
if (old != null) {
multipleEntries.add(uuid);
@@ -188,7 +188,7 @@
continue;
}
// parent is missing
- NodeId parentId = new NodeId(parentUUID);
+ NodeId parentId = NodeId.valueOf(parentUUID);
if (stateMgr.hasItemState(parentId)) {
errors.add(new MissingAncestor(uuid, parentUUID));
} else {
@@ -206,14 +206,14 @@
*/
private String getPath(NodeState node) {
// remember as fallback
- String uuid = node.getUUID();
+ String uuid = node.getNodeId().toString();
StringBuffer path = new StringBuffer();
List elements = new ArrayList();
try {
- while (node.getParentUUID() != null) {
- NodeId parentId = new NodeId(node.getParentUUID());
+ while (node.getParentId() != null) {
+ NodeId parentId = node.getParentId();
NodeState parent = (NodeState) stateMgr.getItemState(parentId);
- NodeState.ChildNodeEntry entry = parent.getChildNodeEntry(node.getUUID());
+ NodeState.ChildNodeEntry entry = parent.getChildNodeEntry(node.getNodeId());
elements.add(entry);
node = parent;
}
@@ -263,12 +263,12 @@
String pUUID = parentUUID;
while (pUUID != null && !documents.containsKey(pUUID)) {
try {
- NodeState n = (NodeState) stateMgr.getItemState(new NodeId(pUUID));
+ NodeState n = (NodeState) stateMgr.getItemState(NodeId.valueOf(pUUID));
log.info("Reparing missing node " + getPath(n));
Document d = index.createDocument(n);
index.addDocument(d);
- documents.put(n.getUUID(), d);
- pUUID = n.getParentUUID();
+ documents.put(n.getNodeId().toString(), d);
+ pUUID = n.getParentId().toString();
} catch (ItemStateException e) {
throw new IOException(e.toString());
} catch (RepositoryException e) {
@@ -331,11 +331,11 @@
index.removeAllDocuments(id);
// then re-index the node
try {
- NodeState node = (NodeState) stateMgr.getItemState(new NodeId(uuid));
+ NodeState node = (NodeState) stateMgr.getItemState(NodeId.valueOf(uuid));
log.info("Re-indexing duplicate node occurrences in index: " + getPath(node));
Document d = index.createDocument(node);
index.addDocument(d);
- documents.put(node.getUUID(), d);
+ documents.put(node.getNodeId().toString(), d);
} catch (ItemStateException e) {
throw new IOException(e.toString());
} catch (RepositoryException e) {
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/DocOrderNodeIteratorImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/DocOrderNodeIteratorImpl.java?rev=378221&r1=378220&r2=378221&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/DocOrderNodeIteratorImpl.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/DocOrderNodeIteratorImpl.java Thu Feb 16 02:48:20 2006
@@ -41,8 +41,8 @@
/** A node iterator with ordered nodes */
private NodeIteratorImpl orderedNodes;
- /** The UUIDs of the nodes in the result set */
- protected String[] uuids;
+ /** The DIs of the nodes in the result set */
+ protected NodeId[] ids;
/** The score values for the nodes in the result set */
protected Float[] scores;
@@ -54,12 +54,12 @@
* Creates a <code>DocOrderNodeIteratorImpl</code> that orders the nodes
* with <code>uuids</code> in document order.
* @param itemMgr the item manager of the session executing the query.
- * @param uuids the uuids of the nodes.
+ * @param ids the uuids of the nodes.
* @param scores the score values of the nodes.
*/
- DocOrderNodeIteratorImpl(final ItemManager itemMgr, String[] uuids, Float[] scores) {
+ DocOrderNodeIteratorImpl(final ItemManager itemMgr, NodeId[] ids, Float[] scores) {
this.itemMgr = itemMgr;
- this.uuids = uuids;
+ this.ids = ids;
this.scores = scores;
}
@@ -116,7 +116,7 @@
if (orderedNodes != null) {
return orderedNodes.getSize();
} else {
- return uuids.length;
+ return ids.length;
}
}
@@ -154,24 +154,24 @@
return;
}
long time = System.currentTimeMillis();
- ScoreNode[] nodes = new ScoreNode[uuids.length];
- for (int i = 0; i < uuids.length; i++) {
- nodes[i] = new ScoreNode(uuids[i], scores[i]);
+ ScoreNode[] nodes = new ScoreNode[ids.length];
+ for (int i = 0; i < ids.length; i++) {
+ nodes[i] = new ScoreNode(ids[i], scores[i]);
}
- final List invalidUUIDs = new ArrayList(2);
+ final List invalidIDs = new ArrayList(2);
do {
- if (invalidUUIDs.size() > 0) {
+ if (invalidIDs.size() > 0) {
// previous sort run was not successful -> remove failed uuids
List tmp = new ArrayList();
for (int i = 0; i < nodes.length; i++) {
- if (!invalidUUIDs.contains(nodes[i].uuid)) {
+ if (!invalidIDs.contains(nodes[i].id)) {
tmp.add(nodes[i]);
}
}
nodes = (ScoreNode[]) tmp.toArray(new ScoreNode[tmp.size()]);
- invalidUUIDs.clear();
+ invalidIDs.clear();
}
try {
@@ -183,20 +183,20 @@
try {
NodeImpl node1;
try {
- node1 = (NodeImpl) itemMgr.getItem(new NodeId(n1.uuid));
+ node1 = (NodeImpl) itemMgr.getItem(n1.id);
} catch (RepositoryException e) {
- log.warn("Node " + n1.uuid + " does not exist anymore: " + e);
+ log.warn("Node " + n1.id + " does not exist anymore: " + e);
// node does not exist anymore
- invalidUUIDs.add(n1.uuid);
+ invalidIDs.add(n1.id);
throw new SortFailedException();
}
NodeImpl node2;
try {
- node2 = (NodeImpl) itemMgr.getItem(new NodeId(n2.uuid));
+ node2 = (NodeImpl) itemMgr.getItem(n2.id);
} catch (RepositoryException e) {
- log.warn("Node " + n2.uuid + " does not exist anymore: " + e);
+ log.warn("Node " + n2.id + " does not exist anymore: " + e);
// node does not exist anymore
- invalidUUIDs.add(n2.uuid);
+ invalidIDs.add(n2.id);
throw new SortFailedException();
}
Path.PathElement[] path1 = node1.getPrimaryPath().getElements();
@@ -245,8 +245,8 @@
}
// if we get here something went wrong
// remove both uuids from array
- invalidUUIDs.add(n1.uuid);
- invalidUUIDs.add(n2.uuid);
+ invalidIDs.add(n1.id);
+ invalidIDs.add(n2.id);
// terminate sorting
throw new SortFailedException();
}
@@ -255,22 +255,22 @@
// retry
}
- } while (invalidUUIDs.size() > 0);
+ } while (invalidIDs.size() > 0);
// resize uuids and scores array if we had to remove some uuids
- if (uuids.length != nodes.length) {
- uuids = new String[nodes.length];
+ if (ids.length != nodes.length) {
+ ids = new NodeId[nodes.length];
scores = new Float[nodes.length];
}
for (int i = 0; i < nodes.length; i++) {
- uuids[i] = nodes[i].uuid;
+ ids[i] = nodes[i].id;
scores[i] = nodes[i].score;
}
if (log.isDebugEnabled()) {
- log.debug("" + uuids.length + " node(s) ordered in " + (System.currentTimeMillis() - time) + " ms");
+ log.debug("" + ids.length + " node(s) ordered in " + (System.currentTimeMillis() - time) + " ms");
}
- orderedNodes = new NodeIteratorImpl(itemMgr, uuids, scores);
+ orderedNodes = new NodeIteratorImpl(itemMgr, ids, scores);
}
/**
@@ -278,12 +278,12 @@
*/
private static final class ScoreNode {
- final String uuid;
+ final NodeId id;
final Float score;
- ScoreNode(String uuid, Float score) {
- this.uuid = uuid;
+ ScoreNode(NodeId id, Float score) {
+ this.id = id;
this.score = score;
}
}
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java?rev=378221&r1=378220&r2=378221&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java Thu Feb 16 02:48:20 2006
@@ -178,9 +178,9 @@
private final RedoLog redoLog;
/**
- * Set<String> of uuids that should not be indexed.
+ * Set<NodeId> of uuids that should not be indexed.
*/
- private final Set excludedUUIDs;
+ private final Set excludedIDs;
/**
* The next transaction id.
@@ -198,22 +198,22 @@
* @param indexDir the base file system
* @param handler the search handler
* @param stateMgr shared item state manager
- * @param rootUUID uuid of the root node
- * @param excludedUUIDs Set<String> that contains uuids that should not
+ * @param rootId id of the root node
+ * @param excludedIDs Set<NodeId> that contains uuids that should not
* be indexed nor further traversed.
* @throws IOException if an error occurs
*/
MultiIndex(File indexDir,
SearchIndex handler,
ItemStateManager stateMgr,
- String rootUUID,
- Set excludedUUIDs) throws IOException {
+ NodeId rootId,
+ Set excludedIDs) throws IOException {
this.indexDir = indexDir;
this.handler = handler;
this.cache = new DocNumberCache(handler.getCacheSize());
- this.redoLog = new RedoLog(new File(indexDir, REDO_LOG));
- this.excludedUUIDs = new HashSet(excludedUUIDs);
+ this.redoLog = new RedoLog(new File(indexDir, REDO_LOG));
+ this.excludedIDs = new HashSet(excludedIDs);
if (indexNames.exists(indexDir)) {
indexNames.read(indexDir);
@@ -273,7 +273,7 @@
if (indexNames.size() == 0) {
// traverse and index workspace
executeAndLog(new Start(Action.INTERNAL_TRANSACTION));
- NodeState rootState = (NodeState) stateMgr.getItemState(new NodeId(rootUUID));
+ NodeState rootState = (NodeState) stateMgr.getItemState(rootId);
createIndex(rootState, stateMgr);
executeAndLog(new Commit(getTransactionId()));
}
@@ -837,16 +837,16 @@
*/
private void createIndex(NodeState node, ItemStateManager stateMgr)
throws IOException, ItemStateException, RepositoryException {
- String uuid = node.getId().toString();
- if (excludedUUIDs.contains(uuid)) {
+ NodeId id = node.getNodeId();
+ if (excludedIDs.contains(id)) {
return;
}
- executeAndLog(new AddNode(getTransactionId(), uuid));
+ executeAndLog(new AddNode(getTransactionId(), id.getUUID().toString()));
checkVolatileCommit();
List children = node.getChildNodeEntries();
for (Iterator it = children.iterator(); it.hasNext();) {
NodeState.ChildNodeEntry child = (NodeState.ChildNodeEntry) it.next();
- NodeState childState = (NodeState) stateMgr.getItemState(new NodeId(child.getUUID()));
+ NodeState childState = (NodeState) stateMgr.getItemState(child.getId());
createIndex(childState, stateMgr);
}
}
@@ -1300,7 +1300,7 @@
public void execute(MultiIndex index) throws IOException {
if (doc == null) {
try {
- doc = index.createDocument(new NodeId(uuid));
+ doc = index.createDocument(NodeId.valueOf(uuid));
} catch (RepositoryException e) {
// node does not exist anymore
log.debug(e.getMessage());
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java?rev=378221&r1=378220&r2=378221&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java Thu Feb 16 02:48:20 2006
@@ -16,7 +16,6 @@
*/
package org.apache.jackrabbit.core.query.lucene;
-import org.apache.jackrabbit.core.NodeId;
import org.apache.jackrabbit.core.PropertyId;
import org.apache.jackrabbit.core.query.TextFilter;
import org.apache.jackrabbit.core.state.ItemStateException;
@@ -37,11 +36,11 @@
import javax.jcr.RepositoryException;
import java.io.Reader;
import java.util.Calendar;
+import java.util.Collections;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.List;
-import java.util.Collections;
/**
* Creates a lucene <code>Document</code> object from a {@link javax.jcr.Node}.
@@ -125,17 +124,17 @@
// special fields
// UUID
- doc.add(new Field(FieldNames.UUID, node.getUUID(), true, true, false));
+ doc.add(new Field(FieldNames.UUID, node.getNodeId().getUUID().toString(), true, true, false));
try {
// parent UUID
- if (node.getParentUUID() == null) {
+ if (node.getParentId() == null) {
// root node
doc.add(new Field(FieldNames.PARENT, "", true, true, false));
doc.add(new Field(FieldNames.LABEL, "", false, true, false));
} else {
- doc.add(new Field(FieldNames.PARENT, node.getParentUUID(), true, true, false));
- NodeState parent = (NodeState) stateProvider.getItemState(new NodeId(node.getParentUUID()));
- NodeState.ChildNodeEntry child = parent.getChildNodeEntry(node.getUUID());
+ doc.add(new Field(FieldNames.PARENT, node.getParentId().toString(), true, true, false));
+ NodeState parent = (NodeState) stateProvider.getItemState(node.getParentId());
+ NodeState.ChildNodeEntry child = parent.getChildNodeEntry(node.getNodeId());
String name = child.getName().toJCRName(mappings);
doc.add(new Field(FieldNames.LABEL, name, false, true, false));
}
@@ -151,7 +150,7 @@
Set props = node.getPropertyNames();
for (Iterator it = props.iterator(); it.hasNext();) {
QName propName = (QName) it.next();
- PropertyId id = new PropertyId(node.getUUID(), propName);
+ PropertyId id = new PropertyId(node.getNodeId(), propName);
try {
PropertyState propState = (PropertyState) stateProvider.getItemState(id);
InternalValue[] values = propState.getValues();
@@ -179,7 +178,7 @@
*/
private void throwRepositoryException(Exception e)
throws RepositoryException {
- String msg = "Error while indexing node: " + node.getUUID() + " of " +
+ String msg = "Error while indexing node: " + node.getNodeId() + " of " +
"type: " + node.getNodeTypeName();
throw new RepositoryException(msg, e);
}
@@ -268,15 +267,18 @@
return;
}
if (node.hasPropertyName(QName.JCR_MIMETYPE)) {
- PropertyState dataProp = (PropertyState) stateProvider.getItemState(new PropertyId(node.getUUID(), QName.JCR_DATA));
+ PropertyState dataProp = (PropertyState) stateProvider.getItemState(
+ new PropertyId(node.getNodeId(), QName.JCR_DATA));
PropertyState mimeTypeProp =
- (PropertyState) stateProvider.getItemState(new PropertyId(node.getUUID(), QName.JCR_MIMETYPE));
+ (PropertyState) stateProvider.getItemState(
+ new PropertyId(node.getNodeId(), QName.JCR_MIMETYPE));
// jcr:encoding is not mandatory
String encoding = null;
if (node.hasPropertyName(QName.JCR_ENCODING)) {
PropertyState encodingProp =
- (PropertyState) stateProvider.getItemState(new PropertyId(node.getUUID(), QName.JCR_ENCODING));
+ (PropertyState) stateProvider.getItemState(
+ new PropertyId(node.getNodeId(), QName.JCR_ENCODING));
encodingProp.getValues()[0].internalValue().toString();
}
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIteratorImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIteratorImpl.java?rev=378221&r1=378220&r2=378221&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIteratorImpl.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIteratorImpl.java Thu Feb 16 02:48:20 2006
@@ -34,8 +34,8 @@
/** Logger instance for this class */
private static final Logger log = Logger.getLogger(NodeIteratorImpl.class);
- /** The UUIDs of the nodes in the result set */
- protected final String[] uuids;
+ /** The node ids of the nodes in the result set */
+ protected final NodeId[] ids;
/** The score values for the nodes in the result set */
protected final Float[] scores;
@@ -56,14 +56,14 @@
* Creates a new <code>NodeIteratorImpl</code> instance.
* @param itemMgr the <code>ItemManager</code> to turn UUIDs into
* <code>Node</code> instances.
- * @param uuids the UUIDs of the result nodes.
+ * @param ids the IDs of the result nodes.
* @param scores the corresponding score values for each result node.
*/
NodeIteratorImpl(ItemManager itemMgr,
- String[] uuids,
+ NodeId[] ids,
Float[] scores) {
this.itemMgr = itemMgr;
- this.uuids = uuids;
+ this.ids = ids;
this.scores = scores;
fetchNext();
}
@@ -113,7 +113,7 @@
if (skipNum < 0) {
throw new IllegalArgumentException("skipNum must not be negative");
}
- if ((pos + skipNum) > uuids.length) {
+ if ((pos + skipNum) > ids.length) {
throw new NoSuchElementException();
}
if (skipNum == 0) {
@@ -137,7 +137,7 @@
* @return the number of node in this iterator.
*/
public long getSize() {
- return uuids.length - invalid;
+ return ids.length - invalid;
}
/**
@@ -187,12 +187,12 @@
protected void fetchNext() {
// reset
next = null;
- while (next == null && (pos + 1) < uuids.length) {
+ while (next == null && (pos + 1) < ids.length) {
try {
- next = (NodeImpl) itemMgr.getItem(new NodeId(uuids[pos + 1]));
+ next = (NodeImpl) itemMgr.getItem(ids[pos + 1]);
} catch (RepositoryException e) {
log.warn("Exception retrieving Node with UUID: "
- + uuids[pos + 1] + ": " + e.toString());
+ + ids[pos + 1] + ": " + e.toString());
// try next
invalid++;
pos++;
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java?rev=378221&r1=378220&r2=378221&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java Thu Feb 16 02:48:20 2006
@@ -164,7 +164,7 @@
}
- List uuids;
+ List ids;
List scores;
AccessManager accessMgr = session.getAccessManager();
@@ -172,20 +172,20 @@
QueryHits result = null;
try {
result = index.executeQuery(this, query, orderProperties, ascSpecs);
- uuids = new ArrayList(result.length());
+ ids = new ArrayList(result.length());
scores = new ArrayList(result.length());
for (int i = 0; i < result.length(); i++) {
- String uuid = result.doc(i).get(FieldNames.UUID);
+ NodeId id = NodeId.valueOf(result.doc(i).get(FieldNames.UUID));
// check access
- if (accessMgr.isGranted(new NodeId(uuid), AccessManager.READ)) {
- uuids.add(uuid);
+ if (accessMgr.isGranted(id, AccessManager.READ)) {
+ ids.add(id);
scores.add(new Float(result.score(i)));
}
}
} catch (IOException e) {
log.error("Exception while executing query: ", e);
- uuids = Collections.EMPTY_LIST;
+ ids = Collections.EMPTY_LIST;
scores = Collections.EMPTY_LIST;
} finally {
if (result != null) {
@@ -199,7 +199,7 @@
// return QueryResult
return new QueryResultImpl(itemMgr,
- (String[]) uuids.toArray(new String[uuids.size()]),
+ (NodeId[]) ids.toArray(new NodeId[ids.size()]),
(Float[]) scores.toArray(new Float[scores.size()]),
getSelectProperties(),
session.getNamespaceResolver(),
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java?rev=378221&r1=378220&r2=378221&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java Thu Feb 16 02:48:20 2006
@@ -17,6 +17,7 @@
package org.apache.jackrabbit.core.query.lucene;
import org.apache.jackrabbit.core.ItemManager;
+import org.apache.jackrabbit.core.NodeId;
import org.apache.jackrabbit.name.NamespaceResolver;
import org.apache.jackrabbit.name.NoPrefixDeclaredException;
import org.apache.jackrabbit.name.QName;
@@ -45,7 +46,7 @@
/**
* The UUIDs of the result nodes
*/
- private final String[] uuids;
+ private final NodeId[] ids;
/**
* The scores of the result nodes
@@ -71,7 +72,7 @@
* Creates a new query result.
*
* @param itemMgr the item manager of the session executing the query.
- * @param uuids the UUIDs of the result nodes.
+ * @param ids the Ids of the result nodes.
* @param scores the score values of the result nodes.
* @param selectProps the select properties of the query.
* @param resolver the namespace resolver of the session executing the query.
@@ -79,12 +80,12 @@
* order.
*/
public QueryResultImpl(ItemManager itemMgr,
- String[] uuids,
+ NodeId[] ids,
Float[] scores,
QName[] selectProps,
NamespaceResolver resolver,
boolean docOrder) {
- this.uuids = uuids;
+ this.ids = ids;
this.scores = scores;
this.itemMgr = itemMgr;
this.selectProps = selectProps;
@@ -130,9 +131,9 @@
*/
private ScoreNodeIterator getNodeIterator() {
if (docOrder) {
- return new DocOrderNodeIteratorImpl(itemMgr, uuids, scores);
+ return new DocOrderNodeIteratorImpl(itemMgr, ids, scores);
} else {
- return new NodeIteratorImpl(itemMgr, uuids, scores);
+ return new NodeIteratorImpl(itemMgr, ids, scores);
}
}
}
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java?rev=378221&r1=378220&r2=378221&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java Thu Feb 16 02:48:20 2006
@@ -18,12 +18,15 @@
import org.apache.jackrabbit.core.ItemManager;
import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.NodeIdIterator;
import org.apache.jackrabbit.core.query.AbstractQueryHandler;
import org.apache.jackrabbit.core.query.ExecutableQuery;
import org.apache.jackrabbit.core.query.QueryHandlerContext;
import org.apache.jackrabbit.core.query.TextFilter;
import org.apache.jackrabbit.core.query.QueryHandler;
import org.apache.jackrabbit.core.state.NodeState;
+import org.apache.jackrabbit.core.state.NodeStateIterator;
import org.apache.jackrabbit.name.NoPrefixDeclaredException;
import org.apache.jackrabbit.name.QName;
import org.apache.log4j.Logger;
@@ -189,13 +192,13 @@
throw new IOException("SearchIndex requires 'path' parameter in configuration!");
}
- Set excludedUUIDs = new HashSet();
- if (context.getExcludedNodeUUID() != null) {
- excludedUUIDs.add(context.getExcludedNodeUUID());
+ Set excludedIDs= new HashSet();
+ if (context.getExcludedNodeId() != null) {
+ excludedIDs.add(context.getExcludedNodeId());
}
index = new MultiIndex(new File(path), this,
- context.getItemStateManager(), context.getRootUUID(), excludedUUIDs);
+ context.getItemStateManager(), context.getRootId(), excludedIDs);
if (index.getRedoLogApplied() || forceConsistencyCheck) {
log.info("Running consistency check...");
try {
@@ -232,11 +235,11 @@
/**
* Removes the node with <code>uuid</code> from the search index.
- * @param uuid the UUID of the node to remove from the index.
+ * @param id the id of the node to remove from the index.
* @throws IOException if an error occurs while removing the node from
* the index.
*/
- public void deleteNode(String uuid) throws IOException {
+ public void deleteNode(NodeId id) throws IOException {
throw new UnsupportedOperationException("deleteNode");
}
@@ -252,13 +255,13 @@
* @throws RepositoryException if an error occurs while indexing a node.
* @throws IOException if an error occurs while updating the index.
*/
- public void updateNodes(Iterator remove, Iterator add)
+ public void updateNodes(NodeIdIterator remove, NodeStateIterator add)
throws RepositoryException, IOException {
checkOpen();
index.update(new AbstractIteratorDecorator(remove) {
public Object next() {
- String uuid = (String) super.next();
- return new Term(FieldNames.UUID, uuid);
+ NodeId id = (NodeId) super.next();
+ return new Term(FieldNames.UUID, id.getUUID().toString());
}
}, new AbstractIteratorDecorator(add) {
public Object next() {
@@ -271,7 +274,7 @@
doc = createDocument(state, getNamespaceMappings());
} catch (RepositoryException e) {
log.error("Exception while creating document for node: " +
- state.getUUID() + ": " + e.toString());
+ state.getNodeId() + ": " + e.toString());
}
return doc;
}
@@ -486,7 +489,7 @@
* @param n document number.
* @return the reader index.
*/
- final private int readerIndex(int n) {
+ private int readerIndex(int n) {
int lo = 0; // search starts array
int hi = subReaders.length - 1; // for first element less
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/AbstractPersistenceManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/AbstractPersistenceManager.java?rev=378221&r1=378220&r2=378221&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/AbstractPersistenceManager.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/AbstractPersistenceManager.java Thu Feb 16 02:48:20 2006
@@ -31,16 +31,14 @@
* {@inheritDoc}
*/
public NodeState createNew(NodeId id) {
- return new NodeState(id.getUUID(), null, null,
- NodeState.STATUS_NEW, false);
+ return new NodeState(id, null, null, NodeState.STATUS_NEW, false);
}
/**
* {@inheritDoc}
*/
public PropertyState createNew(PropertyId id) {
- return new PropertyState(id.getName(), id.getParentUUID(),
- PropertyState.STATUS_NEW, false);
+ return new PropertyState(id, PropertyState.STATUS_NEW, false);
}
/**
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/ChangeLog.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/ChangeLog.java?rev=378221&r1=378220&r2=378221&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/ChangeLog.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/ChangeLog.java Thu Feb 16 02:48:20 2006
@@ -127,10 +127,7 @@
* log; <code>false</code> otherwise
*/
public boolean has(ItemId id) {
- if (addedStates.containsKey(id) || modifiedStates.containsKey(id)) {
- return true;
- }
- return false;
+ return addedStates.containsKey(id) || modifiedStates.containsKey(id);
}
/**
@@ -351,10 +348,10 @@
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append("{");
- buf.append("#addedStates=" + addedStates.size());
- buf.append(", #modifiedStates=" + modifiedStates.size());
- buf.append(", #deletedStates=" + deletedStates.size());
- buf.append(", #modifiedRefs=" + modifiedRefs.size());
+ buf.append("#addedStates=").append(addedStates.size());
+ buf.append(", #modifiedStates=").append(modifiedStates.size());
+ buf.append(", #deletedStates=").append(deletedStates.size());
+ buf.append(", #modifiedRefs=").append(modifiedRefs.size());
buf.append("}");
return buf.toString();
}
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/ItemState.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/ItemState.java?rev=378221&r1=378220&r2=378221&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/ItemState.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/ItemState.java Thu Feb 16 02:48:20 2006
@@ -18,6 +18,7 @@
import org.apache.commons.collections.map.ReferenceMap;
import org.apache.jackrabbit.core.ItemId;
+import org.apache.jackrabbit.core.NodeId;
import org.apache.log4j.Logger;
import java.io.IOException;
@@ -36,12 +37,14 @@
/** Serialization UID of this class. */
static final long serialVersionUID = 2017294661624942639L;
+ /**
+ * the default logger
+ */
private static Logger log = Logger.getLogger(ItemState.class);
/**
- * flags defining the current status of this <code>ItemState</code> instance
+ * undefined state
*/
-
public static final int STATUS_UNDEFINED = 0;
/**
* 'existing', i.e. persistent state
@@ -74,17 +77,10 @@
protected int status = STATUS_UNDEFINED;
/**
- * the uuid of the (primary) parent node or <code>null</code> if this is the root node
- */
- protected String parentUUID;
-
- /**
* a modification counter used to prevent concurrent modifications
*/
private short modCount;
- protected ItemId id;
-
/**
* Flag indicating whether this state is transient
*/
@@ -97,19 +93,18 @@
Collections.synchronizedMap(
new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK));
- // the backing persistent item state (may be null)
+ /**
+ * the backing persistent item state (may be null)
+ */
protected transient ItemState overlayedState;
/**
- * Protected constructor
+ * Constructs a new unconnected item state
*
- * @param parentUUID the UUID of the (primary) parent node or <code>null</code>
- * @param id the id of the item state object
* @param initialStatus the initial status of the item state object
* @param isTransient flag indicating whether this state is transient or not
*/
- protected ItemState(String parentUUID, ItemId id, int initialStatus,
- boolean isTransient) {
+ protected ItemState(int initialStatus, boolean isTransient) {
switch (initialStatus) {
case STATUS_EXISTING:
case STATUS_NEW:
@@ -120,20 +115,20 @@
log.debug(msg);
throw new IllegalArgumentException(msg);
}
- this.id = id;
- this.parentUUID = parentUUID;
modCount = 0;
overlayedState = null;
this.isTransient = isTransient;
}
/**
- * Protected constructor
+ * Constructs a new node state that is initially connected to an overlayed
+ * state.
*
+ * @param overlayedState the backing node state being overlayed
* @param initialStatus the initial status of the new <code>ItemState</code> instance
* @param isTransient flag indicating whether this state is transient or not
*/
- protected ItemState(int initialStatus, boolean isTransient) {
+ protected ItemState(ItemState overlayedState, int initialStatus, boolean isTransient) {
switch (initialStatus) {
case STATUS_EXISTING:
case STATUS_EXISTING_MODIFIED:
@@ -146,18 +141,14 @@
throw new IllegalArgumentException(msg);
}
this.isTransient = isTransient;
+ connect(overlayedState);
}
/**
* Copy state information from a state into this state
* @param state source state information
*/
- protected synchronized void copy(ItemState state) {
- synchronized (state) {
- parentUUID = state.getParentUUID();
- id = state.getId();
- }
- }
+ abstract protected void copy(ItemState state);
/**
* Pull state information from overlayed state.
@@ -315,9 +306,7 @@
*
* @return the identifier of this item state..
*/
- public ItemId getId() {
- return id;
- }
+ abstract public ItemId getId();
/**
* Returns <code>true</code> if this item state represents new or modified
@@ -347,26 +336,13 @@
}
/**
- * Returns the UUID of the parent <code>NodeState</code> or <code>null</code>
+ * Returns the Idof the parent <code>NodeState</code> or <code>null</code>
* if either this item state represents the root node or this item state is
* 'free floating', i.e. not attached to the repository's hierarchy.
*
- * @return the parent <code>NodeState</code>'s UUID
- */
- public String getParentUUID() {
- return parentUUID;
- }
-
- /**
- * Sets the UUID of the parent <code>NodeState</code>.
- *
- * @param parentUUID the parent <code>NodeState</code>'s UUID or <code>null</code>
- * if either this item state should represent the root node or this item state
- * should be 'free floating', i.e. detached from the repository's hierarchy.
+ * @return the parent <code>NodeState</code>'s Id
*/
- public void setParentUUID(String parentUUID) {
- this.parentUUID = parentUUID;
- }
+ abstract public NodeId getParentId();
/**
* Returns the status of this item.
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java?rev=378221&r1=378220&r2=378221&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java Thu Feb 16 02:48:20 2006
@@ -21,7 +21,6 @@
import org.apache.jackrabbit.core.PropertyId;
import org.apache.jackrabbit.core.observation.EventStateCollectionFactory;
import org.apache.jackrabbit.name.QName;
-import org.apache.log4j.Logger;
import javax.jcr.ReferentialIntegrityException;
import java.util.Iterator;
@@ -34,11 +33,6 @@
implements UpdatableItemStateManager, ItemStateListener {
/**
- * Logger instance
- */
- private static Logger log = Logger.getLogger(LocalItemStateManager.class);
-
- /**
* cache of weak references to ItemState objects issued by this
* ItemStateManager
*/
@@ -227,14 +221,14 @@
/**
* {@inheritDoc}
*/
- public NodeState createNew(String uuid, QName nodeTypeName,
- String parentUUID)
+ public NodeState createNew(NodeId id, QName nodeTypeName,
+ NodeId parentId)
throws IllegalStateException {
if (!editMode) {
throw new IllegalStateException("Not in edit mode");
}
- NodeState state = new NodeState(uuid, nodeTypeName, parentUUID,
+ NodeState state = new NodeState(id, nodeTypeName, parentId,
ItemState.STATUS_NEW, false);
changeLog.added(state);
return state;
@@ -243,13 +237,13 @@
/**
* {@inheritDoc}
*/
- public PropertyState createNew(QName propName, String parentUUID)
+ public PropertyState createNew(QName propName, NodeId parentId)
throws IllegalStateException {
if (!editMode) {
throw new IllegalStateException("Not in edit mode");
}
- PropertyState state = new PropertyState(propName, parentUUID,
- ItemState.STATUS_NEW, false);
+ PropertyState state = new PropertyState(
+ new PropertyId(parentId, propName), ItemState.STATUS_NEW, false);
changeLog.added(state);
return state;
}
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeReferences.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeReferences.java?rev=378221&r1=378220&r2=378221&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeReferences.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeReferences.java Thu Feb 16 02:48:20 2006
@@ -17,7 +17,7 @@
package org.apache.jackrabbit.core.state;
import org.apache.jackrabbit.core.PropertyId;
-import org.apache.log4j.Logger;
+import org.apache.jackrabbit.uuid.UUID;
import java.io.Serializable;
import java.util.ArrayList;
@@ -36,11 +36,6 @@
static final long serialVersionUID = 7007727035982680717L;
/**
- * Logger instance
- */
- private static Logger log = Logger.getLogger(NodeReferences.class);
-
- /**
* id of the target node
*/
protected NodeReferencesId targetId;
@@ -78,7 +73,7 @@
*
* @return UUID of the target id
*/
- public String getUUID() {
+ public UUID getUUID() {
return targetId.getUUID();
}
@@ -93,7 +88,7 @@
}
/**
- * @return
+ * @return the list of references
*/
public List getReferences() {
return Collections.unmodifiableList(references);
@@ -115,7 +110,8 @@
/**
* @param refId
- * @return
+ * @return <code>true</code> if the reference was reomved;
+ * <code>false</code> otherwise.
*/
public boolean removeReference(PropertyId refId) {
return references.remove(refId);
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeReferencesId.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeReferencesId.java?rev=378221&r1=378220&r2=378221&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeReferencesId.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeReferencesId.java Thu Feb 16 02:48:20 2006
@@ -17,6 +17,7 @@
package org.apache.jackrabbit.core.state;
import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.uuid.UUID;
/**
* Identifies a <code>NodeReferences</code> object.
@@ -28,11 +29,20 @@
*
* @param uuid uuid of target node
*/
- public NodeReferencesId(String uuid) {
+ public NodeReferencesId(UUID uuid) {
super(uuid);
}
/**
+ * Create a new instance of this class. Takes a id as parameter.
+ *
+ * @param id the id of target node
+ */
+ public NodeReferencesId(NodeId id) {
+ super(id == null ? null : id.getUUID());
+ }
+
+ /**
* Returns a <code>NodeReferencesId</code> holding the value of the specified
* string. The string must be in the format returned by the
* <code>NodeReferencesId.toString()</code> method.
@@ -48,29 +58,7 @@
if (s == null) {
throw new IllegalArgumentException("invalid NodeReferencesId literal");
}
- return new NodeReferencesId(s);
- }
-
- //-------------------------------------------< java.lang.Object overrides >
- /**
- * {@inheritDoc}
- */
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof NodeReferencesId) {
- return super.equals(obj);
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public int hashCode() {
- // use hash code of node id
- return super.hashCode();
+ return new NodeReferencesId(NodeId.valueOf(s));
}
}
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeState.java?rev=378221&r1=378220&r2=378221&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeState.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeState.java Thu Feb 16 02:48:20 2006
@@ -21,6 +21,7 @@
import org.apache.commons.collections.map.LinkedMap;
import org.apache.commons.collections.map.ReferenceMap;
import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.ItemId;
import org.apache.jackrabbit.core.nodetype.NodeDefId;
import org.apache.jackrabbit.name.QName;
@@ -49,34 +50,39 @@
static final long serialVersionUID = -4116945555530446652L;
/**
- * the uuid of this node
+ * the name of this node's primary type
*/
- protected String uuid;
+ private QName nodeTypeName;
/**
- * the name of this node's primary type
+ * the names of this node's mixin types
*/
- protected QName nodeTypeName;
+ private HashSet mixinTypeNames = new HashSet();
/**
- * the names of this node's mixin types
+ * the id of this node state.
*/
- protected HashSet mixinTypeNames = new HashSet();
+ private NodeId id;
+
+ /**
+ * the id of the parent node or <code>null</code> if this is the root node
+ */
+ private NodeId parentId;
/**
* id of this node's definition
*/
- protected NodeDefId defId;
+ private NodeDefId defId;
/**
* insertion-ordered collection of ChildNodeEntry objects
*/
- protected ChildNodeEntries childNodeEntries = new ChildNodeEntries();
+ private ChildNodeEntries childNodeEntries = new ChildNodeEntries();
/**
* set of property names (QName objects)
*/
- protected HashSet propertyNames = new HashSet();
+ private HashSet propertyNames = new HashSet();
/**
* Listeners (weak references)
@@ -85,7 +91,8 @@
new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK);
/**
- * Constructor
+ * Constructs a new node state that is initially connected to an overlayed
+ * state.
*
* @param overlayedState the backing node state being overlayed
* @param initialStatus the initial status of the node state object
@@ -93,27 +100,25 @@
*/
public NodeState(NodeState overlayedState, int initialStatus,
boolean isTransient) {
- super(initialStatus, isTransient);
-
- connect(overlayedState);
+ super(overlayedState, initialStatus, isTransient);
pull();
}
/**
- * Constructor
+ * Constructs a new node state this is not connected.
*
- * @param uuid the UUID of the this node
+ * @param id the Id of the this node
* @param nodeTypeName node type of this node
- * @param parentUUID the UUID of the parent node
+ * @param parentId the Id of the parent node
* @param initialStatus the initial status of the node state object
* @param isTransient flag indicating whether this state is transient or not
*/
- public NodeState(String uuid, QName nodeTypeName, String parentUUID,
+ public NodeState(NodeId id, QName nodeTypeName, NodeId parentId,
int initialStatus, boolean isTransient) {
- super(parentUUID, new NodeId(uuid), initialStatus, isTransient);
-
+ super(initialStatus, isTransient);
+ this.id = id;
+ this.parentId = parentId;
this.nodeTypeName = nodeTypeName;
- this.uuid = uuid;
}
/**
@@ -121,19 +126,18 @@
*/
protected synchronized void copy(ItemState state) {
synchronized (state) {
- super.copy(state);
-
NodeState nodeState = (NodeState) state;
- nodeTypeName = nodeState.getNodeTypeName();
+ id = nodeState.id;
+ parentId = nodeState.parentId;
+ nodeTypeName = nodeState.nodeTypeName;
mixinTypeNames = (HashSet) nodeState.mixinTypeNames.clone();
- defId = nodeState.getDefinitionId();
- uuid = nodeState.getUUID();
+ defId = nodeState.defId;
propertyNames = (HashSet) nodeState.propertyNames.clone();
childNodeEntries = (ChildNodeEntries) nodeState.childNodeEntries.clone();
}
}
- //-------------------------------------------------------< public methods >
+ //-----------------------------------------------------< public methods >---
/**
* Determines if this item state represents a node.
*
@@ -145,6 +149,40 @@
}
/**
+ * {@inheritDoc}
+ */
+ public NodeId getParentId() {
+ return parentId;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ItemId getId() {
+ return id;
+ }
+
+ /**
+ * Returns the id of this node state.
+ * @return the id of this node state.
+ */
+ public NodeId getNodeId() {
+ return id;
+ }
+
+ /**
+ * Sets the Id of the parent <code>NodeState</code>.
+ *
+ * @param parentId the parent <code>NodeState</code>'s Id or <code>null</code>
+ * if either this node state should represent the root node or this node
+ * state should be 'free floating', i.e. detached from the repository's
+ * hierarchy.
+ */
+ public void setParentId(NodeId parentId) {
+ this.parentId = parentId;
+ }
+
+ /**
* Returns the name of this node's node type.
*
* @return the name of this node's node type.
@@ -191,15 +229,6 @@
}
/**
- * Returns the UUID of the repository node this node state is representing.
- *
- * @return the UUID
- */
- public String getUUID() {
- return uuid;
- }
-
- /**
* Determines if there are any child node entries.
*
* @return <code>true</code> if there are child node entries,
@@ -225,12 +254,12 @@
* Determines if there is a <code>ChildNodeEntry</code> with the
* specified <code>uuid</code>.
*
- * @param uuid UUID of the child node
+ * @param id the id of the child node
* @return <code>true</code> if there is a <code>ChildNodeEntry</code> with
* the specified <code>name</code>.
*/
- public synchronized boolean hasChildNodeEntry(String uuid) {
- return childNodeEntries.get(uuid) != null;
+ public synchronized boolean hasChildNodeEntry(NodeId id) {
+ return childNodeEntries.get(id) != null;
}
/**
@@ -275,14 +304,14 @@
* Returns the <code>ChildNodeEntry</code> with the specified uuid or
* <code>null</code> if there's no such entry.
*
- * @param uuid UUID of the child node
+ * @param id the id of the child node
* @return the <code>ChildNodeEntry</code> with the specified uuid or
* <code>null</code> if there's no such entry.
* @see #addChildNodeEntry
* @see #removeChildNodeEntry
*/
- public synchronized ChildNodeEntry getChildNodeEntry(String uuid) {
- return childNodeEntries.get(uuid);
+ public synchronized ChildNodeEntry getChildNodeEntry(NodeId id) {
+ return childNodeEntries.get(id);
}
/**
@@ -313,12 +342,12 @@
* Adds a new <code>ChildNodeEntry</code>.
*
* @param nodeName <code>QName</code> object specifying the name of the new entry.
- * @param uuid UUID the new entry is refering to.
+ * @param id The id the new entry is refering to.
* @return the newly added <code>ChildNodeEntry</code>
*/
public synchronized ChildNodeEntry addChildNodeEntry(QName nodeName,
- String uuid) {
- ChildNodeEntry entry = childNodeEntries.add(nodeName, uuid);
+ NodeId id) {
+ ChildNodeEntry entry = childNodeEntries.add(nodeName, id);
notifyNodeAdded(entry);
return entry;
}
@@ -337,7 +366,7 @@
ChildNodeEntry oldEntry = childNodeEntries.remove(oldName, index);
if (oldEntry != null) {
ChildNodeEntry newEntry =
- childNodeEntries.add(newName, oldEntry.getUUID());
+ childNodeEntries.add(newName, oldEntry.getId());
notifyNodeAdded(newEntry);
notifyNodeRemoved(oldEntry);
return true;
@@ -364,12 +393,12 @@
/**
* Removes a <code>ChildNodeEntry</code>.
*
- * @param uuid UUID of the entry to be removed
+ * @param id the Id of the entry to be removed
* @return <code>true</code> if the specified child node entry was found
* in the list of child node entries and could be removed.
*/
- public synchronized boolean removeChildNodeEntry(String uuid) {
- ChildNodeEntry entry = childNodeEntries.remove(uuid);
+ public synchronized boolean removeChildNodeEntry(NodeId id) {
+ ChildNodeEntry entry = childNodeEntries.remove(id);
if (entry != null) {
notifyNodeRemoved(entry);
}
@@ -583,7 +612,7 @@
for (int i = 0; i < ours.size();) {
ChildNodeEntry entry = (ChildNodeEntry) ours.get(i);
ChildNodeEntry other = (ChildNodeEntry) others.get(i);
- if (entry == other || entry.getUUID().equals(other.getUUID())) {
+ if (entry == other || entry.id.equals(other.id)) {
// no reorder, move to next child entry
i++;
} else {
@@ -599,10 +628,10 @@
if (i + 1 < ours.size()) {
// if entry is the next in the other list then probably
// the other entry at position <code>i</code> was reordered
- if (entry.getUUID().equals(((ChildNodeEntry) others.get(i + 1)).getUUID())) {
+ if (entry.id.equals(((ChildNodeEntry) others.get(i + 1)).id)) {
// scan for the uuid of the other entry in our list
for (int j = i; j < ours.size(); j++) {
- if (((ChildNodeEntry) ours.get(j)).getUUID().equals(other.uuid)) {
+ if (((ChildNodeEntry) ours.get(j)).id.equals(other.id)) {
// found it
entry = (ChildNodeEntry) ours.get(j);
break;
@@ -615,12 +644,12 @@
// remove the entry from both lists
// entries > i are already cleaned
for (int j = i; j < ours.size(); j++) {
- if (((ChildNodeEntry) ours.get(j)).getUUID().equals(entry.getUUID())) {
+ if (((ChildNodeEntry) ours.get(j)).id.equals(entry.id)) {
ours.remove(j);
}
}
for (int j = i; j < ours.size(); j++) {
- if (((ChildNodeEntry) others.get(j)).getUUID().equals(entry.getUUID())) {
+ if (((ChildNodeEntry) others.get(j)).id.equals(entry.id)) {
others.remove(j);
}
}
@@ -680,7 +709,7 @@
NodeStateListener l = (NodeStateListener) iter.next();
if (l != null) {
l.nodeAdded(this, added.getName(),
- added.getIndex(), added.getUUID());
+ added.getIndex(), added.getId());
}
}
}
@@ -711,7 +740,7 @@
NodeStateListener l = (NodeStateListener) iter.next();
if (l != null) {
l.nodeRemoved(this, removed.getName(),
- removed.getIndex(), removed.getUUID());
+ removed.getIndex(), removed.getId());
}
}
}
@@ -740,7 +769,7 @@
*/
private static class ChildNodeEntries implements List, Cloneable, Serializable {
- // insertion-ordered map of entries (key=uuid, value=entry)
+ // insertion-ordered map of entries (key=NodeId, value=entry)
LinkedMap entries;
// map used for lookup by name
// (key=name, value=either a single entry or a list of sns entries)
@@ -751,8 +780,8 @@
nameMap = new HashMap();
}
- ChildNodeEntry get(String uuid) {
- return (ChildNodeEntry) entries.get(uuid);
+ ChildNodeEntry get(NodeId id) {
+ return (ChildNodeEntry) entries.get(id);
}
List get(QName nodeName) {
@@ -793,7 +822,7 @@
return null;
}
- ChildNodeEntry add(QName nodeName, String uuid) {
+ ChildNodeEntry add(QName nodeName, NodeId id) {
List siblings = null;
int index = 0;
Object obj = nameMap.get(nodeName);
@@ -813,13 +842,13 @@
index++;
- ChildNodeEntry entry = new ChildNodeEntry(nodeName, uuid, index);
+ ChildNodeEntry entry = new ChildNodeEntry(nodeName, id, index);
if (siblings != null) {
siblings.add(entry);
} else {
nameMap.put(nodeName, entry);
}
- entries.put(uuid, entry);
+ entries.put(id, entry);
return entry;
}
@@ -829,7 +858,7 @@
while (iter.hasNext()) {
ChildNodeEntry entry = (ChildNodeEntry) iter.next();
// delegate to add(QName, String) to maintain consistency
- add(entry.getName(), entry.getUUID());
+ add(entry.getName(), entry.getId());
}
}
@@ -850,7 +879,7 @@
}
ChildNodeEntry removedEntry = (ChildNodeEntry) obj;
nameMap.remove(nodeName);
- entries.remove(removedEntry.getUUID());
+ entries.remove(removedEntry.getId());
return removedEntry;
}
@@ -863,16 +892,16 @@
// remove from siblings list
ChildNodeEntry removedEntry = (ChildNodeEntry) siblings.remove(index - 1);
// remove from ordered entries map
- entries.remove(removedEntry.getUUID());
+ entries.remove(removedEntry.getId());
// update indices of subsequent same-name siblings
for (int i = index - 1; i < siblings.size(); i++) {
ChildNodeEntry oldEntry = (ChildNodeEntry) siblings.get(i);
- ChildNodeEntry newEntry = new ChildNodeEntry(nodeName, oldEntry.getUUID(), oldEntry.getIndex() - 1);
+ ChildNodeEntry newEntry = new ChildNodeEntry(nodeName, oldEntry.getId(), oldEntry.getIndex() - 1);
// overwrite old entry with updated entry in siblings list
siblings.set(i, newEntry);
// overwrite old entry with updated entry in ordered entries map
- entries.put(newEntry.getUUID(), newEntry);
+ entries.put(newEntry.getId(), newEntry);
}
// clean up name lookup map if necessary
@@ -890,18 +919,31 @@
return removedEntry;
}
- ChildNodeEntry remove(String uuid) {
- ChildNodeEntry entry = (ChildNodeEntry) entries.get(uuid);
+ /**
+ * Removes the child node entry with the given id
+ * @param id
+ * @return the removed entry or <code>null</code>
+ */
+ ChildNodeEntry remove(NodeId id) {
+ ChildNodeEntry entry = (ChildNodeEntry) entries.get(id);
if (entry != null) {
return remove(entry.getName(), entry.getIndex());
}
return entry;
}
+ /**
+ * Removes the child node entry
+ * @param entry
+ * @return the removed entry or <code>null</code>
+ */
public ChildNodeEntry remove(ChildNodeEntry entry) {
return remove(entry.getName(), entry.getIndex());
}
+ /**
+ * Removes all child node entries
+ */
public void removeAll() {
nameMap.clear();
entries.clear();
@@ -932,7 +974,7 @@
Iterator iter = iterator();
while (iter.hasNext()) {
ChildNodeEntry entry = (ChildNodeEntry) iter.next();
- ChildNodeEntry otherEntry = (ChildNodeEntry) other.get(entry.uuid);
+ ChildNodeEntry otherEntry = other.get(entry.id);
if (entry == otherEntry) {
continue;
}
@@ -968,7 +1010,7 @@
Iterator iter = iterator();
while (iter.hasNext()) {
ChildNodeEntry entry = (ChildNodeEntry) iter.next();
- ChildNodeEntry otherEntry = (ChildNodeEntry) other.get(entry.uuid);
+ ChildNodeEntry otherEntry = other.get(entry.id);
if (entry == otherEntry) {
result.add(entry);
} else if (otherEntry != null
@@ -983,7 +1025,7 @@
//-------------------------------------------< unmodifiable List view >
public boolean contains(Object o) {
if (o instanceof ChildNodeEntry) {
- return entries.containsKey(((ChildNodeEntry) o).uuid);
+ return entries.containsKey(((ChildNodeEntry) o).id);
} else {
return false;
}
@@ -1005,7 +1047,7 @@
public int indexOf(Object o) {
if (o instanceof ChildNodeEntry) {
- return entries.indexOf(((ChildNodeEntry) o).uuid);
+ return entries.indexOf(((ChildNodeEntry) o).id);
} else {
return -1;
}
@@ -1122,7 +1164,7 @@
NodeState.ChildNodeEntry entry =
(NodeState.ChildNodeEntry) iter.next();
out.writeUTF(entry.getName().toString()); // name
- out.writeUTF(entry.getUUID()); // uuid
+ out.writeUTF(entry.getId().toString()); // uuid
}
}
@@ -1134,8 +1176,8 @@
short count = in.readShort(); // count
for (int i = 0; i < count; i++) {
QName name = QName.valueOf(in.readUTF()); // name
- String s = in.readUTF(); // uuid
- add(name, s);
+ String s = in.readUTF(); // nodeid
+ add(name, NodeId.valueOf(s));
}
}
@@ -1223,18 +1265,18 @@
private final QName name;
private final int index; // 1-based index for same-name siblings
- private final String uuid;
+ private final NodeId id;
- private ChildNodeEntry(QName name, String uuid, int index) {
+ private ChildNodeEntry(QName name, NodeId id, int index) {
if (name == null) {
throw new IllegalArgumentException("name can not be null");
}
this.name = name;
- if (uuid == null) {
- throw new IllegalArgumentException("uuid can not be null");
+ if (id == null) {
+ throw new IllegalArgumentException("id can not be null");
}
- this.uuid = uuid;
+ this.id = id;
if (index < 1) {
throw new IllegalArgumentException("index is 1-based");
@@ -1242,8 +1284,8 @@
this.index = index;
}
- public String getUUID() {
- return uuid;
+ public NodeId getId() {
+ return id;
}
public QName getName() {
@@ -1261,14 +1303,14 @@
}
if (obj instanceof ChildNodeEntry) {
ChildNodeEntry other = (ChildNodeEntry) obj;
- return (name.equals(other.name) && uuid.equals(other.uuid)
+ return (name.equals(other.name) && id.equals(other.id)
&& index == other.index);
}
return false;
}
public String toString() {
- return name.toString() + "[" + index + "] -> " + uuid;
+ return name.toString() + "[" + index + "] -> " + id;
}
public int hashCode() {
@@ -1277,7 +1319,7 @@
if (h == 0) {
h = 17;
h = 37 * h + name.hashCode();
- h = 37 * h + uuid.hashCode();
+ h = 37 * h + id.hashCode();
h = 37 * h + index;
hash = h;
}
Added: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeStateIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeStateIterator.java?rev=378221&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeStateIterator.java (added)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeStateIterator.java Thu Feb 16 02:48:20 2006
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ * as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.core.state;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * <code>NodeStateIterator</code> extends the Iterator interface by the
+ * respective NodeState methods.
+ */
+public interface NodeStateIterator extends Iterator {
+
+ /**
+ * Returns the next node state of the iterator.
+ * @return the next node state.
+ * @throws NoSuchElementException
+ */
+ NodeState nextNodeState() throws NoSuchElementException;
+}
\ No newline at end of file
Propchange: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeStateIterator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeStateIterator.java
------------------------------------------------------------------------------
svn:keywords = author date id rev url
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeStateListener.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeStateListener.java?rev=378221&r1=378220&r2=378221&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeStateListener.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/NodeStateListener.java Thu Feb 16 02:48:20 2006
@@ -17,6 +17,7 @@
package org.apache.jackrabbit.core.state;
import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.core.NodeId;
/**
* Extends the <code>ItemStateListener</code> allowing a client to be
@@ -32,10 +33,10 @@
* @param state node state that changed
* @param name name of node that was added
* @param index index of new node
- * @param uuid uuid of new node
+ * @param id id of new node
*/
void nodeAdded(NodeState state,
- QName name, int index, String uuid);
+ QName name, int index, NodeId id);
/**
* Called when the children nodes were replaced by other nodes, typically
@@ -51,8 +52,8 @@
* @param state node state that changed
* @param name name of node that was removed
* @param index index of removed node
- * @param uuid uuid of removed node
+ * @param id id of removed node
*/
public void nodeRemoved(NodeState state,
- QName name, int index, String uuid);
+ QName name, int index, NodeId id);
}
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/PMContext.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/PMContext.java?rev=378221&r1=378220&r2=378221&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/PMContext.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/PMContext.java Thu Feb 16 02:48:20 2006
@@ -18,6 +18,7 @@
import org.apache.jackrabbit.core.fs.FileSystem;
import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
+import org.apache.jackrabbit.core.NodeId;
import javax.jcr.NamespaceRegistry;
import java.io.File;
@@ -53,25 +54,25 @@
/**
* uuid of the root node
*/
- private final String rootNodeUUID;
+ private final NodeId rootNodeId;
/**
* Creates a new <code>PMContext</code>.
*
* @param homeDir the physical home directory
* @param fs the virtual jackrabbit filesystem
- * @param rootNodeUUID uuid of the root node
+ * @param rootNodeId id of the root node
* @param nsReg namespace registry
* @param ntReg node type registry
*/
public PMContext(File homeDir,
FileSystem fs,
- String rootNodeUUID,
+ NodeId rootNodeId,
NamespaceRegistry nsReg,
NodeTypeRegistry ntReg) {
this.physicalHomeDir = homeDir;
this.fs = fs;
- this.rootNodeUUID = rootNodeUUID;
+ this.rootNodeId = rootNodeId;
this.nsReg = nsReg;
this.ntReg = ntReg;
}
@@ -79,7 +80,7 @@
/**
* Returns the physical home directory for this persistence manager
- * @return
+ * @return the physical home directory for this persistence manager
*/
public File getHomeDir() {
return physicalHomeDir;
@@ -87,19 +88,18 @@
/**
* Returns the virtual filesystem for this persistence manager
- * @return
+ * @return the virtual filesystem for this persistence manager
*/
public FileSystem getFileSystem() {
return fs;
}
/**
- * Returns the uuid of the root node
- *
- * @return the uuid of the root node
+ * Returns the id of the root node
+ * @return the id of the root node
*/
- public String getRootNodeUUID() {
- return rootNodeUUID;
+ public NodeId getRootNodeId() {
+ return rootNodeId;
}
/**
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java?rev=378221&r1=378220&r2=378221&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java Thu Feb 16 02:48:20 2006
@@ -17,6 +17,8 @@
package org.apache.jackrabbit.core.state;
import org.apache.jackrabbit.core.PropertyId;
+import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.ItemId;
import org.apache.jackrabbit.core.nodetype.PropDefId;
import org.apache.jackrabbit.core.value.BLOBFileValue;
import org.apache.jackrabbit.core.value.InternalValue;
@@ -39,15 +41,34 @@
*/
static final long serialVersionUID = 4569719974514326906L;
- protected QName name;
- protected InternalValue[] values;
- protected int type;
- protected boolean multiValued;
+ /**
+ * the id of this property state
+ */
+ private PropertyId id;
- protected PropDefId defId;
+ /**
+ * the internal values
+ */
+ private InternalValue[] values;
/**
- * Create a new <code>PropertyState</code>
+ * the type of this property state
+ */
+ private int type;
+
+ /**
+ * flag indicating if this is a multivalue property
+ */
+ private boolean multiValued;
+
+ /**
+ * the property definition id
+ */
+ private PropDefId defId;
+
+ /**
+ * Constructs a new property state that is initially connected to an
+ * overlayed state.
*
* @param overlayedState the backing property state being overlayed
* @param initialStatus the initial status of the property state object
@@ -55,24 +76,20 @@
*/
public PropertyState(PropertyState overlayedState, int initialStatus,
boolean isTransient) {
- super(initialStatus, isTransient);
-
- connect(overlayedState);
+ super(overlayedState, initialStatus, isTransient);
pull();
}
/**
* Create a new <code>PropertyState</code>
*
- * @param name name of the property
- * @param parentUUID the uuid of the parent node
+ * @param id id of the property
* @param initialStatus the initial status of the property state object
* @param isTransient flag indicating whether this state is transient or not
*/
- public PropertyState(QName name, String parentUUID, int initialStatus,
- boolean isTransient) {
- super(parentUUID, new PropertyId(parentUUID, name), initialStatus, isTransient);
- this.name = name;
+ public PropertyState(PropertyId id, int initialStatus, boolean isTransient) {
+ super(initialStatus, isTransient);
+ this.id = id;
type = PropertyType.UNDEFINED;
values = InternalValue.EMPTY_ARRAY;
multiValued = false;
@@ -83,14 +100,12 @@
*/
protected synchronized void copy(ItemState state) {
synchronized (state) {
- super.copy(state);
-
PropertyState propState = (PropertyState) state;
- name = propState.getName();
- type = propState.getType();
- defId = propState.getDefinitionId();
- values = propState.getValues();
- multiValued = propState.isMultiValued();
+ id = propState.id;
+ type = propState.type;
+ defId = propState.defId;
+ values = propState.values;
+ multiValued = propState.multiValued;
}
}
@@ -106,12 +121,34 @@
}
/**
+ * {@inheritDoc}
+ */
+ public ItemId getId() {
+ return id;
+ }
+
+ /**
+ * Returns the id of this property state.
+ * @return the id of this property state.
+ */
+ public PropertyId getPropertyId() {
+ return id;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public NodeId getParentId() {
+ return id.getParentId();
+ }
+
+ /**
* Returns the name of this property.
*
* @return the name of this property.
*/
public QName getName() {
- return name;
+ return id.getName();
}
/**
@@ -192,7 +229,7 @@
private void writeObject(ObjectOutputStream out) throws IOException {
// important: fields must be written in same order as they are
// read in readObject(ObjectInputStream)
- out.writeUTF(name.toString());
+ out.writeUTF(getName().toString());
out.writeInt(type);
out.writeBoolean(multiValued);
if (values == null) {
@@ -231,7 +268,7 @@
private void readObject(ObjectInputStream in) throws IOException {
// important: fields must be read in same order as they are
// written in writeObject(ObjectOutputStream)
- name = QName.valueOf(in.readUTF());
+ QName name = QName.valueOf(in.readUTF());
type = in.readInt();
multiValued = in.readBoolean();
short count = in.readShort(); // # of values