reschke commented on code in PR #2328: URL: https://github.com/apache/jackrabbit-oak/pull/2328#discussion_r2152458030
########## oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/name/NamespaceRegistryTest.java: ########## @@ -0,0 +1,257 @@ +/* + * 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.plugins.name; + +import org.apache.jackrabbit.oak.InitialContent; +import org.apache.jackrabbit.oak.Oak; +import org.apache.jackrabbit.oak.api.ContentSession; +import org.apache.jackrabbit.oak.api.PropertyState; +import org.apache.jackrabbit.oak.api.Root; +import org.apache.jackrabbit.oak.api.Tree; +import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.plugins.memory.PropertyBuilder; +import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider; + +import org.junit.Test; + +import java.io.ByteArrayOutputStream; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.HashMap; + +import static org.apache.jackrabbit.oak.spi.namespace.NamespaceConstants.REP_NSDATA; +import static org.apache.jackrabbit.oak.spi.namespace.NamespaceConstants.REP_PREFIXES; +import static org.apache.jackrabbit.oak.spi.namespace.NamespaceConstants.REP_URIS; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class NamespaceRegistryTest { + + @Test + public void testNamespaceRegistryModel() throws Exception { + try (ContentSession session = new Oak() + .with(new OpenSecurityProvider()) + .with(new InitialContent()) + .with(new NamespaceEditorProvider()) + .createContentSession()) { + Root root = session.getLatestRoot(); + ReadWriteNamespaceRegistry registry = new ReadWriteNamespaceRegistry(root) { + @Override + protected Root getWriteRoot() { + return session.getLatestRoot(); + } + @Override + protected void refresh() { + root.refresh(); + } + }; + Tree namespaces = root.getTree("/jcr:system/rep:namespaces"); Review Comment: is that safe re NPEs? ########## oak-run/src/main/java/org/apache/jackrabbit/oak/run/NamespaceRegistryCommand.java: ########## @@ -0,0 +1,164 @@ +/* + * 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.run; + +import joptsimple.OptionParser; +import org.apache.jackrabbit.oak.Oak; +import org.apache.jackrabbit.oak.api.ContentRepository; +import org.apache.jackrabbit.oak.api.ContentSession; +import org.apache.jackrabbit.oak.api.Root; +import org.apache.jackrabbit.oak.commons.pio.Closer; +import org.apache.jackrabbit.oak.plugins.name.NamespaceRegistryModel; +import org.apache.jackrabbit.oak.plugins.name.ReadWriteNamespaceRegistry; +import org.apache.jackrabbit.oak.run.cli.CommonOptions; +import org.apache.jackrabbit.oak.run.cli.NodeStoreFixture; +import org.apache.jackrabbit.oak.run.cli.NodeStoreFixtureProvider; +import org.apache.jackrabbit.oak.run.cli.Options; +import org.apache.jackrabbit.oak.run.commons.Command; +import org.apache.jackrabbit.oak.security.internal.SecurityProviderBuilder; +import org.apache.jackrabbit.oak.spi.commit.CommitInfo; +import org.apache.jackrabbit.oak.spi.commit.EmptyHook; +import org.apache.jackrabbit.oak.spi.state.NodeState; +import org.apache.jackrabbit.oak.spi.state.NodeStore; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.jcr.SimpleCredentials; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +public class NamespaceRegistryCommand implements Command { Review Comment: javadoc? ########## oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/name/NamespaceRegistryTest.java: ########## @@ -0,0 +1,257 @@ +/* + * 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.plugins.name; + +import org.apache.jackrabbit.oak.InitialContent; +import org.apache.jackrabbit.oak.Oak; +import org.apache.jackrabbit.oak.api.ContentSession; +import org.apache.jackrabbit.oak.api.PropertyState; +import org.apache.jackrabbit.oak.api.Root; +import org.apache.jackrabbit.oak.api.Tree; +import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.plugins.memory.PropertyBuilder; +import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider; + +import org.junit.Test; + +import java.io.ByteArrayOutputStream; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.HashMap; + +import static org.apache.jackrabbit.oak.spi.namespace.NamespaceConstants.REP_NSDATA; +import static org.apache.jackrabbit.oak.spi.namespace.NamespaceConstants.REP_PREFIXES; +import static org.apache.jackrabbit.oak.spi.namespace.NamespaceConstants.REP_URIS; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class NamespaceRegistryTest { + + @Test + public void testNamespaceRegistryModel() throws Exception { + try (ContentSession session = new Oak() + .with(new OpenSecurityProvider()) + .with(new InitialContent()) + .with(new NamespaceEditorProvider()) + .createContentSession()) { + Root root = session.getLatestRoot(); + ReadWriteNamespaceRegistry registry = new ReadWriteNamespaceRegistry(root) { + @Override + protected Root getWriteRoot() { + return session.getLatestRoot(); + } + @Override + protected void refresh() { + root.refresh(); + } + }; + Tree namespaces = root.getTree("/jcr:system/rep:namespaces"); Review Comment: ah, it's just a test ########## oak-run/src/main/java/org/apache/jackrabbit/oak/run/NamespaceRegistryOptions.java: ########## @@ -0,0 +1,104 @@ +/* + * 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.run; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import joptsimple.OptionParser; +import joptsimple.OptionSet; +import joptsimple.OptionSpec; +import org.apache.jackrabbit.oak.run.cli.OptionsBean; +import org.apache.jackrabbit.oak.run.cli.OptionsBeanFactory; + +public class NamespaceRegistryOptions implements OptionsBean { + + public static final OptionsBeanFactory FACTORY = NamespaceRegistryOptions::new; + + private OptionSet options; + private final Set<OptionSpec<Void>> actionOpts; + private final Set<String> operationNames; + + private final OptionSpec<Void> analyseOpt; + private final OptionSpec<Void> fixOpt; + private final OptionSpec<String> mappingsOpt; + + public NamespaceRegistryOptions(OptionParser parser) { + analyseOpt = parser.accepts("analyse", "List the prefix to namespace map and check for consistency."); + fixOpt = parser.accepts("fix", "List the prefix to namespace map, check for consistency and fix any inconsistencies, if possible."); + mappingsOpt = parser.accepts("mappings", "Optionally specify explicit prefix to namespace mappings ad a list of prefix=uri expressions").withRequiredArg(); Review Comment: ```suggestion mappingsOpt = parser.accepts("mappings", "Optionally specify explicit prefix to namespace mappings and a list of prefix=uri expressions").withRequiredArg(); ``` ########## oak-run/src/main/java/org/apache/jackrabbit/oak/run/NamespaceRegistryOptions.java: ########## @@ -0,0 +1,104 @@ +/* + * 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.run; Review Comment: same :-) ########## oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/name/NamespaceRegistryTest.java: ########## @@ -0,0 +1,257 @@ +/* + * 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.plugins.name; + +import org.apache.jackrabbit.oak.InitialContent; +import org.apache.jackrabbit.oak.Oak; +import org.apache.jackrabbit.oak.api.ContentSession; +import org.apache.jackrabbit.oak.api.PropertyState; +import org.apache.jackrabbit.oak.api.Root; +import org.apache.jackrabbit.oak.api.Tree; +import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.plugins.memory.PropertyBuilder; +import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider; + +import org.junit.Test; + +import java.io.ByteArrayOutputStream; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.HashMap; + +import static org.apache.jackrabbit.oak.spi.namespace.NamespaceConstants.REP_NSDATA; +import static org.apache.jackrabbit.oak.spi.namespace.NamespaceConstants.REP_PREFIXES; +import static org.apache.jackrabbit.oak.spi.namespace.NamespaceConstants.REP_URIS; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class NamespaceRegistryTest { Review Comment: maybe add class javadoc? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: oak-dev-unsubscr...@jackrabbit.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org