jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: rev 47297 - incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype
Date Mon, 27 Sep 2004 15:55:07 GMT
Author: stefan
Date: Mon Sep 27 08:55:05 2004
New Revision: 47297

Modified:
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ChildItemDef.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDefImpl.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefId.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefStore.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDefId.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.xml
Log:
adopting spec change: 
'*' is returned by ItemDef.getName() instead of null to denote residual child item definition

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ChildItemDef.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ChildItemDef.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ChildItemDef.java
Mon Sep 27 08:55:05 2004
@@ -16,6 +16,7 @@
 package org.apache.jackrabbit.core.nodetype;
 
 import org.apache.jackrabbit.core.QName;
+import org.apache.jackrabbit.core.NamespaceRegistryImpl;
 
 import javax.jcr.version.OnParentVersionAction;
 
@@ -27,8 +28,12 @@
  */
 abstract class ChildItemDef implements Cloneable {
 
+    // '*' denoting residual child item definition
+    protected static final QName ANY_NAME =
+	    new QName(NamespaceRegistryImpl.NS_DEFAULT_URI, "*");
+
     protected QName declaringNodeType = null;
-    private QName name = null;
+    private QName name = ANY_NAME;
     private boolean autoCreate = false;
     private int onParentVersion = OnParentVersionAction.COPY;
     private boolean writeProtected = false;
@@ -113,6 +118,10 @@
 
     public boolean isPrimaryItem() {
 	return primaryItem;
+    }
+
+    public boolean definesResidual() {
+	return name.equals(ANY_NAME);
     }
 
     public abstract boolean definesNode();

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java
Mon Sep 27 08:55:05 2004
@@ -108,23 +108,23 @@
 
 	ChildNodeDef[] cnda = ntd.getChildNodeDefs();
 	for (int i = 0; i < cnda.length; i++) {
-	    QName name = cnda[i].getName();
-	    if (name == null) {
+	    if (cnda[i].definesResidual()) {
 		// residual node definition
 		ent.unnamedItemDefs.add(cnda[i]);
 	    } else {
 		// named node definition
+		QName name = cnda[i].getName();
 		ent.namedItemDefs.put(name, cnda[i]);
 	    }
 	}
 	PropDef[] pda = ntd.getPropertyDefs();
 	for (int i = 0; i < pda.length; i++) {
-	    QName name = pda[i].getName();
-	    if (name == null) {
+	    if (pda[i].definesResidual()) {
 		// residual property definition
 		ent.unnamedItemDefs.add(pda[i]);
 	    } else {
 		// named property definition
+		QName name = pda[i].getName();
 		ent.namedItemDefs.put(name, pda[i]);
 	    }
 	}

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDefImpl.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDefImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDefImpl.java
Mon Sep 27 08:55:05 2004
@@ -34,6 +34,8 @@
 
     private static Logger log = Logger.getLogger(ItemDefImpl.class);
 
+    protected static final String ANY_NAME = "*";
+
     protected final NodeTypeManagerImpl ntMgr;
     // namespace resolver used to translate qualified names to JCR names
     protected final NamespaceResolver nsResolver;
@@ -75,17 +77,17 @@
      * @see ItemDef#getName
      */
     public String getName() {
-	QName name = itemDef.getName();
-	if (name == null) {
-	    return null;
-	}
-	try {
-	    return name.toJCRName(nsResolver);
-	} catch (NoPrefixDeclaredException npde) {
-	    // should never get here
-	    log.error("encountered unregistered namespace in property name", npde);
-	    // not correct, but an acceptable fallback
-	    return itemDef.getName().toString();
+	if (itemDef.definesResidual()) {
+	    return ANY_NAME;
+	} else {
+	    try {
+		return itemDef.getName().toJCRName(nsResolver);
+	    } catch (NoPrefixDeclaredException npde) {
+		// should never get here
+		log.error("encountered unregistered namespace in property name", npde);
+		// not correct, but an acceptable fallback
+		return itemDef.getName().toString();
+	    }
 	}
     }
 

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefId.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefId.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefId.java
Mon Sep 27 08:55:05 2004
@@ -42,7 +42,7 @@
 
 	sb.append(def.getDeclaringNodeType().toString());
 	sb.append('/');
-	if (def.getName() == null) {
+	if (def.definesResidual()) {
 	    sb.append('*');
 	} else {
 	    sb.append(def.getName().toString());

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefStore.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefStore.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefStore.java
Mon Sep 27 08:55:05 2004
@@ -70,6 +70,8 @@
     private static final String REQUIREDPRIMARYTYPE_ELEMENT = "requiredPrimaryType";
     private static final String DEFAULTPRIMARYTYPE_ATTRIBUTE = "defaultPrimaryType";
 
+    private static final String WILDCARD = "*";
+
     // map of node type names and node type definitions
     private HashMap ntDefs;
 
@@ -278,7 +280,7 @@
 	    pd.setDeclaringNodeType(qntName);
 	    // name
 	    String propName = elem.getAttributeValue(NAME_ATTRIBUTE);
-	    if (propName != null && propName.length() > 0) {
+	    if (propName != null && !propName.equals(WILDCARD)) {
 		try {
 		    pd.setName(QName.fromJCRName(propName, nsResolver));
 		} catch (BaseException e) {
@@ -286,6 +288,8 @@
 		    log.error(msg, e);
 		    throw new InvalidNodeTypeDefException(msg, e);
 		}
+	    } else {
+		pd.setName(ChildItemDef.ANY_NAME);
 	    }
 	    // type
 	    String typeName = elem.getAttributeValue(TYPE_ATTRIBUTE);
@@ -402,7 +406,7 @@
 	    cnd.setDeclaringNodeType(qntName);
 	    // name
 	    String nodeName = elem.getAttributeValue(NAME_ATTRIBUTE);
-	    if (nodeName != null && nodeName.length() > 0) {
+	    if (nodeName != null && !nodeName.equals(WILDCARD)) {
 		try {
 		    cnd.setName(QName.fromJCRName(nodeName, nsResolver));
 		} catch (BaseException e) {
@@ -410,6 +414,8 @@
 		    log.error(msg, e);
 		    throw new InvalidNodeTypeDefException(msg, e);
 		}
+	    } else {
+		cnd.setName(ChildItemDef.ANY_NAME);
 	    }
 	    // requiredPrimaryTypes
 	    Element reqTtypesElem = elem.getChild(REQUIREDPRIMARYTYPES_ELEMENT);
@@ -524,7 +530,7 @@
 		ntElem.addContent(elem);
 
 		// name
-		String name = pd.getName() == null ? "" : pd.getName().toJCRName(nsResolver);
+		String name = pd.definesResidual() ? WILDCARD : pd.getName().toJCRName(nsResolver);
 		elem.setAttribute(NAME_ATTRIBUTE, name);
 		// type
 		elem.setAttribute(TYPE_ATTRIBUTE, PropertyType.nameFromValue(pd.getRequiredType()));
@@ -575,7 +581,7 @@
 		ntElem.addContent(elem);
 
 		// name
-		String name = nd.getName() == null ? "" : nd.getName().toJCRName(nsResolver);
+		String name = nd.definesResidual() ? WILDCARD : nd.getName().toJCRName(nsResolver);
 		elem.setAttribute(NAME_ATTRIBUTE, name);
 		// requiredPrimaryTypes
 		qNames = nd.getRequiredPrimaryTypes();

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
Mon Sep 27 08:55:05 2004
@@ -37,6 +37,7 @@
  * @version $Revision: 1.54 $, $Date: 2004/08/27 15:48:20 $
  */
 public class NodeTypeManagerImpl implements NodeTypeManager, NodeTypeRegistryListener {
+
     private static Logger log = Logger.getLogger(NodeTypeManagerImpl.class);
 
     private final NodeTypeRegistry ntReg;
@@ -226,7 +227,7 @@
 	 */
 	public String getName() {
 	    // not applicable
-	    return null;
+	    return "";
 	}
 
 	/**

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
Mon Sep 27 08:55:05 2004
@@ -174,12 +174,12 @@
 	    internalRegister(builtInNTDefs.all());
 	} catch (IOException ioe) {
 	    String error = "internal error: failed to read built-in node type definitions stored
in " + BUILTIN_NODETYPES_RESOURCE_PATH;
-	    log.error(error);
-	    throw new RepositoryException(error);
+	    log.error(error, ioe);
+	    throw new RepositoryException(error, ioe);
 	} catch (InvalidNodeTypeDefException intde) {
 	    String error = "internal error: invalid built-in node type definition stored in " +
BUILTIN_NODETYPES_RESOURCE_PATH;
-	    log.error(error);
-	    throw new RepositoryException(error);
+	    log.error(error, intde);
+	    throw new RepositoryException(error, intde);
 	} finally {
 	    if (in != null) {
 		try {
@@ -229,7 +229,6 @@
     private static ChildNodeDef createRootNodeDef() {
 	ChildNodeDef def = new ChildNodeDef();
 
-	//def.setName(null);
 	// FIXME need a fake declaring node type
 	def.setDeclaringNodeType(new QName(NamespaceRegistryImpl.NS_DEFAULT_URI, ""));
 	def.setRequiredPrimaryTypes(new QName[]{NT_BASE});
@@ -466,7 +465,7 @@
 	    PropDef pd = pda[i];
 	    // check primary item flag
 	    if (pd.isPrimaryItem()) {
-		if (pd.getName() == null) {
+		if (pd.definesResidual()) {
 		    String reason = "primary item must specify a name";
 		    log.error(reason);
 		    throw new InvalidNodeTypeDefException(reason);
@@ -480,7 +479,7 @@
 		}
 	    }
 	    // check that auto-created properties specify a name
-	    if (pd.getName() == null && pd.isAutoCreate()) {
+	    if (pd.definesResidual() && pd.isAutoCreate()) {
 		String reason = "auto-created properties must specify a name";
 		log.error(reason);
 		throw new InvalidNodeTypeDefException(reason);
@@ -496,7 +495,7 @@
 			    constraints[j].check(defVals[k]);
 			} catch (ConstraintViolationException cve) {
 			    String msg = "default value of property "
-				    + (pd.getName() == null ? "[null]" : pd.getName().toString())
+				    + (pd.definesResidual() ? "*" : pd.getName().toString())
 				    + " does not satisfy value constraint "
 				    + constraints[j].getDefinition();
 			    log.error(msg, cve);
@@ -513,7 +512,7 @@
 	    ChildNodeDef cnd = cnda[i];
 	    // check primary item flag
 	    if (cnd.isPrimaryItem()) {
-		if (cnd.getName() == null) {
+		if (cnd.definesResidual()) {
 		    String msg = "primary item must specify a name";
 		    log.error(msg);
 		    throw new InvalidNodeTypeDefException(msg);
@@ -527,7 +526,7 @@
 		}
 	    }
 	    // check that auto-created child-nodes specify a name
-	    if (cnd.getName() == null && cnd.isAutoCreate()) {
+	    if (cnd.definesResidual() && cnd.isAutoCreate()) {
 		String msg = "auto-created child-nodes must specify a name";
 		log.error(msg);
 		throw new InvalidNodeTypeDefException(msg);
@@ -1095,9 +1094,9 @@
 	    for (int i = 0; i < pd.length; i++) {
 		ps.print("\tPropertyDef");
 		ps.println(" (declared in " + pd[i].getDeclaringNodeType() + ") id=" + new PropDefId(pd[i]));
-		ps.println("\t\tName\t\t" + pd[i].getName());
+		ps.println("\t\tName\t\t" + (pd[i].definesResidual() ? "*" : pd[i].getName().toString()));
 		String type = pd[i].getRequiredType() == 0 ? "null" : PropertyType.nameFromValue(pd[i].getRequiredType());
-		ps.println("\t\tRequiredType\t\t" + type);
+		ps.println("\t\tRequiredType\t" + type);
 		ValueConstraint[] vca = pd[i].getValueConstraints();
 		StringBuffer constraints = new StringBuffer();
 		if (vca == null) {
@@ -1135,7 +1134,7 @@
 	    for (int i = 0; i < nd.length; i++) {
 		ps.print("\tNodeDef");
 		ps.println(" (declared in " + nd[i].getDeclaringNodeType() + ") id=" + new NodeDefId(nd[i]));
-		ps.println("\t\tName\t" + nd[i].getName());
+		ps.println("\t\tName\t\t" + (nd[i].definesResidual() ? "*" : nd[i].getName().toString()));
 		QName[] reqPrimaryTypes = nd[i].getRequiredPrimaryTypes();
 		if (reqPrimaryTypes != null && reqPrimaryTypes.length > 0) {
 		    for (int n = 0; n < reqPrimaryTypes.length; n++) {

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDefId.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDefId.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDefId.java
Mon Sep 27 08:55:05 2004
@@ -39,7 +39,7 @@
 
 	sb.append(def.getDeclaringNodeType().toString());
 	sb.append('/');
-	if (def.getName() == null) {
+	if (def.definesResidual()) {
 	    sb.append('*');
 	} else {
 	    sb.append(def.getName().toString());

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.xml
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.xml
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.xml
Mon Sep 27 08:55:05 2004
@@ -72,13 +72,13 @@
 	<supertypes>
 	    <supertype>nt:base</supertype>
 	</supertypes>
-	<childNodeDef name="" defaultPrimaryType="nt:unstructured" autoCreate="false" mandatory="false"
onParentVersion="COPY" protected="false" primaryItem="false" sameNameSibs="true">
+	<childNodeDef name="*" defaultPrimaryType="nt:unstructured" autoCreate="false" mandatory="false"
onParentVersion="COPY" protected="false" primaryItem="false" sameNameSibs="true">
 	    <requiredPrimaryTypes>
 		<requiredPrimaryType>nt:base</requiredPrimaryType>
 	    </requiredPrimaryTypes>
 	</childNodeDef>
-	<propertyDef name="" type="undefined" autoCreate="false" mandatory="false" onParentVersion="COPY"
protected="false" primaryItem="false" multiple="true"/>
-	<propertyDef name="" type="undefined" autoCreate="false" mandatory="false" onParentVersion="COPY"
protected="false" primaryItem="false" multiple="false"/>
+	<propertyDef name="*" type="undefined" autoCreate="false" mandatory="false" onParentVersion="COPY"
protected="false" primaryItem="false" multiple="true"/>
+	<propertyDef name="*" type="undefined" autoCreate="false" mandatory="false" onParentVersion="COPY"
protected="false" primaryItem="false" multiple="false"/>
     </nodeType>
     <nodeType name="nt:hierarchyNode" mixin="false" orderableChildNodes="false">
 	<supertypes>
@@ -110,7 +110,7 @@
 	<supertypes>
 	    <supertype>nt:hierarchyNode</supertype>
 	</supertypes>
-	<childNodeDef name="" defaultPrimaryType="" autoCreate="false" mandatory="false" onParentVersion="VERSION"
protected="false" primaryItem="false" sameNameSibs="false">
+	<childNodeDef name="*" defaultPrimaryType="" autoCreate="false" mandatory="false" onParentVersion="VERSION"
protected="false" primaryItem="false" sameNameSibs="false">
 	    <requiredPrimaryTypes>
 		<requiredPrimaryType>nt:hierarchyNode</requiredPrimaryType>
 	    </requiredPrimaryTypes>
@@ -178,7 +178,7 @@
 		<requiredPrimaryType>nt:version</requiredPrimaryType>
 	    </requiredPrimaryTypes>
 	</childNodeDef>
- 	<childNodeDef name="" defaultPrimaryType="nt:version" autoCreate="false" mandatory="false"
onParentVersion="ABORT" protected="true" primaryItem="false" sameNameSibs="false">
+ 	<childNodeDef name="*" defaultPrimaryType="nt:version" autoCreate="false" mandatory="false"
onParentVersion="ABORT" protected="true" primaryItem="false" sameNameSibs="false">
 	     <requiredPrimaryTypes>
 		 <requiredPrimaryType>nt:version</requiredPrimaryType>
 	     </requiredPrimaryTypes>
@@ -206,9 +206,9 @@
 	<propertyDef name="jcr:frozenPrimaryType" type="Name" autoCreate="false" mandatory="true"
onParentVersion="ABORT" protected="true" primaryItem="false" multiple="false"/>
 	<propertyDef name="jcr:frozenMixinTypes" type="Name" autoCreate="false" mandatory="false"
onParentVersion="ABORT" protected="true" primaryItem="false" multiple="true"/>
 	<propertyDef name="jcr:frozenUUID" type="String" autoCreate="false" mandatory="false"
onParentVersion="ABORT" protected="true" primaryItem="false" multiple="false"/>
-	<propertyDef name="" type="undefined" autoCreate="false" mandatory="false" onParentVersion="ABORT"
protected="true" primaryItem="false" multiple="true"/>
-	<propertyDef name="" type="undefined" autoCreate="false" mandatory="false" onParentVersion="ABORT"
protected="true" primaryItem="false" multiple="false"/>
-	<childNodeDef name="" defaultPrimaryType="nt:frozen" autoCreate="false" mandatory="false"
onParentVersion="ABORT" protected="true" primaryItem="false" sameNameSibs="true">
+	<propertyDef name="*" type="undefined" autoCreate="false" mandatory="false" onParentVersion="ABORT"
protected="true" primaryItem="false" multiple="true"/>
+	<propertyDef name="*" type="undefined" autoCreate="false" mandatory="false" onParentVersion="ABORT"
protected="true" primaryItem="false" multiple="false"/>
+	<childNodeDef name="*" defaultPrimaryType="nt:frozen" autoCreate="false" mandatory="false"
onParentVersion="ABORT" protected="true" primaryItem="false" sameNameSibs="true">
 	    <requiredPrimaryTypes>
 		<requiredPrimaryType>nt:base</requiredPrimaryType>
 	    </requiredPrimaryTypes>

Mime
View raw message