Search in sources :

Example 1 with VisibleEditor

use of org.apache.jackrabbit.oak.spi.commit.VisibleEditor in project jackrabbit-oak by apache.

the class PrefetchDispatcher method contentChanged.

@Override
public synchronized void contentChanged(@Nonnull NodeState root, @Nonnull CommitInfo info) {
    if (root instanceof DocumentNodeState) {
        final DocumentNodeState state = (DocumentNodeState) root;
        if (state.isFromExternalChange()) {
            executor.execute(new Runnable() {

                private final NodeState before = PrefetchDispatcher.this.root;

                @Override
                public void run() {
                    EditorDiff.process(new VisibleEditor(TraversingEditor.INSTANCE), before, state);
                }
            });
        }
    }
    super.contentChanged(root, info);
    this.root = root;
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) VisibleEditor(org.apache.jackrabbit.oak.spi.commit.VisibleEditor)

Example 2 with VisibleEditor

use of org.apache.jackrabbit.oak.spi.commit.VisibleEditor in project jackrabbit-oak by apache.

the class TypeEditorProvider method getRootEditor.

@Override
public Editor getRootEditor(NodeState before, NodeState after, NodeBuilder builder, CommitInfo info) throws CommitFailedException {
    NodeState beforeTypes = before.getChildNode(JCR_SYSTEM).getChildNode(JCR_NODE_TYPES);
    NodeState afterTypes = after.getChildNode(JCR_SYSTEM).getChildNode(JCR_NODE_TYPES);
    String primary = after.getName(JCR_PRIMARYTYPE);
    Iterable<String> mixins = after.getNames(JCR_MIXINTYPES);
    TypeRegistration registration = new TypeRegistration();
    afterTypes.compareAgainstBaseState(beforeTypes, registration);
    if (registration.isModified()) {
        ReadOnlyNodeTypeManager ntBefore = ReadOnlyNodeTypeManager.getInstance(RootFactory.createReadOnlyRoot(before), NamePathMapper.DEFAULT);
        ReadOnlyNodeTypeManager ntAfter = ReadOnlyNodeTypeManager.getInstance(RootFactory.createReadOnlyRoot(after), NamePathMapper.DEFAULT);
        afterTypes = registration.apply(builder);
        Set<String> modifiedTypes = registration.getModifiedTypes(beforeTypes);
        if (!modifiedTypes.isEmpty()) {
            boolean modified = false;
            for (String t : modifiedTypes) {
                boolean mod = !isTrivialChange(ntBefore, ntAfter, t);
                modified = modified || mod;
            }
            if (!modified) {
                LOG.info("Node type changes: " + modifiedTypes + " appear to be trivial, repository will not be scanned");
            } else {
                long start = System.currentTimeMillis();
                // Some node types were modified, so scan the repository
                // to make sure that the modified definitions still apply.
                Editor editor = new VisibleEditor(new TypeEditor(strict, modifiedTypes, afterTypes, primary, mixins, builder));
                LOG.info("Node type changes: " + modifiedTypes + " appear not to be trivial, starting repository scan");
                CommitFailedException exception = EditorDiff.process(editor, MISSING_NODE, after);
                LOG.info("Node type changes: " + modifiedTypes + "; repository scan took " + (System.currentTimeMillis() - start) + "ms" + (exception == null ? "" : "; failed with " + exception.getMessage()));
                if (exception != null) {
                    throw exception;
                }
            }
        }
    }
    return new VisibleEditor(new TypeEditor(strict, null, afterTypes, primary, mixins, builder));
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) VisibleEditor(org.apache.jackrabbit.oak.spi.commit.VisibleEditor) Editor(org.apache.jackrabbit.oak.spi.commit.Editor) VisibleEditor(org.apache.jackrabbit.oak.spi.commit.VisibleEditor) CommitFailedException(org.apache.jackrabbit.oak.api.CommitFailedException)

Example 3 with VisibleEditor

use of org.apache.jackrabbit.oak.spi.commit.VisibleEditor in project jackrabbit-oak by apache.

the class VersionEditorProvider method getRootEditor.

@Override
public Editor getRootEditor(NodeState before, NodeState after, NodeBuilder builder, CommitInfo info) {
    if (!builder.hasChildNode(JCR_SYSTEM)) {
        return null;
    }
    NodeBuilder system = builder.child(JCR_SYSTEM);
    if (!system.hasChildNode(JCR_VERSIONSTORAGE)) {
        return null;
    }
    NodeBuilder versionStorage = system.child(JCR_VERSIONSTORAGE);
    return new VisibleEditor(new CompositeEditor(new VersionEditor(versionStorage, builder, info), new SubtreeEditor(new VersionStorageEditor(versionStorage, builder), JCR_SYSTEM, JCR_VERSIONSTORAGE)));
}
Also used : CompositeEditor(org.apache.jackrabbit.oak.spi.commit.CompositeEditor) VisibleEditor(org.apache.jackrabbit.oak.spi.commit.VisibleEditor) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) SubtreeEditor(org.apache.jackrabbit.oak.spi.commit.SubtreeEditor)

Aggregations

VisibleEditor (org.apache.jackrabbit.oak.spi.commit.VisibleEditor)3 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)2 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)1 CompositeEditor (org.apache.jackrabbit.oak.spi.commit.CompositeEditor)1 Editor (org.apache.jackrabbit.oak.spi.commit.Editor)1 SubtreeEditor (org.apache.jackrabbit.oak.spi.commit.SubtreeEditor)1 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)1