From jackrabbit-commits-return-1341-apmail-incubator-jackrabbit-commits-archive=www.apache.org@incubator.apache.org Fri Sep 02 15:02:10 2005 Return-Path: Delivered-To: apmail-incubator-jackrabbit-commits-archive@www.apache.org Received: (qmail 66069 invoked from network); 2 Sep 2005 15:02:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 2 Sep 2005 15:02:09 -0000 Received: (qmail 620 invoked by uid 500); 2 Sep 2005 15:02:03 -0000 Mailing-List: contact jackrabbit-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jackrabbit-dev@incubator.apache.org Delivered-To: mailing list jackrabbit-commits@incubator.apache.org Received: (qmail 585 invoked by uid 500); 2 Sep 2005 15:02:03 -0000 Delivered-To: apmail-incubator-jackrabbit-cvs@incubator.apache.org Received: (qmail 571 invoked by uid 99); 2 Sep 2005 15:02:03 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 02 Sep 2005 08:02:02 -0700 Received: (qmail 66017 invoked by uid 65534); 2 Sep 2005 15:02:02 -0000 Message-ID: <20050902150202.66016.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r267220 - /incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java Date: Fri, 02 Sep 2005 15:02:02 -0000 To: jackrabbit-cvs@incubator.apache.org From: stefan@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: stefan Date: Fri Sep 2 08:01:59 2005 New Revision: 267220 URL: http://svn.apache.org/viewcvs?rev=267220&view=rev Log: fixed bug in node type validation: some ambiguous definitions were not detected Modified: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java Modified: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java?rev=267220&r1=267219&r2=267220&view=diff ============================================================================== --- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java (original) +++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeType.java Fri Sep 2 08:01:59 2005 @@ -105,8 +105,29 @@ ent.mergedNodeTypes.add(ntName); ent.allNodeTypes.add(ntName); + // map of all item definitions (maps id to definition) + // used to effectively detect ambiguous child definitions where + // ambiguity is defined in terms of definition identity + HashMap itemDefIds = new HashMap(); + NodeDef[] cnda = ntd.getChildNodeDefs(); for (int i = 0; i < cnda.length; i++) { + // check if child node definition would be ambiguous within + // this node type definition + if (itemDefIds.containsKey(cnda[i].getId())) { + // conflict + String msg; + if (cnda[i].definesResidual()) { + msg = ntName + " contains ambiguous residual child node definitions"; + } else { + msg = ntName + " contains ambiguous definitions for child node named " + + cnda[i].getName(); + } + log.debug(msg); + throw new NodeTypeConflictException(msg); + } else { + itemDefIds.put(cnda[i].getId(), cnda[i]); + } if (cnda[i].definesResidual()) { // residual node definition ent.unnamedItemDefs.add(cnda[i]); @@ -139,6 +160,22 @@ } PropDef[] pda = ntd.getPropertyDefs(); for (int i = 0; i < pda.length; i++) { + // check if property definition would be ambiguous within + // this node type definition + if (itemDefIds.containsKey(pda[i].getId())) { + // conflict + String msg; + if (pda[i].definesResidual()) { + msg = ntName + " contains ambiguous residual property definitions"; + } else { + msg = ntName + " contains ambiguous definitions for property named " + + pda[i].getName(); + } + log.debug(msg); + throw new NodeTypeConflictException(msg); + } else { + itemDefIds.put(pda[i].getId(), pda[i]); + } if (pda[i].definesResidual()) { // residual property definition ent.unnamedItemDefs.add(pda[i]); @@ -1051,11 +1088,8 @@ } } } - // @todo do further checks for ambiguous definitions & other conflicts unnamedItemDefs.add(def); } - // @todo implement further validations - for (int i = 0; i < nta.length; i++) { allNodeTypes.add(nta[i]); }