/*
 * 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.upgrade.cli.node;

import org.apache.jackrabbit.oak.api.Blob;
import org.apache.jackrabbit.oak.api.CommitFailedException;
import org.apache.jackrabbit.oak.spi.commit.CommitHook;
import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
import org.apache.jackrabbit.oak.spi.state.NodeState;
import org.apache.jackrabbit.oak.spi.state.NodeStore;

import javax.annotation.Nonnull;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;

public class TarNodeStore implements NodeStore {

    private final NodeStore ns;

    private final SuperRootProvider superRootProvider;

    public TarNodeStore(NodeStore ns, SuperRootProvider superRootProvider) {
        this.ns = ns;
        this.superRootProvider = superRootProvider;
    }

    public void setSuperRoot(NodeBuilder builder) {
        superRootProvider.setSuperRoot(builder);
    }

    public NodeState getSuperRoot() {
        return superRootProvider.getSuperRoot();
    }

    @Nonnull
    @Override
    public NodeState getRoot() {
        return ns.getRoot();
    }

    @Nonnull
    @Override
    public NodeState merge(@Nonnull NodeBuilder builder, @Nonnull CommitHook commitHook, @Nonnull CommitInfo info) throws CommitFailedException {
        return ns.merge(builder, commitHook, info);
    }

    @Nonnull
    @Override
    public NodeState rebase(@Nonnull NodeBuilder builder) {
        return ns.rebase(builder);
    }

    @Override
    public NodeState reset(@Nonnull NodeBuilder builder) {
        return ns.reset(builder);
    }

    @Nonnull
    @Override
    public Blob createBlob(InputStream inputStream) throws IOException {
        return ns.createBlob(inputStream);
    }

    @Override
    public Blob getBlob(@Nonnull String reference) {
        return ns.getBlob(reference);
    }

    @Nonnull
    @Override
    public String checkpoint(long lifetime, @Nonnull Map<String, String> properties) {
        return ns.checkpoint(lifetime, properties);
    }

    @Nonnull
    @Override
    public String checkpoint(long lifetime) {
        return ns.checkpoint(lifetime);
    }

    @Nonnull
    @Override
    public Map<String, String> checkpointInfo(@Nonnull String checkpoint) {
        return ns.checkpointInfo(checkpoint);
    }

    @Nonnull
    @Override
    public Iterable<String> checkpoints() {
        return ns.checkpoints();
    }

    @Override
    public NodeState retrieve(@Nonnull String checkpoint) {
        return ns.retrieve(checkpoint);
    }

    @Override
    public boolean release(@Nonnull String checkpoint) {
        return ns.release(checkpoint);
    }

    interface SuperRootProvider {

        void setSuperRoot(NodeBuilder builder);

        NodeState getSuperRoot();

    }
}

@@ -853,223 +853,8 @@
 e;%0A%0A
-import org.apache.jackrabbit.oak.api.Blob;%0Aimport org.apache.jackrabbit.oak.api.CommitFailedException;%0Aimport org.apache.jackrabbit.oak.spi.commit.CommitHook;%0Aimport org.apache.jackrabbit.oak.spi.commit.CommitInfo;%0A
 impo
@@ -1017,118 +1017,65 @@
 re;%0A
-%0Aimport javax.annotation.Nonnull;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.util.Map
+import org.apache.jackrabbit.oak.spi.state.ProxyNodeStore
 ;%0A%0Ap
@@ -1103,19 +1103,21 @@
 ore 
-implement
+extend
 s 
+Proxy
 Node
@@ -1570,37 +1570,24 @@
 t();%0A    %7D%0A%0A
-    @Nonnull%0A
     @Overrid
@@ -1597,1598 +1597,61 @@
    p
-ublic NodeState getRoot() %7B%0A        return ns.getRoot();%0A    %7D%0A%0A    @Nonnull%0A    @Override%0A    public NodeState merge(@Nonnull NodeBuilder builder, @Nonnull CommitHook commitHook, @Nonnull CommitInfo info) throws CommitFailedException %7B%0A        return ns.merge(builder, commitHook, info);%0A    %7D%0A%0A    @Nonnull%0A    @Override%0A    public NodeState rebase(@Nonnull NodeBuilder builder) %7B%0A        return ns.rebase(builder);%0A    %7D%0A%0A    @Override%0A    public NodeState reset(@Nonnull NodeBuilder builder) %7B%0A        return ns.reset(builder);%0A    %7D%0A%0A    @Nonnull%0A    @Override%0A    public Blob createBlob(InputStream inputStream) throws IOException %7B%0A        return ns.createBlob(inputStream);%0A    %7D%0A%0A    @Override%0A    public Blob getBlob(@Nonnull String reference) %7B%0A        return ns.getBlob(reference);%0A    %7D%0A%0A    @Nonnull%0A    @Override%0A    public String checkpoint(long lifetime, @Nonnull Map%3CString, String%3E properties) %7B%0A        return ns.checkpoint(lifetime, properties);%0A    %7D%0A%0A    @Nonnull%0A    @Override%0A    public String checkpoint(long lifetime) %7B%0A        return ns.checkpoint(lifetime);%0A    %7D%0A%0A    @Nonnull%0A    @Override%0A    public Map%3CString, String%3E checkpointInfo(@Nonnull String checkpoint) %7B%0A        return ns.checkpointInfo(checkpoint);%0A    %7D%0A%0A    @Nonnull%0A    @Override%0A    public Iterable%3CString%3E checkpoints() %7B%0A        return ns.checkpoints();%0A    %7D%0A%0A    @Override%0A    public NodeState retrieve(@Nonnull String checkpoint) %7B%0A        return ns.retrieve(checkpoint);%0A    %7D%0A%0A    @Override%0A    public boolean release(@Nonnull String checkpoint) %7B%0A        return ns.release(checkpoint)
+rotected NodeStore getNodeStore() %7B%0A        return ns
 ;%0A  

Simplify TarNodeStore