Return-Path: X-Original-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Delivered-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9450EF47B for ; Tue, 26 Mar 2013 13:09:47 +0000 (UTC) Received: (qmail 14688 invoked by uid 500); 26 Mar 2013 13:08:09 -0000 Delivered-To: apmail-jackrabbit-oak-commits-archive@jackrabbit.apache.org Received: (qmail 14343 invoked by uid 500); 26 Mar 2013 13:08:08 -0000 Mailing-List: contact oak-commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: oak-dev@jackrabbit.apache.org Delivered-To: mailing list oak-commits@jackrabbit.apache.org Received: (qmail 14156 invoked by uid 99); 26 Mar 2013 13:08:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Mar 2013 13:08:05 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Mar 2013 13:08:03 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id BC94823888EA; Tue, 26 Mar 2013 13:07:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1461107 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ Date: Tue, 26 Mar 2013 13:07:43 -0000 To: oak-commits@jackrabbit.apache.org From: jukka@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130326130743.BC94823888EA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jukka Date: Tue Mar 26 13:07:43 2013 New Revision: 1461107 URL: http://svn.apache.org/r1461107 Log: OAK-702: Optimize access to node type information Remove another getDefinition() signature from DefinitionProvider. No need to check for previous single/multi-valuedness of the property anymore in AuthorizablePropertiesImpl. Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/DefinitionProvider.java jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizablePropertiesImpl.java jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/DefinitionProvider.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/DefinitionProvider.java?rev=1461107&r1=1461106&r2=1461107&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/DefinitionProvider.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/DefinitionProvider.java Tue Mar 26 13:07:43 2013 @@ -91,27 +91,8 @@ public interface DefinitionProvider { * @throws RepositoryException If another error occurs. */ @Nonnull - PropertyDefinition getDefinition(Tree parent, PropertyState propertyState) + PropertyDefinition getDefinition( + Tree parent, PropertyState propertyState, boolean exactTypeMatch) throws ConstraintViolationException,RepositoryException; - /** - * Calculates the applicable definition for the property with the specified - * characteristics under the given parent tree. - * - * @param parent The parent tree. - * @param propertyName The internal oak name of the property for which the - * definition should be retrieved. - * @param isMultiple {@code true} if the target property is multi-valued. - * @param type The target type of the property. - * @param exactTypeMatch {@code true} if the required type of the definition - * must exactly match the type of the target property. - * @return the applicable definition for the target property. - * @throws ConstraintViolationException If no matching definition can be found. - * @throws RepositoryException If another error occurs. - */ - @Nonnull - PropertyDefinition getDefinition(Tree parent, String propertyName, boolean isMultiple, - int type, boolean exactTypeMatch) - throws ConstraintViolationException, RepositoryException; - } \ No newline at end of file Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java?rev=1461107&r1=1461106&r2=1461107&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java Tue Mar 26 13:07:43 2013 @@ -424,15 +424,13 @@ public abstract class ReadOnlyNodeTypeMa @Nonnull @Override - public PropertyDefinition getDefinition(Tree parent, PropertyState propertyState) throws RepositoryException { - return getDefinition(parent, propertyState.getName(), propertyState.isArray(), propertyState.getType().tag(), true); - } - - @Nonnull - @Override - public PropertyDefinition getDefinition(Tree parent, String propertyName, boolean isMultiple, int type, boolean exactTypeMatch) throws RepositoryException { + public PropertyDefinition getDefinition( + Tree parent, PropertyState property, boolean exactTypeMatch) + throws RepositoryException { + Type type = property.getType(); EffectiveNodeType effective = getEffectiveNodeType(parent); - return effective.getPropertyDefinition(propertyName, isMultiple, type, exactTypeMatch); + return effective.getPropertyDefinition( + property.getName(), type.isArray(), type.tag(), exactTypeMatch); } //-----------------------------------------------------------< internal >--- Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizablePropertiesImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizablePropertiesImpl.java?rev=1461107&r1=1461106&r2=1461107&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizablePropertiesImpl.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizablePropertiesImpl.java Tue Mar 26 13:07:43 2013 @@ -22,7 +22,6 @@ import java.util.Iterator; import java.util.List; import javax.annotation.CheckForNull; import javax.annotation.Nonnull; -import javax.jcr.PropertyType; import javax.jcr.RepositoryException; import javax.jcr.Value; import javax.jcr.nodetype.ConstraintViolationException; @@ -129,18 +128,13 @@ class AuthorizablePropertiesImpl impleme checkRelativePath(relPath); String name = Text.getName(relPath); + PropertyState propertyState = + PropertyStates.createProperty(name, value); + String intermediate = (relPath.equals(name)) ? null : Text.getRelativeParent(relPath, 1); Tree parent = getOrCreateTargetTree(intermediate); - checkProtectedProperty(parent, name, false, value.getType()); + checkProtectedProperty(parent, propertyState); - // check if the property has already been created as multi valued - // property before -> in this case remove in order to avoid - // ValueFormatException. - PropertyState p = parent.getProperty(name); - if (p != null && p.isArray()) { - parent.removeProperty(name); - } - PropertyState propertyState = PropertyStates.createProperty(name, value); parent.setProperty(propertyState); } } @@ -156,19 +150,13 @@ class AuthorizablePropertiesImpl impleme checkRelativePath(relPath); String name = Text.getName(relPath); + PropertyState propertyState = + PropertyStates.createProperty(name, Arrays.asList(values)); + String intermediate = (relPath.equals(name)) ? null : Text.getRelativeParent(relPath, 1); Tree parent = getOrCreateTargetTree(intermediate); - int targetType = (values.length == 0) ? PropertyType.UNDEFINED : values[0].getType(); - checkProtectedProperty(parent, name, true, targetType); + checkProtectedProperty(parent, propertyState); - // check if the property has already been created as single valued - // property before -> in this case remove in order to avoid - // ValueFormatException. - PropertyState p = parent.getProperty(name); - if (p != null && !p.isArray()) { - parent.removeProperty(name); - } - PropertyState propertyState = PropertyStates.createProperty(name, Arrays.asList(values)); parent.setProperty(propertyState); } } @@ -255,7 +243,7 @@ class AuthorizablePropertiesImpl impleme log.debug("Unable to determine definition of authorizable property at " + propertyLocation.getPath()); return null; } - PropertyDefinition def = nodeTypeManager.getDefinition(parent, property); + PropertyDefinition def = nodeTypeManager.getDefinition(parent, property, true); if (def.isProtected() || (authorizablePath.equals(parent.getPath()) && !def.getDeclaringNodeType().isNodeType(UserConstants.NT_REP_AUTHORIZABLE))) { return null; @@ -264,10 +252,12 @@ class AuthorizablePropertiesImpl impleme return property; } - private void checkProtectedProperty(Tree parent, String propertyName, boolean isArray, int type) throws RepositoryException { - PropertyDefinition def = nodeTypeManager.getDefinition(parent, propertyName, isArray, type, false); + private void checkProtectedProperty(Tree parent, PropertyState property) throws RepositoryException { + PropertyDefinition def = + nodeTypeManager.getDefinition(parent, property, false); if (def.isProtected()) { - throw new ConstraintViolationException("Attempt to set an protected property " + propertyName); + throw new ConstraintViolationException( + "Attempt to set an protected property " + property.getName()); } } Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java?rev=1461107&r1=1461106&r2=1461107&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java (original) +++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java Tue Mar 26 13:07:43 2013 @@ -60,7 +60,6 @@ import javax.jcr.version.VersionManager; import com.google.common.base.Function; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Iterators; @@ -362,7 +361,7 @@ public class NodeImpl() { @Override protected void checkPreconditions() throws RepositoryException { @@ -1606,9 +1612,12 @@ public class NodeImpl() { @Override protected void checkPreconditions() throws RepositoryException { @@ -1642,23 +1652,25 @@ public class NodeImpl nonNullValues = Iterables.filter( - Arrays.asList(targetValues), Predicates.notNull()); - PropertyState state = - PropertyStates.createProperty(oakName, nonNullValues); return new PropertyImpl(dlg.setProperty(state), sessionContext); } }); @@ -1693,4 +1705,30 @@ public class NodeImpl