You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by kw...@apache.org on 2020/02/10 14:17:30 UTC
svn commit: r1873857 - in
/jackrabbit/commons/filevault/trunk/vault-validation/src:
main/java/org/apache/jackrabbit/vault/validation/spi/
main/java/org/apache/jackrabbit/vault/validation/spi/util/
test/java/org/apache/jackrabbit/vault/validation/spi/util/
Author: kwin
Date: Mon Feb 10 14:17:29 2020
New Revision: 1873857
URL: http://svn.apache.org/viewvc?rev=1873857&view=rev
Log:
trivial: clarify namespacing in DocumentViewXmlValidators and provide
some util methods
Added:
jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/util/
jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/util/NameUtil.java
jackrabbit/commons/filevault/trunk/vault-validation/src/test/java/org/apache/jackrabbit/vault/validation/spi/util/
jackrabbit/commons/filevault/trunk/vault-validation/src/test/java/org/apache/jackrabbit/vault/validation/spi/util/NameUtilTest.java
Modified:
jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/DocumentViewXmlValidator.java
Modified: jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/DocumentViewXmlValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/DocumentViewXmlValidator.java?rev=1873857&r1=1873856&r2=1873857&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/DocumentViewXmlValidator.java (original)
+++ jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/DocumentViewXmlValidator.java Mon Feb 10 14:17:29 2020
@@ -37,7 +37,9 @@ public interface DocumentViewXmlValidato
/**
* Called for the beginning of each new JCR document view node.
* Deserialization of the node information was already done when this method is called!
- * The node and attribute names have the string representation outlined in {@link Name} (i.e. including the expanded namespace uri in the format <code>{namespaceURI}localPart</code>).
+ * The attribute names have the string representation outlined in {@link Name} (i.e. including the expanded namespace uri in the format <code>{namespaceURI}localPart</code>).
+ * This is also referred to as <a href="https://docs.adobe.com/docs/en/spec/jcr/2.0/3_Repository_Model.html#3.2.5.1%20Expanded%20Form">JCR name expanded form</a>.
+ * To construct such names either use {@link NameUtil} or use the constants from {@link NameConstants}.
*
* @param node the node which should be validated
* @param nodePath the absolute repository path of the given node
Added: jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/util/NameUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/util/NameUtil.java?rev=1873857&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/util/NameUtil.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/util/NameUtil.java Mon Feb 10 14:17:29 2020
@@ -0,0 +1,53 @@
+/*
+ * 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.vault.validation.spi.util;
+
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Utility methods to generate JCR names in the <a href="https://docs.adobe.com/docs/en/spec/jcr/2.0/3_Repository_Model.html#3.2.5.1%20Expanded%20Form">Expanded Form</a>.
+ * @see Name
+ */
+public class NameUtil {
+
+ private NameUtil() {
+
+ }
+
+ /**
+ * Use {@link NameUtil#getExpandedNameString(String)} to get the expanded form of a name with no specific namespace (using the default namespace).
+ * @param namespaceURI the namespace URI
+ * @param localName the local name (without any namespace prefix)
+ * @return the expanded form of a JCR name consisting out of the given namespace URI and local name
+ * @see <a href="https://docs.adobe.com/docs/en/spec/jcr/2.0/3_Repository_Model.html#3.2.5.1%20Expanded%20Form">Expanded Form</a>
+ */
+ public static @NotNull String getExpandedNameString(@NotNull String namespaceURI, @NotNull String localName) {
+ return NameFactoryImpl.getInstance().create(namespaceURI, localName).toString();
+ }
+
+ /**
+ * Use {@link NameUtil#getExpandedNameString(String, String)} to get the expanded form of a name with a namespace.
+ * @param name the name without any namespace prefix
+ * @return the expanded form of the given JCR name (without a specific namespace, i.e. using the default namespace)
+ * @see <a href="https://docs.adobe.com/docs/en/spec/jcr/2.0/3_Repository_Model.html#3.2.5.1%20Expanded%20Form">Expanded Form</a>
+ */
+ public static @NotNull String getExpandedNameString(@NotNull String name) {
+ return NameFactoryImpl.getInstance().create(Name.NS_DEFAULT_URI, name).toString();
+ }
+}
Added: jackrabbit/commons/filevault/trunk/vault-validation/src/test/java/org/apache/jackrabbit/vault/validation/spi/util/NameUtilTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-validation/src/test/java/org/apache/jackrabbit/vault/validation/spi/util/NameUtilTest.java?rev=1873857&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-validation/src/test/java/org/apache/jackrabbit/vault/validation/spi/util/NameUtilTest.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-validation/src/test/java/org/apache/jackrabbit/vault/validation/spi/util/NameUtilTest.java Mon Feb 10 14:17:29 2020
@@ -0,0 +1,30 @@
+/*
+ * 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.vault.validation.spi.util;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class NameUtilTest {
+
+ @Test
+ public void testGetNameString() {
+ Assert.assertEquals("{http://www.jcp.org/jcr/1.0}primaryType", NameUtil.getExpandedNameString("http://www.jcp.org/jcr/1.0", "primaryType"));
+ Assert.assertEquals("{}unnamespacedName", NameUtil.getExpandedNameString("unnamespacedName"));
+ }
+
+}