You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by "reschke (via GitHub)" <gi...@apache.org> on 2025/04/17 12:02:36 UTC

[PR] OAK-10952: improve autogenerated namespace prefixes - test with prototype [jackrabbit-oak]

reschke opened a new pull request, #2237:
URL: https://github.com/apache/jackrabbit-oak/pull/2237

   PoC, hopefully illustrating the idea.
   
   (needs more documentation and support for edge cases, final location in project to be decided)


-- 
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-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-10952: improve autogenerated namespace prefixes - test with prototype [jackrabbit-oak]

Posted by "mbaedke (via GitHub)" <gi...@apache.org>.
mbaedke commented on code in PR #2237:
URL: https://github.com/apache/jackrabbit-oak/pull/2237#discussion_r2075215947


##########
oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/NamespaceHelperPrototypeTest.java:
##########
@@ -0,0 +1,190 @@
+/*
+ * 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.commons;
+
+// experimental location for prototyping namespace related support functions
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.junit.Test;
+
+import java.math.BigInteger;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Locale;
+import java.util.Map;
+import java.util.UUID;
+import java.util.function.Function;
+
+import static org.junit.Assert.assertEquals;
+
+public class NamespaceHelperPrototypeTest {
+
+    // map with 'optimal' prefix mappings; hard-wired should be ok
+    private static final Map<String, String> KNOWN_PREFIXES =
+            Map.of("http://purl.org/dc/terms/", "dc",
+                    "http://ns.adobe.com/exif/1.0/", "exif");
+
+    // public API: suggest an available prefix for the provided namespace
+    // (while considering pre-existing mappings)
+    private static @NotNull String suggestPrefix(@NotNull String namespace,
+                                                 @NotNull Function<String, String> lookupPrefix) {
+        // try hard-wired map
+        String known = KNOWN_PREFIXES.get(namespace);
+
+        // lookup using supplied mapper as well
+        String lookedUpNamespace = known != null ? lookupPrefix.apply(known) : null;
+
+        // return hardwired prefix if unused or mapper has the prefix mapped to the same namespace
+        if (known != null && (lookedUpNamespace == null || namespace.equals(lookedUpNamespace))) {
+            return known;
+        } else {
+            return makeUpPrefix(namespace, lookupPrefix);
+        }
+    }
+
+    // public API: suggest an available prefix for the provided namespace
+    public static @NotNull String suggestPrefix(String namespace) {
+        return suggestPrefix(namespace, n -> null);
+    }
+
+    // suggest an available prefix for the provided namespace, based on the characters
+    // in the namespace name
+    // (while considering pre-existing mappings)
+    private static @NotNull String makeUpPrefix(@NotNull String namespace,
+                                                @NotNull Function<String, String> lookupNamespace) {

Review Comment:
   Shouldn't it be rather named getRegisteredPrefix() here?



-- 
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-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-10952: improve autogenerated namespace prefixes - test with prototype [jackrabbit-oak]

Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke commented on PR #2237:
URL: https://github.com/apache/jackrabbit-oak/pull/2237#issuecomment-2812879569

   > could the makeUpPrefixTryEvenHarder make a somewhat shorter (perhaps sha-hash) suggestion?
   
   SHA-1 would be 160 bits, thus 20 bytes, right? That's not always less than the actual namespace name. I could however special case that case.
   
   > generally I think this is useful indeed, to avoid later namespace remorse. How impossible would it be to look into support for changing namespaces (I know it's a challenge)
   
   That's a separate issue. I believe we already found that it can be done using the namespace registry, although risky. The point of *this* is to reduce the number of cases where it actually comes up.


-- 
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-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-10952: improve autogenerated namespace prefixes - test with prototype [jackrabbit-oak]

Posted by "stefan-egli (via GitHub)" <gi...@apache.org>.
stefan-egli commented on PR #2237:
URL: https://github.com/apache/jackrabbit-oak/pull/2237#issuecomment-2812846244

   * could the `makeUpPrefixTryEvenHarder` make a somewhat shorter (perhaps sha-hash) suggestion?
   * generally I think this is useful indeed, to avoid later namespace remorse. How impossible would it be to look into support for changing namespaces (I know it's a challenge)


-- 
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-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-10952: improve autogenerated namespace prefixes - test with prototype [jackrabbit-oak]

Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke commented on PR #2237:
URL: https://github.com/apache/jackrabbit-oak/pull/2237#issuecomment-2813375574

   > I was thinking of something like the `cca2a4f` part of a `cca2a4f1dbde1e0f7e337615763ac20a64e39160` git commit
   
   -> https://github.com/apache/jackrabbit-oak/pull/2237/commits/7024038f2e79c3069164bf864f2d7652e8c860a1
   


-- 
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-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-10952: improve autogenerated namespace prefixes - test with prototype [jackrabbit-oak]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #2237:
URL: https://github.com/apache/jackrabbit-oak/pull/2237#issuecomment-2812650370

   # Commit-Check ✔️


-- 
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-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-10952: improve autogenerated namespace prefixes - test with prototype [jackrabbit-oak]

Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke closed pull request #2237: OAK-10952: improve autogenerated namespace prefixes - test with prototype
URL: https://github.com/apache/jackrabbit-oak/pull/2237


-- 
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-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-10952: improve autogenerated namespace prefixes - test with prototype [jackrabbit-oak]

Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke commented on PR #2237:
URL: https://github.com/apache/jackrabbit-oak/pull/2237#issuecomment-2813383617

   re valid prefixes: the JCR spec allows many characters here; but checking exactly might be hard and overkill.
   
   As valid URIs, strictly speaking, are only ASCII, we should filter out all non-ASCII. That would leaves with a short "allow" list of characters.


-- 
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-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-10952: improve autogenerated namespace prefixes - test with prototype [jackrabbit-oak]

Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #2237:
URL: https://github.com/apache/jackrabbit-oak/pull/2237#discussion_r2073659577


##########
oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/NamespaceHelperPrototypeTest.java:
##########
@@ -0,0 +1,190 @@
+/*
+ * 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.commons;
+
+// experimental location for prototyping namespace related support functions
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.junit.Test;
+
+import java.math.BigInteger;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Locale;
+import java.util.Map;
+import java.util.UUID;
+import java.util.function.Function;
+
+import static org.junit.Assert.assertEquals;
+
+public class NamespaceHelperPrototypeTest {
+
+    // map with 'optimal' prefix mappings; hard-wired should be ok
+    private static final Map<String, String> KNOWN_PREFIXES =
+            Map.of("http://purl.org/dc/terms/", "dc",
+                    "http://ns.adobe.com/exif/1.0/", "exif");
+
+    // public API: suggest an available prefix for the provided namespace
+    // (while considering pre-existing mappings)
+    private static @NotNull String suggestPrefix(@NotNull String namespace,

Review Comment:
   suggest is a bit fuzzy to me, why not `getUnusedPrefix(...)`



##########
oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/NamespaceHelperPrototypeTest.java:
##########
@@ -0,0 +1,190 @@
+/*
+ * 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.commons;
+
+// experimental location for prototyping namespace related support functions
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.junit.Test;
+
+import java.math.BigInteger;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Locale;
+import java.util.Map;
+import java.util.UUID;
+import java.util.function.Function;
+
+import static org.junit.Assert.assertEquals;
+
+public class NamespaceHelperPrototypeTest {
+
+    // map with 'optimal' prefix mappings; hard-wired should be ok
+    private static final Map<String, String> KNOWN_PREFIXES =
+            Map.of("http://purl.org/dc/terms/", "dc",
+                    "http://ns.adobe.com/exif/1.0/", "exif");
+
+    // public API: suggest an available prefix for the provided namespace
+    // (while considering pre-existing mappings)
+    private static @NotNull String suggestPrefix(@NotNull String namespace,
+                                                 @NotNull Function<String, String> lookupPrefix) {
+        // try hard-wired map
+        String known = KNOWN_PREFIXES.get(namespace);
+
+        // lookup using supplied mapper as well
+        String lookedUpNamespace = known != null ? lookupPrefix.apply(known) : null;
+
+        // return hardwired prefix if unused or mapper has the prefix mapped to the same namespace
+        if (known != null && (lookedUpNamespace == null || namespace.equals(lookedUpNamespace))) {
+            return known;
+        } else {
+            return makeUpPrefix(namespace, lookupPrefix);
+        }
+    }
+
+    // public API: suggest an available prefix for the provided namespace
+    public static @NotNull String suggestPrefix(String namespace) {
+        return suggestPrefix(namespace, n -> null);
+    }
+
+    // suggest an available prefix for the provided namespace, based on the characters
+    // in the namespace name
+    // (while considering pre-existing mappings)
+    private static @NotNull String makeUpPrefix(@NotNull String namespace,
+                                                @NotNull Function<String, String> lookupNamespace) {
+        String prefix = namespace.toLowerCase(Locale.ENGLISH);
+
+        // https://www.w3.org/guide/editor/namespaces.html
+        if (prefix.startsWith("http://www.w3c.org/ns/")) {

Review Comment:
   Let us use String constants and their length method to get rid of the magical size.



##########
oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/NamespaceHelperPrototypeTest.java:
##########
@@ -0,0 +1,190 @@
+/*
+ * 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.commons;
+
+// experimental location for prototyping namespace related support functions
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.junit.Test;
+
+import java.math.BigInteger;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Locale;
+import java.util.Map;
+import java.util.UUID;
+import java.util.function.Function;
+
+import static org.junit.Assert.assertEquals;
+
+public class NamespaceHelperPrototypeTest {
+
+    // map with 'optimal' prefix mappings; hard-wired should be ok
+    private static final Map<String, String> KNOWN_PREFIXES =
+            Map.of("http://purl.org/dc/terms/", "dc",
+                    "http://ns.adobe.com/exif/1.0/", "exif");
+
+    // public API: suggest an available prefix for the provided namespace
+    // (while considering pre-existing mappings)
+    private static @NotNull String suggestPrefix(@NotNull String namespace,
+                                                 @NotNull Function<String, String> lookupPrefix) {
+        // try hard-wired map
+        String known = KNOWN_PREFIXES.get(namespace);
+
+        // lookup using supplied mapper as well
+        String lookedUpNamespace = known != null ? lookupPrefix.apply(known) : null;
+
+        // return hardwired prefix if unused or mapper has the prefix mapped to the same namespace
+        if (known != null && (lookedUpNamespace == null || namespace.equals(lookedUpNamespace))) {
+            return known;
+        } else {
+            return makeUpPrefix(namespace, lookupPrefix);
+        }
+    }
+
+    // public API: suggest an available prefix for the provided namespace
+    public static @NotNull String suggestPrefix(String namespace) {
+        return suggestPrefix(namespace, n -> null);
+    }
+
+    // suggest an available prefix for the provided namespace, based on the characters
+    // in the namespace name
+    // (while considering pre-existing mappings)
+    private static @NotNull String makeUpPrefix(@NotNull String namespace,
+                                                @NotNull Function<String, String> lookupNamespace) {

Review Comment:
   `lookupNamespace` is hard to grasp why not `getRegisteredNamespaceForPrefix`



-- 
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-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-10952: improve autogenerated namespace prefixes - test with prototype [jackrabbit-oak]

Posted by "stefan-egli (via GitHub)" <gi...@apache.org>.
stefan-egli commented on PR #2237:
URL: https://github.com/apache/jackrabbit-oak/pull/2237#issuecomment-2813397232

   +1, `"s-1578eb4"` looks nice!


-- 
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-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-10952: improve autogenerated namespace prefixes - test with prototype [jackrabbit-oak]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #2237:
URL: https://github.com/apache/jackrabbit-oak/pull/2237#issuecomment-2813613757

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2237) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2237&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2237&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2237&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2237&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2237&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2237)
   
   


-- 
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-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-10952: improve autogenerated namespace prefixes - test with prototype [jackrabbit-oak]

Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #2237:
URL: https://github.com/apache/jackrabbit-oak/pull/2237#discussion_r2075226730


##########
oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/NamespaceHelperPrototypeTest.java:
##########
@@ -0,0 +1,190 @@
+/*
+ * 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.commons;
+
+// experimental location for prototyping namespace related support functions
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.junit.Test;
+
+import java.math.BigInteger;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Locale;
+import java.util.Map;
+import java.util.UUID;
+import java.util.function.Function;
+
+import static org.junit.Assert.assertEquals;
+
+public class NamespaceHelperPrototypeTest {
+
+    // map with 'optimal' prefix mappings; hard-wired should be ok
+    private static final Map<String, String> KNOWN_PREFIXES =
+            Map.of("http://purl.org/dc/terms/", "dc",
+                    "http://ns.adobe.com/exif/1.0/", "exif");
+
+    // public API: suggest an available prefix for the provided namespace
+    // (while considering pre-existing mappings)
+    private static @NotNull String suggestPrefix(@NotNull String namespace,
+                                                 @NotNull Function<String, String> lookupPrefix) {
+        // try hard-wired map
+        String known = KNOWN_PREFIXES.get(namespace);
+
+        // lookup using supplied mapper as well
+        String lookedUpNamespace = known != null ? lookupPrefix.apply(known) : null;
+
+        // return hardwired prefix if unused or mapper has the prefix mapped to the same namespace
+        if (known != null && (lookedUpNamespace == null || namespace.equals(lookedUpNamespace))) {
+            return known;
+        } else {
+            return makeUpPrefix(namespace, lookupPrefix);
+        }
+    }
+
+    // public API: suggest an available prefix for the provided namespace
+    public static @NotNull String suggestPrefix(String namespace) {
+        return suggestPrefix(namespace, n -> null);
+    }
+
+    // suggest an available prefix for the provided namespace, based on the characters
+    // in the namespace name
+    // (while considering pre-existing mappings)
+    private static @NotNull String makeUpPrefix(@NotNull String namespace,
+                                                @NotNull Function<String, String> lookupNamespace) {

Review Comment:
   I think this returns a namespace URI for a given prefix (not the other way around). But this definitely calls for a non ambiguous name.



-- 
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-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-10952: improve autogenerated namespace prefixes - test with prototype [jackrabbit-oak]

Posted by "stefan-egli (via GitHub)" <gi...@apache.org>.
stefan-egli commented on PR #2237:
URL: https://github.com/apache/jackrabbit-oak/pull/2237#issuecomment-2812986905

   I was thinking of something like the `cca2a4f` part of a `cca2a4f1dbde1e0f7e337615763ac20a64e39160` git commit


-- 
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-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-10952: improve autogenerated namespace prefixes - test with prototype [jackrabbit-oak]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #2237:
URL: https://github.com/apache/jackrabbit-oak/pull/2237#issuecomment-2813107653

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2237) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2237&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2237&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2237&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2237&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2237&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2237)
   
   


-- 
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-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-10952: improve autogenerated namespace prefixes - test with prototype [jackrabbit-oak]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #2237:
URL: https://github.com/apache/jackrabbit-oak/pull/2237#issuecomment-2813098595

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2237) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2237&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2237&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2237&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2237&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2237&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2237)
   
   


-- 
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-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-10952: improve autogenerated namespace prefixes - test with prototype [jackrabbit-oak]

Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on PR #2237:
URL: https://github.com/apache/jackrabbit-oak/pull/2237#issuecomment-2859787274

   I would place this in `org.apache.jackrabbit.oak.namepath.impl.GlobalNameMapper` and then call this from according `getOrCreateOakName(orNull)`. This should be imho the only place dealing with name resolving in Oak.


-- 
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-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org