Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/RowIteratorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/RowIteratorImpl.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/RowIteratorImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/RowIteratorImpl.java Thu Oct 18 11:41:45 2007
@@ -29,15 +29,12 @@
import javax.jcr.query.Row;
import javax.jcr.query.RowIterator;
-import org.apache.jackrabbit.name.IllegalNameException;
-import org.apache.jackrabbit.name.NameFormat;
-import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.UnknownPrefixException;
-import org.apache.jackrabbit.value.ValueFormat;
+import org.apache.jackrabbit.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.spi.QueryInfo;
import org.apache.jackrabbit.spi.QueryResultRow;
import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.value.ValueFormat;
/**
* Implements the {@link javax.jcr.query.RowIterator} interface returned by
@@ -53,12 +50,12 @@
/**
* The column names.
*/
- private final QName[] columnNames;
+ private final Name[] columnNames;
/**
- * The <code>NamespaceResolver</code> of the user <code>Session</code>.
+ * The <code>NamePathResolver</code> of the user <code>Session</code>.
*/
- private final NamespaceResolver nsResolver;
+ private final org.apache.jackrabbit.conversion.NamePathResolver resolver;
/**
* The JCR value factory.
@@ -70,14 +67,14 @@
* nodes.
*
* @param queryInfo the query info.
- * @param resolver <code>NamespaceResolver</code> of the user
+ * @param nameResolver <code>NameResolver</code> of the user
* <code>Session</code>.
* @param vFactory the JCR value factory.
*/
- RowIteratorImpl(QueryInfo queryInfo, NamespaceResolver resolver, ValueFactory vFactory) {
+ RowIteratorImpl(QueryInfo queryInfo, NamePathResolver resolver, ValueFactory vFactory) {
this.rows = queryInfo.getRows();
this.columnNames = queryInfo.getColumnNames();
- this.nsResolver = resolver;
+ this.resolver = resolver;
this.vFactory = vFactory;
}
@@ -180,7 +177,7 @@
private Value[] values;
/**
- * Map of select property <code>QName</code>s. Key: QName, Value:
+ * Map of select property <code>Name</code>s. Key: Name, Value:
* Integer, which refers to the array index in {@link #values}.
*/
private Map propertyMap;
@@ -215,7 +212,7 @@
tmp[i] = null;
} else {
tmp[i] = ValueFormat.getJCRValue(
- qVals[i], nsResolver, vFactory);
+ qVals[i], resolver, vFactory);
}
}
values = tmp;
@@ -249,7 +246,7 @@
propertyMap = tmp;
}
try {
- QName prop = NameFormat.parse(propertyName, nsResolver);
+ Name prop = resolver.getQName(propertyName);
Integer idx = (Integer) propertyMap.get(prop);
if (idx == null) {
throw new ItemNotFoundException(propertyName);
@@ -259,9 +256,7 @@
getValues();
}
return values[idx.intValue()];
- } catch (IllegalNameException e) {
- throw new RepositoryException(e.getMessage(), e);
- } catch (UnknownPrefixException e) {
+ } catch (org.apache.jackrabbit.conversion.NameException e) {
throw new RepositoryException(e.getMessage(), e);
}
}
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/security/AccessManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/security/AccessManager.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/security/AccessManager.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/security/AccessManager.java Thu Oct 18 11:41:45 2007
@@ -16,7 +16,7 @@
*/
package org.apache.jackrabbit.jcr2spi.security;
-import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.spi.Path;
import org.apache.jackrabbit.jcr2spi.state.ItemState;
import org.apache.jackrabbit.jcr2spi.state.NodeState;
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChangeLog.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChangeLog.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChangeLog.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChangeLog.java Thu Oct 18 11:41:45 2007
@@ -21,7 +21,7 @@
import org.apache.jackrabbit.jcr2spi.operation.AddProperty;
import org.apache.jackrabbit.jcr2spi.operation.SetMixin;
import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
-import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.NameConstants;
import org.apache.commons.collections.iterators.IteratorChain;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -308,7 +308,7 @@
if (op instanceof AddNode) {
AddNode operation = (AddNode) op;
if (operation.getParentState() == parent
- && operation.getNodeName().equals(state.getQName())) {
+ && operation.getNodeName().equals(state.getName())) {
// TODO: this will not work for name name siblings!
it.remove();
break;
@@ -316,12 +316,12 @@
} else if (op instanceof AddProperty) {
AddProperty operation = (AddProperty) op;
if (operation.getParentState() == parent
- && operation.getPropertyName().equals(state.getQName())) {
+ && operation.getPropertyName().equals(state.getName())) {
it.remove();
break;
}
} else if (op instanceof SetMixin &&
- QName.JCR_MIXINTYPES.equals(state.getQName()) &&
+ NameConstants.JCR_MIXINTYPES.equals(state.getName()) &&
((SetMixin)op).getNodeState() == parent) {
it.remove();
break;
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java Thu Oct 18 11:41:45 2007
@@ -20,8 +20,8 @@
import org.apache.jackrabbit.spi.ItemId;
import org.apache.jackrabbit.spi.NodeId;
import org.apache.jackrabbit.spi.PropertyId;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.Path;
import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry;
import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
import org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry;
@@ -166,13 +166,13 @@
/**
* Utility method:
- * Returns the name of this state. Shortcut for calling 'getQName' on the
+ * Returns the name of this state. Shortcut for calling 'getName' on the
* {@link ItemState#getHierarchyEntry() hierarchy entry}.
*
* @return name of this state
*/
- public QName getQName() {
- return getHierarchyEntry().getQName();
+ public Name getName() {
+ return getHierarchyEntry().getName();
}
/**
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java Thu Oct 18 11:41:45 2007
@@ -36,9 +36,9 @@
import org.apache.jackrabbit.spi.QNodeDefinition;
import org.apache.jackrabbit.spi.QPropertyDefinition;
import org.apache.jackrabbit.spi.QItemDefinition;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.Path;
-import org.apache.jackrabbit.name.NamespaceResolver;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.PathFactory;
import javax.jcr.nodetype.ConstraintViolationException;
import javax.jcr.nodetype.NoSuchNodeTypeException;
@@ -92,14 +92,16 @@
* manager provider
*/
private final ManagerProvider mgrProvider;
+ private final PathFactory pathFactory;
/**
* Creates a new <code>ItemStateValidator</code> instance.
*
* @param mgrProvider manager provider
*/
- public ItemStateValidator(ManagerProvider mgrProvider) {
+ public ItemStateValidator(ManagerProvider mgrProvider, PathFactory pathFactory) {
this.mgrProvider = mgrProvider;
+ this.pathFactory = pathFactory;
}
/**
@@ -125,7 +127,7 @@
QNodeDefinition def = nodeState.getDefinition();
// check if primary type satisfies the 'required node types' constraint
- QName[] requiredPrimaryTypes = def.getRequiredPrimaryTypes();
+ Name[] requiredPrimaryTypes = def.getRequiredPrimaryTypes();
for (int i = 0; i < requiredPrimaryTypes.length; i++) {
if (!entPrimary.includesNodeType(requiredPrimaryTypes[i])) {
String msg = safeGetJCRPath(nodeState)
@@ -141,9 +143,9 @@
QPropertyDefinition[] pda = entPrimaryAndMixins.getMandatoryQPropertyDefinitions();
for (int i = 0; i < pda.length; i++) {
QPropertyDefinition pd = pda[i];
- if (!nodeState.hasPropertyName(pd.getQName())) {
+ if (!nodeState.hasPropertyName(pd.getName())) {
String msg = safeGetJCRPath(nodeState)
- + ": mandatory property " + pd.getQName()
+ + ": mandatory property " + pd.getName()
+ " does not exist";
log.debug(msg);
throw new ConstraintViolationException(msg);
@@ -153,9 +155,9 @@
QNodeDefinition[] cnda = entPrimaryAndMixins.getMandatoryQNodeDefinitions();
for (int i = 0; i < cnda.length; i++) {
QNodeDefinition cnd = cnda[i];
- if (!nodeState.getNodeEntry().hasNodeEntry(cnd.getQName())) {
+ if (!nodeState.getNodeEntry().hasNodeEntry(cnd.getName())) {
String msg = safeGetJCRPath(nodeState)
- + ": mandatory child node " + cnd.getQName()
+ + ": mandatory child node " + cnd.getName()
+ " does not exist";
log.debug(msg);
throw new ConstraintViolationException(msg);
@@ -170,10 +172,10 @@
*
* @param itemState
* @return JCR path
- * @see LogUtil#safeGetJCRPath(ItemState,NamespaceResolver)
+ * @see LogUtil#safeGetJCRPath(ItemState,org.apache.jackrabbit.conversion.PathResolver)
*/
private String safeGetJCRPath(ItemState itemState) {
- return LogUtil.safeGetJCRPath(itemState, mgrProvider.getNamespaceResolver());
+ return LogUtil.safeGetJCRPath(itemState, mgrProvider.getPathResolver());
}
//------------------------------------------------------< check methods >---
@@ -247,7 +249,7 @@
NodeState parent = propState.getParent();
QPropertyDefinition def = propState.getDefinition();
- checkWriteProperty(parent, propState.getQName(), def, options);
+ checkWriteProperty(parent, propState.getName(), def, options);
}
/**
@@ -279,7 +281,7 @@
* @throws PathNotFoundException
* @throws RepositoryException
*/
- public void checkAddProperty(NodeState parentState, QName propertyName, QPropertyDefinition definition, int options)
+ public void checkAddProperty(NodeState parentState, Name propertyName, QPropertyDefinition definition, int options)
throws ConstraintViolationException, AccessDeniedException,
VersionException, LockException, ItemNotFoundException,
ItemExistsException, PathNotFoundException, RepositoryException {
@@ -302,7 +304,7 @@
* @throws PathNotFoundException
* @throws RepositoryException
*/
- private void checkWriteProperty(NodeState parentState, QName propertyName, QPropertyDefinition definition, int options)
+ private void checkWriteProperty(NodeState parentState, Name propertyName, QPropertyDefinition definition, int options)
throws ConstraintViolationException, AccessDeniedException,
VersionException, LockException, ItemNotFoundException,
ItemExistsException, PathNotFoundException, RepositoryException {
@@ -312,7 +314,7 @@
// access restriction on prop.
if ((options & CHECK_ACCESS) == CHECK_ACCESS) {
// make sure current session is granted write access on new prop
- Path relPath = Path.create(propertyName, Path.INDEX_UNDEFINED);
+ Path relPath = pathFactory.create(propertyName);
if (!mgrProvider.getAccessManager().isGranted(parentState, relPath, new String[] {AccessManager.SET_PROPERTY_ACTION})) {
throw new AccessDeniedException(safeGetJCRPath(parentState) + ": not allowed to create property with name " + propertyName);
}
@@ -360,8 +362,8 @@
* @throws ItemExistsException
* @throws RepositoryException
*/
- public void checkAddNode(NodeState parentState, QName nodeName,
- QName nodeTypeName, int options)
+ public void checkAddNode(NodeState parentState, Name nodeName,
+ Name nodeTypeName, int options)
throws ConstraintViolationException, AccessDeniedException,
VersionException, LockException, ItemNotFoundException,
ItemExistsException, RepositoryException {
@@ -371,7 +373,7 @@
// access restrictions on new node
if ((options & CHECK_ACCESS) == CHECK_ACCESS) {
// make sure current session is granted write access on parent node
- Path relPath = Path.create(nodeName, Path.INDEX_UNDEFINED);
+ Path relPath = pathFactory.create(nodeName);
if (!mgrProvider.getAccessManager().isGranted(parentState, relPath, new String[] {AccessManager.ADD_NODE_ACTION})) {
throw new AccessDeniedException(safeGetJCRPath(parentState) + ": not allowed to add child node '" + nodeName +"'");
}
@@ -545,7 +547,7 @@
* @throws ItemExistsException
* @throws RepositoryException
*/
- private void checkCollision(NodeState parentState, QName propertyName) throws ItemExistsException, RepositoryException {
+ private void checkCollision(NodeState parentState, Name propertyName) throws ItemExistsException, RepositoryException {
NodeEntry parentEntry = (NodeEntry) parentState.getHierarchyEntry();
// check for name collisions with existing child nodes
if (parentEntry.hasNodeEntry(propertyName)) {
@@ -558,7 +560,7 @@
if (pe != null) {
try {
pe.getPropertyState();
- throw new ItemExistsException("Property '" + pe.getQName() + "' already exists.");
+ throw new ItemExistsException("Property '" + pe.getName() + "' already exists.");
} catch (ItemNotFoundException e) {
// apparently conflicting entry does not exist any more
// ignore and return
@@ -575,7 +577,7 @@
* @throws ConstraintViolationException
* @throws NoSuchNodeTypeException
*/
- private void checkCollision(NodeState parentState, QName nodeName, QName nodeTypeName) throws RepositoryException, ConstraintViolationException, NoSuchNodeTypeException {
+ private void checkCollision(NodeState parentState, Name nodeName, Name nodeTypeName) throws RepositoryException, ConstraintViolationException, NoSuchNodeTypeException {
if (parentState.hasPropertyName(nodeName)) {
// there's already a property with that name
throw new ItemExistsException("cannot add child node '"
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java Thu Oct 18 11:41:45 2007
@@ -21,11 +21,12 @@
import org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry;
import org.apache.jackrabbit.jcr2spi.util.StateUtility;
import org.apache.jackrabbit.jcr2spi.nodetype.ItemDefinitionProvider;
-import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.spi.NodeId;
import org.apache.jackrabbit.spi.ItemId;
import org.apache.jackrabbit.spi.QNodeDefinition;
import org.apache.jackrabbit.spi.NodeInfo;
+import org.apache.jackrabbit.name.NameConstants;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
@@ -49,7 +50,7 @@
/**
* the name of this node's primary type
*/
- private final QName nodeTypeName;
+ private final Name nodeTypeName;
/**
* Definition of this node state
@@ -59,7 +60,7 @@
/**
* the names of this node's mixin types
*/
- private QName[] mixinTypeNames = QName.EMPTY_ARRAY;
+ private Name[] mixinTypeNames = Name.EMPTY_ARRAY;
/**
* Constructs a NEW NodeState
@@ -71,7 +72,7 @@
* @param definition
* @param definitionProvider
*/
- protected NodeState(NodeEntry entry, QName nodeTypeName, QName[] mixinTypeNames,
+ protected NodeState(NodeEntry entry, Name nodeTypeName, Name[] mixinTypeNames,
ItemStateFactory isf, QNodeDefinition definition,
ItemDefinitionProvider definitionProvider) {
super(Status.NEW, entry, isf, definitionProvider);
@@ -255,7 +256,7 @@
// if property state defines a modified jcr:mixinTypes the parent
// is listed as modified state and needs to be processed at the end.
- if (QName.JCR_MIXINTYPES.equals(modState.getQName())) {
+ if (NameConstants.JCR_MIXINTYPES.equals(modState.getName())) {
try {
modifiedParent(modState.getParent(), modState, modParents);
} catch (RepositoryException e) {
@@ -332,7 +333,7 @@
*
* @return the name of this node's node type.
*/
- public QName getNodeTypeName() {
+ public Name getNodeTypeName() {
return nodeTypeName;
}
@@ -341,7 +342,7 @@
*
* @return a set of the names of this node's mixin types.
*/
- public QName[] getMixinTypeNames() {
+ public Name[] getMixinTypeNames() {
return mixinTypeNames;
}
@@ -351,7 +352,7 @@
*
* @param mixinTypeNames
*/
- public void setMixinTypeNames(QName[] mixinTypeNames) {
+ public void setMixinTypeNames(Name[] mixinTypeNames) {
if (mixinTypeNames != null) {
this.mixinTypeNames = mixinTypeNames;
}
@@ -363,10 +364,10 @@
*
* @return array of NodeType names
*/
- public synchronized QName[] getNodeTypeNames() {
+ public synchronized Name[] getNodeTypeNames() {
// mixin types
- QName[] mixinNames = getMixinTypeNames();
- QName[] types = new QName[mixinNames.length + 1];
+ Name[] mixinNames = getMixinTypeNames();
+ Name[] types = new Name[mixinNames.length + 1];
System.arraycopy(mixinNames, 0, types, 0, mixinNames.length);
// primary type
types[types.length - 1] = getNodeTypeName();
@@ -402,12 +403,12 @@
* Determines if there is a valid <code>NodeEntry</code> with the
* specified <code>name</code> and <code>index</code>.
*
- * @param name <code>QName</code> object specifying a node name.
+ * @param name <code>Name</code> object specifying a node name.
* @param index 1-based index if there are same-name child node entries.
* @return <code>true</code> if there is a <code>NodeEntry</code> with
* the specified <code>name</code> and <code>index</code>.
*/
- public boolean hasChildNodeEntry(QName name, int index) {
+ public boolean hasChildNodeEntry(Name name, int index) {
return getNodeEntry().hasNodeEntry(name, index);
}
@@ -417,13 +418,13 @@
* and index. Throws <code>ItemNotFoundException</code> if there's no
* matching, valid entry.
*
- * @param nodeName <code>QName</code> object specifying a node name.
+ * @param nodeName <code>Name</code> object specifying a node name.
* @param index 1-based index if there are same-name child node entries.
* @return The <code>NodeState</code> with the specified name and index
* @throws ItemNotFoundException
* @throws RepositoryException
*/
- public NodeState getChildNodeState(QName nodeName, int index) throws ItemNotFoundException, RepositoryException {
+ public NodeState getChildNodeState(Name nodeName, int index) throws ItemNotFoundException, RepositoryException {
NodeEntry ne = getNodeEntry().getNodeEntry(nodeName, index, true);
if (ne != null) {
return ne.getNodeState();
@@ -436,11 +437,11 @@
/**
* Utility
*
- * @param propName <code>QName</code> object specifying a property name
+ * @param propName <code>Name</code> object specifying a property name
* @return <code>true</code> if there is a valid property entry with the
- * specified <code>QName</code>.
+ * specified <code>Name</code>.
*/
- public boolean hasPropertyName(QName propName) {
+ public boolean hasPropertyName(Name propName) {
return getNodeEntry().hasPropertyEntry(propName);
}
@@ -455,10 +456,10 @@
* @throws RepositoryException If an error occurs while retrieving the
* property state.
*
- * @see NodeEntry#getPropertyEntry(QName, boolean)
+ * @see NodeEntry#getPropertyEntry(Name, boolean)
* @see PropertyEntry#getPropertyState()
*/
- public PropertyState getPropertyState(QName propertyName) throws ItemNotFoundException, RepositoryException {
+ public PropertyState getPropertyState(Name propertyName) throws ItemNotFoundException, RepositoryException {
PropertyEntry pe = getNodeEntry().getPropertyEntry(propertyName, true);
if (pe != null) {
return pe.getPropertyState();
@@ -495,12 +496,12 @@
*
* @param newParent
* @param childState
- * @param newName <code>QName</code> object specifying the entry's new name
+ * @param newName <code>Name</code> object specifying the entry's new name
* @throws RepositoryException if the given child state is not a child
* of this node state.
*/
synchronized void moveChildNodeEntry(NodeState newParent, NodeState childState,
- QName newName, QNodeDefinition newDefinition)
+ Name newName, QNodeDefinition newDefinition)
throws RepositoryException {
// move child entry
childState.getNodeEntry().move(newName, newParent.getNodeEntry(), true);
@@ -525,7 +526,7 @@
l = new ArrayList(2);
modParents.put(parent, l);
}
- if (childState != null && !childState.isNode() && StateUtility.isUuidOrMixin(childState.getQName())) {
+ if (childState != null && !childState.isNode() && StateUtility.isUuidOrMixin(childState.getName())) {
l.add(childState);
}
}
@@ -538,15 +539,15 @@
private static void adjustNodeState(NodeState parent, PropertyState[] props) {
for (int i = 0; i < props.length; i++) {
PropertyState propState = props[i];
- if (QName.JCR_UUID.equals(propState.getQName())) {
+ if (NameConstants.JCR_UUID.equals(propState.getName())) {
if (propState.getStatus() == Status.REMOVED) {
parent.getNodeEntry().setUniqueID(null);
} else {
// retrieve uuid from persistent layer
propState.reload(false);
}
- } else if (QName.JCR_MIXINTYPES.equals(propState.getQName())) {
- QName[] mixins = StateUtility.getMixinNames(propState);
+ } else if (NameConstants.JCR_MIXINTYPES.equals(propState.getName())) {
+ Name[] mixins = StateUtility.getMixinNames(propState);
parent.setMixinTypeNames(mixins);
} // else: ignore.
}
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java Thu Oct 18 11:41:45 2007
@@ -49,12 +49,13 @@
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
-import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.spi.QPropertyDefinition;
import org.apache.jackrabbit.spi.QNodeDefinition;
import org.apache.jackrabbit.spi.QValue;
import org.apache.jackrabbit.spi.QValueFactory;
import org.apache.jackrabbit.uuid.UUID;
+import org.apache.jackrabbit.name.NameConstants;
import javax.jcr.InvalidItemStateException;
import javax.jcr.ReferentialIntegrityException;
@@ -271,7 +272,7 @@
*/
public void visit(AddProperty operation) throws ValueFormatException, LockException, ConstraintViolationException, AccessDeniedException, ItemExistsException, UnsupportedRepositoryOperationException, VersionException, RepositoryException {
NodeState parent = operation.getParentState();
- QName propertyName = operation.getPropertyName();
+ Name propertyName = operation.getPropertyName();
QPropertyDefinition pDef = operation.getDefinition();
int targetType = pDef.getRequiredType();
if (targetType == PropertyType.UNDEFINED) {
@@ -347,12 +348,12 @@
*/
public void visit(SetMixin operation) throws ConstraintViolationException, AccessDeniedException, NoSuchNodeTypeException, UnsupportedRepositoryOperationException, VersionException, RepositoryException {
// NOTE: nodestate is only modified upon save of the changes!
- QName[] mixinNames = operation.getMixinNames();
+ Name[] mixinNames = operation.getMixinNames();
NodeState nState = operation.getNodeState();
NodeEntry nEntry = (NodeEntry) nState.getHierarchyEntry();
// new array of mixinNames to be set on the nodestate (and corresponding property state)
- PropertyEntry mixinEntry = nEntry.getPropertyEntry(QName.JCR_MIXINTYPES);
+ PropertyEntry mixinEntry = nEntry.getPropertyEntry(NameConstants.JCR_MIXINTYPES);
if (mixinNames != null && mixinNames.length > 0) {
// update/create corresponding property state
if (mixinEntry != null) {
@@ -363,10 +364,10 @@
} else {
// create new jcr:mixinTypes property
ItemDefinitionProvider defProvider = mgrProvider.getItemDefinitionProvider();
- QPropertyDefinition pd = defProvider.getQPropertyDefinition(nState, QName.JCR_MIXINTYPES, PropertyType.NAME, true);
+ QPropertyDefinition pd = defProvider.getQPropertyDefinition(nState, NameConstants.JCR_MIXINTYPES, PropertyType.NAME, true);
QValue[] mixinValue = getQValues(mixinNames, qValueFactory);
int options = ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_VERSIONING;
- addPropertyState(nState, pd.getQName(), pd.getRequiredType(), mixinValue, pd, options);
+ addPropertyState(nState, pd.getName(), pd.getRequiredType(), mixinValue, pd, options);
}
nState.markModified();
transientStateMgr.addOperation(operation);
@@ -587,7 +588,7 @@
* @throws VersionException
* @throws RepositoryException
*/
- private void addPropertyState(NodeState parent, QName propertyName,
+ private void addPropertyState(NodeState parent, Name propertyName,
int propertyType, QValue[] values,
QPropertyDefinition pDef, int options)
throws LockException, ConstraintViolationException, AccessDeniedException, ItemExistsException, NoSuchNodeTypeException, UnsupportedRepositoryOperationException, VersionException, RepositoryException {
@@ -598,7 +599,7 @@
transientStateMgr.createNewPropertyState(propertyName, parent, pDef, values, propertyType);
}
- private void addNodeState(NodeState parent, QName nodeName, QName nodeTypeName,
+ private void addNodeState(NodeState parent, Name nodeName, Name nodeTypeName,
String uuid, QNodeDefinition definition, int options)
throws RepositoryException, ConstraintViolationException, AccessDeniedException,
UnsupportedRepositoryOperationException, NoSuchNodeTypeException,
@@ -628,20 +629,20 @@
if (uuid != null) {
QValue[] value = getQValues(uuid, qValueFactory);
ItemDefinitionProvider defProvider = mgrProvider.getItemDefinitionProvider();
- QPropertyDefinition pDef = defProvider.getQPropertyDefinition(QName.MIX_REFERENCEABLE, QName.JCR_UUID, PropertyType.STRING, false);
- addPropertyState(nodeState, QName.JCR_UUID, PropertyType.STRING, value, pDef, 0);
+ QPropertyDefinition pDef = defProvider.getQPropertyDefinition(NameConstants.MIX_REFERENCEABLE, NameConstants.JCR_UUID, PropertyType.STRING, false);
+ addPropertyState(nodeState, NameConstants.JCR_UUID, PropertyType.STRING, value, pDef, 0);
}
// add 'auto-create' properties defined in node type
QPropertyDefinition[] pda = ent.getAutoCreateQPropertyDefinitions();
for (int i = 0; i < pda.length; i++) {
QPropertyDefinition pd = pda[i];
- if (!nodeState.hasPropertyName(pd.getQName())) {
+ if (!nodeState.hasPropertyName(pd.getName())) {
QValue[] autoValue = computeSystemGeneratedPropertyValues(nodeState, pd);
if (autoValue != null) {
int propOptions = ItemStateValidator.CHECK_NONE;
// execute 'addProperty' without adding operation.
- addPropertyState(nodeState, pd.getQName(), pd.getRequiredType(), autoValue, pd, propOptions);
+ addPropertyState(nodeState, pd.getName(), pd.getRequiredType(), autoValue, pd, propOptions);
}
}
}
@@ -652,7 +653,7 @@
QNodeDefinition nd = nda[i];
// execute 'addNode' without adding the operation.
int opt = ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_COLLISION;
- addNodeState(nodeState, nd.getQName(), nd.getDefaultPrimaryType(), null, nd, opt);
+ addNodeState(nodeState, nd.getName(), nd.getDefaultPrimaryType(), null, nd, opt);
}
}
@@ -709,33 +710,33 @@
} else if (def.isAutoCreated()) {
// handle known predefined nodetypes that declare auto-created
// properties without default values
- QName declaringNT = def.getDeclaringNodeType();
- QName name = def.getQName();
- if (QName.MIX_REFERENCEABLE.equals(declaringNT) && QName.JCR_UUID.equals(name)) {
+ Name declaringNT = def.getDeclaringNodeType();
+ Name name = def.getName();
+ if (NameConstants.MIX_REFERENCEABLE.equals(declaringNT) && NameConstants.JCR_UUID.equals(name)) {
// mix:referenceable node type defines jcr:uuid
genValues = getQValues(parent.getUniqueID(), qValueFactory);
- } else if (QName.NT_BASE.equals(declaringNT)) {
+ } else if (NameConstants.NT_BASE.equals(declaringNT)) {
// nt:base node type
- if (QName.JCR_PRIMARYTYPE.equals(name)) {
+ if (NameConstants.JCR_PRIMARYTYPE.equals(name)) {
// jcr:primaryType property
genValues = new QValue[]{qValueFactory.create(parent.getNodeTypeName())};
- } else if (QName.JCR_MIXINTYPES.equals(name)) {
+ } else if (NameConstants.JCR_MIXINTYPES.equals(name)) {
// jcr:mixinTypes property
- QName[] mixins = parent.getMixinTypeNames();
+ Name[] mixins = parent.getMixinTypeNames();
genValues = getQValues(mixins, qValueFactory);
}
- } else if (QName.NT_HIERARCHYNODE.equals(declaringNT) && QName.JCR_CREATED.equals(name)) {
+ } else if (NameConstants.NT_HIERARCHYNODE.equals(declaringNT) && NameConstants.JCR_CREATED.equals(name)) {
// nt:hierarchyNode node type defines jcr:created property
genValues = new QValue[]{qValueFactory.create(Calendar.getInstance())};
- } else if (QName.NT_RESOURCE.equals(declaringNT) && QName.JCR_LASTMODIFIED.equals(name)) {
+ } else if (NameConstants.NT_RESOURCE.equals(declaringNT) && NameConstants.JCR_LASTMODIFIED.equals(name)) {
// nt:resource node type defines jcr:lastModified property
genValues = new QValue[]{qValueFactory.create(Calendar.getInstance())};
- } else if (QName.NT_VERSION.equals(declaringNT) && QName.JCR_CREATED.equals(name)) {
+ } else if (NameConstants.NT_VERSION.equals(declaringNT) && NameConstants.JCR_CREATED.equals(name)) {
// nt:version node type defines jcr:created property
genValues = new QValue[]{qValueFactory.create(Calendar.getInstance())};
} else {
// TODO: TOBEFIXED. other nodetype -> build some default value
- log.warn("Missing implementation. Nodetype " + def.getDeclaringNodeType() + " defines autocreated property " + def.getQName() + " without default value.");
+ log.warn("Missing implementation. Nodetype " + def.getDeclaringNodeType() + " defines autocreated property " + def.getName() + " without default value.");
}
}
return genValues;
@@ -744,9 +745,9 @@
/**
* @param qNames
* @param factory
- * @return An array of QValue objects from the given <code>QName</code>s
+ * @return An array of QValue objects from the given <code>Name</code>s
*/
- private static QValue[] getQValues(QName[] qNames, QValueFactory factory) {
+ private static QValue[] getQValues(Name[] qNames, QValueFactory factory) {
QValue[] ret = new QValue[qNames.length];
for (int i = 0; i < qNames.length; i++) {
ret[i] = factory.create(qNames[i]);
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientISFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientISFactory.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientISFactory.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientISFactory.java Thu Oct 18 11:41:45 2007
@@ -22,7 +22,7 @@
import org.apache.jackrabbit.spi.NodeId;
import org.apache.jackrabbit.spi.PropertyId;
import org.apache.jackrabbit.spi.QPropertyDefinition;
-import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
import org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry;
import org.apache.jackrabbit.jcr2spi.nodetype.ItemDefinitionProvider;
@@ -53,12 +53,12 @@
//------------------------------------------< TransientItemStateFactory >---
/**
* @inheritDoc
- * @see TransientItemStateFactory#createNewNodeState(NodeEntry , QName, QNodeDefinition)
+ * @see TransientItemStateFactory#createNewNodeState(NodeEntry , Name, QNodeDefinition)
*/
- public NodeState createNewNodeState(NodeEntry entry, QName nodetypeName,
+ public NodeState createNewNodeState(NodeEntry entry, Name nodetypeName,
QNodeDefinition definition) {
- NodeState nodeState = new NodeState(entry, nodetypeName, QName.EMPTY_ARRAY, this, definition, defProvider);
+ NodeState nodeState = new NodeState(entry, nodetypeName, Name.EMPTY_ARRAY, this, definition, defProvider);
// notify listeners that a node state has been created
notifyCreated(nodeState);
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateFactory.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateFactory.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateFactory.java Thu Oct 18 11:41:45 2007
@@ -16,7 +16,7 @@
*/
package org.apache.jackrabbit.jcr2spi.state;
-import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
import org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry;
import org.apache.jackrabbit.spi.QNodeDefinition;
@@ -38,7 +38,7 @@
* @return the created <code>NodeState</code>
*/
public NodeState createNewNodeState(NodeEntry entry,
- QName nodeTypeName,
+ Name nodeTypeName,
QNodeDefinition definition);
/**
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java Thu Oct 18 11:41:45 2007
@@ -18,7 +18,7 @@
import org.apache.jackrabbit.jcr2spi.operation.Operation;
import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
-import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.spi.QNodeDefinition;
import org.apache.jackrabbit.spi.QPropertyDefinition;
import org.apache.jackrabbit.spi.QValue;
@@ -35,9 +35,9 @@
* {@link ItemState}s and also provides methods to create new item states.
* While all other modifications can be invoked on the item state instances itself,
* creating a new node state is done using
- * {@link #createNewNodeState(QName, String, QName, QNodeDefinition, NodeState)}
+ * {@link #createNewNodeState(Name, String, Name, QNodeDefinition, NodeState)}
* and
- * {@link #createNewPropertyState(QName, NodeState, QPropertyDefinition, QValue[], int)}.
+ * {@link #createNewPropertyState(Name, NodeState, QPropertyDefinition, QValue[], int)}.
*/
public class TransientItemStateManager implements ItemStateCreationListener {
@@ -96,7 +96,7 @@
* @param parent the parent of the new node state.
* @return a new transient {@link NodeState}.
*/
- NodeState createNewNodeState(QName nodeName, String uniqueID, QName nodeTypeName,
+ NodeState createNewNodeState(Name nodeName, String uniqueID, Name nodeTypeName,
QNodeDefinition definition, NodeState parent)
throws RepositoryException {
NodeState nodeState = ((NodeEntry) parent.getHierarchyEntry()).addNewNodeEntry(nodeName, uniqueID, nodeTypeName, definition);
@@ -118,7 +118,7 @@
* @throws ConstraintViolationException
* @throws RepositoryException
*/
- PropertyState createNewPropertyState(QName propName, NodeState parent,
+ PropertyState createNewPropertyState(Name propName, NodeState parent,
QPropertyDefinition definition,
QValue[] values, int propertyType)
throws ItemExistsException, ConstraintViolationException, RepositoryException {
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java Thu Oct 18 11:41:45 2007
@@ -18,6 +18,11 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.jcr2spi.nodetype.ItemDefinitionProvider;
+import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
+import org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry;
+import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry;
+import org.apache.jackrabbit.name.NameConstants;
import org.apache.jackrabbit.spi.NodeId;
import org.apache.jackrabbit.spi.PropertyId;
import org.apache.jackrabbit.spi.NodeInfo;
@@ -25,13 +30,8 @@
import org.apache.jackrabbit.spi.SessionInfo;
import org.apache.jackrabbit.spi.RepositoryService;
import org.apache.jackrabbit.spi.ItemInfo;
-import org.apache.jackrabbit.jcr2spi.nodetype.ItemDefinitionProvider;
-import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
-import org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry;
-import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.Path;
-import org.apache.jackrabbit.name.MalformedPathException;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.Path;
import javax.jcr.PathNotFoundException;
import javax.jcr.RepositoryException;
@@ -163,7 +163,7 @@
public NodeReferences getNodeReferences(NodeState nodeState) {
NodeEntry entry = nodeState.getNodeEntry();
// shortcut
- if (entry.getUniqueID() == null || !entry.hasPropertyEntry(QName.JCR_UUID)) {
+ if (entry.getUniqueID() == null || !entry.hasPropertyEntry(NameConstants.JCR_UUID)) {
// for sure not referenceable
return EmptyNodeReferences.getInstance();
}
@@ -263,7 +263,7 @@
List propNames = new ArrayList();
for (Iterator it = info.getPropertyIds(); it.hasNext(); ) {
PropertyId pId = (PropertyId) it.next();
- QName propertyName = pId.getQName();
+ Name propertyName = pId.getName();
propNames.add(propertyName);
}
try {
@@ -315,11 +315,11 @@
// entries are missing -> calculate relative path.
Path anyParentPath = anyParent.getPath();
Path relPath = anyParentPath.computeRelativePath(info.getPath());
- Path.PathElement[] missingElems = relPath.getElements();
+ Path.Element[] missingElems = relPath.getElements();
NodeEntry entry = anyParent;
for (int i = 0; i < missingElems.length; i++) {
- QName name = missingElems[i].getName();
+ Name name = missingElems[i].getName();
int index = missingElems[i].getNormalizedIndex();
entry = createIntermediateNodeEntry(entry, name, index);
}
@@ -329,8 +329,6 @@
return createNodeState(info, entry);
} catch (PathNotFoundException e) {
throw new ItemNotFoundException(e.getMessage(), e);
- } catch (MalformedPathException e) {
- throw new RepositoryException(e.getMessage(), e);
}
}
@@ -348,18 +346,18 @@
// entries are missing -> calculate relative path.
Path anyParentPath = anyParent.getPath();
Path relPath = anyParentPath.computeRelativePath(info.getPath());
- Path.PathElement[] missingElems = relPath.getElements();
+ Path.Element[] missingElems = relPath.getElements();
NodeEntry entry = anyParent;
int i = 0;
// NodeEntries except for the very last 'missingElem'
while (i < missingElems.length - 1) {
- QName name = missingElems[i].getName();
+ Name name = missingElems[i].getName();
int index = missingElems[i].getNormalizedIndex();
entry = createIntermediateNodeEntry(entry, name, index);
i++;
}
// create PropertyEntry for the last element if not existing yet
- QName propName = missingElems[i].getName();
+ Name propName = missingElems[i].getName();
PropertyEntry propEntry = entry.getPropertyEntry(propName);
if (propEntry == null) {
propEntry = entry.addPropertyEntry(propName);
@@ -367,8 +365,6 @@
return createPropertyState(info, propEntry);
} catch (PathNotFoundException e) {
throw new ItemNotFoundException(e.getMessage());
- } catch (MalformedPathException e) {
- throw new RepositoryException(e.getMessage());
}
}
@@ -380,7 +376,7 @@
* @return
* @throws RepositoryException
*/
- private static NodeEntry createIntermediateNodeEntry(NodeEntry parentEntry, QName name, int index) throws RepositoryException {
+ private static NodeEntry createIntermediateNodeEntry(NodeEntry parentEntry, Name name, int index) throws RepositoryException {
NodeEntry entry;
if (parentEntry.hasNodeEntry(name, index)) {
entry = parentEntry.getNodeEntry(name, index);
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/LogUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/LogUtil.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/LogUtil.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/LogUtil.java Thu Oct 18 11:41:45 2007
@@ -18,16 +18,15 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.jackrabbit.name.Path;
-import org.apache.jackrabbit.name.PathFormat;
-import org.apache.jackrabbit.name.NoPrefixDeclaredException;
-import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.NameFormat;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.jcr2spi.state.ItemState;
import org.apache.jackrabbit.spi.ItemId;
+import org.apache.jackrabbit.conversion.NameResolver;
+import org.apache.jackrabbit.conversion.PathResolver;
import javax.jcr.RepositoryException;
+import javax.jcr.NamespaceException;
/**
* <code>LogUtil</code>...
@@ -41,13 +40,13 @@
* error messages etc.
*
* @param qPath path to convert
- * @param nsResolver
+ * @param pathResolver
* @return JCR path
*/
- public static String safeGetJCRPath(Path qPath, NamespaceResolver nsResolver) {
+ public static String safeGetJCRPath(Path qPath, PathResolver pathResolver) {
try {
- return PathFormat.format(qPath, nsResolver);
- } catch (NoPrefixDeclaredException npde) {
+ return pathResolver.getJCRPath(qPath);
+ } catch (NamespaceException e) {
log.error("failed to convert " + qPath + " to JCR path.");
// return string representation of internal path as a fallback
return qPath.toString();
@@ -59,12 +58,12 @@
* error messages etc.
*
* @param itemState
- * @param nsResolver
+ * @param pathResolver
* @return JCR path
*/
- public static String safeGetJCRPath(ItemState itemState, NamespaceResolver nsResolver) {
+ public static String safeGetJCRPath(ItemState itemState, PathResolver pathResolver) {
try {
- return safeGetJCRPath(itemState.getHierarchyEntry().getPath(), nsResolver);
+ return safeGetJCRPath(itemState.getHierarchyEntry().getPath(), pathResolver);
} catch (RepositoryException e) {
ItemId id = itemState.getId();
log.error("failed to convert " + id + " to JCR path.");
@@ -73,18 +72,18 @@
}
/**
- * Failsafe conversion of a <code>QName</code> to a JCR name for use in
+ * Failsafe conversion of a <code>Name</code> to a JCR name for use in
* error messages etc.
*
* @param qName
- * @param nsResolver
- * @return JCR name or String representation of the given <code>QName</code>
+ * @param nameResolver
+ * @return JCR name or String representation of the given <code>Name</code>
* in case the resolution fails.
*/
- public static String saveGetJCRName(QName qName, NamespaceResolver nsResolver) {
+ public static String saveGetJCRName(Name qName, NameResolver nameResolver) {
try {
- return NameFormat.format(qName, nsResolver);
- } catch (NoPrefixDeclaredException e) {
+ return nameResolver.getJCRName(qName);
+ } catch (NamespaceException e) {
log.error("failed to convert " + qName + " to JCR name.");
return qName.toString();
}
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/StateUtility.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/StateUtility.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/StateUtility.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/StateUtility.java Thu Oct 18 11:41:45 2007
@@ -18,12 +18,13 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.jcr2spi.state.PropertyState;
import org.apache.jackrabbit.jcr2spi.state.Status;
import org.apache.jackrabbit.jcr2spi.state.NodeState;
import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.name.NameConstants;
import javax.jcr.RepositoryException;
@@ -39,20 +40,20 @@
* @param ps
* @return
* @throws IllegalArgumentException if the name of the PropertyState is NOT
- * {@link QName#JCR_MIXINTYPES}
+ * {@link NameConstants#JCR_MIXINTYPES}
*/
- public static QName[] getMixinNames(PropertyState ps) {
- if (!QName.JCR_MIXINTYPES.equals(ps.getQName())) {
+ public static Name[] getMixinNames(PropertyState ps) {
+ if (!NameConstants.JCR_MIXINTYPES.equals(ps.getName())) {
throw new IllegalArgumentException();
}
if (ps.getStatus() == Status.REMOVED) {
- return QName.EMPTY_ARRAY;
+ return Name.EMPTY_ARRAY;
} else {
QValue[] values = ps.getValues();
- QName[] newMixins = new QName[values.length];
+ Name[] newMixins = new Name[values.length];
for (int i = 0; i < values.length; i++) {
try {
- newMixins[i] = values[i].getQName();
+ newMixins[i] = values[i].getName();
} catch (RepositoryException e) {
// ignore: should never occur.
}
@@ -62,8 +63,8 @@
}
- public static boolean isUuidOrMixin(QName propName) {
- return QName.JCR_UUID.equals(propName) || QName.JCR_MIXINTYPES.equals(propName);
+ public static boolean isUuidOrMixin(Name propName) {
+ return NameConstants.JCR_UUID.equals(propName) || NameConstants.JCR_MIXINTYPES.equals(propName);
}
public static boolean isMovedState(NodeState state) {
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/DefaultVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/DefaultVersionManager.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/DefaultVersionManager.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/DefaultVersionManager.java Thu Oct 18 11:41:45 2007
@@ -23,8 +23,8 @@
import javax.jcr.UnsupportedRepositoryOperationException;
import javax.jcr.version.VersionException;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.Path;
import org.apache.jackrabbit.jcr2spi.state.NodeState;
import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
@@ -58,11 +58,11 @@
throw new UnsupportedRepositoryOperationException("Versioning ist not supported by this repository.");
}
- public void addVersionLabel(NodeState versionHistoryState, NodeState versionState, QName qLabel, boolean moveLabel) throws RepositoryException {
+ public void addVersionLabel(NodeState versionHistoryState, NodeState versionState, Name qLabel, boolean moveLabel) throws RepositoryException {
throw new UnsupportedRepositoryOperationException("Versioning ist not supported by this repository.");
}
- public void removeVersionLabel(NodeState versionHistoryState, NodeState versionState, QName qLabel) throws RepositoryException {
+ public void removeVersionLabel(NodeState versionHistoryState, NodeState versionState, Name qLabel) throws RepositoryException {
throw new UnsupportedRepositoryOperationException("Versioning ist not supported by this repository.");
}
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java Thu Oct 18 11:41:45 2007
@@ -26,11 +26,10 @@
import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
import org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry;
import org.apache.jackrabbit.jcr2spi.state.NodeState;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.NameException;
-import org.apache.jackrabbit.name.NoPrefixDeclaredException;
-import org.apache.jackrabbit.name.Path;
-import org.apache.jackrabbit.name.NameFormat;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.conversion.NameException;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.name.NameConstants;
import javax.jcr.version.VersionHistory;
import javax.jcr.version.Version;
@@ -65,7 +64,7 @@
this.vhEntry = (NodeEntry) state.getHierarchyEntry();
// retrieve hierarchy entry of the jcr:versionLabels node
- labelNodeEntry = vhEntry.getNodeEntry(QName.JCR_VERSIONLABELS, Path.INDEX_DEFAULT, true);
+ labelNodeEntry = vhEntry.getNodeEntry(NameConstants.JCR_VERSIONLABELS, Path.INDEX_DEFAULT, true);
if (labelNodeEntry == null) {
String msg = "Unexpected error: nt:versionHistory requires a mandatory, autocreated child node jcr:versionLabels.";
log.error(msg);
@@ -82,7 +81,7 @@
*/
public String getVersionableUUID() throws RepositoryException {
checkStatus();
- return getProperty(QName.JCR_VERSIONABLEUUID).getString();
+ return getProperty(NameConstants.JCR_VERSIONABLEUUID).getString();
}
/**
@@ -93,7 +92,7 @@
*/
public Version getRootVersion() throws RepositoryException {
checkStatus();
- NodeEntry vEntry = vhEntry.getNodeEntry(QName.JCR_ROOTVERSION, Path.INDEX_DEFAULT, true);
+ NodeEntry vEntry = vhEntry.getNodeEntry(NameConstants.JCR_ROOTVERSION, Path.INDEX_DEFAULT, true);
if (vEntry == null) {
String msg = "Unexpected error: VersionHistory state does not contain a root version child node entry.";
log.error(msg);
@@ -116,7 +115,7 @@
// all child-nodes except from jcr:versionLabels point to Versions.
while (childIter.hasNext()) {
NodeEntry entry = (NodeEntry) childIter.next();
- if (!QName.JCR_VERSIONLABELS.equals(entry.getQName())) {
+ if (!NameConstants.JCR_VERSIONLABELS.equals(entry.getName())) {
versionEntries.add(entry);
}
}
@@ -160,7 +159,7 @@
*/
public void addVersionLabel(String versionName, String label, boolean moveLabel) throws VersionException, RepositoryException {
checkStatus();
- QName qLabel = getQLabel(label);
+ Name qLabel = getQLabel(label);
NodeState vState = getVersionState(versionName);
// delegate to version manager that operates on workspace directely
session.getVersionManager().addVersionLabel((NodeState) getItemState(), vState, qLabel, moveLabel);
@@ -175,7 +174,7 @@
*/
public void removeVersionLabel(String label) throws VersionException, RepositoryException {
checkStatus();
- QName qLabel = getQLabel(label);
+ Name qLabel = getQLabel(label);
Version version = getVersionByLabel(qLabel);
NodeState vState = getVersionState(version.getName());
// delegate to version manager that operates on workspace directely
@@ -191,8 +190,8 @@
*/
public boolean hasVersionLabel(String label) throws RepositoryException {
checkStatus();
- QName l = getQLabel(label);
- QName[] qLabels = getQLabels();
+ Name l = getQLabel(label);
+ Name[] qLabels = getQLabels();
for (int i = 0; i < qLabels.length; i++) {
if (qLabels[i].equals(l)) {
return true;
@@ -213,9 +212,9 @@
// check-status performed within checkValidVersion
checkValidVersion(version);
String vUUID = version.getUUID();
- QName l = getQLabel(label);
+ Name l = getQLabel(label);
- QName[] qLabels = getQLabels();
+ Name[] qLabels = getQLabels();
for (int i = 0; i < qLabels.length; i++) {
if (qLabels[i].equals(l)) {
String uuid = getVersionByLabel(qLabels[i]).getUUID();
@@ -233,16 +232,11 @@
*/
public String[] getVersionLabels() throws RepositoryException {
checkStatus();
- QName[] qLabels = getQLabels();
+ Name[] qLabels = getQLabels();
String[] labels = new String[qLabels.length];
for (int i = 0; i < qLabels.length; i++) {
- try {
- labels[i] = NameFormat.format(qLabels[i], session.getNamespaceResolver());
- } catch (NoPrefixDeclaredException e) {
- // unexpected error. should not occur.
- throw new RepositoryException(e);
- }
+ labels[i] = session.getNameResolver().getJCRName(qLabels[i]);
}
return labels;
}
@@ -261,16 +255,11 @@
String vUUID = version.getUUID();
List vlabels = new ArrayList();
- QName[] qLabels = getQLabels();
+ Name[] qLabels = getQLabels();
for (int i = 0; i < qLabels.length; i++) {
String uuid = getVersionByLabel(qLabels[i]).getUUID();
if (vUUID.equals(uuid)) {
- try {
- vlabels.add(NameFormat.format(qLabels[i], session.getNamespaceResolver()));
- } catch (NoPrefixDeclaredException e) {
- // should never occur
- throw new RepositoryException("Unexpected error while accessing version label", e);
- }
+ vlabels.add(session.getNameResolver().getJCRName(qLabels[i]));
}
}
return (String[]) vlabels.toArray(new String[vlabels.size()]);
@@ -339,17 +328,17 @@
*
* @return
*/
- private QName[] getQLabels() throws RepositoryException {
+ private Name[] getQLabels() throws RepositoryException {
refreshEntry(labelNodeEntry);
- List labelQNames = new ArrayList();
+ List labelNames = new ArrayList();
for (Iterator it = labelNodeEntry.getPropertyEntries(); it.hasNext(); ) {
PropertyEntry pe = (PropertyEntry) it.next();
- if (! QName.JCR_PRIMARYTYPE.equals(pe.getQName()) &&
- ! QName.JCR_MIXINTYPES.equals(pe.getQName())) {
- labelQNames.add(pe.getQName());
+ if (! NameConstants.JCR_PRIMARYTYPE.equals(pe.getName()) &&
+ ! NameConstants.JCR_MIXINTYPES.equals(pe.getName())) {
+ labelNames.add(pe.getName());
}
}
- return (QName[]) labelQNames.toArray(new QName[labelQNames.size()]);
+ return (Name[]) labelNames.toArray(new Name[labelNames.size()]);
}
/**
@@ -361,15 +350,15 @@
*/
private NodeState getVersionState(String versionName) throws VersionException, RepositoryException {
try {
- QName vQName = NameFormat.parse(versionName, session.getNamespaceResolver());
+ Name vName = session.getNameResolver().getQName(versionName);
refreshEntry(vhEntry);
- NodeEntry vEntry = vhEntry.getNodeEntry(vQName, Path.INDEX_DEFAULT, true);
+ NodeEntry vEntry = vhEntry.getNodeEntry(vName, Path.INDEX_DEFAULT, true);
if (vEntry == null) {
throw new VersionException("Version '" + versionName + "' does not exist in this version history.");
} else {
return vEntry.getNodeState();
}
- } catch (NameException e) {
+ } catch (org.apache.jackrabbit.conversion.NameException e) {
throw new RepositoryException(e);
}
}
@@ -381,7 +370,7 @@
* @throws VersionException
* @throws RepositoryException
*/
- private Version getVersionByLabel(QName qLabel) throws VersionException, RepositoryException {
+ private Version getVersionByLabel(Name qLabel) throws VersionException, RepositoryException {
refreshEntry(labelNodeEntry);
// retrieve reference property value -> and retrieve referenced node
PropertyEntry pEntry = labelNodeEntry.getPropertyEntry(qLabel, true);
@@ -398,9 +387,9 @@
* @return
* @throws RepositoryException
*/
- private QName getQLabel(String label) throws RepositoryException {
+ private Name getQLabel(String label) throws RepositoryException {
try {
- return NameFormat.parse(label, session.getNamespaceResolver());
+ return session.getNameResolver().getQName(label);
} catch (NameException e) {
String error = "Invalid version label: " + e.getMessage();
log.error(error);
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionImpl.java Thu Oct 18 11:41:45 2007
@@ -23,7 +23,8 @@
import org.apache.jackrabbit.jcr2spi.SessionImpl;
import org.apache.jackrabbit.jcr2spi.ItemLifeCycleListener;
import org.apache.jackrabbit.jcr2spi.state.NodeState;
-import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.name.NameConstants;
import javax.jcr.version.Version;
import javax.jcr.version.VersionHistory;
@@ -65,7 +66,7 @@
* @see Version#getCreated()
*/
public Calendar getCreated() throws RepositoryException {
- return getProperty(QName.JCR_CREATED).getDate();
+ return getProperty(NameConstants.JCR_CREATED).getDate();
}
/**
@@ -75,7 +76,7 @@
* @see Version#getSuccessors()
*/
public Version[] getSuccessors() throws RepositoryException {
- return getVersions(QName.JCR_SUCCESSORS);
+ return getVersions(NameConstants.JCR_SUCCESSORS);
}
/**
@@ -85,7 +86,7 @@
* @see Version#getPredecessors()
*/
public Version[] getPredecessors() throws RepositoryException {
- return getVersions(QName.JCR_PREDECESSORS);
+ return getVersions(NameConstants.JCR_PREDECESSORS);
}
//---------------------------------------------------------------< Item >---
@@ -141,7 +142,7 @@
* @param propertyName
* @return
*/
- private Version[] getVersions(QName propertyName) throws RepositoryException {
+ private Version[] getVersions(Name propertyName) throws RepositoryException {
Version[] versions;
Value[] values = getProperty(propertyName).getValues();
if (values != null) {
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManager.java Thu Oct 18 11:41:45 2007
@@ -16,8 +16,8 @@
*/
package org.apache.jackrabbit.jcr2spi.version;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.Path;
import org.apache.jackrabbit.jcr2spi.state.NodeState;
import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
@@ -97,7 +97,7 @@
* @throws RepositoryException
* @see javax.jcr.version.VersionHistory#addVersionLabel(String, String, boolean)
*/
- public void addVersionLabel(NodeState versionHistoryState, NodeState versionState, QName qLabel, boolean moveLabel) throws VersionException, RepositoryException;
+ public void addVersionLabel(NodeState versionHistoryState, NodeState versionState, Name qLabel, boolean moveLabel) throws VersionException, RepositoryException;
/**
* @param versionHistoryState
@@ -107,7 +107,7 @@
* @throws RepositoryException
* @see javax.jcr.version.VersionHistory#removeVersionLabel(String)
*/
- public void removeVersionLabel(NodeState versionHistoryState, NodeState versionState, QName qLabel) throws VersionException, RepositoryException;
+ public void removeVersionLabel(NodeState versionHistoryState, NodeState versionState, Name qLabel) throws VersionException, RepositoryException;
/**
* @param nodeState
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionManagerImpl.java Thu Oct 18 11:41:45 2007
@@ -37,10 +37,11 @@
import javax.jcr.ItemNotFoundException;
import javax.jcr.version.VersionException;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.Path;
import org.apache.jackrabbit.spi.NodeId;
import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.name.NameConstants;
import java.util.Iterator;
@@ -87,7 +88,7 @@
// entry might even not be accessible, the check may not detect
// a checked-in parent. ok, as long as the 'server' finds out upon
// save or upon executing the workspace operation.
- while (!nodeEntry.hasPropertyEntry(QName.JCR_ISCHECKEDOUT)) {
+ while (!nodeEntry.hasPropertyEntry(NameConstants.JCR_ISCHECKEDOUT)) {
NodeEntry parent = nodeEntry.getParent();
if (parent == null) {
// reached root state without finding a jcr:isCheckedOut property
@@ -95,7 +96,7 @@
}
nodeEntry = parent;
}
- PropertyState propState = nodeEntry.getPropertyEntry(QName.JCR_ISCHECKEDOUT).getPropertyState();
+ PropertyState propState = nodeEntry.getPropertyEntry(NameConstants.JCR_ISCHECKEDOUT).getPropertyState();
Boolean b = Boolean.valueOf(propState.getValue().getString());
return b.booleanValue();
} catch (ItemNotFoundException e) {
@@ -117,12 +118,12 @@
workspaceManager.execute(op);
}
- public void addVersionLabel(NodeState versionHistoryState, NodeState versionState, QName qLabel, boolean moveLabel) throws RepositoryException {
+ public void addVersionLabel(NodeState versionHistoryState, NodeState versionState, Name qLabel, boolean moveLabel) throws RepositoryException {
Operation op = AddLabel.create(versionHistoryState, versionState, qLabel, moveLabel);
workspaceManager.execute(op);
}
- public void removeVersionLabel(NodeState versionHistoryState, NodeState versionState, QName qLabel) throws RepositoryException {
+ public void removeVersionLabel(NodeState versionHistoryState, NodeState versionState, Name qLabel) throws RepositoryException {
Operation op = RemoveLabel.create(versionHistoryState, versionState, qLabel);
workspaceManager.execute(op);
}
@@ -147,7 +148,7 @@
boolean done) throws RepositoryException {
NodeId vId = versionState.getNodeId();
- PropertyState mergeFailedState = nodeState.getPropertyState(QName.JCR_MERGEFAILED);
+ PropertyState mergeFailedState = nodeState.getPropertyState(NameConstants.JCR_MERGEFAILED);
QValue[] vs = mergeFailedState.getValues();
NodeId[] mergeFailedIds = new NodeId[vs.length - 1];
@@ -161,7 +162,7 @@
// part of 'jcr:mergefailed' any more
}
- PropertyState predecessorState = nodeState.getPropertyState(QName.JCR_PREDECESSORS);
+ PropertyState predecessorState = nodeState.getPropertyState(NameConstants.JCR_PREDECESSORS);
vs = predecessorState.getValues();
int noOfPredecessors = (done) ? vs.length + 1 : vs.length;
@@ -180,8 +181,8 @@
}
public NodeEntry getVersionableNodeEntry(NodeState versionState) throws RepositoryException {
- NodeState ns = versionState.getChildNodeState(QName.JCR_FROZENNODE, Path.INDEX_DEFAULT);
- PropertyState ps = ns.getPropertyState(QName.JCR_FROZENUUID);
+ NodeState ns = versionState.getChildNodeState(NameConstants.JCR_FROZENNODE, Path.INDEX_DEFAULT);
+ PropertyState ps = ns.getPropertyState(NameConstants.JCR_FROZENUUID);
String uniqueID = ps.getValue().getString();
NodeId versionableId = workspaceManager.getIdFactory().createNodeId(uniqueID);
@@ -189,7 +190,7 @@
}
public NodeEntry getVersionHistoryEntry(NodeState versionableState) throws RepositoryException {
- PropertyState ps = versionableState.getPropertyState(QName.JCR_VERSIONHISTORY);
+ PropertyState ps = versionableState.getPropertyState(NameConstants.JCR_VERSIONHISTORY);
String uniqueID = ps.getValue().getString();
NodeId vhId = workspaceManager.getIdFactory().createNodeId(uniqueID);
return (NodeEntry) workspaceManager.getHierarchyManager().getHierarchyEntry(vhId);
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/AbstractSAXEventGenerator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/AbstractSAXEventGenerator.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/AbstractSAXEventGenerator.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/AbstractSAXEventGenerator.java Thu Oct 18 11:41:45 2007
@@ -16,11 +16,13 @@
*/
package org.apache.jackrabbit.jcr2spi.xml;
-import org.apache.jackrabbit.name.NameException;
-import org.apache.jackrabbit.name.NameFormat;
-import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.SessionNamespaceResolver;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.namespace.SessionNamespaceResolver;
+import org.apache.jackrabbit.namespace.NamespaceResolver;
+import org.apache.jackrabbit.name.NameConstants;
+import org.apache.jackrabbit.name.NameFactoryImpl;
+import org.apache.jackrabbit.conversion.NameResolver;
+import org.apache.jackrabbit.conversion.ParsingNameResolver;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
@@ -63,9 +65,9 @@
*/
protected final Session session;
/**
- * the session's namespace resolver
+ * the name resolver
*/
- protected final NamespaceResolver nsResolver;
+ protected final NameResolver nameResolver;
/**
* the content handler to feed the SAX events to
@@ -123,7 +125,8 @@
throws RepositoryException {
startNode = node;
session = node.getSession();
- nsResolver = new SessionNamespaceResolver(session);
+ NamespaceResolver nsResolver = new SessionNamespaceResolver(session);
+ nameResolver = new ParsingNameResolver(NameFactoryImpl.getInstance(), nsResolver);
this.contentHandler = contentHandler;
this.skipBinary = skipBinary;
@@ -133,19 +136,12 @@
// resolve the names of some wellknown properties
// allowing for session-local prefix mappings
- try {
- jcrPrimaryType = NameFormat.format(QName.JCR_PRIMARYTYPE, nsResolver);
- jcrMixinTypes = NameFormat.format(QName.JCR_MIXINTYPES, nsResolver);
- jcrUUID = NameFormat.format(QName.JCR_UUID, nsResolver);
- jcrRoot = NameFormat.format(QName.JCR_ROOT, nsResolver);
- jcrXMLText = NameFormat.format(QName.JCR_XMLTEXT, nsResolver);
- jcrXMLCharacters = NameFormat.format(QName.JCR_XMLCHARACTERS, nsResolver);
- } catch (NameException e) {
- // should never get here...
- String msg = "internal error: failed to resolve namespace mappings";
- log.error(msg, e);
- throw new RepositoryException(msg, e);
- }
+ jcrPrimaryType = nameResolver.getJCRName(NameConstants.JCR_PRIMARYTYPE);
+ jcrMixinTypes = nameResolver.getJCRName(NameConstants.JCR_MIXINTYPES);
+ jcrUUID = nameResolver.getJCRName(NameConstants.JCR_UUID);
+ jcrRoot = nameResolver.getJCRName(NameConstants.JCR_ROOT);
+ jcrXMLText = nameResolver.getJCRName(NameConstants.JCR_XMLTEXT);
+ jcrXMLCharacters = nameResolver.getJCRName(NameConstants.JCR_XMLCHARACTERS);
}
/**
@@ -178,7 +174,7 @@
String[] prefixes = session.getNamespacePrefixes();
for (int i = 0; i < prefixes.length; i++) {
String prefix = prefixes[i];
- if (QName.NS_XML_PREFIX.equals(prefix)) {
+ if (Name.NS_XML_PREFIX.equals(prefix)) {
// skip 'xml' prefix as this would be an illegal namespace declaration
continue;
}
@@ -197,7 +193,7 @@
String[] prefixes = session.getNamespacePrefixes();
for (int i = 0; i < prefixes.length; i++) {
String prefix = prefixes[i];
- if (QName.NS_XML_PREFIX.equals(prefix)) {
+ if (Name.NS_XML_PREFIX.equals(prefix)) {
// skip 'xml' prefix as this would be an illegal namespace declaration
continue;
}
@@ -225,7 +221,7 @@
String prefix = prefixes[i];
if (prefix.length() > 0
- && !QName.NS_XML_PREFIX.equals(prefix)) {
+ && !Name.NS_XML_PREFIX.equals(prefix)) {
String uri = session.getNamespaceURI(prefix);
// get the matching namespace from previous declarations
@@ -234,9 +230,9 @@
if (!uri.equals(mappedToNs)) {
// when not the same, add a declaration
attributes.addAttribute(
- QName.NS_XMLNS_URI,
+ Name.NS_XMLNS_URI,
prefix,
- QName.NS_XMLNS_PREFIX + ":" + prefix,
+ Name.NS_XMLNS_PREFIX + ":" + prefix,
"CDATA",
uri);
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/DocViewImportHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/DocViewImportHandler.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/DocViewImportHandler.java (original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/DocViewImportHandler.java Thu Oct 18 11:41:45 2007
@@ -16,11 +16,12 @@
*/
package org.apache.jackrabbit.jcr2spi.xml;
-import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.name.NameException;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.NameFormat;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.NameFactory;
+import org.apache.jackrabbit.name.NameConstants;
+import org.apache.jackrabbit.conversion.NameResolver;
import org.apache.jackrabbit.util.ISO9075;
+import org.apache.jackrabbit.namespace.NamespaceResolver;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.slf4j.LoggerFactory;
@@ -28,6 +29,7 @@
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
+import javax.jcr.NamespaceException;
import java.io.IOException;
import java.io.Reader;
@@ -42,6 +44,7 @@
private static Logger log = LoggerFactory.getLogger(DocViewImportHandler.class);
+ private final NameFactory nameFactory;
/**
* stack of NodeInfo instances; an instance is pushed onto the stack
* in the startElement method and is popped from the stack in the
@@ -57,8 +60,10 @@
* @param importer
* @param nsContext
*/
- DocViewImportHandler(Importer importer, NamespaceResolver nsContext) {
- super(importer, nsContext);
+ DocViewImportHandler(Importer importer, NamespaceResolver nsContext,
+ NameResolver nameResolver, NameFactory nameFactory) {
+ super(importer, nsContext, nameResolver);
+ this.nameFactory = nameFactory;
}
/**
@@ -125,12 +130,12 @@
}
Importer.NodeInfo node =
- new Importer.NodeInfo(QName.JCR_XMLTEXT, null, null, null);
+ new Importer.NodeInfo(NameConstants.JCR_XMLTEXT, null, null, null);
Importer.TextValue[] values =
new Importer.TextValue[]{textHandler};
ArrayList props = new ArrayList();
Importer.PropInfo prop =
- new Importer.PropInfo(QName.JCR_XMLCHARACTERS, PropertyType.STRING, values);
+ new Importer.PropInfo(NameConstants.JCR_XMLCHARACTERS, PropertyType.STRING, values);
props.add(prop);
// call Importer
importer.startNode(node, props, nsContext);
@@ -164,42 +169,41 @@
processCharacters();
try {
- QName nodeName = new QName(namespaceURI, localName);
- // decode node name
- nodeName = ISO9075.decode(nodeName);
+ String dcdLocalName = ISO9075.decode(localName);
+ Name nodeName = nameFactory.create(namespaceURI, dcdLocalName);
// properties
String uuid = null;
- QName nodeTypeName = null;
- QName[] mixinTypes = null;
+ Name nodeTypeName = null;
+ Name[] mixinTypes = null;
ArrayList props = new ArrayList(atts.getLength());
for (int i = 0; i < atts.getLength(); i++) {
- if (atts.getURI(i).equals(QName.NS_XMLNS_URI)) {
+ if (atts.getURI(i).equals(Name.NS_XMLNS_URI)) {
// skip namespace declarations reported as attributes
// see http://issues.apache.org/jira/browse/JCR-620#action_12448164
continue;
}
- QName propName = new QName(atts.getURI(i), atts.getLocalName(i));
- // decode property name
- propName = ISO9075.decode(propName);
+
+ dcdLocalName = ISO9075.decode(atts.getLocalName(i));
+ Name propName = nameFactory.create(atts.getURI(i), dcdLocalName);
// attribute value
String attrValue = atts.getValue(i);
- if (propName.equals(QName.JCR_PRIMARYTYPE)) {
+ if (propName.equals(NameConstants.JCR_PRIMARYTYPE)) {
// jcr:primaryType
if (attrValue.length() > 0) {
try {
- nodeTypeName = NameFormat.parse(attrValue, nsContext);
- } catch (NameException ne) {
+ nodeTypeName = nameResolver.getQName(attrValue);
+ } catch (org.apache.jackrabbit.conversion.NameException ne) {
throw new SAXException("illegal jcr:primaryType value: "
+ attrValue, ne);
}
}
- } else if (propName.equals(QName.JCR_MIXINTYPES)) {
+ } else if (propName.equals(NameConstants.JCR_MIXINTYPES)) {
// jcr:mixinTypes
mixinTypes = parseNames(attrValue);
- } else if (propName.equals(QName.JCR_UUID)) {
+ } else if (propName.equals(NameConstants.JCR_UUID)) {
// jcr:uuid
if (attrValue.length() > 0) {
uuid = attrValue;
@@ -230,20 +234,22 @@
* Parses the given string as a list of JCR names. Any whitespace sequence
* is supported as a names separator instead of just a single space to
* be more liberal in what we accept. The current namespace context is
- * used to convert the prefixed name strings to QNames.
+ * used to convert the prefixed name strings to Names.
*
* @param value string value
* @return the parsed names
* @throws SAXException if an invalid name was encountered
*/
- private QName[] parseNames(String value) throws SAXException {
+ private Name[] parseNames(String value) throws SAXException {
String[] names = value.split("\\p{Space}+");
- QName[] qnames = new QName[names.length];
+ Name[] qnames = new Name[names.length];
for (int i = 0; i < names.length; i++) {
try {
- qnames[i] = NameFormat.parse(names[i], nsContext);
- } catch (NameException ne) {
+ qnames[i] = nameResolver.getQName(names[i]);
+ } catch (org.apache.jackrabbit.conversion.NameException ne) {
throw new SAXException("Invalid name: " + names[i], ne);
+ } catch (NamespaceException e) {
+ throw new SAXException("Invalid name: " + names[i], e);
}
}
return qnames;
|