This is an automated email from the ASF dual-hosted git repository.
joerghoh pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/trunk by this push:
new 1bd815d6b2 OAK-10639 : NodeImpl calculate mixinTypes lazy (#1300)
1bd815d6b2 is described below
commit 1bd815d6b22f3867afb2bfb8de2a3046b49ccb08
Author: Jörg Hoh <[email protected]>
AuthorDate: Tue Feb 13 13:58:21 2024 +0100
OAK-10639 : NodeImpl calculate mixinTypes lazy (#1300)
Change the EffectiveNodeTypeProvider.isNodeType() to use a Supplier for the
mixins, as they are not always required, and adapt all consumers of it (most
notably the NodeImpl).
Updated package version of org.apache.jackrabbit.oak.spi.nodetype.
Co-authored-by: Julian Reschke <[email protected]>
---
.../oak/spi/nodetype/EffectiveNodeTypeProvider.java | 21 ++++++++++++++++++++-
.../jackrabbit/oak/spi/nodetype/package-info.java | 2 +-
.../plugins/nodetype/ReadOnlyNodeTypeManager.java | 5 +++--
.../oak/plugins/version/VersionEditor.java | 2 +-
.../apache/jackrabbit/oak/jcr/session/NodeImpl.java | 3 +--
5 files changed, 26 insertions(+), 7 deletions(-)
diff --git
a/oak-core-spi/src/main/java/org/apache/jackrabbit/oak/spi/nodetype/EffectiveNodeTypeProvider.java
b/oak-core-spi/src/main/java/org/apache/jackrabbit/oak/spi/nodetype/EffectiveNodeTypeProvider.java
index e295ba502d..c551499dd8 100644
---
a/oak-core-spi/src/main/java/org/apache/jackrabbit/oak/spi/nodetype/EffectiveNodeTypeProvider.java
+++
b/oak-core-spi/src/main/java/org/apache/jackrabbit/oak/spi/nodetype/EffectiveNodeTypeProvider.java
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.spi.nodetype;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.function.Supplier;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
@@ -83,8 +84,26 @@ public interface EffectiveNodeTypeProvider {
* refer to an existing node type.
* @throws RepositoryException If the given node type name is invalid or if
* some other error occurs.
+ * @deprecated use {@link #isNodeType(String, Supplier, String)} instead
*/
- boolean isNodeType(@NotNull String primaryTypeName, @NotNull
Iterable<String> mixinTypes, @NotNull String nodeTypeName) throws
NoSuchNodeTypeException, RepositoryException;
+ default boolean isNodeType(@NotNull String primaryTypeName, @NotNull
Iterable<String> mixinTypes, @NotNull String nodeTypeName) throws
NoSuchNodeTypeException, RepositoryException {
+ return isNodeType(primaryTypeName, () -> mixinTypes, nodeTypeName);
+ }
+
+ /**
+ * Returns {@code true} if {@code typeName} is of the specified primary
node
+ * type or mixin type, or a subtype thereof. Returns {@code false}
otherwise.
+ *
+ * @param primaryTypeName the internal oak name of the node to test
+ * @param mixinTypes the internal oak names of the node to test.
+ * @param nodeTypeName The internal oak name of the node type to be tested.
+ * @return {@code true} if the specified node type is of the given node
type.
+ * @throws NoSuchNodeTypeException If the specified node type name doesn't
+ * refer to an existing node type.
+ * @throws RepositoryException If the given node type name is invalid or if
+ * some other error occurs.
+ */
+ boolean isNodeType(@NotNull String primaryTypeName, @NotNull
Supplier<Iterable<String>> mixinTypes, @NotNull String nodeTypeName) throws
NoSuchNodeTypeException, RepositoryException;
/**
* Returns {@code true} if {@code typeName} is of the specified primary
node
diff --git
a/oak-core-spi/src/main/java/org/apache/jackrabbit/oak/spi/nodetype/package-info.java
b/oak-core-spi/src/main/java/org/apache/jackrabbit/oak/spi/nodetype/package-info.java
index d3591ee390..32ef9c8640 100644
---
a/oak-core-spi/src/main/java/org/apache/jackrabbit/oak/spi/nodetype/package-info.java
+++
b/oak-core-spi/src/main/java/org/apache/jackrabbit/oak/spi/nodetype/package-info.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-@Version("1.1.0")
+@Version("1.2.0")
package org.apache.jackrabbit.oak.spi.nodetype;
import org.osgi.annotation.versioning.Version;
diff --git
a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java
b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java
index 32d9730323..7a38c1e87d 100644
---
a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java
+++
b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java
@@ -26,6 +26,7 @@ import static
org.apache.jackrabbit.oak.spi.nodetype.NodeTypeConstants.NODE_TYPE
import static
org.apache.jackrabbit.oak.spi.nodetype.NodeTypeConstants.REP_SUPERTYPES;
import java.util.List;
+import java.util.function.Supplier;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
@@ -284,7 +285,7 @@ public abstract class ReadOnlyNodeTypeManager implements
NodeTypeManager, Effect
}
@Override
- public boolean isNodeType(@Nullable String primaryTypeName, @NotNull
Iterable<String> mixinTypes, @NotNull String nodeTypeName) {
+ public boolean isNodeType(@Nullable String primaryTypeName, @NotNull
Supplier<Iterable<String>> mixinTypes, @NotNull String nodeTypeName) {
// shortcut
if (JcrConstants.NT_BASE.equals(nodeTypeName)) {
return true;
@@ -293,7 +294,7 @@ public abstract class ReadOnlyNodeTypeManager implements
NodeTypeManager, Effect
if (primaryTypeName != null && isa(types, primaryTypeName,
nodeTypeName)) {
return true;
}
- for (String mixin : mixinTypes) {
+ for (String mixin : mixinTypes.get()) {
if (isa(types, mixin, nodeTypeName)) {
return true;
}
diff --git
a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionEditor.java
b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionEditor.java
index a6d535eff0..e9752fea04 100644
---
a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionEditor.java
+++
b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionEditor.java
@@ -114,7 +114,7 @@ class VersionEditor implements Editor {
&& !this.before.exists()) {
Tree tree = new
TreeProviderService().createReadOnlyTree(this.node.getNodeState());
if (vMgr.getNodeTypeManager().isNodeType(
- TreeUtil.getPrimaryTypeName(tree),
TreeUtil.getMixinTypeNames(tree), MIX_VERSIONABLE)) {
+ TreeUtil.getPrimaryTypeName(tree), () ->
TreeUtil.getMixinTypeNames(tree), MIX_VERSIONABLE)) {
// OAK-10462: the node has mix:versionable, but not the
mandatory property jcr:isCheckedOut,
// so it has to be sentinel node for a restore operation.
// Unfortunately, there is no API available to detect that.
diff --git
a/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/NodeImpl.java
b/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/NodeImpl.java
index b926fea47b..b9b992c636 100644
--- a/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/NodeImpl.java
+++ b/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/NodeImpl.java
@@ -36,7 +36,6 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-
import javax.jcr.AccessDeniedException;
import javax.jcr.Binary;
import javax.jcr.InvalidItemStateException;
@@ -976,7 +975,7 @@ public class NodeImpl<T extends NodeDelegate> extends
ItemImpl<T> implements Jac
@Override
public Boolean perform() throws RepositoryException {
Tree tree = node.getTree();
- return
getNodeTypeManager().isNodeType(getPrimaryTypeName(tree),
getMixinTypeNames(tree), oakName);
+ return
getNodeTypeManager().isNodeType(getPrimaryTypeName(tree), () ->
getMixinTypeNames(tree), oakName);
}
});
}