Return-Path: Delivered-To: apmail-incubator-jackrabbit-commits-archive@www.apache.org Received: (qmail 3592 invoked from network); 10 Dec 2004 11:07:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 10 Dec 2004 11:07:39 -0000 Received: (qmail 56091 invoked by uid 500); 10 Dec 2004 11:07:38 -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 56075 invoked by uid 500); 10 Dec 2004 11:07:38 -0000 Delivered-To: apmail-incubator-jackrabbit-cvs@incubator.apache.org Received: (qmail 56070 invoked by uid 99); 10 Dec 2004 11:07:38 -0000 X-ASF-Spam-Status: No, hits=-10.0 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Fri, 10 Dec 2004 03:07:37 -0800 Received: (qmail 3572 invoked by uid 65534); 10 Dec 2004 11:07:36 -0000 Date: 10 Dec 2004 11:07:36 -0000 Message-ID: <20041210110736.3560.qmail@minotaur.apache.org> From: stefan@apache.org To: jackrabbit-cvs@incubator.apache.org Subject: svn commit: r111495 - /incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: stefan Date: Fri Dec 10 03:07:35 2004 New Revision: 111495 URL: http://svn.apache.org/viewcvs?view=rev&rev=111495 Log: fixing JIRA issue JCR-27: ArrayIndexOutofBoundException while setting a reference property http://nagoya.apache.org/jira/browse/JCR-27 Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java Url: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java?view=diff&rev=111495&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java&r1=111494&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java&r2=111495 ============================================================================== --- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java (original) +++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java Fri Dec 10 03:07:35 2004 @@ -466,8 +466,8 @@ * * for every transient property: * - check the WRITE permission - * - check if the property value satisfies the value constraints specified - * in the property's definition + * - check if the property value satisfies the value constraints + * specified in the property's definition * * note that the protected flag is checked in Node.addNode/Node.remove * (for adding/removing child entries of a node), in @@ -487,17 +487,21 @@ NodeImpl node = (NodeImpl) itemMgr.getItem(id); NodeDef def = node.getDefinition(); NodeTypeImpl nt = (NodeTypeImpl) node.getPrimaryNodeType(); - // if the transient node was added (i.e. if it is 'new'), - // check its node's node type against the required node type - // in its definition + /** + * if the transient node was added (i.e. if it is 'new'), + * check its node's node type against the required node type + * in its definition + */ NodeType[] nta = def.getRequiredPrimaryTypes(); for (int i = 0; i < nta.length; i++) { NodeTypeImpl ntReq = (NodeTypeImpl) nta[i]; if (nodeState.getStatus() == ItemState.STATUS_NEW && !(nt.getQName().equals(ntReq.getQName()) || nt.isDerivedFrom(ntReq.getQName()))) { - // the transient node's node type does not satisfy the - // 'required primary types' constraint + /** + * the transient node's node type does not satisfy the + * 'required primary types' constraint + */ String msg = node.safeGetJCRPath() + " must be of node type " + ntReq.getName(); log.warn(msg); throw new ConstraintViolationException(msg); @@ -513,8 +517,10 @@ throw new AccessDeniedException(msg); } - // no need to check the protected flag - // as this is checked in NodeImpl.remove(String) + /** + * no need to check the protected flag as this is checked + * in NodeImpl.remove(String) + */ } // check child additions @@ -578,10 +584,12 @@ } } - // check value constraints - // (no need to check value constraints of protected properties - // as those are set by the implementation only, i.e. they - // cannot be set by the user through the api) + /** + * check value constraints + * (no need to check value constraints of protected properties + * as those are set by the implementation only, i.e. they + * cannot be set by the user through the api) + */ if (!def.isProtected()) { String[] constraints = def.getValueConstraints(); if (constraints != null) { @@ -595,21 +603,28 @@ throw new ConstraintViolationException(msg); } - // need to manually check REFERENCE value constraints - // as this requires a session (target node needs to - // be checked) - if (def.getRequiredType() == PropertyType.REFERENCE) { + /** + * need to manually check REFERENCE value constraints + * as this requires a session (target node needs to + * be checked) + */ + if (constraints.length > 0 + && def.getRequiredType() == PropertyType.REFERENCE) { for (int i = 0; i < values.length; i++) { boolean satisfied = false; try { UUID targetUUID = (UUID) values[i].internalValue(); Node targetNode = session.getNodeByUUID(targetUUID.toString()); - // constraints are OR-ed, i.e. at least one - // has to be satisfied + /** + * constraints are OR-ed, i.e. at least one + * has to be satisfied + */ for (int j = 0; j < constraints.length; j++) { - // a REFERENCE value constraint specifies - // the name of the required node type of - // the target node + /** + * a REFERENCE value constraint specifies + * the name of the required node type of + * the target node + */ String ntName = constraints[j]; if (targetNode.isNodeType(ntName)) { satisfied = true; @@ -634,8 +649,10 @@ } } - // no need to check the protected flag - // as this is checked in PropertyImpl.setValue(Value) + /** + * no need to check the protected flag* as this is checked + * in PropertyImpl.setValue(Value) + */ } } } @@ -1220,9 +1237,12 @@ itemStateMgr.disposeTransientItemState(transientState); } - // all changes are persisted, now dispatch events - // forward this to the session to let it decide on the right time for those - // events to be dispatched in case of transactional support + /** + * all changes are persisted, now dispatch events; + * forward this to the session to let it decide on the right + * time for those events to be dispatched in case of + * transactional support + */ session.dispatch(events); } finally { // turn off temporary path caching