jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r772929 - in /jackrabbit/trunk: jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/ jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/ jackrab...
Date Fri, 08 May 2009 10:35:31 GMT
Author: angela
Date: Fri May  8 10:35:31 2009
New Revision: 772929

URL: http://svn.apache.org/viewvc?rev=772929&view=rev
Log:
JCR-2105: JSR 283 NodeType Management (work in progress)

Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/PropertyDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QPropertyDefinition.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QPropertyDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QPropertyDefinitionImpl.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeDefinitionImpl.java?rev=772929&r1=772928&r2=772929&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeDefinitionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeDefinitionImpl.java
Fri May  8 10:35:31 2009
@@ -26,6 +26,7 @@
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.nodetype.NodeDefinition;
 import javax.jcr.nodetype.NodeType;
+import javax.jcr.NamespaceException;
 
 /**
  * This class implements the <code>NodeDefinition</code> interface.
@@ -100,12 +101,46 @@
         return ((QNodeDefinition) itemDef).allowsSameNameSiblings();
     }
 
+    /**
+     * @see NodeDefinition#getDefaultPrimaryTypeName()
+     * @since JCR 2.0
+     */
     public String getDefaultPrimaryTypeName() {
-        throw new UnsupportedOperationException("JCR-1591");
+        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;
+        }
     }
 
+    /**
+     * @see NodeDefinition#getRequiredPrimaryTypeNames()
+     * @since JCR 2.0
+     */
     public String[] getRequiredPrimaryTypeNames() {
-        throw new UnsupportedOperationException("JCR-1591");
+        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];
+        }
     }
 }
 

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/PropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/PropertyDefinitionImpl.java?rev=772929&r1=772928&r2=772929&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/PropertyDefinitionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/PropertyDefinitionImpl.java
Fri May  8 10:35:31 2009
@@ -19,14 +19,15 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
+import javax.jcr.NamespaceException;
 import javax.jcr.nodetype.PropertyDefinition;
 
 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.nodetype.InvalidConstraintException;
 import org.apache.jackrabbit.spi.commons.nodetype.ValueConstraint;
-import org.apache.jackrabbit.spi.commons.query.qom.Operator;
 import org.apache.jackrabbit.spi.commons.value.ValueFormat;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -120,17 +121,36 @@
         return ((QPropertyDefinition) itemDef).isMultiple();
     }
 
+    /**
+     * @see javax.jcr.nodetype.PropertyDefinition#getAvailableQueryOperators()
+     */
     public String[] getAvailableQueryOperators() {
-        // TODO: JCR-2091
-        return Operator.getAllQueryOperators();
+        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 true; // TODO: JCR-2091
+        return ((QPropertyDefinition) itemDef).isFullTextSearcheable();
     }
 
