jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r161553 [1/4] - in incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org: ./ apache/ apache/jackrabbit/ apache/jackrabbit/base/ apache/jackrabbit/base/nodetype/ apache/jackrabbit/decorator/ apache/jackrabbit/iterator/ apache/jackrabbit/lite/ apache/jackrabbit/lite/nodetype/ apache/jackrabbit/name/ apache/jackrabbit/trace/ apache/jackrabbit/xml/
Date Sat, 16 Apr 2005 05:46:26 GMT
Author: jukka
Date: Fri Apr 15 22:46:17 2005
New Revision: 161553

URL: http://svn.apache.org/viewcvs?view=rev&rev=161553
Log:
jcr-ext: Migrating code to Jackrabbit. Alpha quality!

Added:
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseItem.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseNamespaceRegistry.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseNode.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseProperty.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseRepository.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseSession.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseWorkspace.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BaseItemDef.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BaseNodeDef.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BaseNodeType.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BaseNodeTypeManager.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BasePropertyDef.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/package.html   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratorFactory.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/ItemDecorator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/RepositoryDecorator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/SessionDecorator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/SimpleDecoratorFactory.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/WorkspaceDecorator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/package.html   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/ArrayIterator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/ArrayNodeIterator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/ArrayNodeTypeIterator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/ArrayPropertyIterator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/package.html   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteItem.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteNamedNode.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteNamespaceRegistry.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteNode.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteProperty.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteRepository.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteRootNode.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteRootNodeType.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteSession.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteWorkspace.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/nodetype/
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/nodetype/LiteItemDef.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/nodetype/LiteNodeDef.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/nodetype/LiteNodeType.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/nodetype/LiteNodeTypeManager.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/nodetype/LitePropertyDef.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/nodetype/PropertyDefBuilder.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/package.html   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/name/
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/name/IndexedElement.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/name/Name.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/name/NamedElement.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/name/ParentElement.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/name/Path.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/name/PathElement.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/name/RootElement.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/name/ThisElement.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/trace/
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/trace/TraceDecoratorFactory.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/trace/TraceFingerprint.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/trace/TraceLogger.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/trace/TraceRepositoryDecorator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/trace/TraceSessionDecorator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/trace/TraceWorkspaceDecorator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/xml/
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/xml/DocumentViewExportVisitor.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/xml/DocumentViewImportContentHandler.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/xml/SystemViewExportVisitor.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/xml/SystemViewImportContentHandler.java   (with props)

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseItem.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseItem.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseItem.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseItem.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,213 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.base;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.Item;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.ItemVisitor;
+import javax.jcr.Node;
+import javax.jcr.ReferentialIntegrityException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.version.VersionException;
+
+/**
+ * TODO
+ */
+public class BaseItem implements Item {
+    
+    private Item item;
+
+    protected BaseItem() {
+        this.item = null;
+    }
+
+    protected BaseItem(Item item) {
+        this.item = item;
+    }
+
+    protected void setProxyItem(Item item) {
+        this.item = item;
+    }
+
+    /** {@inheritDoc} */
+    public String getPath() throws RepositoryException {
+        if (item != null) {
+            return item.getPath();
+        } else {
+            try {
+                Node parent = getParent();
+                String path = parent.getPath();
+                if (path.equals("/")) {
+                    return path + getName();
+                } else {
+                    return path + "/" + getName();
+                }
+            } catch (ItemNotFoundException e) {
+                return "/";
+            }
+        }
+    }
+
+    /** {@inheritDoc} */
+    public String getName() throws RepositoryException {
+        if (item != null) {
+            return item.getName();
+        } else {
+            throw new UnsupportedRepositoryOperationException();
+        }
+    }
+
+    /** {@inheritDoc} */
+    public Item getAncestor(int depth) throws ItemNotFoundException,
+            AccessDeniedException, RepositoryException {
+        if (item != null) {
+            return item.getAncestor(depth);
+        } else {
+            int thisDepth = getDepth();
+            if (depth >= 0 || depth < thisDepth) {
+                return getParent().getAncestor(depth);
+            } else if (thisDepth == depth) {
+                return this;
+            } else {
+                throw new ItemNotFoundException(
+                        "Invalid ancestor depth " + depth);
+            }
+        }
+    }
+
+    /** {@inheritDoc} */
+    public Node getParent() throws ItemNotFoundException,
+            AccessDeniedException, RepositoryException {
+        if (item != null) {
+            return item.getParent();
+        } else {
+            throw new UnsupportedRepositoryOperationException();
+        }
+    }
+
+    /** {@inheritDoc} */
+    public int getDepth() throws RepositoryException {
+        if (item != null) {
+            return item.getDepth();
+        } else {
+            try {
+                return getParent().getDepth() + 1;
+            } catch (ItemNotFoundException e) {
+                return 0;
+            }
+        }
+    }
+
+    /** {@inheritDoc} */
+    public Session getSession() throws RepositoryException {
+        if (item != null) {
+            return item.getSession();
+        } else {
+            throw new UnsupportedRepositoryOperationException();
+        }
+    }
+
+    /** {@inheritDoc} */
+    public boolean isNode() {
+        if (item != null) {
+            return item.isNode();
+        } else {
+            return this instanceof Node;
+        }
+    }
+
+    /** {@inheritDoc} */
+    public boolean isNew() {
+        if (item != null) {
+            return item.isNew();
+        } else {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    /** {@inheritDoc} */
+    public boolean isModified() {
+        if (item != null) {
+            return item.isModified();
+        } else {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    /** {@inheritDoc} */
+    public boolean isSame(Item otherItem) {
+        try {
+            if (item != null) {
+                return item.isSame(otherItem);
+            } else if (otherItem == this) {
+                return true;
+            } else {
+                return getPath().equals(otherItem.getPath());
+            }
+        } catch (RepositoryException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public void accept(ItemVisitor visitor) throws RepositoryException {
+        if (item != null) {
+            item.accept(visitor);
+        } else {
+            throw new UnsupportedRepositoryOperationException();
+        }
+    }
+
+    /** {@inheritDoc} */
+    public void save() throws AccessDeniedException,
+            ConstraintViolationException, InvalidItemStateException,
+            ReferentialIntegrityException, VersionException, LockException,
+            RepositoryException {
+        if (item != null) {
+            item.save();
+        } else {
+            throw new UnsupportedRepositoryOperationException();
+        }
+    }
+
+    /** {@inheritDoc} */
+    public void refresh(boolean keepChanges) throws InvalidItemStateException,
+            RepositoryException {
+        if (item != null) {
+            item.refresh(keepChanges);
+        } else {
+            throw new UnsupportedRepositoryOperationException();
+        }
+    }
+
+    /** {@inheritDoc} */
+    public void remove() throws VersionException, LockException,
+            RepositoryException {
+        if (item != null) {
+            item.remove();
+        } else {
+            throw new UnsupportedRepositoryOperationException();
+        }
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseItem.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseNamespaceRegistry.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseNamespaceRegistry.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseNamespaceRegistry.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseNamespaceRegistry.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.base;
+
+import javax.jcr.NamespaceException;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+
+/**
+ * General base class for implementing the JCR NamespaceRegistry interface.
+ */
+public class BaseNamespaceRegistry implements NamespaceRegistry {
+
+    /**
+     * The default constructor is protected to signify that this
+     * class needs to be subclassed to be of any real use.
+     */
+    protected BaseNamespaceRegistry() {
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public void registerNamespace(String prefix, String uri)
+            throws NamespaceException, UnsupportedRepositoryOperationException,
+            RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public void unregisterNamespace(String prefix) throws NamespaceException,
+            UnsupportedRepositoryOperationException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public String[] getPrefixes() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /**
+     * Implemented by mapping all prefixes returned by
+     * <code>getPrefixes()</code> into namespace URIs using
+     * <code>getURI(prefix)</code>.
+     * {@inheritDoc}
+     */
+    public String[] getURIs() throws RepositoryException {
+        String[] prefixes = getPrefixes();
+        String[] uris = new String[prefixes.length];
+        for (int i = 0; i < prefixes.length; i++) {
+            uris[i] = getURI(prefixes[i]);
+        }
+        return uris;
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public String getURI(String prefix) throws NamespaceException,
+            RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /**
+     * Implemented by iterating over the prefixes returned by
+     * <code>getPrefixes()</code> and selecting the prefix for which
+     * <code>getURI(prefix)</code> returns the given namespace URI.
+     * {@inheritDoc}
+     */
+    public String getPrefix(String uri) throws NamespaceException,
+            RepositoryException {
+        String[] prefixes = getPrefixes();
+        for (int i = 0; i < prefixes.length; i++) {
+            if (uri.equals(getURI(prefixes[i]))) {
+                return prefixes[i];
+            }
+        }
+        throw new NamespaceException(
+                "Namespace URI " + uri + " is not registered.");
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseNamespaceRegistry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseNode.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseNode.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseNode.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseNode.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,454 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.base;
+
+import java.io.InputStream;
+import java.util.Calendar;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.BinaryValue;
+import javax.jcr.BooleanValue;
+import javax.jcr.DateValue;
+import javax.jcr.DoubleValue;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.Item;
+import javax.jcr.ItemExistsException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.ItemVisitor;
+import javax.jcr.LongValue;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+import javax.jcr.ReferenceValue;
+import javax.jcr.RepositoryException;
+import javax.jcr.StringValue;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
+import javax.jcr.lock.Lock;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.nodetype.NodeDef;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionException;
+import javax.jcr.version.VersionHistory;
+
+/**
+ * TODO
+ */
+public class BaseNode extends BaseItem implements Node {
+
+    protected BaseNode() {
+    }
+
+    protected BaseNode(Item item) {
+        super(item);
+    }
+
+    public String getPath() throws RepositoryException {
+        if (getDefinition().allowSameNameSibs()) {
+            return super.getPath() + "[" + getIndex() + "]";
+        } else {
+            return super.getPath();
+        }
+    }
+
+    public void accept(ItemVisitor visitor) throws RepositoryException {
+        visitor.visit(this);
+    }
+
+    public boolean isNode() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    public Node addNode(String relPath) throws ItemExistsException,
+            PathNotFoundException, VersionException,
+            ConstraintViolationException, LockException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public Node addNode(String relPath, String primaryNodeTypeName)
+            throws ItemExistsException, PathNotFoundException,
+            NoSuchNodeTypeException, LockException, VersionException,
+            ConstraintViolationException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public void orderBefore(String srcChildRelPath, String destChildRelPath)
+            throws UnsupportedRepositoryOperationException, VersionException,
+            ConstraintViolationException, ItemNotFoundException, LockException,
+            RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public Property setProperty(String name, Value value)
+            throws ValueFormatException, VersionException, LockException,
+            RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public Property setProperty(String name, Value[] values)
+            throws ValueFormatException, VersionException, LockException,
+            RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public Property setProperty(String name, Value[] values, int type)
+            throws ValueFormatException, VersionException, LockException,
+            RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public Property setProperty(String name, String[] values)
+            throws ValueFormatException, VersionException, LockException,
+            RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public Property setProperty(String name, String[] values, int type)
+            throws ValueFormatException, VersionException, LockException,
+            RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public Property setProperty(String name, String value)
+            throws ValueFormatException, VersionException, LockException,
+            RepositoryException {
+        return setProperty(name, new StringValue(value));
+    }
+
+    /** {@inheritDoc} */
+    public Property setProperty(String name, InputStream value)
+            throws ValueFormatException, VersionException, LockException,
+            RepositoryException {
+        return setProperty(name, new BinaryValue(value));
+    }
+
+    /** {@inheritDoc} */
+    public Property setProperty(String name, boolean value)
+            throws ValueFormatException, VersionException, LockException,
+            RepositoryException {
+        return setProperty(name, new BooleanValue(value));
+    }
+
+    /** {@inheritDoc} */
+    public Property setProperty(String name, double value)
+            throws ValueFormatException, VersionException, LockException,
+            RepositoryException {
+        return setProperty(name, new DoubleValue(value));
+    }
+
+    /** {@inheritDoc} */
+    public Property setProperty(String name, long value)
+            throws ValueFormatException, VersionException, LockException,
+            RepositoryException {
+        return setProperty(name, new LongValue(value));
+    }
+
+    /** {@inheritDoc} */
+    public Property setProperty(String name, Calendar value)
+            throws ValueFormatException, VersionException, LockException,
+            RepositoryException {
+        return setProperty(name, new DateValue(value));
+    }
+
+    /** {@inheritDoc} */
+    public Property setProperty(String name, Node value)
+            throws ValueFormatException, VersionException, LockException,
+            RepositoryException {
+        return setProperty(name, new ReferenceValue(value));
+    }
+
+    /** {@inheritDoc} */
+    public Node getNode(String relPath) throws PathNotFoundException,
+            RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public NodeIterator getNodes() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public NodeIterator getNodes(String namePattern) throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public Property getProperty(String relPath) throws PathNotFoundException,
+            RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public PropertyIterator getProperties() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public PropertyIterator getProperties(String namePattern)
+            throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public Item getPrimaryItem() throws ItemNotFoundException,
+            RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public String getUUID() throws UnsupportedRepositoryOperationException,
+            RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public int getIndex() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public PropertyIterator getReferences() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public boolean hasNode(String relPath) throws RepositoryException {
+        try {
+            getNode(relPath);
+            return true;
+        } catch (PathNotFoundException e) {
+            return false;
+        }
+    }
+
+    /** {@inheritDoc} */
+    public boolean hasProperty(String relPath) throws RepositoryException {
+        try {
+            getProperty(relPath);
+            return true;
+        } catch (PathNotFoundException e) {
+            return false;
+        }
+    }
+
+    /** {@inheritDoc} */
+    public boolean hasNodes() throws RepositoryException {
+        return getNodes().getSize() > 0;
+    }
+
+    /** {@inheritDoc} */
+    public boolean hasProperties() throws RepositoryException {
+        return getProperties().getSize() > 0;
+    }
+
+    /** {@inheritDoc} */
+    public NodeType getPrimaryNodeType() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public NodeType[] getMixinNodeTypes() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public boolean isNodeType(String nodeTypeName) throws RepositoryException {
+        if (getPrimaryNodeType().isNodeType(nodeTypeName)) {
+            return true;
+        } else {
+            NodeType[] types = getMixinNodeTypes();
+            for (int i = 0; i < types.length; i++) {
+                if (types[i].isNodeType(nodeTypeName)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    public void addMixin(String mixinName) throws NoSuchNodeTypeException,
+            VersionException, ConstraintViolationException, LockException,
+            RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public void removeMixin(String mixinName) throws NoSuchNodeTypeException,
+            VersionException, ConstraintViolationException, LockException,
+            RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public boolean canAddMixin(String mixinName) throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public NodeDef getDefinition() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public Version checkin() throws VersionException,
+            UnsupportedRepositoryOperationException, InvalidItemStateException,
+            LockException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public void checkout() throws UnsupportedRepositoryOperationException,
+            LockException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public void doneMerge(Version version) throws VersionException,
+            InvalidItemStateException, UnsupportedRepositoryOperationException,
+            RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public void cancelMerge(Version version) throws VersionException,
+            InvalidItemStateException, UnsupportedRepositoryOperationException,
+            RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public void update(String srcWorkspaceName)
+            throws NoSuchWorkspaceException, AccessDeniedException,
+            LockException, InvalidItemStateException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public void merge(String srcWorkspace, boolean bestEffort)
+            throws UnsupportedRepositoryOperationException,
+            NoSuchWorkspaceException, AccessDeniedException, VersionException,
+            LockException, InvalidItemStateException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public String getCorrespondingNodePath(String workspaceName)
+            throws ItemNotFoundException, NoSuchWorkspaceException,
+            AccessDeniedException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public boolean isCheckedOut() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public void restore(String versionName, boolean removeExisting)
+            throws VersionException, ItemExistsException,
+            UnsupportedRepositoryOperationException, LockException,
+            InvalidItemStateException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public void restore(Version version, boolean removeExisting)
+            throws VersionException, ItemExistsException,
+            UnsupportedRepositoryOperationException, LockException,
+            RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public void restore(Version version, String relPath, boolean removeExisting)
+            throws PathNotFoundException, ItemExistsException,
+            VersionException, ConstraintViolationException,
+            UnsupportedRepositoryOperationException, LockException,
+            InvalidItemStateException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public void restoreByLabel(String versionLabel, boolean removeExisting)
+            throws VersionException, ItemExistsException,
+            UnsupportedRepositoryOperationException, LockException,
+            InvalidItemStateException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public VersionHistory getVersionHistory()
+            throws UnsupportedRepositoryOperationException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public Version getBaseVersion()
+            throws UnsupportedRepositoryOperationException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public Lock lock(boolean isDeep, boolean isSessionScoped)
+            throws UnsupportedRepositoryOperationException, LockException,
+            AccessDeniedException, InvalidItemStateException,
+            RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public Lock getLock() throws UnsupportedRepositoryOperationException,
+            LockException, AccessDeniedException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public void unlock() throws UnsupportedRepositoryOperationException,
+            LockException, AccessDeniedException, InvalidItemStateException,
+            RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public boolean holdsLock() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public boolean isLocked() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseNode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseProperty.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseProperty.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseProperty.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,193 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.base;
+
+import java.io.InputStream;
+import java.util.Calendar;
+
+import javax.jcr.BinaryValue;
+import javax.jcr.BooleanValue;
+import javax.jcr.DateValue;
+import javax.jcr.DoubleValue;
+import javax.jcr.Item;
+import javax.jcr.ItemVisitor;
+import javax.jcr.LongValue;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.ReferenceValue;
+import javax.jcr.RepositoryException;
+import javax.jcr.StringValue;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.PropertyDef;
+import javax.jcr.version.VersionException;
+
+/**
+ * TODO
+ */
+public class BaseProperty extends BaseItem implements Property {
+
+    protected BaseProperty(Item item) {
+        super(item);
+    }
+
+    public void accept(ItemVisitor visitor) throws RepositoryException {
+        visitor.visit(this);
+    }
+
+    public boolean isNode() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    public void setValue(Value value) throws ValueFormatException,
+            VersionException, LockException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public void setValue(Value[] values) throws ValueFormatException,
+            VersionException, LockException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public void setValue(String value) throws ValueFormatException,
+            VersionException, LockException, RepositoryException {
+        setValue(new StringValue(value));
+    }
+
+    /** {@inheritDoc} */
+    public void setValue(String[] values) throws ValueFormatException,
+            VersionException, LockException, RepositoryException {
+        Value[] stringValues = new Value[values.length];
+        for (int i = 0; i < values.length; i++) {
+            stringValues[i] = new StringValue(values[i]);
+        }
+        setValue(stringValues);
+    }
+
+    /** {@inheritDoc} */
+    public void setValue(InputStream value) throws ValueFormatException,
+            VersionException, LockException, RepositoryException {
+        setValue(new BinaryValue(value));
+    }
+
+    /** {@inheritDoc} */
+    public void setValue(long value) throws ValueFormatException,
+            VersionException, LockException, RepositoryException {
+        setValue(new LongValue(value));
+    }
+
+    /** {@inheritDoc} */
+    public void setValue(double value) throws ValueFormatException,
+            VersionException, LockException, RepositoryException {
+        setValue(new DoubleValue(value));
+    }
+
+    /** {@inheritDoc} */
+    public void setValue(Calendar value) throws ValueFormatException,
+            VersionException, LockException, RepositoryException {
+        setValue(new DateValue(value));
+    }
+
+    /** {@inheritDoc} */
+    public void setValue(boolean value) throws ValueFormatException,
+            VersionException, LockException, RepositoryException {
+        setValue(new BooleanValue(value));
+    }
+
+    /** {@inheritDoc} */
+    public void setValue(Node value) throws ValueFormatException,
+            VersionException, LockException, RepositoryException {
+        try {
+            setValue(new ReferenceValue(value));
+        } catch (IllegalArgumentException e) {
+            throw new ValueFormatException("Invalid reference target", e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public Value getValue() throws ValueFormatException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public Value[] getValues() throws ValueFormatException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public String getString() throws ValueFormatException, RepositoryException {
+        return getValue().getString();
+    }
+
+    /** {@inheritDoc} */
+    public InputStream getStream() throws ValueFormatException,
+            RepositoryException {
+        return getValue().getStream();
+    }
+
+    /** {@inheritDoc} */
+    public long getLong() throws ValueFormatException, RepositoryException {
+        return getValue().getLong();
+    }
+
+    /** {@inheritDoc} */
+    public double getDouble() throws ValueFormatException, RepositoryException {
+        return getValue().getDouble();
+    }
+
+    /** {@inheritDoc} */
+    public Calendar getDate() throws ValueFormatException, RepositoryException {
+        return getValue().getDate();
+    }
+
+    /** {@inheritDoc} */
+    public boolean getBoolean() throws ValueFormatException,
+            RepositoryException {
+        return getValue().getBoolean();
+    }
+
+    /** {@inheritDoc} */
+    public Node getNode() throws ValueFormatException, RepositoryException {
+        return getSession().getNodeByUUID(getString());
+    }
+
+    /** {@inheritDoc} */
+    public long getLength() throws ValueFormatException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public long[] getLengths() throws ValueFormatException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public PropertyDef getDefinition() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public int getType() throws RepositoryException {
+        return getValue().getType();
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseProperty.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseRepository.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseRepository.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseRepository.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseRepository.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.base;
+
+import javax.jcr.Credentials;
+import javax.jcr.LoginException;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.UnsupportedRepositoryOperationException;
+
+/**
+ * General base class for implementing the JCR Repository interface.
+ */
+public class BaseRepository implements Repository {
+
+    /**
+     * The default constructor is protected to signify that this
+     * class needs to be subclassed to be of any real use.
+     */
+    protected BaseRepository() {
+    }
+
+    /** Unsupported operation. {@inheritDoc} */
+    public String[] getDescriptorKeys() {
+        throw new UnsupportedOperationException();
+    }
+
+    /** Unsupported operation. {@inheritDoc} */
+    public String getDescriptor(String key) {
+        throw new UnsupportedOperationException();
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public Session login(Credentials credentials, String workspaceName)
+            throws LoginException, NoSuchWorkspaceException,
+            RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** Calls <code>login(credentials, null)</code>. {@inheritDoc} */
+    public Session login(Credentials credentials) throws LoginException,
+            NoSuchWorkspaceException, RepositoryException {
+        return login(credentials, null);
+    }
+
+    /** Calls <code>login(null, workspaceName)</code>. {@inheritDoc} */
+    public Session login(String workspaceName) throws LoginException,
+            NoSuchWorkspaceException, RepositoryException {
+        return login(null, workspaceName);
+    }
+
+    /** Calls <code>login(null, null)</code>. {@inheritDoc} */
+    public Session login() throws LoginException, NoSuchWorkspaceException,
+            RepositoryException {
+        return login(null, null);
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseRepository.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseSession.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseSession.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseSession.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseSession.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,324 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.base;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.AccessControlException;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.Credentials;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.InvalidSerializedDataException;
+import javax.jcr.Item;
+import javax.jcr.ItemExistsException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.LoginException;
+import javax.jcr.NamespaceException;
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Workspace;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.version.VersionException;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.sax.SAXResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.xml.serialize.OutputFormat;
+import org.apache.xml.serialize.XMLSerializer;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+/**
+ * General base class for implementing the JCR Session interface.
+ */
+public class BaseSession implements Session {
+
+    /**
+     * The default constructor is protected to signify that this
+     * class needs to be subclassed to be of any real use.
+     */
+    protected BaseSession() {
+    }
+
+    /** Unsupported operation. {@inheritDoc} */
+    public Repository getRepository() {
+        throw new UnsupportedOperationException();
+    }
+
+    /** Unsupported operation. {@inheritDoc} */
+    public String getUserId() {
+        throw new UnsupportedOperationException();
+    }
+
+    /** Unsupported operation. {@inheritDoc} */
+    public Object getAttribute(String name) {
+        throw new UnsupportedOperationException();
+    }
+
+    /** Unsupported operation. {@inheritDoc} */
+    public String[] getAttributeNames() {
+        throw new UnsupportedOperationException();
+    }
+
+    /** Unsupported operation. {@inheritDoc} */
+    public Workspace getWorkspace() {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Calls
+     * <code>getRepository().login(credentials, getWorkspace().getName())</code>.
+     * {@inheritDoc}
+     */
+    public Session impersonate(Credentials credentials) throws LoginException,
+            RepositoryException {
+        return getRepository().login(credentials, getWorkspace().getName());
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public Node getRootNode() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public Node getNodeByUUID(String uuid) throws ItemNotFoundException,
+            RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public Item getItem(String absPath) throws PathNotFoundException,
+            RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /**
+     * Calls <code>getItem(absPath)</code> and returns <code>true</code>
+     * if a {@link PathNotFoundException PathNotFoundException} is not thrown.
+     * Throws a {@link RuntimeException RuntimeException} if a general
+     * {@link RepositoryException RepositoryException} is thrown by getItem().
+     * {@inheritDoc}
+     */
+    public boolean itemExists(String absPath) {
+        try {
+            getItem(absPath);
+            return true;
+        } catch (PathNotFoundException e) {
+            return false;
+        } catch (RepositoryException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /** Unsupported repository operation.{@inheritDoc} */
+    public void move(String srcAbsPath, String destAbsPath)
+            throws ItemExistsException, PathNotFoundException,
+            VersionException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public void save() throws AccessDeniedException,
+            ConstraintViolationException, InvalidItemStateException,
+            VersionException, LockException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public void refresh(boolean keepChanges) throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public boolean hasPendingChanges() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** Unsupported operation. {@inheritDoc} */
+    public void checkPermission(String absPath, String actions)
+            throws AccessControlException {
+        throw new UnsupportedOperationException();
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public ContentHandler getImportContentHandler(String parentAbsPath)
+            throws PathNotFoundException, ConstraintViolationException,
+            VersionException, LockException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /**
+     * Calls
+     * <code>transformer.transform(new StreamSource(in), new SAXResult(handler))</code>
+     * with an identity {@link Transformer Transformer} and a
+     * {@link ContentHandler ContentHandler} instance created by calling
+     * <code>getImportContentHandler(parentAbsPath)</code>. Possible
+     * {@see TransformerException TransformerExceptions} and
+     * {@see TransformerConfigurationException TransformerConfigurationExceptions}
+     * are converted to {@link IOException IOExceptions}.
+     * {@inheritDoc}
+     */
+    public void importXML(String parentAbsPath, InputStream in)
+            throws IOException, PathNotFoundException, ItemExistsException,
+            ConstraintViolationException, VersionException,
+            InvalidSerializedDataException, LockException, RepositoryException {
+        try {
+            ContentHandler handler = getImportContentHandler(parentAbsPath);
+
+            TransformerFactory factory = TransformerFactory.newInstance();
+            Transformer transformer = factory.newTransformer();
+            transformer.transform(new StreamSource(in), new SAXResult(handler));
+        } catch (TransformerConfigurationException e) {
+            throw new IOException(
+                    "Unable to deserialize a SAX stream: " + e.getMessage());
+        } catch (TransformerException e) {
+            throw new IOException(
+                    "Unable to deserialize a SAX stream: " + e.getMessage());
+        }
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public void exportSysView(String absPath, ContentHandler contentHandler,
+            boolean skipBinary, boolean noRecurse)
+            throws PathNotFoundException, SAXException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /**
+     * Calls
+     * <code>exportSysView(absPath, handler, binaryAsLink, noRecurse)</code>
+     * with a content handler instance <code>handler</code> created on
+     * top fo the given output stream using the Xerces
+     * {@link XMLSerializer XMLSerializer} class. Possible
+     * {@link SAXException SAXExceptions} are converted to
+     * {@link IOException IOExceptions}.
+     * {@inheritDoc}
+     */
+    public void exportSysView(String absPath, OutputStream out,
+            boolean skipBinary, boolean noRecurse) throws IOException,
+            PathNotFoundException, RepositoryException {
+        try {
+            XMLSerializer serializer =
+                new XMLSerializer(out, new OutputFormat());
+            exportDocView(absPath, serializer.asContentHandler(),
+                    skipBinary, noRecurse);
+        } catch (SAXException e) {
+            throw new IOException(
+                    "Unable to serialize a system view SAX stream: "
+                    + e.getMessage());
+        }
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public void exportDocView(String absPath, ContentHandler contentHandler,
+            boolean skipBinary, boolean noRecurse)
+            throws InvalidSerializedDataException, PathNotFoundException,
+            SAXException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /**
+     * Calls
+     * <code>exportDocView(absPath, handler, binaryAsLink, noRecurse)</code>
+     * with a content handler instance <code>handler</code> created on
+     * top fo the given output stream using the Xerces
+     * {@link XMLSerializer XMLSerializer} class. Possible
+     * {@link SAXException SAXExceptions} are converted to
+     * {@link IOException IOExceptions}.
+     * {@inheritDoc}
+     */
+    public void exportDocView(String absPath, OutputStream out,
+            boolean skipBinary, boolean noRecurse)
+            throws InvalidSerializedDataException, IOException,
+            PathNotFoundException, RepositoryException {
+        try {
+            XMLSerializer serializer =
+                new XMLSerializer(out, new OutputFormat("xml", "UTF-8", true));
+            exportDocView(absPath, serializer.asContentHandler(),
+                    skipBinary, noRecurse);
+        } catch (SAXException e) {
+            throw new IOException(
+                    "Unable to serialize a document view SAX stream: "
+                    + e.getMessage());
+        }
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public void setNamespacePrefix(String prefix, String uri)
+            throws NamespaceException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public String[] getNamespacePrefixes() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public String getNamespaceURI(String prefix) throws NamespaceException,
+            RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /**
+     * Implemented by iterating over the prefix array returned by
+     * <code>getNamespacePrefixes()</code> and calling
+     * <code>getNamespaceURI(prefix)</code> repeatedly until a match
+     * is found for the given namespace URI.
+     * {@inheritDoc}
+     */
+    public String getNamespacePrefix(String uri) throws NamespaceException,
+            RepositoryException {
+        String[] prefixes = getNamespacePrefixes();
+        for (int i = 0; i < prefixes.length; i++) {
+            if (uri.equals(getNamespaceURI(prefixes[i]))) {
+                return prefixes[i];
+            }
+        }
+        throw new NamespaceException("Unknown namespace URI " + uri);
+    }
+
+    /** Does nothing. {@inheritDoc} */
+    public void logout() {
+    }
+
+    /** Unsupported operation. {@inheritDoc} */
+    public void addLockToken(String lt) {
+        throw new UnsupportedOperationException();
+    }
+
+    /** Unsupported operation. {@inheritDoc} */
+    public String[] getLockTokens() {
+        throw new UnsupportedOperationException();
+    }
+
+    /** Unsupported operation. {@inheritDoc} */
+    public void removeLockToken(String lt) {
+        throw new UnsupportedOperationException();
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseSession.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseWorkspace.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseWorkspace.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseWorkspace.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseWorkspace.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,177 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.base;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.InvalidSerializedDataException;
+import javax.jcr.ItemExistsException;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Workspace;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NodeTypeManager;
+import javax.jcr.observation.ObservationManager;
+import javax.jcr.query.QueryManager;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionException;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.sax.SAXResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.xml.sax.ContentHandler;
+
+/**
+ * General base class for implementing the JCR Workspace interface.
+ */
+public class BaseWorkspace implements Workspace {
+
+    /**
+     * The default constructor is protected to signify that this
+     * class needs to be subclassed to be of any real use.
+     */
+    protected BaseWorkspace() {
+    }
+
+    /** Unsupported operation. {@inheritDoc} */
+    public Session getSession() {
+        throw new UnsupportedOperationException();
+    }
+
+    /** Unsupported operation. {@inheritDoc} */
+    public String getName() {
+        throw new UnsupportedOperationException();
+    }
+
+    /** Calls <code>copy(getName(), srcAbsPath, destAbsPath). {@inheritDoc} */
+    public void copy(String srcAbsPath, String destAbsPath)
+            throws ConstraintViolationException, VersionException,
+            AccessDeniedException, PathNotFoundException, ItemExistsException,
+            LockException, RepositoryException {
+        copy(getName(), srcAbsPath, destAbsPath);
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public void copy(String srcWorkspace, String srcAbsPath, String destAbsPath)
+            throws NoSuchWorkspaceException, ConstraintViolationException,
+            VersionException, AccessDeniedException, PathNotFoundException,
+            ItemExistsException, LockException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public void clone(String srcWorkspace, String srcAbsPath,
+            String destAbsPath, boolean removeExisting)
+            throws NoSuchWorkspaceException, ConstraintViolationException,
+            VersionException, AccessDeniedException, PathNotFoundException,
+            ItemExistsException, LockException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public void move(String srcAbsPath, String destAbsPath)
+            throws ConstraintViolationException, VersionException,
+            AccessDeniedException, PathNotFoundException, ItemExistsException,
+            LockException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public void restore(Version[] versions, boolean removeExisting)
+            throws ItemExistsException,
+            UnsupportedRepositoryOperationException, VersionException,
+            LockException, InvalidItemStateException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public QueryManager getQueryManager() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public NamespaceRegistry getNamespaceRegistry() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public NodeTypeManager getNodeTypeManager() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public ObservationManager getObservationManager()
+            throws UnsupportedRepositoryOperationException, RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public String[] getAccessibleWorkspaceNames() throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /** Unsupported repository operation. {@inheritDoc} */
+    public ContentHandler getImportContentHandler(String parentAbsPath,
+            int uuidBehavior) throws PathNotFoundException,
+            ConstraintViolationException, VersionException, LockException,
+            RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /**
+     * Calls
+     * <code>transformer.transform(new StreamSource(in), new SAXResult(handler))</code>
+     * with an identity {@link Transformer Transformer} and a
+     * {@link ContentHandler ContentHandler} instance created by calling
+     * <code>getImportContentHandler(parentAbsPath, uuidBehaviour)</code>.
+     * Possible {@see TransformerException TransformerExceptions} and
+     * {@see TransformerConfigurationException TransformerConfigurationExceptions}
+     * are converted to {@link IOException IOExceptions}.
+     * {@inheritDoc}
+     */
+    public void importXML(String parentAbsPath, InputStream in, int uuidBehavior)
+            throws IOException, PathNotFoundException, ItemExistsException,
+            ConstraintViolationException, InvalidSerializedDataException,
+            LockException, RepositoryException {
+        try {
+            ContentHandler handler =
+                getImportContentHandler(parentAbsPath, uuidBehavior);
+
+            TransformerFactory factory = TransformerFactory.newInstance();
+            Transformer transformer = factory.newTransformer();
+            transformer.transform(new StreamSource(in), new SAXResult(handler));
+        } catch (TransformerConfigurationException e) {
+            throw new IOException(
+                    "Unable to deserialize a SAX stream: " + e.getMessage());
+        } catch (TransformerException e) {
+            throw new IOException(
+                    "Unable to deserialize a SAX stream: " + e.getMessage());
+        }
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseWorkspace.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BaseItemDef.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BaseItemDef.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BaseItemDef.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BaseItemDef.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.base.nodetype;
+
+import javax.jcr.nodetype.ItemDef;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.version.OnParentVersionAction;
+
+/**
+ * TODO
+ */
+public class BaseItemDef implements ItemDef {
+
+    /** {@inheritDoc} */
+    public NodeType getDeclaringNodeType() {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    public String getName() {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    public boolean isAutoCreate() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    public boolean isMandatory() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    public int getOnParentVersion() {
+        return OnParentVersionAction.IGNORE;
+    }
+
+    /** {@inheritDoc} */
+    public boolean isProtected() {
+        return false;
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BaseItemDef.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BaseNodeDef.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BaseNodeDef.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BaseNodeDef.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BaseNodeDef.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.base.nodetype;
+
+import javax.jcr.nodetype.NodeDef;
+import javax.jcr.nodetype.NodeType;
+
+/**
+ * TODO
+ */
+public class BaseNodeDef extends BaseItemDef implements NodeDef {
+
+    /** {@inheritDoc} */
+    public NodeType[] getRequiredPrimaryTypes() {
+        return new NodeType[0];
+    }
+
+    /** {@inheritDoc} */
+    public NodeType getDefaultPrimaryType() {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    public boolean allowSameNameSibs() {
+        return false;
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BaseNodeDef.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BaseNodeType.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BaseNodeType.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BaseNodeType.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BaseNodeType.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,210 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.base.nodetype;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.jcr.Value;
+import javax.jcr.nodetype.ItemDef;
+import javax.jcr.nodetype.NodeDef;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.PropertyDef;
+
+/**
+ * TODO
+ */
+public class BaseNodeType implements NodeType {
+
+    /** {@inheritDoc} */
+    public String getName() {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    public boolean isMixin() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    public boolean hasOrderableChildNodes() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    public String getPrimaryItemName() {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    public NodeType[] getSupertypes() {
+        Set defs = new HashSet();
+
+        NodeType[] types = getDeclaredSupertypes();
+        for (int i = 0; i < types.length; i++) {
+            defs.addAll(Arrays.asList(types[i].getSupertypes()));
+        }
+        defs.addAll(Arrays.asList(types));
+
+        return (NodeType[]) defs.toArray(new NodeType[0]);
+    }
+
+    /** {@inheritDoc} */
+    public NodeType[] getDeclaredSupertypes() {
+        return new NodeType[0];
+    }
+
+    /** {@inheritDoc} */
+    public boolean isNodeType(String nodeTypeName) {
+        if (nodeTypeName.equals(getName())) {
+            return true;
+        } else {
+            NodeType[] types = getSupertypes();
+            for (int i = 0; i < types.length; i++) {
+                if (nodeTypeName.equals(types[i].getName())) {
+                    return true;
+                }
+            }
+            return false;
+        }
+    }
+
+    /** {@inheritDoc} */
+    public PropertyDef[] getPropertyDefs() {
+        Set defs = new HashSet();
+
+        NodeType[] types = getSupertypes();
+        for (int i = 0; i < types.length; i++) {
+            defs.addAll(Arrays.asList(types[i].getPropertyDefs()));
+        }
+        defs.addAll(Arrays.asList(getDeclaredPropertyDefs()));
+
+        return (PropertyDef[]) defs.toArray(new PropertyDef[0]);
+    }
+
+    /** {@inheritDoc} */
+    public PropertyDef[] getDeclaredPropertyDefs() {
+        return new PropertyDef[0];
+    }
+
+    /** {@inheritDoc} */
+    public NodeDef[] getChildNodeDefs() {
+        Set defs = new HashSet();
+
+        NodeType[] types = getSupertypes();
+        for (int i = 0; i < types.length; i++) {
+            defs.addAll(Arrays.asList(types[i].getChildNodeDefs()));
+        }
+        defs.addAll(Arrays.asList(getDeclaredChildNodeDefs()));
+
+        return (NodeDef[]) defs.toArray(new NodeDef[0]);
+    }
+
+    /** {@inheritDoc} */
+    public NodeDef[] getDeclaredChildNodeDefs() {
+        return new NodeDef[0];
+    }
+
+    protected PropertyDef getPropertyDef(String propertyName) {
+        PropertyDef[] defs = getPropertyDefs();
+        for (int i = 0; i < defs.length; i++) {
+            if (propertyName.equals(defs[i].getName())) {
+                return defs[i];
+            }
+        }
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    public boolean canSetProperty(String propertyName, Value value) {
+        PropertyDef def = getPropertyDef(propertyName);
+        if (def == null) {
+            def = getPropertyDef("*");
+        }
+        if (def == null || def.isMultiple()) {
+            return false;
+        } else {
+            return true; // TODO check constraints!
+        }
+    }
+
+    /** {@inheritDoc} */
+    public boolean canSetProperty(String propertyName, Value[] values) {
+        PropertyDef def = getPropertyDef(propertyName);
+        if (def == null) {
+            def = getPropertyDef("*");
+        }
+        if (def == null || !def.isMultiple()) {
+            return false;
+        } else {
+            return true; // TODO check constraints!
+        }
+    }
+
+    protected NodeDef getChildNodeDef(String childNodeName) {
+        NodeDef[] defs = getChildNodeDefs();
+        for (int i = 0; i < defs.length; i++) {
+            if (childNodeName.equals(defs[i].getName())) {
+                return defs[i];
+            }
+        }
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    public boolean canAddChildNode(String childNodeName) {
+        NodeDef def = getChildNodeDef(childNodeName);
+        if (def == null) {
+            def = getChildNodeDef("*");
+        }
+        return def != null;
+    }
+
+    /** {@inheritDoc} */
+    public boolean canAddChildNode(String childNodeName, String nodeTypeName) {
+        NodeDef def = getChildNodeDef(childNodeName);
+        if (def == null) {
+            def = getChildNodeDef("*");
+        }
+        if (def == null) {
+            return false;
+        }
+
+        NodeType[] types = def.getRequiredPrimaryTypes();
+        for (int i = 0; i < types.length; i++) {
+            if (types[i].isNodeType(nodeTypeName)) {
+                return true;
+            }
+        }
+        return types.length == 0;
+    }
+
+    /** {@inheritDoc} */
+    public boolean canRemoveItem(String itemName) {
+        ItemDef def = getPropertyDef(itemName);
+        if (def == null) {
+            def = getChildNodeDef(itemName);
+        }
+        if (def == null) {
+            return true;
+        } else {
+            return def.isMandatory();
+        }
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BaseNodeType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BaseNodeTypeManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BaseNodeTypeManager.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BaseNodeTypeManager.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BaseNodeTypeManager.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.base.nodetype;
+
+import java.util.Vector;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NodeTypeIterator;
+import javax.jcr.nodetype.NodeTypeManager;
+
+import org.apache.jackrabbit.iterator.ArrayNodeTypeIterator;
+
+/**
+ * TODO
+ */
+public class BaseNodeTypeManager implements NodeTypeManager {
+
+    /**
+     * Static empty node type array instance. Used to avoid
+     * instantiating the empty array more than once.
+     */
+    private static final NodeType[] EMPTY_NODETYPE_ARRAY = new NodeType[0];
+
+    /**
+     * Returns an empty iterator. Subclasses should override this method
+     * to return all the available node types.
+     *
+     * @return all node types (empty array)
+     * @throws RepositoryException on repository errors (not thrown)
+     */
+    public NodeTypeIterator getAllNodeTypes() throws RepositoryException {
+        return new ArrayNodeTypeIterator(EMPTY_NODETYPE_ARRAY);
+    }
+
+    /**
+     * Returns the named node type. Implemented by searching through
+     * the iterator returned by <code>getAllNodeTypes()</code> looking
+     * for a match for <code>nodeTypeName.equals(type.getName())</code>.
+     * <p>
+     * Note that names are compared using normal string comparison, which
+     * means that both the given name and the internal node type names must
+     * use the same namespace mappings.
+     *
+     * @param nodeTypeName node type name
+     * @return named node type
+     * @throws NoSuchNodeTypeException if the named node type does not exist
+     * @throws RepositoryException on repository errors
+     */
+    public NodeType getNodeType(String nodeTypeName)
+            throws NoSuchNodeTypeException, RepositoryException {
+        NodeTypeIterator types = getAllNodeTypes();
+        while (types.hasNext()) {
+            NodeType type = types.nextNodeType();
+            if (nodeTypeName.equals(type.getName())) {
+                return type;
+            }
+        }
+
+        throw new NoSuchNodeTypeException(
+                "Node type " + nodeTypeName + " not found");
+    }
+
+    /**
+     * Returns all primary node types. Implemented by filtering the iterator
+     * returned by <code>getAllNodeTypes()</code> with
+     * <code>!type.isMixin()</code>.
+     *
+     * @return primary node types
+     * @throws RepositoryException on repository errors
+     */
+    public NodeTypeIterator getPrimaryNodeTypes() throws RepositoryException {
+        Vector primaryTypes = new Vector();
+
+        NodeTypeIterator types = getAllNodeTypes();
+        while (types.hasNext()) {
+            NodeType type = types.nextNodeType();
+            if (!type.isMixin()) {
+                primaryTypes.add(type);
+            }
+        }
+
+        return new ArrayNodeTypeIterator(
+                (NodeType[]) primaryTypes.toArray(EMPTY_NODETYPE_ARRAY));
+    }
+
+    /**
+     * Returns all mixin node types. Implemented by filtering the iterator
+     * returned by <code>getAllNodeTypes()</code> with
+     * <code>type.isMixin()</code>.
+     *
+     * @return mixin node types
+     * @throws RepositoryException on repository errors
+     */
+    public NodeTypeIterator getMixinNodeTypes() throws RepositoryException {
+        Vector mixinTypes = new Vector();
+
+        NodeTypeIterator types = getAllNodeTypes();
+        while (types.hasNext()) {
+            NodeType type = types.nextNodeType();
+            if (!type.isMixin()) {
+                mixinTypes.add(type);
+            }
+        }
+
+        return new ArrayNodeTypeIterator(
+                (NodeType[]) mixinTypes.toArray(EMPTY_NODETYPE_ARRAY));
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BaseNodeTypeManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BasePropertyDef.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BasePropertyDef.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BasePropertyDef.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BasePropertyDef.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.base.nodetype;
+
+import javax.jcr.PropertyType;
+import javax.jcr.Value;
+import javax.jcr.nodetype.PropertyDef;
+
+/**
+ * TODO
+ */
+public class BasePropertyDef extends BaseItemDef implements PropertyDef {
+
+    /** {@inheritDoc} */
+    public int getRequiredType() {
+        return PropertyType.UNDEFINED;
+    }
+
+    /** {@inheritDoc} */
+    public String[] getValueConstraints() {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    public Value[] getDefaultValues() {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    public boolean isMultiple() {
+        return false;
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/nodetype/BasePropertyDef.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message