jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r774294 [2/2] - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/ jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/nodetype/ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/j...
Date Wed, 13 May 2009 12:43:20 GMT
Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeDefinitionImpl.java?rev=774294&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeDefinitionImpl.java
(added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeDefinitionImpl.java
Wed May 13 12:43:19 2009
@@ -0,0 +1,163 @@
+/*
+ * 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.spi.commons.nodetype;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.spi.QItemDefinition;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
+
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.NamespaceException;
+
+/**
+ * This class implements the <code>NodeDefinition</code> interface.
+ * All method calls are delegated to the wrapped {@link QNodeDefinition},
+ * performing the translation from <code>Name</code>s to JCR names
+ * where necessary.
+ */
+public class NodeDefinitionImpl extends ItemDefinitionImpl implements NodeDefinition {
+
+    /**
+     * logger instance
+     */
+    private static final Logger log = LoggerFactory.getLogger(NodeDefinitionImpl.class);
+
+    /**
+     * Constructor to create a definition that is based on a template.
+     *
+     * @param itemDef  item definition
+     * @param resolver
+     */
+    public NodeDefinitionImpl(QItemDefinition itemDef, NamePathResolver resolver) {
+        super(itemDef, resolver);
+    }
+
+    /**
+     * Constructor to create a definition that is based on an
+     * existing node type.
+     *
+     * @param itemDef  item definition
+     * @param resolver
+     */
+    public NodeDefinitionImpl(QItemDefinition itemDef, AbstractNodeTypeManager ntMgr, NamePathResolver
resolver) {
+        super(itemDef, ntMgr, resolver);
+    }
+
+    //-------------------------------------------------------< NodeDefinition >
+    /**
+     * {@inheritDoc}
+     */
+    public boolean allowsSameNameSiblings() {
+        return ((QNodeDefinition) itemDef).allowsSameNameSiblings();
+    }
+
+    /**
+     * @see NodeDefinition#getDefaultPrimaryTypeName()
+     * @since JCR 2.0
+     */
+    public String getDefaultPrimaryTypeName() {
+        Name ntName = ((QNodeDefinition) itemDef).getDefaultPrimaryType();
+        if (ntName == null) {
+            return null;
+        }
+        try {
+            return resolver.getJCRName(ntName);
+        } catch (NamespaceException e) {
+            // should never get here
+            log.error("invalid default node type " + ntName, e);
+            return null;
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public NodeType getDefaultPrimaryType() {
+        if (ntMgr == null) {
+            // not attached to an existing node type
+            return null;
+        }
+        Name ntName = ((QNodeDefinition) itemDef).getDefaultPrimaryType();
+        if (ntName == null) {
+            return null;
+        }
+        try {
+            return ntMgr.getNodeType(ntName);
+        } catch (NoSuchNodeTypeException e) {
+            // should never get here
+            log.error("invalid default node type " + ntName, e);
+            return null;
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public NodeType[] getRequiredPrimaryTypes() {
+        if (ntMgr == null) {
+            // not attached to an existing node type
+            return null;
+        }
+        Name[] ntNames = ((QNodeDefinition) itemDef).getRequiredPrimaryTypes();
+        try {
+            if (ntNames == null || ntNames.length == 0) {
+                // return "nt:base"
+                return new NodeType[] { ntMgr.getNodeType(NameConstants.NT_BASE) };
+            } else {
+                NodeType[] nodeTypes = new NodeType[ntNames.length];
+                for (int i = 0; i < ntNames.length; i++) {
+                    nodeTypes[i] = ntMgr.getNodeType(ntNames[i]);
+                }
+                return nodeTypes;
+            }
+        } catch (NoSuchNodeTypeException e) {
+            // should never get here
+            log.error("required node type does not exist", e);
+            return new NodeType[0];
+        }
+    }
+
+    /**
+     * @see NodeDefinition#getRequiredPrimaryTypeNames()
+     * @since JCR 2.0
+     */
+    public String[] getRequiredPrimaryTypeNames() {
+        Name[] ntNames = ((QNodeDefinition) itemDef).getRequiredPrimaryTypes();
+        try {
+            if (ntNames == null || ntNames.length == 0) {
+                // return "nt:base"
+                return new String[] { resolver.getJCRName(NameConstants.NT_BASE) };
+            } else {
+                String[] jcrNames = new String[ntNames.length];
+                for (int i = 0; i < ntNames.length; i++) {
+                    jcrNames[i] = resolver.getJCRName(ntNames[i]);
+                }
+                return jcrNames;
+            }
+        } catch (NamespaceException e) {
+            // should never get here
+            log.error("required node type does not exist", e);
+            return new String[0];
+        }
+    }
+}
\ No newline at end of file

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionImpl.java?rev=774294&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionImpl.java
(added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionImpl.java
Wed May 13 12:43:19 2009
@@ -0,0 +1,162 @@
+/*
+ * 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.spi.commons.nodetype;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+
+import javax.jcr.nodetype.NodeTypeDefinition;
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.NamespaceException;
+import javax.jcr.ValueFactory;
+
+/**
+ * <code>AbstractNodeTypeDefinition</code>...
+ */
+public class NodeTypeDefinitionImpl implements NodeTypeDefinition {
+
+    /**
+     * logger instance
+     */
+    private static final Logger log = LoggerFactory.getLogger(NodeTypeDefinitionImpl.class);
+
+    private final QNodeTypeDefinition ntd;
+    private final NamePathResolver resolver;
+    private final ValueFactory valueFactory;
+
+    /**
+     * 
+     * @param ntd
+     * @param resolver
+     * @param valueFactory
+     */
+    public NodeTypeDefinitionImpl(QNodeTypeDefinition ntd, NamePathResolver resolver,
+                                  ValueFactory valueFactory) {
+        this.ntd = ntd;
+        this.resolver = resolver;
+        this.valueFactory = valueFactory;
+    }
+
+    //-------------------------------------------------< NodeTypeDefinition >---
+    /**
+     * @see javax.jcr.nodetype.NodeTypeDefinition#getName()
+     */
+    public String getName() {
+        try {
+            return resolver.getJCRName(ntd.getName());
+        } catch (NamespaceException e) {
+            // should never get here
+            log.error("encountered unregistered namespace in node type name", e);
+            return ntd.getName().toString();
+        }
+    }
+
+    /**
+     * @see javax.jcr.nodetype.NodeTypeDefinition#getPrimaryItemName()
+     */
+    public String getPrimaryItemName() {
+        try {
+            Name piName = ntd.getPrimaryItemName();
+            if (piName != null) {
+                return resolver.getJCRName(piName);
+            } else {
+                return null;
+            }
+        } catch (NamespaceException e) {
+            // should never get here
+            log.error("encountered unregistered namespace in name of primary item", e);
+            return ntd.getName().toString();
+        }
+    }
+
+    /**
+     * @see javax.jcr.nodetype.NodeTypeDefinition#isMixin()
+     */
+    public boolean isMixin() {
+        return ntd.isMixin();
+    }
+
+    /**
+     * @see javax.jcr.nodetype.NodeTypeDefinition#hasOrderableChildNodes()
+     */
+    public boolean hasOrderableChildNodes() {
+        return ntd.hasOrderableChildNodes();
+    }
+
+    /**
+     * @see javax.jcr.nodetype.NodeTypeDefinition#isAbstract()
+     */
+    public boolean isAbstract() {
+        return ntd.isAbstract();
+    }
+
+    /**
+     * @see javax.jcr.nodetype.NodeTypeDefinition#isQueryable()
+     */
+    public boolean isQueryable() {
+        return ntd.isQueryable();
+    }
+
+    /**
+     * @see javax.jcr.nodetype.NodeTypeDefinition#getDeclaredPropertyDefinitions()
+     */
+    public PropertyDefinition[] getDeclaredPropertyDefinitions() {
+        QPropertyDefinition[] pds = ntd.getPropertyDefs();
+        PropertyDefinition[] propDefs = new PropertyDefinition[pds.length];
+        for (int i = 0; i < pds.length; i++) {
+            propDefs[i] = new PropertyDefinitionImpl(pds[i], resolver, valueFactory);
+        }
+        return propDefs;
+    }
+
+
+    /**
+     * @see javax.jcr.nodetype.NodeTypeDefinition#getDeclaredChildNodeDefinitions()
+     */
+    public NodeDefinition[] getDeclaredChildNodeDefinitions() {
+        QNodeDefinition[] cnda = ntd.getChildNodeDefs();
+        NodeDefinition[] nodeDefs = new NodeDefinition[cnda.length];
+        for (int i = 0; i < cnda.length; i++) {
+            nodeDefs[i] = new NodeDefinitionImpl(cnda[i], resolver);
+        }
+        return nodeDefs;
+    }
+
+    /**
+     * @see javax.jcr.nodetype.NodeTypeDefinition#getDeclaredSupertypeNames()
+     */
+    public String[] getDeclaredSupertypeNames() {
+        Name[] stNames = ntd.getSupertypes();
+        String[] dstn = new String[stNames.length];
+        for (int i = 0; i < stNames.length; i++) {
+            try {
+                dstn[i] = resolver.getJCRName(stNames[i]);
+            } catch (NamespaceException e) {
+                // should never get here
+                log.error("invalid node type name: " + stNames[i], e);
+                dstn[i] = stNames.toString();
+            }
+        }
+        return dstn;
+    }
+}
\ No newline at end of file

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/PropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/PropertyDefinitionImpl.java?rev=774294&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/PropertyDefinitionImpl.java
(added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/PropertyDefinitionImpl.java
Wed May 13 12:43:19 2009
@@ -0,0 +1,167 @@
+/*
+ * 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.spi.commons.nodetype;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.value.ValueFormat;
+
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.Value;
+import javax.jcr.RepositoryException;
+import javax.jcr.NamespaceException;
+import javax.jcr.ValueFactory;
+
+/**
+ * This class implements the <code>PropertyDefinition</code> interface.
+ * All method calls are delegated to the wrapped {@link QPropertyDefinition},
+ * performing the translation from <code>Name</code>s to JCR names
+ * (and vice versa) where necessary.
+ */
+public class PropertyDefinitionImpl extends ItemDefinitionImpl implements PropertyDefinition
{
+
+    /**
+     * logger instance
+     */
+    private static final Logger log = LoggerFactory.getLogger(PropertyDefinitionImpl.class);
+
+    private final ValueFactory valueFactory;
+
+    /**
+     * Package private constructor
+     *
+     * @param propDef    property definition
+     * @param resolver
+     * @param valueFactory
+     */
+    public PropertyDefinitionImpl(QPropertyDefinition propDef, NamePathResolver resolver,
+                                  ValueFactory valueFactory) {
+        this(propDef, null, resolver, valueFactory);
+    }
+
+    /**
+     *
+     * @param propDef
+     * @param ntMgr
+     * @param resolver
+     * @param valueFactory
+     */
+    public PropertyDefinitionImpl(QPropertyDefinition propDef,
+                                  AbstractNodeTypeManager ntMgr,
+                                  NamePathResolver resolver,
+                                  ValueFactory valueFactory) {
+        super(propDef, ntMgr, resolver);
+        this.valueFactory = valueFactory;
+    }
+
+    //-------------------------------------------------< PropertyDefinition >---
+    /**
+     * {@inheritDoc}
+     */
+    public Value[] getDefaultValues() {
+        QPropertyDefinition pDef = ((QPropertyDefinition) itemDef);
+        QValue[] defVals = pDef.getDefaultValues();
+        if (defVals == null) {
+            return null;
+        }
+
+        Value[] values = new Value[defVals.length];
+        for (int i = 0; i < defVals.length; i++) {
+            try {
+                values[i] = ValueFormat.getJCRValue(defVals[i], resolver, valueFactory);
+            } catch (RepositoryException e) {
+                // should never get here
+                String propName = (getName() == null) ? "[null]" : getName();
+                log.error("illegal default value specified for property " + propName + "
in node type " + getDeclaringNodeType(), e);
+                return null;
+            }
+        }
+        return values;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getRequiredType() {
+        return ((QPropertyDefinition) itemDef).getRequiredType();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String[] getValueConstraints() {
+        QPropertyDefinition pd = (QPropertyDefinition)itemDef;
+        String[] constraints = pd.getValueConstraints();
+        if (constraints == null || constraints.length == 0) {
+            return new String[0];
+        }
+        try {
+            String[] vca = new String[constraints.length];
+            for (int i = 0; i < constraints.length; i++) {
+                ValueConstraint constr = ValueConstraint.create(pd.getRequiredType(), constraints[i]);
+                vca[i] = constr.getDefinition(resolver);
+            }
+            return vca;
+        } catch (InvalidConstraintException e) {
+            log.error("Invalid value constraint: " + e.getMessage());
+            return null;
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isMultiple() {
+        return ((QPropertyDefinition) itemDef).isMultiple();
+    }
+
+    /**
+     * @see javax.jcr.nodetype.PropertyDefinition#getAvailableQueryOperators()
+     */
+    public String[] getAvailableQueryOperators() {
+        Name[] names = ((QPropertyDefinition) itemDef).getAvailableQueryOperators();
+        String[] aqos = new String[names.length];
+        for (int i = 0; i < names.length; i++) {
+            try {
+                aqos[i] = resolver.getJCRName(names[i]);
+            } catch (NamespaceException e) {
+                // should not occure. fallback
+                log.warn(e.getMessage());
+                aqos[i] = names[i].toString();
+            }
+        }
+        return aqos;
+    }
+
+    /**
+     * @see javax.jcr.nodetype.PropertyDefinition#isFullTextSearchable()
+     */
+    public boolean isFullTextSearchable() {
+        return ((QPropertyDefinition) itemDef).isFullTextSearchable();
+    }
+
+    /**
+     * @see javax.jcr.nodetype.PropertyDefinition#isQueryOrderable()
+     */
+    public boolean isQueryOrderable() {
+        return ((QPropertyDefinition) itemDef).isQueryOrderable();
+    }
+}
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QPropertyDefinition.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QPropertyDefinition.java?rev=774294&r1=774293&r2=774294&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QPropertyDefinition.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QPropertyDefinition.java
Wed May 13 12:43:19 2009
@@ -76,7 +76,7 @@
      * @return <code>true</code> if this property definition is full text searchable.
      * @since JCR 2.0
      */
-    public boolean isFullTextSearcheable();
+    public boolean isFullTextSearchable();
 
     /**
      * Reports whether this property definition is query-orderable.

Modified: jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java?rev=774294&r1=774293&r2=774294&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
Wed May 13 12:43:19 2009
@@ -38,6 +38,8 @@
 import javax.jcr.lock.LockException;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.nodetype.NodeTypeExistsException;
+import javax.jcr.nodetype.InvalidNodeTypeDefinitionException;
 import javax.jcr.query.InvalidQueryException;
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionException;
@@ -1056,6 +1058,41 @@
      */
     public Iterator getQNodeTypeDefinitions(SessionInfo sessionInfo, Name[] nodetypeNames)
throws RepositoryException;
 
+    /**
+     * Registers the node types with the specified <code>QNodeTypeDefinition</code>s.
+     * If <code>allowUpdate</code> is <code>true</code> this method
may also be
+     * used to reregister existing node types with a modified definition, otherwise
+     * this method will fail with <code>NodeTypeExistsException</code> if any
of
+     * the specified definition has the name of an already registered node type.
+     *
+     * @param sessionInfo
+     * @param nodeTypeDefinitions
+     * @param allowUpdate
+     * @throws InvalidNodeTypeDefinitionException If any of the specified definitions
+     * is invalid.
+     * @throws NodeTypeExistsException If any of the specified definitions has the
+     * name of an already registered node type and <code>allowUpdate</code> is
<code>false</code>.
+     * @throws UnsupportedRepositoryOperationException If registering node types
+     * is not supported.
+     * @throws RepositoryException If another error occurs.
+     * @see javax.jcr.nodetype.NodeTypeManager#registerNodeTypes(javax.jcr.nodetype.NodeTypeDefinition[],
boolean)
+     */
+    public void registerNodeTypes(SessionInfo sessionInfo, QNodeTypeDefinition[] nodeTypeDefinitions,
boolean allowUpdate) throws InvalidNodeTypeDefinitionException, NodeTypeExistsException, UnsupportedRepositoryOperationException,
RepositoryException;
+
+    /**
+     * Unregisters the node types with the specified <code>names</code>.
+     * 
+     * @param sessionInfo
+     * @param nodeTypeNames
+     * @throws UnsupportedRepositoryOperationException If unregistering node types
+     * is not supported.
+     * @throws NoSuchNodeTypeException If any of the specified names has no
+     * corresponding registered node type.
+     * @throws RepositoryException If another error occurs.
+     * @see javax.jcr.nodetype.NodeTypeManager#unregisterNodeTypes(String[])
+     */
+    public void unregisterNodeTypes(SessionInfo sessionInfo, Name[] nodeTypeNames) throws
UnsupportedRepositoryOperationException, NoSuchNodeTypeException, RepositoryException;
+
     //-----------------------------------------------< Workspace Management >---
     /**
      * Create a new workspace with the specified <code>name</code>. If

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QPropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QPropertyDefinitionImpl.java?rev=774294&r1=774293&r2=774294&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QPropertyDefinitionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QPropertyDefinitionImpl.java
Wed May 13 12:43:19 2009
@@ -62,19 +62,9 @@
      */
     private final boolean multiple;
 
-    /**
-     * TODO
-     */
-    private final Name[] availableQueryOperators = new Name[0];
-
-    /**
-     * TODO
-     */
-    private final boolean fullTextSearcheable = false;
-    /**
-     * TODO
-     */
-    private final boolean queryOrderable = false;
+    private final Name[] availableQueryOperators;
+    private final boolean fullTextSearcheable;
+    private final boolean queryOrderable;
 
     /**
      * Default constructor.
@@ -98,6 +88,17 @@
             multiple = false;
         }
 
+        if (pdefElement.hasAttribute(FULL_TEXT_SEARCHABLE_ATTRIBUTE)) {
+            fullTextSearcheable = Boolean.valueOf(pdefElement.getAttribute(FULL_TEXT_SEARCHABLE_ATTRIBUTE)).booleanValue();
+        } else {
+            fullTextSearcheable = false;
+        }
+        if (pdefElement.hasAttribute(QUERY_ORDERABLE_ATTRIBUTE)) {
+            queryOrderable = Boolean.valueOf(pdefElement.getAttribute(QUERY_ORDERABLE_ATTRIBUTE)).booleanValue();
+        } else {
+            queryOrderable = false;
+        }
+
         Element child = DomUtil.getChildElement(pdefElement, DEFAULTVALUES_ELEMENT, null);
         if (child == null) {
             // No default value defined at all.
@@ -141,6 +142,20 @@
             }
             valueConstraints = (String[]) vc.toArray(new String[vc.size()]);
         }
+
+        child = DomUtil.getChildElement(pdefElement, AVAILABLE_QUERY_OPERATORS_ELEMENT, null);
+        if (child == null) {
+            availableQueryOperators = new Name[0];
+        } else {
+            List names = new ArrayList();
+            ElementIterator it = DomUtil.getChildren(child, AVAILABLE_QUERY_OPERATOR_ELEMENT,
null);
+            while (it.hasNext()) {
+                String str = DomUtil.getText(it.nextElement());
+                Name n = resolver.getQName(str);
+                names.add(n);
+            }
+            availableQueryOperators = (Name[]) names.toArray(new Name[names.size()]);
+        }
     }
     
     //------------------------------------------------< QPropertyDefinition >---
@@ -176,24 +191,21 @@
      * {@inheritDoc}
      */
     public Name[] getAvailableQueryOperators() {
-        // TODO
-        throw new UnsupportedOperationException("JCR-2003 Add support for JCR 2.0. Implementation
missing");
+        return availableQueryOperators;
     }
 
     /**
      * {@inheritDoc}
      */
-    public boolean isFullTextSearcheable() {
-        // TODO
-        throw new UnsupportedOperationException("JCR-2003 Add support for JCR 2.0. Implementation
missing");
+    public boolean isFullTextSearchable() {
+        return fullTextSearcheable;
     }
 
     /**
      * {@inheritDoc}
      */
     public boolean isQueryOrderable() {
-        // TODO
-        throw new UnsupportedOperationException("JCR-2003 Add support for JCR 2.0. Implementation
missing");
+        return queryOrderable;
     }
 
     /**
@@ -225,7 +237,7 @@
             return super.equals(obj)
                     && requiredType == other.getRequiredType()
                     && multiple == other.isMultiple()
-                    && fullTextSearcheable == other.isFullTextSearcheable()
+                    && fullTextSearcheable == other.isFullTextSearchable()
                     && queryOrderable == other.isQueryOrderable()
                     && Arrays.equals(valueConstraints, other.getValueConstraints())
                     && Arrays.equals(defaultValues, other.getDefaultValues())

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?rev=774294&r1=774293&r2=774294&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Wed May 13 12:43:19 2009
@@ -171,6 +171,8 @@
 import javax.jcr.lock.LockException;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.nodetype.InvalidNodeTypeDefinitionException;
+import javax.jcr.nodetype.NodeTypeExistsException;
 import javax.jcr.query.InvalidQueryException;
 import javax.jcr.version.VersionException;
 import javax.xml.parsers.DocumentBuilder;
@@ -2016,6 +2018,22 @@
     /**
      * {@inheritDoc}
      */
+    public void registerNodeTypes(SessionInfo sessionInfo, QNodeTypeDefinition[] nodeTypeDefinitions,
boolean allowUpdate) throws InvalidNodeTypeDefinitionException, NodeTypeExistsException, UnsupportedRepositoryOperationException,
RepositoryException {
+        // TODO
+        throw new UnsupportedOperationException("JCR-2003. Implementation missing");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void unregisterNodeTypes(SessionInfo sessionInfo, Name[] nodeTypeNames) throws
UnsupportedRepositoryOperationException, NoSuchNodeTypeException, RepositoryException {
+        // TODO
+        throw new UnsupportedOperationException("JCR-2003. Implementation missing");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public void createWorkspace(SessionInfo sessionInfo, String name, String srcWorkspaceName)
throws AccessDeniedException, UnsupportedRepositoryOperationException, NoSuchWorkspaceException,
RepositoryException {
         // TODO
         throw new UnsupportedOperationException("JCR-2003. Implementation missing");

Modified: jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java?rev=774294&r1=774293&r2=774294&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
Wed May 13 12:43:19 2009
@@ -38,7 +38,9 @@
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.Subscription;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.spi.commons.EventFilterImpl;
+import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeDefinitionImpl;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
 import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
@@ -94,6 +96,9 @@
 import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.nodetype.NodeTypeIterator;
 import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.InvalidNodeTypeDefinitionException;
+import javax.jcr.nodetype.NodeTypeExistsException;
+import javax.jcr.nodetype.NodeTypeDefinition;
 import java.util.Map;
 import java.util.Iterator;
 import java.util.HashMap;
@@ -1108,6 +1113,34 @@
     /**
      * {@inheritDoc}
      */
+    public void registerNodeTypes(SessionInfo sessionInfo, QNodeTypeDefinition[] nodeTypeDefinitions,
boolean allowUpdate) throws InvalidNodeTypeDefinitionException, NodeTypeExistsException, UnsupportedRepositoryOperationException,
RepositoryException {
+        SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
+        NodeTypeManager ntMgr = sInfo.getSession().getWorkspace().getNodeTypeManager();
+
+        NodeTypeDefinition[] defs = new NodeTypeDefinition[nodeTypeDefinitions.length];
+        for (int i = 0; i < nodeTypeDefinitions.length; i++) {
+            defs[i] = new NodeTypeDefinitionImpl(nodeTypeDefinitions[i], sInfo.getNamePathResolver(),
sInfo.getSession().getValueFactory()) {
+            };
+        }
+        ntMgr.registerNodeTypes(defs, allowUpdate);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void unregisterNodeTypes(SessionInfo sessionInfo, Name[] nodeTypeNames) throws
UnsupportedRepositoryOperationException, NoSuchNodeTypeException, RepositoryException {
+        SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
+        NodeTypeManager ntMgr = sInfo.getSession().getWorkspace().getNodeTypeManager();
+        String[] names = new String[nodeTypeNames.length];
+        for (int i = 0; i < nodeTypeNames.length; i++) {
+            names[i] = sInfo.getNamePathResolver().getJCRName(nodeTypeNames[i]);
+        }
+        ntMgr.unregisterNodeTypes(names);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public void createWorkspace(SessionInfo sessionInfo, String name, String srcWorkspaceName)
throws AccessDeniedException, UnsupportedRepositoryOperationException, NoSuchWorkspaceException,
RepositoryException {
         SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
         Workspace wsp = sInfo.getSession().getWorkspace();



Mime
View raw message