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 2021/06/28 06:31:52 UTC
[jackrabbit-filevault] branch master updated: JCRVLT-506 remove
handling of JCR 1.0 nt:nodeType (#129)
This is an automated email from the ASF dual-hosted git repository.
kwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault.git
The following commit(s) were added to refs/heads/master by this push:
new 2381d35 JCRVLT-506 remove handling of JCR 1.0 nt:nodeType (#129)
2381d35 is described below
commit 2381d35b1ba4eb2785f3d632b8501983899ce980
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Mon Jun 28 08:31:47 2021 +0200
JCRVLT-506 remove handling of JCR 1.0 nt:nodeType (#129)
remove support for xcnd files and nt:nodeType nodes completely (JCR 1.0
legacy)
---
.../jackrabbit/vault/fs/api/SerializationType.java | 4 +-
.../jackrabbit/vault/fs/config/Registry.java | 8 +-
.../jackrabbit/vault/fs/impl/TransactionImpl.java | 5 -
.../fs/impl/aggregator/NodeTypeAggregator.java | 95 ----
.../jackrabbit/vault/fs/impl/io/CNDImporter.java | 482 ---------------------
.../jackrabbit/vault/fs/impl/io/CNDSerializer.java | 280 ------------
.../vault/fs/impl/io/NodeTypeArtifactHandler.java | 75 ----
.../apache/jackrabbit/vault/fs/io/Importer.java | 3 -
.../vault/fs/config/defaultConfig-1.0.xml | 124 ------
.../vault/fs/config/defaultConfig-1.1.xml | 7 -
10 files changed, 7 insertions(+), 1076 deletions(-)
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/SerializationType.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/SerializationType.java
index 92987a0..941403b 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/SerializationType.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/SerializationType.java
@@ -44,8 +44,10 @@ public enum SerializationType {
XML_DOCVIEW("xml/docview", "text/xml"),
/**
- * specifies that the source is a compact node type definition
+ * specifies that the source is a compact node type definition (xcnd file, only relevant for JCR 1.0), regular CND files should be placed in meta data
+ * @deprecated Don't rely on this serialization type at all and rather place CND files in metadata.
*/
+ @Deprecated
CND("text/cnd", "text/cnd"),
/**
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/config/Registry.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/config/Registry.java
index 5e1113b..ff1b52c 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/config/Registry.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/config/Registry.java
@@ -26,11 +26,9 @@ import org.apache.jackrabbit.vault.fs.impl.aggregator.FileAggregator;
import org.apache.jackrabbit.vault.fs.impl.aggregator.FileFolderAggregator;
import org.apache.jackrabbit.vault.fs.impl.aggregator.FullCoverageAggregator;
import org.apache.jackrabbit.vault.fs.impl.aggregator.GenericAggregator;
-import org.apache.jackrabbit.vault.fs.impl.aggregator.NodeTypeAggregator;
import org.apache.jackrabbit.vault.fs.impl.io.FileArtifactHandler;
import org.apache.jackrabbit.vault.fs.impl.io.FolderArtifactHandler;
import org.apache.jackrabbit.vault.fs.impl.io.GenericArtifactHandler;
-import org.apache.jackrabbit.vault.fs.impl.io.NodeTypeArtifactHandler;
/**
* {@code Registry}...
@@ -55,13 +53,15 @@ public class Registry {
aggregators.put("file", FileAggregator.class);
aggregators.put("full", FullCoverageAggregator.class);
aggregators.put("generic", GenericAggregator.class);
- aggregators.put("nodetype", NodeTypeAggregator.class);
+ // no longer supported, just use GenericAggregator
+ aggregators.put("nodetype", GenericAggregator.class);
aggregators.put("filefolder", FileFolderAggregator.class);
handlers = new HashMap<String, Class<? extends ArtifactHandler>>();
handlers.put("file", FileArtifactHandler.class);
handlers.put("folder", FolderArtifactHandler.class);
- handlers.put("nodetype", NodeTypeArtifactHandler.class);
+ // no longer supported, just use GenericArtifactHandler
+ handlers.put("nodetype", GenericArtifactHandler.class);
handlers.put("generic", GenericArtifactHandler.class);
}
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/TransactionImpl.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/TransactionImpl.java
index c923e78..3befca2 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/TransactionImpl.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/TransactionImpl.java
@@ -182,11 +182,6 @@ public class TransactionImpl implements VaultFsTransaction {
// force generic
serType = SerializationType.GENERIC;
}
- } else if (ext.equals(".xcnd")) {
- aType = ArtifactType.PRIMARY;
- serType = SerializationType.CND;
- repoName = base;
- extension = ext;
} else if (ext.equals(".binary")) {
aType = ArtifactType.BINARY;
repoName = base;
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/aggregator/NodeTypeAggregator.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/aggregator/NodeTypeAggregator.java
deleted file mode 100644
index 1641d5f..0000000
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/aggregator/NodeTypeAggregator.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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.fs.impl.aggregator;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.apache.jackrabbit.vault.fs.api.ArtifactType;
-import org.apache.jackrabbit.vault.fs.api.DumpContext;
-import org.apache.jackrabbit.vault.fs.api.ImportInfo;
-import org.apache.jackrabbit.vault.fs.filter.NodeTypeItemFilter;
-import org.apache.jackrabbit.vault.fs.impl.AggregateImpl;
-import org.apache.jackrabbit.vault.fs.impl.ArtifactSetImpl;
-import org.apache.jackrabbit.vault.fs.impl.io.CNDSerializer;
-import org.apache.jackrabbit.vault.fs.impl.io.ImportInfoImpl;
-import org.apache.jackrabbit.vault.fs.io.Serializer;
-import org.apache.jackrabbit.vault.util.JcrConstants;
-
-/**
- * Implements an aggregator that serializes nt:nodeType nodes into a .cnd files.
- */
-public class NodeTypeAggregator extends GenericAggregator {
-
- /**
- * {@inheritDoc}
- *
- * @return {@code true} always.
- */
- public boolean hasFullCoverage() {
- return true;
- }
-
- /**
- * {@inheritDoc}
- *
- * If no match filter is defined, add the nt:nodeType as node type filter.
- */
- public boolean matches(Node node, String path) throws RepositoryException {
- if (getMatchFilter().isEmpty()) {
- getMatchFilter().addInclude(
- new NodeTypeItemFilter(JcrConstants.NT_NODETYPE, true)
- );
- }
- return super.matches(node, path);
- }
-
-
- /**
- * {@inheritDoc}
- */
- public ArtifactSetImpl createArtifacts(AggregateImpl aggregate) throws RepositoryException {
- ArtifactSetImpl artifacts = new ArtifactSetImpl();
- Serializer ser = new CNDSerializer(aggregate);
- artifacts.add(null, aggregate.getRelPath(), ".xcnd", ArtifactType.PRIMARY, ser, 0);
- return artifacts;
- }
-
- /**
- * {@inheritDoc}
- */
- public ImportInfo remove(Node node, boolean recursive, boolean trySave) throws RepositoryException {
- ImportInfo info = new ImportInfoImpl();
- info.onDeleted(node.getPath());
- Session s = node.getSession();
- node.remove();
- if (trySave) {
- s.save();
- }
- return info;
- }
-
- /**
- * {@inheritDoc}
- */
- public void dump(DumpContext ctx, boolean isLast) {
- ctx.println(isLast, getClass().getSimpleName());
- }
-
-}
\ No newline at end of file
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/CNDImporter.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/CNDImporter.java
deleted file mode 100644
index 7cf98b0..0000000
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/CNDImporter.java
+++ /dev/null
@@ -1,482 +0,0 @@
-/*
- * 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.fs.impl.io;
-
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.Value;
-
-import org.apache.jackrabbit.util.ISO9075;
-import org.apache.jackrabbit.vault.fs.impl.io.legacycnd.Lexer;
-import org.apache.jackrabbit.vault.fs.impl.io.legacycnd.ParseException;
-import org.apache.jackrabbit.vault.util.Constants;
-import org.apache.jackrabbit.vault.util.JcrConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * {@code CNDImporter}...
- *
- */
-public class CNDImporter {
-
- /**
- * default logger
- */
- private static final Logger log = LoggerFactory.getLogger(CNDImporter.class);
-
- /**
- * the underlying lexer
- */
- private Lexer lexer;
-
- /**
- * the current token
- */
- private String currentToken;
-
- /**
- * old namespace mappings that need to be reverted
- */
- private Map<String, String> oldMappings = new HashMap<String, String>();
-
- public ImportInfoImpl doImport(Node parent, String name, Reader r, String systemId)
- throws RepositoryException {
- try {
- lexer = new Lexer(r, systemId);
- nextToken();
- ImportInfoImpl info = parse(parent, name);
- // reset name spaces
- for (String prefix: oldMappings.keySet()) {
- String uri = oldMappings.get(prefix);
- try {
- parent.getSession().setNamespacePrefix(prefix, uri);
- } catch (RepositoryException e) {
- // ignore
- }
- }
- return info;
- } catch (ParseException e) {
- log.error("Error while parsing.", e);
- return null;
- }
- }
-
- private ImportInfoImpl parse(Node parent, String name) throws ParseException, RepositoryException {
- while (!currentTokenEquals(Lexer.EOF)) {
- if (!doNameSpace(parent.getSession())) {
- break;
- }
- }
- ImportInfoImpl info = new ImportInfoImpl();
- while (!currentTokenEquals(Lexer.EOF)) {
- String ntName = doNodeTypeName();
- if (name == null) {
- name = ntName;
- }
- if (parent.hasNode(name)) {
- parent.getNode(name).remove();
- }
- Node node;
- if (parent.hasNode(name)) {
- parent.getNode(name).remove();
- node = parent.addNode(name, JcrConstants.NT_NODETYPE);
- info.onReplaced(node.getPath());
- } else {
- node = parent.addNode(name, JcrConstants.NT_NODETYPE);
- info.onCreated(node.getPath());
- }
- node.setProperty(JcrConstants.JCR_NODETYPENAME, name);
-
- // init mandatory props
- node.setProperty(JcrConstants.JCR_HASORDERABLECHILDNODES, false);
- node.setProperty(JcrConstants.JCR_ISMIXIN, false);
- doSuperTypes(node);
- doOptions(node);
- doItemDefs(node);
- name = null;
- }
- return info;
- }
-
- private boolean doNameSpace(Session session) throws ParseException {
- if (!currentTokenEquals('<')) {
- return false;
- }
- nextToken();
- String prefix = currentToken;
- nextToken();
- if (!currentTokenEquals('=')) {
- lexer.fail("Missing = in namespace decl.");
- }
- nextToken();
- String uri = currentToken;
- nextToken();
- if (!currentTokenEquals('>')) {
- lexer.fail("Missing > in namespace decl.");
- }
- String oldPrefix = null;
- try {
- oldPrefix = session.getNamespacePrefix(uri);
- } catch (RepositoryException e) {
- // assume does not exist yet, so register
- }
- try {
- if (oldPrefix == null) {
- session.getWorkspace().getNamespaceRegistry().registerNamespace(prefix, uri);
- } else if (!oldPrefix.equals(prefix)) {
- // remap
- oldMappings.put(oldPrefix, uri);
- session.setNamespacePrefix(prefix, uri);
- }
- } catch (RepositoryException e) {
- lexer.fail("unable to remap namespace", e);
- }
- nextToken();
- return true;
- }
-
- private String doNodeTypeName() throws ParseException {
- String name;
- if (!currentTokenEquals(Lexer.BEGIN_NODE_TYPE_NAME)) {
- lexer.fail("Missing '" + Lexer.BEGIN_NODE_TYPE_NAME + "' delimiter for beginning of node type name");
- }
- nextToken();
- name = ISO9075.decode(currentToken);
-
- nextToken();
- if (!currentTokenEquals(Lexer.END_NODE_TYPE_NAME)) {
- lexer.fail("Missing '" + Lexer.END_NODE_TYPE_NAME + "' delimiter for end of node type name, found " + currentToken);
- }
- nextToken();
-
- return name;
- }
-
- private static void setProperty(Node node, String name, List<String> values)
- throws RepositoryException {
- node.setProperty(name, values.toArray(new String[values.size()]));
- }
-
- private static void setProperty(Node node, String name, List<String> values, int type)
- throws RepositoryException {
- node.setProperty(name, values.toArray(new String[values.size()]), type);
- }
-
- private void doSuperTypes(Node ntd) throws ParseException, RepositoryException {
- // a set would be nicer here, in case someone defines a super type twice.
- // but due to issue [JCR-333], the resulting node type definition is
- // not symmetric anymore and the tests will fail.
- List<String> supertypes = new ArrayList<String>();
- if (!currentTokenEquals(Lexer.EXTENDS)) {
- return;
- }
- do {
- nextToken();
- supertypes.add(ISO9075.decode(currentToken));
- nextToken();
- } while (currentTokenEquals(Lexer.LIST_DELIMITER));
- setProperty(ntd, JcrConstants.JCR_SUPERTYPES, supertypes);
- }
-
- private void doOptions(Node ntd) throws ParseException, RepositoryException {
- if (currentTokenEquals(Lexer.ORDERABLE)) {
- ntd.setProperty(JcrConstants.JCR_HASORDERABLECHILDNODES, true);
- nextToken();
- if (currentTokenEquals(Lexer.MIXIN)) {
- ntd.setProperty(JcrConstants.JCR_ISMIXIN, true);
- nextToken();
- }
- } else if (currentTokenEquals(Lexer.MIXIN)) {
- ntd.setProperty(JcrConstants.JCR_ISMIXIN, true);
- nextToken();
- if (currentTokenEquals(Lexer.ORDERABLE)) {
- ntd.setProperty(JcrConstants.JCR_HASORDERABLECHILDNODES, true);
- nextToken();
- }
- }
- }
-
- private void doItemDefs(Node ntd) throws ParseException, RepositoryException {
- while (currentTokenEquals(Lexer.PROPERTY_DEFINITION) || currentTokenEquals(Lexer.CHILD_NODE_DEFINITION)) {
- if (currentTokenEquals(Lexer.PROPERTY_DEFINITION)) {
- Node pdi = ntd.addNode(JcrConstants.JCR_PROPERTYDEFINITION);
- nextToken();
- doPropertyDefinition(pdi);
-
- } else if (currentTokenEquals(Lexer.CHILD_NODE_DEFINITION)) {
- Node ndi = ntd.addNode(JcrConstants.JCR_CHILDNODEDEFINITION);
-
- nextToken();
- doChildNodeDefinition(ndi);
- }
- }
- }
-
- private void doPropertyDefinition(Node pdi) throws ParseException, RepositoryException {
- String name = ISO9075.decode(currentToken);
- if (!name.equals("") && !name.equals("*")) {
- pdi.setProperty(JcrConstants.JCR_NAME, name);
- }
- // init mandatory props
- pdi.setProperty(JcrConstants.JCR_AUTOCREATED, false);
- pdi.setProperty(JcrConstants.JCR_MANDATORY, false);
- pdi.setProperty(JcrConstants.JCR_MULTIPLE, false);
- pdi.setProperty(JcrConstants.JCR_ONPARENTVERSION, "COPY");
- pdi.setProperty(JcrConstants.JCR_PROTECTED, false);
- pdi.setProperty(JcrConstants.JCR_REQUIREDTYPE, "UNDEFINED");
-
- nextToken();
- int type = doPropertyType(pdi);
- doPropertyDefaultValue(pdi, type);
- doPropertyAttributes(pdi);
- doPropertyValueConstraints(pdi);
- }
-
- private int doPropertyType(Node pdi) throws ParseException, RepositoryException {
- if (!currentTokenEquals(Lexer.BEGIN_TYPE)) {
- return PropertyType.UNDEFINED;
- }
- nextToken();
- int type = PropertyType.UNDEFINED;
- if (currentTokenEquals(Lexer.STRING)) {
- type = PropertyType.STRING;
- } else if (currentTokenEquals(Lexer.BINARY)) {
- type = PropertyType.BINARY;
- } else if (currentTokenEquals(Lexer.LONG)) {
- type = PropertyType.LONG;
- } else if (currentTokenEquals(Lexer.DOUBLE)) {
- type = PropertyType.DOUBLE;
- } else if (currentTokenEquals(Lexer.BOOLEAN)) {
- type = PropertyType.BOOLEAN;
- } else if (currentTokenEquals(Lexer.DATE)) {
- type = PropertyType.DATE;
- } else if (currentTokenEquals(Lexer.NAME)) {
- type = PropertyType.NAME;
- } else if (currentTokenEquals(Lexer.PATH)) {
- type = PropertyType.PATH;
- } else if (currentTokenEquals(Lexer.REFERENCE)) {
- type = PropertyType.REFERENCE;
- } else if (currentTokenEquals(Lexer.UNDEFINED)) {
- type = PropertyType.UNDEFINED;
- } else {
- lexer.fail("Unknown property type '" + currentToken + "' specified");
- }
- pdi.setProperty(JcrConstants.JCR_REQUIREDTYPE, PropertyType.nameFromValue(type).toUpperCase());
- nextToken();
- if (!currentTokenEquals(Lexer.END_TYPE)) {
- lexer.fail("Missing '" + Lexer.END_TYPE + "' delimiter for end of property type");
- }
- nextToken();
- return type;
- }
-
- private void doPropertyAttributes(Node pdi) throws ParseException, RepositoryException {
- while (currentTokenEquals(Lexer.ATTRIBUTE)) {
- if (currentTokenEquals(Lexer.PRIMARY)) {
- Value name = pdi.getProperty(JcrConstants.JCR_NAME).getValue();
- if (pdi.getParent().hasProperty(JcrConstants.JCR_PRIMARYITEMNAME)) {
- lexer.fail("More than one primary item specified in node type '" + name.getString() + "'");
- }
- pdi.getParent().setProperty(JcrConstants.JCR_PRIMARYITEMNAME, name);
- } else if (currentTokenEquals(Lexer.AUTOCREATED)) {
- pdi.setProperty(JcrConstants.JCR_AUTOCREATED, true);
- } else if (currentTokenEquals(Lexer.MANDATORY)) {
- pdi.setProperty(JcrConstants.JCR_MANDATORY, true);
- } else if (currentTokenEquals(Lexer.PROTECTED)) {
- pdi.setProperty(JcrConstants.JCR_PROTECTED, true);
- } else if (currentTokenEquals(Lexer.MULTIPLE)) {
- pdi.setProperty(JcrConstants.JCR_MULTIPLE, true);
- } else if (currentTokenEquals(Lexer.COPY)) {
- pdi.setProperty(JcrConstants.JCR_ONPARENTVERSION, "COPY");
- } else if (currentTokenEquals(Lexer.VERSION)) {
- pdi.setProperty(JcrConstants.JCR_ONPARENTVERSION, "VERSION");
- } else if (currentTokenEquals(Lexer.INITIALIZE)) {
- pdi.setProperty(JcrConstants.JCR_ONPARENTVERSION, "INITIALIZE");
- } else if (currentTokenEquals(Lexer.COMPUTE)) {
- pdi.setProperty(JcrConstants.JCR_ONPARENTVERSION, "COMPUTE");
- } else if (currentTokenEquals(Lexer.IGNORE)) {
- pdi.setProperty(JcrConstants.JCR_ONPARENTVERSION, "IGNORE");
- } else if (currentTokenEquals(Lexer.ABORT)) {
- pdi.setProperty(JcrConstants.JCR_ONPARENTVERSION, "ABORT");
- }
- nextToken();
- }
- }
-
- private void doPropertyDefaultValue(Node pdi, int type)
- throws ParseException, RepositoryException {
- if (!currentTokenEquals(Lexer.DEFAULT)) {
- return;
- }
- List<String> defaultValues = new ArrayList<String>();
- do {
- nextToken();
- defaultValues.add(currentToken);
- nextToken();
- } while (currentTokenEquals(Lexer.LIST_DELIMITER));
- // use required type
- setProperty(pdi, JcrConstants.JCR_DEFAULTVALUES, defaultValues, type);
- }
-
- private void doPropertyValueConstraints(Node pdi) throws ParseException, RepositoryException {
- if (!currentTokenEquals(Lexer.CONSTRAINT)) {
- return;
- }
- List<String> constraints = new ArrayList<String>();
- do {
- nextToken();
- constraints.add(currentToken);
- nextToken();
- } while (currentTokenEquals(Lexer.LIST_DELIMITER));
- setProperty(pdi, JcrConstants.JCR_VALUECONSTRAINTS, constraints);
- }
-
- private void doChildNodeDefinition(Node ndi) throws ParseException, RepositoryException {
- String name = ISO9075.decode(currentToken);
- if (!name.equals("") && !name.equals("*")) {
- ndi.setProperty(JcrConstants.JCR_NAME, name);
- }
- // init mandatory props
- ndi.setProperty(JcrConstants.JCR_AUTOCREATED, false);
- ndi.setProperty(JcrConstants.JCR_MANDATORY, false);
- ndi.setProperty(JcrConstants.JCR_SAMENAMESIBLINGS, false);
- ndi.setProperty(JcrConstants.JCR_ONPARENTVERSION, "COPY");
- ndi.setProperty(JcrConstants.JCR_PROTECTED, false);
- ndi.setProperty(JcrConstants.JCR_REQUIREDPRIMARYTYPES, Constants.EMPTY_STRING_ARRAY);
-
- nextToken();
- doChildNodeRequiredTypes(ndi);
- doChildNodeDefaultType(ndi);
- doChildNodeAttributes(ndi);
- }
-
- private void doChildNodeRequiredTypes(Node ndi) throws ParseException, RepositoryException {
- if (!currentTokenEquals(Lexer.BEGIN_TYPE)) {
- return;
- }
- List<String> types = new ArrayList<String>();
- do {
- nextToken();
- types.add(ISO9075.decode(currentToken));
- nextToken();
- } while (currentTokenEquals(Lexer.LIST_DELIMITER));
- setProperty(ndi, JcrConstants.JCR_REQUIREDPRIMARYTYPES, types);
- nextToken();
- }
-
- private void doChildNodeDefaultType(Node ndi) throws ParseException, RepositoryException {
- if (!currentTokenEquals(Lexer.DEFAULT)) {
- return;
- }
- nextToken();
- ndi.setProperty(JcrConstants.JCR_DEFAULTPRIMARYTYPE, ISO9075.decode(currentToken));
- nextToken();
- }
-
- private void doChildNodeAttributes(Node ndi) throws ParseException, RepositoryException {
- while (currentTokenEquals(Lexer.ATTRIBUTE)) {
- if (currentTokenEquals(Lexer.PRIMARY)) {
- Value name = ndi.getProperty(JcrConstants.JCR_NAME).getValue();
- if (ndi.getParent().hasProperty(JcrConstants.JCR_PRIMARYITEMNAME)) {
- lexer.fail("More than one primary item specified in node type '" + name.getString() + "'");
- }
- ndi.getParent().setProperty(JcrConstants.JCR_PRIMARYITEMNAME, name);
- } else if (currentTokenEquals(Lexer.AUTOCREATED)) {
- ndi.setProperty(JcrConstants.JCR_AUTOCREATED, true);
- } else if (currentTokenEquals(Lexer.MANDATORY)) {
- ndi.setProperty(JcrConstants.JCR_MANDATORY, true);
- } else if (currentTokenEquals(Lexer.PROTECTED)) {
- ndi.setProperty(JcrConstants.JCR_PROTECTED, true);
- } else if (currentTokenEquals(Lexer.MULTIPLE)) {
- ndi.setProperty(JcrConstants.JCR_SAMENAMESIBLINGS, true);
- } else if (currentTokenEquals(Lexer.COPY)) {
- ndi.setProperty(JcrConstants.JCR_ONPARENTVERSION, "COPY");
- } else if (currentTokenEquals(Lexer.VERSION)) {
- ndi.setProperty(JcrConstants.JCR_ONPARENTVERSION, "VERSION");
- } else if (currentTokenEquals(Lexer.INITIALIZE)) {
- ndi.setProperty(JcrConstants.JCR_ONPARENTVERSION, "INITIALIZE");
- } else if (currentTokenEquals(Lexer.COMPUTE)) {
- ndi.setProperty(JcrConstants.JCR_ONPARENTVERSION, "COMPUTE");
- } else if (currentTokenEquals(Lexer.IGNORE)) {
- ndi.setProperty(JcrConstants.JCR_ONPARENTVERSION, "IGNORE");
- } else if (currentTokenEquals(Lexer.ABORT)) {
- ndi.setProperty(JcrConstants.JCR_ONPARENTVERSION, "ABORT");
- }
- nextToken();
- }
- }
-
- /**
- * Gets the next token from the underlying lexer.
- *
- * @see Lexer#getNextToken()
- * @throws ParseException if the lexer fails to get the next token.
- */
- private void nextToken() throws ParseException {
- currentToken = lexer.getNextToken();
- }
-
- /**
- * Checks if the {@link #currentToken} is semantically equal to the given
- * argument.
- *
- * @param s the tokens to compare with
- * @return {@code true} if equals; {@code false} otherwise.
- */
- private boolean currentTokenEquals(String[] s) {
- for (String value : s) {
- if (currentToken.equals(value)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Checks if the {@link #currentToken} is semantically equal to the given
- * argument.
- *
- * @param c the tokens to compare with
- * @return {@code true} if equals; {@code false} otherwise.
- */
- private boolean currentTokenEquals(char c) {
- return currentToken.length() == 1 && currentToken.charAt(0) == c;
- }
-
- /**
- * Checks if the {@link #currentToken} is semantically equal to the given
- * argument.
- *
- * @param s the tokens to compare with
- * @return {@code true} if equals; {@code false} otherwise.
- */
- private boolean currentTokenEquals(String s) {
- return currentToken.equals(s);
- }
-
-
-}
\ No newline at end of file
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/CNDSerializer.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/CNDSerializer.java
deleted file mode 100644
index d0661ba..0000000
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/CNDSerializer.java
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * 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.fs.impl.io;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-
-import org.apache.commons.io.output.CloseShieldOutputStream;
-import org.apache.jackrabbit.vault.fs.api.Aggregate;
-import org.apache.jackrabbit.vault.fs.api.SerializationType;
-import org.apache.jackrabbit.vault.fs.io.Serializer;
-import org.apache.jackrabbit.vault.util.JcrConstants;
-
-/**
- * {@code DocViewSerializer}...
-*
-*/
-public class CNDSerializer implements Serializer {
-
- /**
- * the indention string
- */
- private static final String INDENT = " ";
-
- /**
- * the export context
- */
- private final Aggregate aggregate;
-
- /**
- * Creates a new doc view serializer
- * @param aggregate the export context
- */
- public CNDSerializer(Aggregate aggregate) {
- this.aggregate = aggregate;
- }
-
- /**
- * {@inheritDoc}
- */
- public void writeContent(OutputStream out) throws IOException, RepositoryException {
- try (Writer w = new OutputStreamWriter(new CloseShieldOutputStream(out), "utf-8")) {
- for (String prefix: aggregate.getNamespacePrefixes()) {
- w.write("<'");
- w.write(prefix);
- w.write("'='");
- w.write(escape(aggregate.getNamespaceURI(prefix)));
- w.write("'>\n");
- }
- w.write("\n");
-
- writeNodeTypeDef(w, aggregate.getNode());
- }
- out.flush();
- }
-
- private void writeNodeTypeDef(Writer out, Node node) throws IOException, RepositoryException {
- writeName(out, node);
- writeSupertypes(out, node);
- writeOptions(out, node);
- writeDefs(out, node);
- out.write("\n");
- }
-
- private void writeName(Writer out, Node node)
- throws IOException, RepositoryException {
- out.write("[");
- out.write(node.getProperty(JcrConstants.JCR_NODETYPENAME).getString());
- out.write("]");
- }
-
- private void writeSupertypes(Writer out, Node node) throws IOException, RepositoryException {
- Value[] types = node.getProperty(JcrConstants.JCR_SUPERTYPES).getValues();
- String delim = " > ";
- for (Value s: types) {
- out.write(delim);
- out.write(s.getString());
- delim = ", ";
- }
- }
-
- private void writeOptions(Writer out, Node node) throws IOException, RepositoryException {
- String delim = "\n " + INDENT;
- if (node.getProperty(JcrConstants.JCR_HASORDERABLECHILDNODES).getBoolean()) {
- out.write(delim);
- out.write("orderable");
- delim = " ";
- }
- if (node.getProperty(JcrConstants.JCR_ISMIXIN).getBoolean()) {
- out.write(delim);
- out.write("mixin");
- }
- }
-
- private void writeDefs(Writer out, Node node) throws IOException, RepositoryException {
- NodeIterator iter = node.getNodes();
- String primary = null;
- if (node.hasProperty(JcrConstants.JCR_PRIMARYITEMNAME)) {
- primary = node.getProperty(JcrConstants.JCR_PRIMARYITEMNAME).getString();
- }
- while (iter.hasNext()) {
- Node child = iter.nextNode();
- if (child.getPrimaryNodeType().getName().equals(JcrConstants.NT_PROPERTYDEFINITION)) {
- writePropDef(out, child, primary);
- }
- }
- iter = node.getNodes();
- while (iter.hasNext()) {
- Node child = iter.nextNode();
- if (child.getPrimaryNodeType().getName().equals(JcrConstants.NT_CHILDNODEDEFINITION)) {
- writeNodeDef(out, child, primary);
- }
- }
- }
-
- private void writePropDef(Writer out, Node node, String primary) throws IOException, RepositoryException {
- out.write("\n" + INDENT + "- ");
- String name = "*";
- if (node.hasProperty(JcrConstants.JCR_NAME)) {
- name = node.getProperty(JcrConstants.JCR_NAME).getString();
- }
- out.write(name);
- out.write(" (");
- out.write(node.getProperty(JcrConstants.JCR_REQUIREDTYPE).getString().toLowerCase());
- out.write(")");
- if (node.hasProperty(JcrConstants.JCR_DEFAULTVALUES)) {
- writeDefaultValues(out, node.getProperty(JcrConstants.JCR_DEFAULTVALUES).getValues());
- }
- if (primary != null && primary.equals(name)) {
- out.write(" primary");
- }
- if (node.getProperty(JcrConstants.JCR_MANDATORY).getBoolean()) {
- out.write(" mandatory");
- }
- if (node.getProperty(JcrConstants.JCR_AUTOCREATED).getBoolean()) {
- out.write(" autocreated");
- }
- if (node.getProperty(JcrConstants.JCR_PROTECTED).getBoolean()) {
- out.write(" protected");
- }
- if (node.getProperty(JcrConstants.JCR_MULTIPLE).getBoolean()) {
- out.write(" multiple");
- }
- String opv = node.getProperty(JcrConstants.JCR_ONPARENTVERSION).getString().toLowerCase();
- if (!opv.equals("copy")) {
- out.write(" ");
- out.write(opv);
- }
- if (node.hasProperty(JcrConstants.JCR_VALUECONSTRAINTS)) {
- writeValueConstraints(out, node.getProperty(JcrConstants.JCR_VALUECONSTRAINTS).getValues());
- }
- }
-
- private void writeDefaultValues(Writer out, Value[] dva) throws IOException, RepositoryException {
- if (dva != null && dva.length > 0) {
- String delim = " = '";
- for (Value value : dva) {
- out.write(delim);
- out.write(escape(value.getString()));
- out.write("'");
- delim = ", '";
- }
- }
- }
-
- private void writeValueConstraints(Writer out, Value[] vca) throws IOException, RepositoryException {
- String delim = "\n" + INDENT + " < ";
- for (Value v: vca) {
- out.write(delim);
- out.write("'");
- out.write(escape(v.getString()));
- out.write("'");
- delim = ", ";
- }
- }
-
- private void writeNodeDef(Writer out, Node node, String primary) throws IOException, RepositoryException {
- out.write("\n" + INDENT + "+ ");
- String name = "*";
- if (node.hasProperty(JcrConstants.JCR_NAME)) {
- name = node.getProperty(JcrConstants.JCR_NAME).getString();
- }
- out.write(name);
-
- writeRequiredTypes(out, node.getProperty(JcrConstants.JCR_REQUIREDPRIMARYTYPES).getValues());
- if (node.hasProperty(JcrConstants.JCR_DEFAULTPRIMARYTYPE)) {
- writeDefaultType(out, node.getProperty(JcrConstants.JCR_DEFAULTPRIMARYTYPE).getString());
- }
- if (primary != null && primary.equals(name)) {
- out.write(" primary");
- }
- if (node.getProperty(JcrConstants.JCR_MANDATORY).getBoolean()) {
- out.write(" mandatory");
- }
- if (node.getProperty(JcrConstants.JCR_AUTOCREATED).getBoolean()) {
- out.write(" autocreated");
- }
- if (node.getProperty(JcrConstants.JCR_PROTECTED).getBoolean()) {
- out.write(" protected");
- }
- if (node.getProperty(JcrConstants.JCR_SAMENAMESIBLINGS).getBoolean()) {
- out.write(" multiple");
- }
- String opv = node.getProperty(JcrConstants.JCR_ONPARENTVERSION).getString().toLowerCase();
- if (!opv.equals("copy")) {
- out.write(" ");
- out.write(opv);
- }
- }
-
- private void writeRequiredTypes(Writer out, Value[] reqTypes) throws IOException, RepositoryException {
- if (reqTypes.length > 0) {
- String delim = " (";
- for (Value value : reqTypes) {
- out.write(delim);
- out.write(value.getString());
- delim = ", ";
- }
- out.write(")");
- }
- }
-
- private void writeDefaultType(Writer out, String defType) throws IOException {
- if (!defType.equals("*")) {
- out.write(" = ");
- out.write(defType);
- }
- }
-
- /**
- * escape
- * @param s the string to escape
- * @return the escaped string
- */
- private String escape(String s) {
- StringBuffer sb = new StringBuffer(s);
- for (int i = 0; i < sb.length(); i++) {
- if (sb.charAt(i) == '\\') {
- sb.insert(i, '\\');
- i++;
- } else if (sb.charAt(i) == '\'') {
- sb.insert(i, '\'');
- i++;
- }
- }
- return sb.toString();
- }
-
-
- /**
- * {@inheritDoc}
- *
- * @return {@link SerializationType#CND}
- */
- public SerializationType getType() {
- return SerializationType.CND;
- }
-}
\ No newline at end of file
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/NodeTypeArtifactHandler.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/NodeTypeArtifactHandler.java
deleted file mode 100644
index 3560d8b..0000000
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/NodeTypeArtifactHandler.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.fs.impl.io;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.apache.jackrabbit.vault.fs.api.Artifact;
-import org.apache.jackrabbit.vault.fs.api.ImportMode;
-import org.apache.jackrabbit.vault.fs.api.SerializationType;
-import org.apache.jackrabbit.vault.fs.api.WorkspaceFilter;
-import org.apache.jackrabbit.vault.fs.impl.ArtifactSetImpl;
-import org.apache.jackrabbit.vault.util.PathUtil;
-
-/**
- * Creates nt:nodeType structures from {@link SerializationType#CND} artifacts.
- *
- */
-public class NodeTypeArtifactHandler extends AbstractArtifactHandler {
-
- /**
- * {@inheritDoc}
- * <p>
- * Handles generic artifact sets
- */
- protected ImportInfoImpl accept(WorkspaceFilter wspFilter, Node parent,
- String name, ArtifactSetImpl artifacts)
- throws RepositoryException, IOException {
- // need at least one primary data
- Artifact primary = artifacts.getPrimaryData();
- if (primary == null) {
- return null;
- }
- if (artifacts.size() != 1) {
- return null;
- }
- if (primary.getSerializationType() != SerializationType.CND) {
- return null;
- }
- String path = PathUtil.getPath(parent, primary.getRelativePath());
- if (wspFilter.getImportMode(path) == ImportMode.MERGE) {
- ImportInfoImpl info = new ImportInfoImpl();
- info.onNop(path);
- return info;
- }
- // do import
- CNDImporter importer = new CNDImporter();
- try (InputStream in = primary.getInputStream()) {
- Reader r = new InputStreamReader(in, "utf-8");
- return importer.doImport(parent, primary.getRelativePath(), r, primary.getRelativePath());
- }
- }
-
-
-}
\ No newline at end of file
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java
index bd90f9d..372ba8d 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java
@@ -750,9 +750,6 @@ public class Importer {
}
ext = "";
type = ArtifactType.FILE;
- } else if (".xcnd".equals(ext)) {
- serType = SerializationType.CND;
- repoName = repoBase;
} else if (".binary".equals(ext)) {
serType = SerializationType.GENERIC;
type = ArtifactType.BINARY;
diff --git a/vault-core/src/main/resources/org/apache/jackrabbit/vault/fs/config/defaultConfig-1.0.xml b/vault-core/src/main/resources/org/apache/jackrabbit/vault/fs/config/defaultConfig-1.0.xml
deleted file mode 100644
index f7cd71b..0000000
--- a/vault-core/src/main/resources/org/apache/jackrabbit/vault/fs/config/defaultConfig-1.0.xml
+++ /dev/null
@@ -1,124 +0,0 @@
-<!--
- 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.
- -->
-<vaultfs version="1.0">
- <!--
- Defines the default java packages to search for the respective
- elements below.
- -->
- <defaultPackages>
- <aggregator>org.apache.jackrabbit.vault.fs.aggregator</aggregator>
- <handler>org.apache.jackrabbit.vault.fs.imprt</handler>
- <include>org.apache.jackrabbit.vault.fs.filter</include>
- <exclude>org.apache.jackrabbit.vault.fs.filter</exclude>
- </defaultPackages>
-
- <!--
- Defines the default java classes to use for the respective elements
- below.
- -->
- <defaultClasses>
- <aggregator>org.apache.jackrabbit.vault.fs.impl.aggregator.GenericAggregator</aggregator>
- </defaultClasses>
-
- <!--
- Defines the content aggregators
- -->
- <aggregators>
-
- <!--
- Defines an aggregator that handles nt:file and nt:resource nodes.
- -->
- <aggregator name="File" class="FileAggregator" />
-
- <!--
- Defines an aggregator that handles cq:Page like nodes. It matches
- all cq:Page nodes and excludes child nodes with cq:Page in the
- aggregate.
- -->
- <aggregator name="Page">
- <contentFilter>
- <exclude class="NodeTypeItemFilter" nodeType="cq:Page" respectSupertype="true" />
- </contentFilter>
- <matchFilter>
- <include class="NodeTypeItemFilter" nodeType="cq:Page" respectSupertype="true" />
- </matchFilter>
- </aggregator>
-
- <!--
- Defines an aggregator that defines full coverage for certain node
- types.
- -->
- <aggregator name="FullCoverage" class="FullCoverageAggregator">
- <matchFilter>
- <include class="NodeTypeItemFilter" nodeType="rep:AccessControl" respectSupertype="true" />
- <include class="NodeTypeItemFilter" nodeType="cq:AbstractWidget" respectSupertype="true" />
- <include class="NodeTypeItemFilter" nodeType="cq:DropTarget" respectSupertype="true" />
- <include class="NodeTypeItemFilter" nodeType="cq:EditConfig" respectSupertype="true" />
- </matchFilter>
- </aggregator>
-
- <!--
- Defines an aggregator that handles nt:nodeType nodes and serializes
- them into .cnd notation.
- -->
- <aggregator name="NodeType" class="NodeTypeAggregator">
- <matchFilter>
- <include class="NodeTypeItemFilter" nodeType="nt:nodeType" />
- </matchFilter>
- </aggregator>
-
- <!--
- Defines an aggregator that handles nt:folder nodes.
- -->
- <aggregator name="Folder">
- <contentFilter>
- <exclude class="IsNodeFilter" />
- </contentFilter>
- <matchFilter>
- <include class="NodeTypeItemFilter" nodeType="nt:folder" respectSupertype="true" />
- <include class="NodeTypeItemFilter" nodeType="cq:Folder" respectSupertype="true" />
- <include class="NodeTypeItemFilter" nodeType="sling:Folder" respectSupertype="true" />
- <include class="NodeTypeItemFilter" nodeType="wiki:Topic" respectSupertype="true" />
- </matchFilter>
- </aggregator>
-
- <!--
- Defines the default aggregator
- -->
- <aggregator name="default" isDefault="true">
- <contentFilter>
- <exclude class="NodeTypeItemFilter" nodeType="nt:hierarchyNode" respectSupertype="true" />
- <!-- <exclude class="IsNodeFilter" /> -->
- <include class="ItemFilter#ALL" />
- </contentFilter>
- <matchFilter>
- <include class="ItemFilter#ALL" />
- </matchFilter>
- </aggregator>
-
- </aggregators>
-
- <!--
- defines the input handlers
- -->
- <handlers>
- <handler class="FolderArtifactHandler"/>
- <handler class="FileArtifactHandler"/>
- <handler class="NodeTypeArtifactHandler"/>
- <handler class="GenericArtifactHandler"/>
- </handlers>
-</vaultfs>
diff --git a/vault-core/src/main/resources/org/apache/jackrabbit/vault/fs/config/defaultConfig-1.1.xml b/vault-core/src/main/resources/org/apache/jackrabbit/vault/fs/config/defaultConfig-1.1.xml
index b525f1c..f1b081a 100644
--- a/vault-core/src/main/resources/org/apache/jackrabbit/vault/fs/config/defaultConfig-1.1.xml
+++ b/vault-core/src/main/resources/org/apache/jackrabbit/vault/fs/config/defaultConfig-1.1.xml
@@ -33,12 +33,6 @@
<aggregate type="filefolder" title="File/Folder Aggregate"/>
<!--
- Defines an aggregate that handles nt:nodeType nodes and serializes
- them into .cnd notation.
- -->
- <aggregate type="nodetype" title="Node Type Aggregate" />
-
- <!--
Defines an aggregate that defines full coverage for certain node
types that cannot be covered by the default aggregator.
-->
@@ -87,7 +81,6 @@
<handlers>
<handler type="folder"/>
<handler type="file"/>
- <handler type="nodetype"/>
<handler type="generic"/>
</handlers>
</vaultfs>