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 0A55E10DE5 for ; Wed, 24 Jul 2013 17:50:26 +0000 (UTC) Received: (qmail 59702 invoked by uid 500); 24 Jul 2013 17:50:25 -0000 Delivered-To: apmail-jackrabbit-oak-commits-archive@jackrabbit.apache.org Received: (qmail 59664 invoked by uid 500); 24 Jul 2013 17:50:25 -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 59654 invoked by uid 99); 24 Jul 2013 17:50:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Jul 2013 17:50:24 +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; Wed, 24 Jul 2013 17:50:21 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 12C4623888E2; Wed, 24 Jul 2013 17:50:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1506642 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr: PropertyImpl.java operation/PropertyOperation.java Date: Wed, 24 Jul 2013 17:49:59 -0000 To: oak-commits@jackrabbit.apache.org From: jukka@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130724175000.12C4623888E2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jukka Date: Wed Jul 24 17:49:59 2013 New Revision: 1506642 URL: http://svn.apache.org/r1506642 Log: OAK-672: Avoid JCR APIs calling other JCR APIs Add PropertyOperation and adjust code accordingly. Add TODOs on places that still need work. Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/operation/PropertyOperation.java (with props) Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java?rev=1506642&r1=1506641&r2=1506642&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java (original) +++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java Wed Jul 24 17:49:59 2013 @@ -42,7 +42,7 @@ import org.apache.jackrabbit.oak.api.Tre import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate; import org.apache.jackrabbit.oak.jcr.delegate.PropertyDelegate; -import org.apache.jackrabbit.oak.jcr.operation.ItemOperation; +import org.apache.jackrabbit.oak.jcr.operation.PropertyOperation; import org.apache.jackrabbit.oak.plugins.value.ValueFactoryImpl; import org.apache.jackrabbit.value.ValueHelper; @@ -67,14 +67,14 @@ public class PropertyImpl extends ItemIm @Override @Nonnull public Node getParent() throws RepositoryException { - return perform(new ItemOperation(dlg) { + return perform(new PropertyOperation(dlg) { @Override public Node perform() throws RepositoryException { - NodeDelegate parent = dlg.getParent(); + NodeDelegate parent = property.getParent(); if (parent == null) { throw new AccessDeniedException(); } else { - return sessionContext.createNodeOrNull(dlg.getParent()); + return sessionContext.createNodeOrNull(parent); } } }); @@ -82,20 +82,20 @@ public class PropertyImpl extends ItemIm @Override public boolean isNew() { - return safePerform(new ItemOperation(dlg) { + return safePerform(new PropertyOperation(dlg) { @Override public Boolean perform() { - return dlg.getStatus() == Status.NEW; + return property.getStatus() == Status.NEW; } }); } @Override public boolean isModified() { - return safePerform(new ItemOperation(dlg) { + return safePerform(new PropertyOperation(dlg) { @Override public Boolean perform() { - return dlg.getStatus() == Status.MODIFIED; + return property.getStatus() == Status.MODIFIED; } }); } @@ -224,10 +224,11 @@ public class PropertyImpl extends ItemIm @Override @Nonnull public Value getValue() throws RepositoryException { - return perform(new ItemOperation(dlg) { + return perform(new PropertyOperation(dlg) { @Override public Value perform() throws RepositoryException { - return ValueFactoryImpl.createValue(dlg.getSingleState(), sessionContext); + return ValueFactoryImpl.createValue( + property.getSingleState(), sessionContext); } }); } @@ -235,10 +236,11 @@ public class PropertyImpl extends ItemIm @Override @Nonnull public Value[] getValues() throws RepositoryException { - return perform(new ItemOperation>(dlg) { + return perform(new PropertyOperation>(dlg) { @Override public List perform() throws RepositoryException { - return ValueFactoryImpl.createValues(dlg.getMultiState(), sessionContext); + return ValueFactoryImpl.createValues( + property.getMultiState(), sessionContext); } }).toArray(NO_VALUES); } @@ -292,9 +294,10 @@ public class PropertyImpl extends ItemIm @Override @Nonnull public Node getNode() throws RepositoryException { - return perform(new ItemOperation(dlg) { + return perform(new PropertyOperation(dlg) { @Override public Node perform() throws RepositoryException { + // TODO: avoid nested calls Value value = getValue(); switch (value.getType()) { case PropertyType.REFERENCE: @@ -344,9 +347,10 @@ public class PropertyImpl extends ItemIm @Override @Nonnull public Property getProperty() throws RepositoryException { - return perform(new ItemOperation(dlg) { + return perform(new PropertyOperation(dlg) { @Override public Property perform() throws RepositoryException { + // TODO: avoid nested calls Value value = getValue(); Value pathValue = ValueHelper.convert(value, PropertyType.PATH, getValueFactory()); String path = pathValue.getString(); @@ -379,31 +383,32 @@ public class PropertyImpl extends ItemIm @Override @Nonnull public PropertyDefinition getDefinition() throws RepositoryException { - return perform(new ItemOperation(dlg) { + return perform(new PropertyOperation(dlg) { @Override public PropertyDefinition perform() throws RepositoryException { return getDefinitionProvider().getDefinition( - dlg.getParent().getTree(), dlg.getPropertyState(), true); + property.getParent().getTree(), + property.getPropertyState(), true); } }); } @Override public int getType() throws RepositoryException { - return perform(new ItemOperation(dlg) { + return perform(new PropertyOperation(dlg) { @Override public Integer perform() throws RepositoryException { - return dlg.getPropertyState().getType().tag(); + return property.getPropertyState().getType().tag(); } }); } @Override public boolean isMultiple() throws RepositoryException { - return perform(new ItemOperation(dlg) { + return perform(new PropertyOperation(dlg) { @Override public Boolean perform() throws RepositoryException { - return dlg.getPropertyState().isArray(); + return property.getPropertyState().isArray(); } }); } Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/operation/PropertyOperation.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/operation/PropertyOperation.java?rev=1506642&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/operation/PropertyOperation.java (added) +++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/operation/PropertyOperation.java Wed Jul 24 17:49:59 2013 @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.jcr.operation; + +import org.apache.jackrabbit.oak.jcr.delegate.PropertyDelegate; + +public abstract class PropertyOperation extends ItemOperation { + + protected final PropertyDelegate property; + + protected PropertyOperation(PropertyDelegate property) { + super(property); + this.property = property; + } + +} \ No newline at end of file Propchange: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/operation/PropertyOperation.java ------------------------------------------------------------------------------ svn:eol-style = native