+    /**
+     * @see javax.jcr.nodetype.PropertyDefinition#isQueryOrderable()
+     */
     public boolean isQueryOrderable() {
-        return true; // TODO: JCR-2091
+        return ((QPropertyDefinition) itemDef).isQueryOrderable();
     }
 
 }

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java?rev=772929&r1=772928&r2=772929&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java
Fri May  8 10:35:31 2009
@@ -51,6 +51,21 @@
     private final boolean multiple;
 
     /**
+     * The 'multiple' flag
+     */
+    private final Name[] availableQueryOperators;
+
+    /**
+     * The 'fullTextSearcheable' flag
+     */
+    private final boolean fullTextSearcheable;
+
+    /**
+     * The 'queryOrderable' flag
+     */
+    private final boolean queryOrderable;
+
+    /**
      * Copy constructor.
      *
      * @param propDef some other property definition.
@@ -60,7 +75,10 @@
                 propDef.isAutoCreated(), propDef.isMandatory(),
                 propDef.getOnParentVersion(), propDef.isProtected(),
                 propDef.getDefaultValues(), propDef.isMultiple(),
-                propDef.getRequiredType(), propDef.getValueConstraints());
+                propDef.getRequiredType(), propDef.getValueConstraints(),
+                propDef.getAvailableQueryOperators(),
+                propDef.isFullTextSearcheable(),
+                propDef.isQueryOrderable());
     }
 
     /**
@@ -80,12 +98,50 @@
      *                          exist an empty array must be passed.
      * @throws NullPointerException if <code>valueConstraints</code> is
      *                              <code>null</code>.
+     * @deprecated Use {@link #QPropertyDefinitionImpl(Name, Name,
+                                   boolean, boolean, int, boolean, QValue[], boolean,
+                                   int, String[], Name[], boolean, boolean)} instead.
      */
     public QPropertyDefinitionImpl(Name name, Name declaringNodeType,
                                    boolean isAutoCreated, boolean isMandatory,
                                    int onParentVersion, boolean isProtected,
                                    QValue[] defaultValues, boolean isMultiple,
                                    int requiredType, String[] valueConstraints) {
+        this(name, declaringNodeType, isAutoCreated, isMandatory,
+                onParentVersion, isProtected, defaultValues, isMultiple,
+                requiredType, valueConstraints, null, false, false);
+    }
+
+    /**
+     * Creates a new serializable qualified property definition.
+     *
+     * @param name              the name of the child item.
+     * @param declaringNodeType the delaring node type
+     * @param isAutoCreated     if this item is auto created.
+     * @param isMandatory       if this is a mandatory item.
+     * @param onParentVersion   the on parent version behaviour.
+     * @param isProtected       if this item is protected.
+     * @param defaultValues     the default values or <code>null</code> if there
+     *                          are none.
+     * @param isMultiple        if this property is multi-valued.
+     * @param requiredType      the required type for this property.
+     * @param valueConstraints  the value constraints for this property. If none
+     *                          exist an empty array must be passed.
+     * @param availableQueryOperators
+     * @param isFullTextSearcheable
+     * @param isQueryOrderable
+     * @throws NullPointerException if <code>valueConstraints</code> is
+     *                              <code>null</code>.
+     * @since JCR 2.0
+     */
+    public QPropertyDefinitionImpl(Name name, Name declaringNodeType,
+                                   boolean isAutoCreated, boolean isMandatory,
+                                   int onParentVersion, boolean isProtected,
+                                   QValue[] defaultValues, boolean isMultiple,
+                                   int requiredType, String[] valueConstraints,
+                                   Name[] availableQueryOperators,
+                                   boolean isFullTextSearcheable,
+                                   boolean isQueryOrderable) {
         super(name, declaringNodeType, isAutoCreated, isMandatory,
                 onParentVersion, isProtected);
         if (valueConstraints == null) {
@@ -95,6 +151,9 @@
         this.multiple = isMultiple;
         this.requiredType = requiredType;
         this.valueConstraints = valueConstraints;
+        this.availableQueryOperators = availableQueryOperators;
+        this.fullTextSearcheable = isFullTextSearcheable;
+        this.queryOrderable = isQueryOrderable;
     }
 
     //------------------------------------------------< QPropertyDefinition >---
@@ -128,6 +187,27 @@
 
     /**
      * {@inheritDoc}
+     */
+    public Name[] getAvailableQueryOperators() {
+        return availableQueryOperators;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isFullTextSearcheable() {
+        return fullTextSearcheable;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isQueryOrderable() {
+        return queryOrderable;
+    }
+
+    /**
+     * {@inheritDoc}
      *
      * @return always <code>false</code>
      */

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=772929&r1=772928&r2=772929&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
Fri May  8 10:35:31 2009
@@ -61,4 +61,28 @@
      * @return the 'multiple' flag.
      */
     public boolean isMultiple();
+
+    /**
+     * Returns the availabe query operators.
+     *
+     * @return the availabe query operators.
+     * @since JCR 2.0
+     */
+    public Name[] getAvailableQueryOperators();
+
+    /**
+     * Reports whether this property definition is full text searchable.
+     *
+     * @return <code>true</code> if this property definition is full text searchable.
+     * @since JCR 2.0
+     */
+    public boolean isFullTextSearcheable();
+
+    /**
+     * Reports whether this property definition is query-orderable.
+     *
+     * @return <code>true</code> if this property definition is query-orderable.
+     * @since JCR 2.0
+     */
+    public boolean isQueryOrderable();
 }

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=772929&r1=772928&r2=772929&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
Fri May  8 10:35:31 2009
@@ -158,6 +158,30 @@
 
     /**
      * {@inheritDoc}
+     */
+    public Name[] getAvailableQueryOperators() {
+        // TODO
+        throw new UnsupportedOperationException("JCR-2003 Add support for JCR 2.0. Implementation
missing");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isFullTextSearcheable() {
+        // TODO
+        throw new UnsupportedOperationException("JCR-2003 Add support for JCR 2.0. Implementation
missing");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isQueryOrderable() {
+        // TODO
+        throw new UnsupportedOperationException("JCR-2003 Add support for JCR 2.0. Implementation
missing");
+    }
+
+    /**
+     * {@inheritDoc}
      *
      * @return always <code>false</code>
      */

Modified: jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QPropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QPropertyDefinitionImpl.java?rev=772929&r1=772928&r2=772929&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QPropertyDefinitionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QPropertyDefinitionImpl.java
Fri May  8 10:35:31 2009
@@ -18,14 +18,17 @@
 
 import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.conversion.NameException;
+import org.apache.jackrabbit.spi.commons.conversion.IllegalNameException;
 import org.apache.jackrabbit.spi.commons.value.ValueFormat;
 
 import javax.jcr.nodetype.PropertyDefinition;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.PropertyType;
+import javax.jcr.NamespaceException;
 
 /**
  * <code>QPropertyDefinitionImpl</code> implements a qualified property
@@ -54,7 +57,9 @@
                 propDef.getOnParentVersion(), propDef.isProtected(),
                 convertValues(propDef.getDefaultValues(), resolver, qValueFactory),
                 propDef.isMultiple(), propDef.getRequiredType(),
-                convertConstraints(propDef.getValueConstraints(), resolver, qValueFactory,
propDef.getRequiredType()));
+                convertConstraints(propDef.getValueConstraints(), resolver, qValueFactory,
propDef.getRequiredType()),
+                convertQueryOperators(propDef.getAvailableQueryOperators(), resolver),
+                propDef.isFullTextSearchable(), propDef.isQueryOrderable());
     }
 
     /**
@@ -110,4 +115,21 @@
         }
         return constraints;
     }
+
+    /**
+     * Convert String jcr names to Name objects.
+     *
+     * @param aqos
+     * @param resolver
+     * @return
+     * @throws NamespaceException
+     * @throws IllegalNameException
+     */
+    private static Name[] convertQueryOperators(String[] aqos, NamePathResolver resolver)
throws NamespaceException, IllegalNameException {
+        Name[] names = new Name[aqos.length];
+        for (int i = 0; i < aqos.length; i++) {
+            names[i] = resolver.getQName(aqos[i]);
+        }
+        return names;
+    }
 }



Mime
View raw message