jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r512795 [2/4] - in /jackrabbit/trunk/contrib/spi/spi-rmi: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/jackrabbit/ src/main/java/org/apache/jackrabbit/spi/ src/main/java/org/apache/j...
Date Wed, 28 Feb 2007 15:09:29 GMT
Added: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/PropertyInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/PropertyInfoImpl.java?view=auto&rev=512795
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/PropertyInfoImpl.java (added)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/PropertyInfoImpl.java Wed Feb 28 07:09:27 2007
@@ -0,0 +1,103 @@
+/*
+ * 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.rmi.common;
+
+import org.apache.jackrabbit.spi.PropertyInfo;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.Path;
+
+/**
+ * <code>PropertyInfoImpl</code> implements a serializable
+ * <code>PropertyInfo</code> based on another property info.
+ */
+public class PropertyInfoImpl extends ItemInfoImpl implements PropertyInfo {
+
+    /**
+     * The property info of the underlying property.
+     */
+    private final PropertyId propertyId;
+
+    /**
+     * The type of the property.
+     */
+    private final int type;
+
+    /**
+     * The multiValued flag.
+     */
+    private final boolean isMultiValued;
+
+    /**
+     * The values of this property info.
+     */
+    private final QValue[] values;
+
+    /**
+     * Creates a new serializable property info for the given
+     * <code>property</code>.
+     *
+     * @param parentId      the parent id.
+     * @param name          the name of this property.
+     * @param path          the path to this property.
+     * @param id            the id of this property.
+     * @param type          the type of this property.
+     * @param isMultiValued whether this property is multi-valued.
+     * @param values        the values.
+     */
+    public PropertyInfoImpl(NodeId parentId, QName name, Path path,
+                            PropertyId id, int type, boolean isMultiValued,
+                            QValue[] values) {
+        super(parentId, name, path, false);
+        this.propertyId = id;
+        this.type = type;
+        this.isMultiValued = isMultiValued;
+        this.values = values;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public PropertyId getId() {
+        return propertyId;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getType() {
+        return type;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isMultiValued() {
+        return isMultiValued;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QValue[] getValues() {
+        QValue[] vals = new QValue[values.length];
+        System.arraycopy(values, 0, vals, 0, values.length);
+        return vals;
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/PropertyInfoImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QItemDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QItemDefinitionImpl.java?view=auto&rev=512795
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QItemDefinitionImpl.java (added)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QItemDefinitionImpl.java Wed Feb 28 07:09:27 2007
@@ -0,0 +1,172 @@
+/*
+ * 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.rmi.common;
+
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.QItemDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+
+import java.io.Serializable;
+
+/**
+ * This abstract class implements the <code>QItemDefinition</code>
+ * interface and additionally provides setter methods for the
+ * various item definition attributes.
+ * TODO: mostly copied from spi2dav, move common parts to spi-commons.
+ */
+public abstract class QItemDefinitionImpl implements QItemDefinition, Serializable {
+
+    /**
+     * The special wildcard name used as the name of residual item definitions.
+     */
+    public static final QName ANY_NAME = new QName("", "*");
+
+    /**
+     * The name of the child item.
+     */
+    private final QName name;
+
+    /**
+     * The name of the declaring node type.
+     */
+    private final QName declaringNodeType;
+
+    /**
+     * The 'autoCreated' flag.
+     */
+    private final boolean autoCreated;
+
+    /**
+     * The 'onParentVersion' attribute.
+     */
+    private final int onParentVersion;
+
+    /**
+     * The 'protected' flag.
+     */
+    private final boolean writeProtected;
+
+    /**
+     * The 'mandatory' flag.
+     */
+    private final boolean mandatory;
+
+    /**
+     * HashCode of this object
+     */
+    protected transient int hashCode = 0;
+
+    /**
+     *
+     * @param itemDef
+     */
+    QItemDefinitionImpl(QItemDefinition itemDef) {
+        this.autoCreated = itemDef.isAutoCreated();
+        this.declaringNodeType = itemDef.getDeclaringNodeType();
+        this.mandatory = itemDef.isMandatory();
+        this.name = itemDef.getQName();
+        this.onParentVersion = itemDef.getOnParentVersion();
+        this.writeProtected = itemDef.isProtected();
+    }
+
+    //--------------------------------------------------------------< QItemDefinition >
+    /**
+     * {@inheritDoc}
+     */
+    public QName getDeclaringNodeType() {
+        return declaringNodeType;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QName getQName() {
+        return name;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isAutoCreated() {
+        return autoCreated;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getOnParentVersion() {
+        return onParentVersion;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isProtected() {
+        return writeProtected;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isMandatory() {
+        return mandatory;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean definesResidual() {
+        return name.equals(ANY_NAME);
+    }
+
+    //-------------------------------------------< java.lang.Object overrides >
+    /**
+     * Compares two item definitions for equality. Returns <code>true</code>
+     * if the given object is an item defintion and has the same attributes
+     * as this item definition.
+     *
+     * @param obj the object to compare this item definition with
+     * @return <code>true</code> if the object is equal to this item definition,
+     *         <code>false</code> otherwise
+     * @see Object#equals(Object)
+     */
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof QItemDefinition) {
+            QItemDefinition other = (QItemDefinition) obj;
+            return (declaringNodeType == null
+                    ? other.getDeclaringNodeType() == null
+                    : declaringNodeType.equals(other.getDeclaringNodeType()))
+                    && (name == null ? other.getQName() == null : name.equals(other.getQName()))
+                    && autoCreated == other.isAutoCreated()
+                    && onParentVersion == other.getOnParentVersion()
+                    && writeProtected == other.isProtected()
+                    && mandatory == other.isMandatory();
+        }
+        return false;
+    }
+
+    /**
+     * See {@link QNodeDefinition#hashCode()} and {@link QPropertyDefinition#hashCode()}.
+     *
+     * @return
+     */
+    public abstract int hashCode();
+}

Propchange: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QItemDefinitionImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QNodeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QNodeDefinitionImpl.java?view=auto&rev=512795
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QNodeDefinitionImpl.java (added)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QNodeDefinitionImpl.java Wed Feb 28 07:09:27 2007
@@ -0,0 +1,149 @@
+/*
+ * 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.rmi.common;
+
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.name.QName;
+
+import java.util.Arrays;
+import java.util.TreeSet;
+
+/**
+ * <code>QNodeDefinitionImpl</code> implements a <code>QNodeDefinition</code>.
+ * TODO: mostly copied from spi2dav, move common parts to spi-commons.
+ */
+public class QNodeDefinitionImpl extends QItemDefinitionImpl implements QNodeDefinition {
+
+    /**
+     * The name of the default primary type.
+     */
+    private final QName defaultPrimaryType;
+
+    /**
+     * The names of the required primary types.
+     */
+    private final QName[] requiredPrimaryTypes;
+
+    /**
+     * The 'allowsSameNameSiblings' flag.
+     */
+    private final boolean allowsSameNameSiblings;
+
+    /**
+     * Creates a new serializable qualified node definition based on another
+     * qualified node definition.
+     *
+     * @param qNodeDefinition the qualified node definition.
+     */
+    public QNodeDefinitionImpl(QNodeDefinition qNodeDefinition) {
+        super(qNodeDefinition);
+        this.allowsSameNameSiblings = qNodeDefinition.allowsSameNameSiblings();
+        this.defaultPrimaryType = qNodeDefinition.getDefaultPrimaryType();
+        this.requiredPrimaryTypes = qNodeDefinition.getRequiredPrimaryTypes();
+    }
+
+    //-------------------------------------------------------< QNodeDefinition >
+    /**
+     * {@inheritDoc}
+     */
+    public QName getDefaultPrimaryType() {
+        return defaultPrimaryType;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QName[] getRequiredPrimaryTypes() {
+        return requiredPrimaryTypes;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean allowsSameNameSiblings() {
+        return allowsSameNameSiblings;
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @return always <code>true</code>
+     */
+    public boolean definesNode() {
+        return true;
+    }
+
+    //-------------------------------------------< java.lang.Object overrides >
+    /**
+     * Compares two node definitions for equality. Returns <code>true</code>
+     * if the given object is a node defintion and has the same attributes
+     * as this node definition.
+     *
+     * @param obj the object to compare this node definition with
+     * @return <code>true</code> if the object is equal to this node definition,
+     *         <code>false</code> otherwise
+     * @see Object#equals(Object)
+     */
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof QNodeDefinition) {
+            QNodeDefinition other = (QNodeDefinition) obj;
+            return super.equals(obj)
+                    && Arrays.equals(requiredPrimaryTypes, other.getRequiredPrimaryTypes())
+                    && (defaultPrimaryType == null
+                            ? other.getDefaultPrimaryType() == null
+                            : defaultPrimaryType.equals(other.getDefaultPrimaryType()))
+                    && allowsSameNameSiblings == other.allowsSameNameSiblings();
+        }
+        return false;
+    }
+
+    /**
+     * Overwrites {@link QItemDefinitionImpl#hashCode()}.
+     *
+     * @return
+     */
+    public int hashCode() {
+        if (hashCode == 0) {
+            // build hashCode (format: <declaringNodeType>/<name>/<requiredPrimaryTypes>)
+            StringBuffer sb = new StringBuffer();
+
+            if (getDeclaringNodeType() != null) {
+                sb.append(getDeclaringNodeType().toString());
+                sb.append('/');
+            }
+            if (definesResidual()) {
+                sb.append('*');
+            } else {
+                sb.append(getQName().toString());
+            }
+            sb.append('/');
+            // set of required node type names, sorted in ascending order
+            TreeSet set = new TreeSet();
+            QName[] names = getRequiredPrimaryTypes();
+            for (int i = 0; i < names.length; i++) {
+                set.add(names[i]);
+            }
+            sb.append(set.toString());
+
+            hashCode = sb.toString().hashCode();
+        }
+        return hashCode;
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QNodeDefinitionImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QNodeTypeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QNodeTypeDefinitionImpl.java?view=auto&rev=512795
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QNodeTypeDefinitionImpl.java (added)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QNodeTypeDefinitionImpl.java Wed Feb 28 07:09:27 2007
@@ -0,0 +1,258 @@
+/*
+ * 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.rmi.common;
+
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.name.QName;
+
+import javax.jcr.PropertyType;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Collections;
+import java.io.Serializable;
+
+/**
+ * <code>QNodeTypeDefinitionImpl</code> implements a serializable qualified node
+ * type definition.
+ */
+public class QNodeTypeDefinitionImpl implements QNodeTypeDefinition, Serializable {
+
+    /**
+     * The name of the node definition.
+     */
+    private final QName name;
+
+    /**
+     * The names of the declared super types of this node type definition.
+     */
+    private final QName[] supertypes;
+
+    /**
+     * Indicates whether this is a mixin node type definition.
+     */
+    private final boolean isMixin;
+
+    /**
+     * Indicates whether this node type definition has orderable child nodes.
+     */
+    private final boolean hasOrderableChildNodes;
+
+    /**
+     * The name of the primary item or <code>null</code> if none is defined.
+     */
+    private final QName primaryItemName;
+
+    /**
+     * The list of property definitions.
+     */
+    private final QPropertyDefinition[] propertyDefs;
+
+    /**
+     * The list of child node definitions.
+     */
+    private final QNodeDefinition[] childNodeDefs;
+
+    /**
+     * Unmodifiable collection of dependent node type <code>QName</code>s.
+     * @see #getDependencies()
+     */
+    private transient Collection dependencies;
+
+    /**
+     * Copy constructor.
+     *
+     * @param nt the qualified node type definition.
+     */
+    public QNodeTypeDefinitionImpl(QNodeTypeDefinition nt) {
+        this(nt.getQName(), nt.getSupertypes(), nt.isMixin(),
+                nt.hasOrderableChildNodes(), nt.getPrimaryItemName(),
+                nt.getPropertyDefs(), nt.getChildNodeDefs());
+    }
+
+    /**
+     * Creates a new serializable qualified node type definition.
+     *
+     * @param name                   the name of the node type
+     * @param supertypes             the names of the supertypes
+     * @param isMixin                if this is a mixin node type
+     * @param hasOrderableChildNodes if this node type has orderable child
+     *                               nodes.
+     * @param primaryItemName        the name of the primary item, or
+     *                               <code>null</code>.
+     * @param declaredPropDefs       the declared property definitions.
+     * @param declaredNodeDefs       the declared child node definitions.
+     */
+    public QNodeTypeDefinitionImpl(QName name,
+                                   QName[] supertypes,
+                                   boolean isMixin,
+                                   boolean hasOrderableChildNodes,
+                                   QName primaryItemName,
+                                   QPropertyDefinition[] declaredPropDefs,
+                                   QNodeDefinition[] declaredNodeDefs) {
+        this.name = name;
+        this.supertypes = supertypes;
+        this.isMixin = isMixin;
+        this.hasOrderableChildNodes = hasOrderableChildNodes;
+        this.primaryItemName = primaryItemName;
+        this.propertyDefs = getSerializablePropertyDefs(declaredPropDefs);
+        this.childNodeDefs = getSerializableNodeDefs(declaredNodeDefs);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QName getQName() {
+        return name;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QName[] getSupertypes() {
+        QName[] sTypes = new QName[supertypes.length];
+        System.arraycopy(supertypes, 0, sTypes, 0, supertypes.length);
+        return sTypes;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isMixin() {
+        return isMixin;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean hasOrderableChildNodes() {
+        return hasOrderableChildNodes;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QName getPrimaryItemName() {
+        return primaryItemName;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QPropertyDefinition[] getPropertyDefs() {
+        QPropertyDefinition[] pDefs = new QPropertyDefinition[propertyDefs.length];
+        System.arraycopy(propertyDefs, 0, pDefs, 0, propertyDefs.length);
+        return pDefs;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QNodeDefinition[] getChildNodeDefs() {
+        QNodeDefinition[] cnDefs = new QNodeDefinition[childNodeDefs.length];
+        System.arraycopy(childNodeDefs, 0, cnDefs, 0, childNodeDefs.length);
+        return cnDefs;
+    }
+
+    /**
+     * TODO: generalize (this method is copied from spi2dav)
+     */
+    public Collection getDependencies() {
+        if (dependencies == null) {
+            Collection deps = new HashSet();
+            // supertypes
+            for (int i = 0; i < supertypes.length; i++) {
+                deps.add(supertypes[i]);
+            }
+            // child node definitions
+            for (int i = 0; i < childNodeDefs.length; i++) {
+                // default primary type
+                QName ntName = childNodeDefs[i].getDefaultPrimaryType();
+                if (ntName != null && !name.equals(ntName)) {
+                    deps.add(ntName);
+                }
+                // required primary type
+                QName[] ntNames = childNodeDefs[i].getRequiredPrimaryTypes();
+                for (int j = 0; j < ntNames.length; j++) {
+                    if (ntNames[j] != null && !name.equals(ntNames[j])) {
+                        deps.add(ntNames[j]);
+                    }
+                }
+            }
+            // property definitions
+            for (int i = 0; i < propertyDefs.length; i++) {
+                // REFERENCE value constraints
+                if (propertyDefs[i].getRequiredType() == PropertyType.REFERENCE) {
+                    String[] ca = propertyDefs[i].getValueConstraints();
+                    if (ca != null) {
+                        for (int j = 0; j < ca.length; j++) {
+                            QName ntName = QName.valueOf(ca[j]);
+                            if (!name.equals(ntName)) {
+                                deps.add(ntName);
+                            }
+                        }
+                    }
+                }
+            }
+            dependencies = Collections.unmodifiableCollection(deps);
+        }
+        return dependencies;
+    }
+
+    //-------------------------------< internal >-------------------------------
+
+    /**
+     * Returns an array of serializable property definitions for
+     * <code>propDefs</code>.
+     *
+     * @param propDefs the qualified property definitions.
+     * @return an array of serializable property definitions.
+     */
+    private static QPropertyDefinition[] getSerializablePropertyDefs(
+            QPropertyDefinition[] propDefs) {
+        QPropertyDefinition[] serDefs = new QPropertyDefinition[propDefs.length];
+        for (int i = 0; i < propDefs.length; i++) {
+            if (propDefs[i] instanceof Serializable) {
+                serDefs[i] = propDefs[i];
+            } else {
+                serDefs[i] = new QPropertyDefinitionImpl(propDefs[i]);
+            }
+        }
+        return serDefs;
+    }
+
+    /**
+     * Returns an array of serializable node definitions for
+     * <code>nodeDefs</code>.
+     *
+     * @param nodeDefs the qualified node definitions.
+     * @return an array of serializable node definitions.
+     */
+    private static QNodeDefinition[] getSerializableNodeDefs(
+            QNodeDefinition[] nodeDefs) {
+        QNodeDefinition[] serDefs = new QNodeDefinition[nodeDefs.length];
+        for (int i = 0; i < nodeDefs.length; i++) {
+            if (nodeDefs[i] instanceof Serializable) {
+                serDefs[i] = nodeDefs[i];
+            } else {
+                serDefs[i] = new QNodeDefinitionImpl(nodeDefs[i]);
+            }
+        }
+        return serDefs;
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QNodeTypeDefinitionImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QPropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QPropertyDefinitionImpl.java?view=auto&rev=512795
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QPropertyDefinitionImpl.java (added)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QPropertyDefinitionImpl.java Wed Feb 28 07:09:27 2007
@@ -0,0 +1,155 @@
+/*
+ * 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.rmi.common;
+
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QValue;
+
+import java.util.Arrays;
+
+/**
+ * <code>QPropertyDefinitionImpl</code> implements a qualified property
+ * definition based on a JCR {@link javax.jcr.nodetype.PropertyDefinition}.
+ * TODO: mostly copied from spi2dav, move common parts to spi-commons.
+ */
+public class QPropertyDefinitionImpl extends QItemDefinitionImpl implements QPropertyDefinition {
+
+    /**
+     * The required type.
+     */
+    private final int requiredType;
+
+    /**
+     * The value constraints.
+     */
+    private final String[] valueConstraints;
+
+    /**
+     * The default values.
+     */
+    private final QValue[] defaultValues;
+
+    /**
+     * The 'multiple' flag
+     */
+    private final boolean multiple;
+
+    /**
+     * Creates a new serializable qualified property definition based on
+     * <code>propDef</code>.
+     *
+     * @param propDef the qualified property definition.
+     */
+    public QPropertyDefinitionImpl(QPropertyDefinition propDef) {
+        super(propDef);
+        this.defaultValues = propDef.getDefaultValues();
+        this.multiple = propDef.isMultiple();
+        this.requiredType = propDef.getRequiredType();
+        this.valueConstraints = propDef.getValueConstraints();
+    }
+
+    //------------------------------------------------< QPropertyDefinition >---
+    /**
+     * {@inheritDoc}
+     */
+    public int getRequiredType() {
+        return requiredType;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String[] getValueConstraints() {
+        return valueConstraints;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QValue[] getDefaultValues() {
+        return defaultValues;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isMultiple() {
+        return multiple;
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @return always <code>false</code>
+     */
+    public boolean definesNode() {
+        return false;
+    }
+
+    //-------------------------------------------< java.lang.Object overrides >
+    /**
+     * Compares two property definitions for equality. Returns <code>true</code>
+     * if the given object is a property defintion and has the same attributes
+     * as this property definition.
+     *
+     * @param obj the object to compare this property definition with
+     * @return <code>true</code> if the object is equal to this property definition,
+     *         <code>false</code> otherwise
+     * @see Object#equals(Object)
+     */
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof QPropertyDefinition) {
+            QPropertyDefinition other = (QPropertyDefinition) obj;
+            return super.equals(obj)
+                    && requiredType == other.getRequiredType()
+                    && Arrays.equals(valueConstraints, other.getValueConstraints())
+                    && Arrays.equals(defaultValues, other.getDefaultValues())
+                    && multiple == other.isMultiple();
+        }
+        return false;
+    }
+
+    /**
+     * Overwrites {@link QItemDefinitionImpl#hashCode()}.
+     *
+     * @return
+     */
+    public int hashCode() {
+        if (hashCode == 0) {
+            // build hashCode (format: <declaringNodeType>/<name>/<requiredType>/<multiple>)
+            StringBuffer sb = new StringBuffer();
+
+            sb.append(getDeclaringNodeType().toString());
+            sb.append('/');
+            if (definesResidual()) {
+                sb.append('*');
+            } else {
+                sb.append(getQName().toString());
+            }
+            sb.append('/');
+            sb.append(getRequiredType());
+            sb.append('/');
+            sb.append(isMultiple() ? 1 : 0);
+
+            hashCode = sb.toString().hashCode();
+        }
+        return hashCode;
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QPropertyDefinitionImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QueryResultRowImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QueryResultRowImpl.java?view=auto&rev=512795
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QueryResultRowImpl.java (added)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QueryResultRowImpl.java Wed Feb 28 07:09:27 2007
@@ -0,0 +1,83 @@
+/*
+ * 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.rmi.common;
+
+import org.apache.jackrabbit.spi.QueryResultRow;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.QValue;
+
+import java.io.Serializable;
+
+/**
+ * <code>QueryResultRowImpl</code> implements a serializable
+ * <code>QueryResultRow</code>. This implementation requires that the passed
+ * {@link org.apache.jackrabbit.spi.QValue}s passed in the constructor are
+ * serializable!
+ */
+public class QueryResultRowImpl implements QueryResultRow, Serializable {
+
+    /**
+     * The node id of the underlying row.
+     */
+    private final NodeId nodeId;
+
+    /**
+     * The score value for this row.
+     */
+    private final double score;
+
+    /**
+     * The QValues for this row.
+     */
+    private final QValue[] values;
+
+    /**
+     * Creates a new query result row for the given <code>row</code>.
+     *
+     * @param nodeId the id of the node this row represents.
+     * @param score  the score value for this row
+     * @param values the values for this row
+     */
+    public QueryResultRowImpl(NodeId nodeId, double score, QValue[] values) {
+        this.nodeId = nodeId;
+        this.score = score;
+        this.values = values;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public NodeId getNodeId() {
+        return nodeId;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public double getScore() {
+        return score;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QValue[] getValues() {
+        QValue[] vals = new QValue[values.length];
+        System.arraycopy(values, 0, vals, 0, values.length);
+        return vals;
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QueryResultRowImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/SerializableIdFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/SerializableIdFactory.java?view=auto&rev=512795
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/SerializableIdFactory.java (added)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/SerializableIdFactory.java Wed Feb 28 07:09:27 2007
@@ -0,0 +1,233 @@
+/*
+ * 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.rmi.common;
+
+import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.ItemId;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.MalformedPathException;
+
+import java.io.Serializable;
+
+/**
+ * <code>SerializableIdFactory</code> implements an id factory with serializable
+ * item ids.
+ * TODO: copied from spi2dav, move common part to spi-commons.
+ */
+public class SerializableIdFactory implements IdFactory {
+
+    private static final SerializableIdFactory INSTANCE = new SerializableIdFactory();
+
+    private SerializableIdFactory() {};
+
+    public static SerializableIdFactory getInstance() {
+        return INSTANCE;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public PropertyId createPropertyId(NodeId parentId, QName propertyName) {
+        try {
+            return new PropertyIdImpl(parentId, propertyName);
+        } catch (MalformedPathException e) {
+            throw new IllegalArgumentException(e.getMessage());
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public NodeId createNodeId(NodeId parentId, Path path) {
+        try {
+            return new NodeIdImpl(parentId, path);
+        } catch (MalformedPathException e) {
+            throw new IllegalArgumentException(e.getMessage());
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public NodeId createNodeId(String uniqueID, Path path) {
+        return new NodeIdImpl(uniqueID, path);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public NodeId createNodeId(String uniqueID) {
+        return new NodeIdImpl(uniqueID);
+    }
+
+    //------------------------------------------------------< Inner classes >---
+    private static abstract class ItemIdImpl implements ItemId, Serializable {
+
+        private final String uniqueID;
+        private final Path path;
+
+        private transient int hashCode = 0;
+
+        private ItemIdImpl(String uniqueID, Path path) {
+            if (uniqueID == null && path == null) {
+                throw new IllegalArgumentException("Only uniqueID or relative path might be null.");
+            }
+            this.uniqueID = uniqueID;
+            this.path = path;
+        }
+
+        private ItemIdImpl(NodeId parentId, QName name) throws MalformedPathException {
+            if (parentId == null || name == null) {
+                throw new IllegalArgumentException("Invalid ItemIdImpl: parentId and name must not be null.");
+            }
+            this.uniqueID = parentId.getUniqueID();
+            Path parentPath = parentId.getPath();
+            if (parentPath != null) {
+                this.path = Path.create(parentPath, name, true);
+            } else {
+                this.path = Path.create(name, Path.INDEX_UNDEFINED);
+            }
+        }
+
+        public abstract boolean denotesNode();
+
+        public String getUniqueID() {
+            return uniqueID;
+        }
+
+        public Path getPath() {
+            return path;
+        }
+
+        /**
+         * ItemIdImpl objects are equal if the have the same uuid and relative path.
+         *
+         * @param obj
+         * @return
+         */
+        public boolean equals(Object obj) {
+            if (obj == this) {
+                return true;
+            }
+            if (obj instanceof ItemId) {
+                ItemId other = (ItemId) obj;
+                return equals(other);
+            }
+            return false;
+        }
+
+        boolean equals(ItemId other) {
+            return (uniqueID == null ? other.getUniqueID() == null : uniqueID.equals(other.getUniqueID()))
+                && (path == null ? other.getPath() == null : path.equals(other.getPath()));
+        }
+
+        /**
+         * Returns the hash code of the uuid and the path. The computed hash code
+         * is memorized for better performance.
+         *
+         * @return hash code
+         * @see Object#hashCode()
+         */
+        public int hashCode() {
+            // since the ItemIdImpl is immutable, store the computed hash code value
+            if (hashCode == 0) {
+                hashCode = toString().hashCode();
+            }
+            return hashCode;
+        }
+
+        /**
+         * Combination of uuid and relative path
+         *
+         * @return
+         */
+        public String toString() {
+            StringBuffer b = new StringBuffer();
+            if (uniqueID != null) {
+                b.append(uniqueID);
+            }
+            if (path != null) {
+                b.append(path.toString());
+            }
+            return b.toString();
+        }
+    }
+
+    private static class NodeIdImpl extends ItemIdImpl implements NodeId {
+
+        public NodeIdImpl(String uniqueID) {
+            super(uniqueID, null);
+        }
+
+        public NodeIdImpl(String uniqueID, Path path) {
+            super(uniqueID, path);
+        }
+
+        public NodeIdImpl(NodeId parentId, Path path) throws MalformedPathException {
+            super(parentId.getUniqueID(), (parentId.getPath() != null) ? Path.create(parentId.getPath(), path, true) : path);
+        }
+
+        public boolean denotesNode() {
+            return true;
+        }
+
+        public boolean equals(Object obj) {
+            if (obj == this) {
+                return true;
+            }
+            if (obj instanceof NodeId) {
+                return super.equals((NodeId)obj);
+            }
+            return false;
+        }
+    }
+
+    private static class PropertyIdImpl extends ItemIdImpl implements PropertyId {
+
+        private final NodeId parentId;
+
+        private PropertyIdImpl(NodeId parentId, QName name) throws MalformedPathException {
+            super(parentId, name);
+            this.parentId = parentId;
+        }
+
+        public boolean denotesNode() {
+            return false;
+        }
+
+        public NodeId getParentId() {
+            return parentId;
+        }
+
+        public QName getQName() {
+            return getPath().getNameElement().getName();
+        }
+
+        public boolean equals(Object obj) {
+            if (obj == this) {
+                return true;
+            }
+            if (obj instanceof PropertyId) {
+                return super.equals((PropertyId)obj);
+            }
+            return false;
+        }
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/SerializableIdFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/SerializableInputStream.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/SerializableInputStream.java?view=auto&rev=512795
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/SerializableInputStream.java (added)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/SerializableInputStream.java Wed Feb 28 07:09:27 2007
@@ -0,0 +1,187 @@
+/*
+ * 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.rmi.common;
+
+import java.io.InputStream;
+import java.io.Serializable;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.File;
+import java.io.OutputStream;
+import java.io.FileOutputStream;
+import java.io.FileInputStream;
+
+/**
+ * <code>SerializableInputStream</code> implements an input stream that can
+ * be serialized.
+ */
+public class SerializableInputStream extends InputStream implements Serializable {
+
+    private InputStream stream;
+
+    /**
+     * Creates a new serializable stream. A client must not use any of the
+     * available methods on this input stream if he wishes to serialize this
+     * stream, otherwise the passed stream is only serialized partially!
+     *
+     * @param stream the stream to serialize.
+     */
+    public SerializableInputStream(InputStream stream) {
+        this.stream = stream;
+    }
+
+    //--------------------------< InputStream >---------------------------------
+
+    /**
+     * Forwards the call to the underlying stream.
+     */
+    public int read() throws IOException {
+        return stream.read();
+    }
+
+    /**
+     * Forwards the call to the underlying stream.
+     */
+    public int available() throws IOException {
+        return stream.available();
+    }
+
+    /**
+     * Forwards the call to the underlying stream.
+     */
+    public void close() throws IOException {
+        stream.close();
+    }
+
+    /**
+     * Forwards the call to the underlying stream.
+     */
+    public void reset() throws IOException {
+        stream.reset();
+    }
+
+    /**
+     * Forwards the call to the underlying stream.
+     */
+    public boolean markSupported() {
+        return stream.markSupported();
+    }
+
+    /**
+     * Forwards the call to the underlying stream.
+     */
+    public void mark(int readlimit) {
+        stream.mark(readlimit);
+    }
+
+    /**
+     * Forwards the call to the underlying stream.
+     */
+    public long skip(long n) throws IOException {
+        return stream.skip(n);
+    }
+
+    /**
+     * Forwards the call to the underlying stream.
+     */
+    public int read(byte b[]) throws IOException {
+        return stream.read(b);
+    }
+
+    /**
+     * Forwards the call to the underlying stream.
+     */
+    public int read(byte b[], int off, int len) throws IOException {
+        return stream.read(b, off, len);
+    }
+
+    //---------------------------< Serializable >-------------------------------
+
+    /**
+     * Writes the contents of the underlying stream to the
+     * <code>ObjectOutputStream</code>.
+     *
+     * @param out The <code>ObjectOutputStream</code> to where the binary data
+     *            is copied.
+     * @throws IOException If an error occurs writing the binary data.
+     */
+    private void writeObject(ObjectOutputStream out)
+            throws IOException {
+        byte[] buffer = new byte[4096];
+        int bytes;
+        while ((bytes = stream.read(buffer)) >= 0) {
+            // Write a segment of the input stream
+            if (bytes > 0) {
+                // just to ensure that no 0 is written
+                out.writeInt(bytes);
+                out.write(buffer, 0, bytes);
+            }
+        }
+        // Write the end of stream marker
+        out.writeInt(0);
+        // close stream
+        stream.close();
+    }
+
+    /**
+     * Reads the binary data from the <code>ObjectInputStream</code> into a
+     * temporary file that is used to back up the binary stream contents of the
+     * constructed value instance. The temporary file gets deleted when the
+     * binary stream is closed or garbage collected.
+     *
+     * @param in The <code>ObjectInputStream</code> from where to get the binary
+     *           data.
+     * @throws IOException If an error occurs reading the binary data.
+     */
+    private void readObject(ObjectInputStream in)
+            throws IOException {
+        final File file = File.createTempFile("serializable-stream", "bin");
+
+        OutputStream out = new FileOutputStream(file);
+        byte[] buffer = new byte[4096];
+        for (int bytes = in.readInt(); bytes > 0; bytes = in.readInt()) {
+            if (buffer.length < bytes) {
+                buffer = new byte[bytes];
+            }
+            in.readFully(buffer, 0, bytes);
+            out.write(buffer, 0, bytes);
+        }
+        out.close();
+
+        stream = new FileInputStream(file) {
+
+            private boolean closed = false;
+
+            public void close() throws IOException {
+                super.close();
+                closed = true;
+                file.delete();
+            }
+
+            protected void finalize() throws IOException {
+                try {
+                    if (!closed) {
+                        file.delete();
+                    }
+                } finally {
+                    super.finalize();
+                }
+            }
+        };
+    }
+}

Propchange: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/SerializableInputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/ValueFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/ValueFactoryImpl.java?view=auto&rev=512795
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/ValueFactoryImpl.java (added)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/ValueFactoryImpl.java Wed Feb 28 07:09:27 2007
@@ -0,0 +1,135 @@
+/*
+ * 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.rmi.common;
+
+import javax.jcr.Value;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.ValueFormatException;
+import javax.jcr.PropertyType;
+import javax.jcr.ValueFactory;
+import java.util.Calendar;
+import java.io.InputStream;
+
+/**
+ * <code>ValueFactoryImpl</code>...
+ * TODO: copied from spi2dav, move this class to spi-commons?
+ */
+public class ValueFactoryImpl implements ValueFactory {
+
+    private static final ValueFactory factory = new ValueFactoryImpl();
+
+    /**
+     * Delegatee for all calls except for REFERENCE values.
+     */
+    private final ValueFactory commonsFactory = org.apache.jackrabbit.value.ValueFactoryImpl.getInstance();
+
+    /**
+     * Constructs a <code>ValueFactory</code> object.
+     */
+    private ValueFactoryImpl() {
+    }
+
+    public static ValueFactory getInstance() {
+        return factory;
+    }
+
+    public Value createValue(Node value) throws RepositoryException {
+        return new ReferenceValue(value);
+    }
+
+    public Value createValue(String string) {
+        return commonsFactory.createValue(string);
+    }
+
+    public Value createValue(String value, int type) throws ValueFormatException {
+        Value val;
+        switch (type) {
+            case PropertyType.REFERENCE:
+                val = ReferenceValue.valueOf(value);
+                break;
+            default:
+                val = commonsFactory.createValue(value, type);
+        }
+        return val;
+    }
+
+    public Value createValue(long l) {
+        return commonsFactory.createValue(l);
+    }
+
+    public Value createValue(double v) {
+        return commonsFactory.createValue(v);
+    }
+
+    public Value createValue(boolean b) {
+        return commonsFactory.createValue(b);
+    }
+
+    public Value createValue(Calendar calendar) {
+        return commonsFactory.createValue(calendar);
+    }
+
+    public Value createValue(InputStream inputStream) {
+        return commonsFactory.createValue(inputStream);
+    }
+
+    /**
+     * A <code>ReferenceValue</code> provides an implementation
+     * of the <code>Value</code> interface representing a <code>REFERENCE</code> value
+     * (a jcr:uuid property of an existing, referenceable node).
+     */
+    private static class ReferenceValue extends org.apache.jackrabbit.value.ReferenceValue {
+
+        private ReferenceValue(String uuid) {
+            super(uuid);
+        }
+
+        /**
+         * Constructs a <code>ReferenceValue</code> object representing the UUID of
+         * an existing node.
+         *
+         * @param target the node to be referenced
+         * @throws IllegalArgumentException If <code>target</code> is nonreferenceable.
+         * @throws javax.jcr.RepositoryException      If another error occurs.
+         */
+        private ReferenceValue(Node target) throws RepositoryException {
+            super(target);
+        }
+
+        /**
+         * Returns a new <code>ReferenceValue</code> initialized to the value
+         * represented by the specified <code>String</code>.
+         * <p/>
+         * The specified <code>String</code> must denote the jcr:uuid property
+         * of an existing node.
+         *
+         * @param s the string to be parsed.
+         * @return a newly constructed <code>ReferenceValue</code> representing
+         * the specified value.
+         * @throws javax.jcr.ValueFormatException If the <code>String</code> is
+         * null or empty String.
+         */
+        public static org.apache.jackrabbit.value.ReferenceValue valueOf(String s) throws ValueFormatException {
+            if (s != null && !"".equals(s)) {
+                return new ReferenceValue(s);
+            } else {
+                throw new ValueFormatException("Invalid format for jcr:uuid");
+            }
+        }
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/ValueFactoryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteBatch.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteBatch.java?view=auto&rev=512795
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteBatch.java (added)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteBatch.java Wed Feb 28 07:09:27 2007
@@ -0,0 +1,97 @@
+/*
+ * 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.rmi.remote;
+
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.ItemId;
+import org.apache.jackrabbit.name.QName;
+
+import javax.jcr.RepositoryException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * <code>RemoteBatch</code> is the remote version of the SPI
+ * {@link org.apache.jackrabbit.spi.Batch} interface.
+ */
+public interface RemoteBatch extends Remote {
+
+    /**
+     * @see org.apache.jackrabbit.spi.Batch#addNode(org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.name.QName, org.apache.jackrabbit.name.QName, String)
+     */
+    public void addNode(NodeId parentId,
+                        QName nodeName,
+                        QName nodetypeName,
+                        String uuid)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @see org.apache.jackrabbit.spi.Batch#addProperty(org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.name.QName, org.apache.jackrabbit.spi.QValue)
+     */
+    public void addProperty(NodeId parentId, QName propertyName, QValue value)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @see org.apache.jackrabbit.spi.Batch#addProperty(org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.name.QName, org.apache.jackrabbit.spi.QValue[])
+     */
+    public void addProperty(NodeId parentId,
+                            QName propertyName,
+                            QValue[] values)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @see org.apache.jackrabbit.spi.Batch#setValue(org.apache.jackrabbit.spi.PropertyId, org.apache.jackrabbit.spi.QValue)
+     */
+    public void setValue(PropertyId propertyId, QValue value)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @see org.apache.jackrabbit.spi.Batch#setValue(org.apache.jackrabbit.spi.PropertyId, org.apache.jackrabbit.spi.QValue[])
+     */
+    public void setValue(PropertyId propertyId, QValue[] values)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @see org.apache.jackrabbit.spi.Batch#remove(org.apache.jackrabbit.spi.ItemId)
+     */
+    public void remove(ItemId itemId)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @see org.apache.jackrabbit.spi.Batch#reorderNodes(org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.spi.NodeId)
+     */
+    public void reorderNodes(NodeId parentId,
+                             NodeId srcNodeId,
+                             NodeId beforeNodeId)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @see org.apache.jackrabbit.spi.Batch#setMixins(org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.name.QName[])
+     */
+    public void setMixins(NodeId nodeId, QName[] mixinNodeTypeIds)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * @see org.apache.jackrabbit.spi.Batch#move(org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.spi.NodeId, org.apache.jackrabbit.name.QName)
+     */
+    public void move(NodeId srcNodeId,
+                     NodeId destParentNodeId,
+                     QName destName)
+            throws RepositoryException, RemoteException;
+}

Propchange: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteBatch.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteIterator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteIterator.java?view=auto&rev=512795
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteIterator.java (added)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteIterator.java Wed Feb 28 07:09:27 2007
@@ -0,0 +1,60 @@
+/*
+ * 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.rmi.remote;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.util.NoSuchElementException;
+
+/**
+ * Remote version of the JCR {@link javax.jcr.RangeIterator} interface.
+ */
+public interface RemoteIterator extends Remote {
+
+    /**
+     * Returns the size of the iteration, or <code>-1</code> if the
+     * size is unknown.
+     *
+     * @return size of the iteration, or <code>-1</code> if unknown
+     * @throws RemoteException on RMI errors
+     * @see javax.jcr.RangeIterator#getSize()
+     */
+    long getSize() throws RemoteException;
+
+    /**
+     * Skips the given number of elements in this iteration.
+     *
+     * @param items number of elements to skip
+     * @throws NoSuchElementException if skipped past the last element
+     * @throws RemoteException on RMI errors
+     * @see javax.jcr.RangeIterator#skip(long)
+     */
+    void skip(long items) throws NoSuchElementException, RemoteException;
+
+    /**
+     * Returns an array of the next elements in this iterator. Returns
+     * <code>null</code> if the end of this iteration has been reached.
+     * <p/>
+     * To reduce the amount of remote method calls, this method returns an array
+     * of one or more elements in this iteration.
+     *
+     * @return array of remote references, or <code>null</code>
+     * @throws RemoteException on RMI errors
+     * @see java.util.Iterator#next()
+     */
+    Object[] nextObjects() throws RemoteException;
+}

Propchange: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteQueryInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteQueryInfo.java?view=auto&rev=512795
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteQueryInfo.java (added)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteQueryInfo.java Wed Feb 28 07:09:27 2007
@@ -0,0 +1,41 @@
+/*
+ * 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.rmi.remote;
+
+import org.apache.jackrabbit.name.QName;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * <code>RemoteQueryInfo</code>...
+ */
+public interface RemoteQueryInfo extends Remote {
+
+    /**
+     * @return an iterator over the serializable {@link org.apache.jackrabbit.spi.QueryResultRow}s
+     * @see javax.jcr.query.QueryResult#getRows()
+     */
+    public RemoteIterator getRows() throws RemoteException;
+
+    /**
+     * @return an array of QName representing the column names of the query
+     *         result.
+     * @see javax.jcr.query.QueryResult#getColumnNames()
+     */
+    public QName[] getColumnNames() throws RemoteException;
+}

Propchange: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteQueryInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message