jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r161553 [2/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
Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/package.html
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/package.html?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/package.html (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/package.html Fri Apr 15 22:46:17 2005
@@ -0,0 +1,15 @@
+<body>
+General base classes for JCR implementations.
+<p>
+This package contains simple base class implementations of the JCR API
+interfaces. The API methods are implemented either by throwing
+{@link javax.jcr.UnsupportedRepositoryOperationException UnsupportedRepositoryOperationExceptions}
+or
+{@link java.lang.UnsupportedOperationException UnsupportedOperationExceptions},
+or (if possible) by calling other API methods. The implementation mechanism
+of each method is documented using the respective Javadoc comment.
+<p>
+The purpose of this package is to make it easy for JCR implementations
+to implement the JCR API incrementally without creating a large numbers of
+stub methods.
+</body>

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

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratorFactory.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratorFactory.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratorFactory.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.decorator;
+
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.Repository;
+import javax.jcr.Session;
+import javax.jcr.Workspace;
+
+/**
+ * Factory interface for creating decorator instances.
+ * 
+ * @author Jukka Zitting
+ */
+public interface DecoratorFactory {
+
+    /**
+     * Creates a {@link Repository Repository} decorator.
+     *  
+     * @param repository the underlying repository instance
+     * @return decorator for the given repository
+     */
+    public Repository getRepositoryDecorator(Repository repository);
+    
+    /**
+     * Creates a {@link Session Session} decorator. 
+     *  
+     * @param repository the repository decorator 
+     * @param session the underlying session instance
+     * @return decorator for the given session
+     */
+    public Session getSessionDecorator(Repository repository, Session session);
+    
+    public Workspace getWorkspaceDecorator(Session session, Workspace workspace);
+    
+    public Node getNodeDecorator(Session session, Node node);
+    
+    public Property getPropertyDecorator(Session session, Property property);
+    
+    public Item getItemDecorator(Session session, Item item);
+    
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/ItemDecorator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/ItemDecorator.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/ItemDecorator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/ItemDecorator.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,128 @@
+/*
+ * 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.decorator;
+
+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.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.version.VersionException;
+
+/**
+ * TODO
+ */
+public class ItemDecorator implements Item {
+    
+    private DecoratorFactory factory;
+    
+    private Session session;
+    
+    private Item item;
+
+    /**
+     * Returns the decorated session through which this item decorator
+     * was acquired.
+     * 
+     * @return decorated session
+     */
+    public Session getSession() throws RepositoryException {
+        return session;
+    }
+
+    /** {@inheritDoc} */
+    public String getPath() throws RepositoryException {
+        return item.getPath();
+    }
+
+    /** {@inheritDoc} */
+    public String getName() throws RepositoryException {
+        return item.getName();
+    }
+
+    /** {@inheritDoc} */
+    public Item getAncestor(int depth) throws ItemNotFoundException,
+            AccessDeniedException, RepositoryException {
+        Item ancestor = item.getAncestor(depth);
+        return factory.getItemDecorator(session, ancestor);
+    }
+
+    /** {@inheritDoc} */
+    public Node getParent() throws ItemNotFoundException,
+            AccessDeniedException, RepositoryException {
+        Node parent = item.getParent();
+        return factory.getNodeDecorator(session, parent);
+    }
+
+    /** {@inheritDoc} */
+    public int getDepth() throws RepositoryException {
+        return item.getDepth();
+    }
+
+    /** {@inheritDoc} */
+    public boolean isNode() {
+        return item.isNode();
+    }
+
+    /** {@inheritDoc} */
+    public boolean isNew() {
+        return item.isNew();
+    }
+
+    /** {@inheritDoc} */
+    public boolean isModified() {
+        return item.isModified();
+    }
+
+    /** {@inheritDoc} */
+    public boolean isSame(Item otherItem) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    public void accept(ItemVisitor visitor) throws RepositoryException {
+        item.accept(visitor);
+    }
+
+    /** {@inheritDoc} */
+    public void save() throws AccessDeniedException,
+            ConstraintViolationException, InvalidItemStateException,
+            ReferentialIntegrityException, VersionException, LockException,
+            RepositoryException {
+        item.save();
+    }
+
+    /** {@inheritDoc} */
+    public void refresh(boolean keepChanges) throws InvalidItemStateException,
+            RepositoryException {
+        item.refresh(keepChanges);
+    }
+
+    /** {@inheritDoc} */
+    public void remove() throws VersionException, LockException,
+            RepositoryException {
+        item.remove();
+    }
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/RepositoryDecorator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/RepositoryDecorator.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/RepositoryDecorator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/RepositoryDecorator.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,103 @@
+/*
+ * 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.decorator;
+
+import javax.jcr.Credentials;
+import javax.jcr.LoginException;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+/**
+ * Simple {@link Repository Repository} decorator. This class 
+ */
+public class RepositoryDecorator implements Repository {
+
+    private DecoratorFactory factory;
+    
+    private Repository repository;
+    
+    public RepositoryDecorator(
+            DecoratorFactory factory, Repository repository) {
+        this.factory = factory;
+        this.repository = repository;
+    }
+    
+    /**
+     * Forwards the method call to the underlying repository.
+     */
+    public String[] getDescriptorKeys() {
+        return repository.getDescriptorKeys();
+    }
+
+    /**
+     * Forwards the method call to the underlying repository.
+     */
+    public String getDescriptor(String key) {
+        return repository.getDescriptor(key);
+    }
+
+    /**
+     * Forwards the method call to the underlying repository. The returned
+     * session is wrapped into a session decorator using the decorator factory.
+     * 
+     * @return decorated session
+     */
+    public Session login(Credentials credentials, String workspaceName) throws
+            LoginException, NoSuchWorkspaceException, RepositoryException {
+        Session session = repository.login(credentials, workspaceName);
+        return factory.getSessionDecorator(this, session); 
+    }
+
+    /**
+     * Forwards the method call to the underlying repository. The returned
+     * session is wrapped into a session decorator using the decorator factory.
+     * 
+     * @return decorated session
+     */
+    public Session login(Credentials credentials) throws LoginException,
+            NoSuchWorkspaceException, RepositoryException {
+        Session session = repository.login(credentials);
+        return factory.getSessionDecorator(this, session); 
+    }
+
+    /**
+     * Forwards the method call to the underlying repository. The returned
+     * session is wrapped into a session decorator using the decorator factory.
+     * 
+     * @return decorated session
+     */
+    public Session login(String workspaceName) throws LoginException,
+            NoSuchWorkspaceException, RepositoryException {
+        Session session = repository.login(workspaceName);
+        return factory.getSessionDecorator(this, session); 
+    }
+
+    /**
+     * Forwards the method call to the underlying repository. The returned
+     * session is wrapped into a session decorator using the decorator factory.
+     * 
+     * @return decorated session
+     */
+    public Session login() throws LoginException, NoSuchWorkspaceException,
+            RepositoryException {
+        Session session = repository.login();
+        return factory.getSessionDecorator(this, session); 
+    }
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/SessionDecorator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/SessionDecorator.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/SessionDecorator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/SessionDecorator.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,320 @@
+/*
+ * 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.decorator;
+
+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.Property;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Workspace;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.version.VersionException;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+/**
+ * TODO
+ */
+public class SessionDecorator implements Session {
+
+    private DecoratorFactory factory;
+    
+    private Repository repository;
+    
+    private Session session;
+    
+    public SessionDecorator(
+            DecoratorFactory factory, Repository repository, Session session) {
+        this.factory = factory;
+        this.repository = repository;
+        this.session = session;
+    }
+    
+    /** {@inheritDoc} */
+    public Repository getRepository() {
+        return repository;
+    }
+
+    /**
+     * Forwards the method call to the underlying session.
+     */
+    public String getUserId() {
+        return session.getUserId();
+    }
+
+    /**
+     * Forwards the method call to the underlying session.
+     */
+    public Object getAttribute(String name) {
+        return session.getAttribute(name);
+    }
+
+    /**
+     * Forwards the method call to the underlying session.
+     */
+    public String[] getAttributeNames() {
+        return session.getAttributeNames();
+    }
+
+    /**
+     * Forwards the method call to the underlying session. The returned
+     * workspace is wrapped into a workspace decorator using the decorator
+     * factory.
+     * 
+     * @return decorated workspace
+     */
+    public Workspace getWorkspace() {
+        return factory.getWorkspaceDecorator(this, session.getWorkspace());
+    }
+
+    /**
+     * Forwards the method call to the underlying session. The returned
+     * session is wrapped into a session decorator using the decorator factory.
+     * 
+     * @return decorated session
+     */
+    public Session impersonate(Credentials credentials) throws LoginException,
+            RepositoryException {
+        Session newSession = session.impersonate(credentials);
+        return factory.getSessionDecorator(repository, newSession);
+    }
+
+    /**
+     * Forwards the method call to the underlying session. The returned
+     * node is wrapped into a node decorator using the decorator factory.
+     * 
+     * @return decorated node
+     */
+    public Node getRootNode() throws RepositoryException {
+        Node root = session.getRootNode();
+        return factory.getNodeDecorator(session, root);
+    }
+
+    /**
+     * Forwards the method call to the underlying session. The returned
+     * node is wrapped into a node decorator using the decorator factory.
+     * 
+     * @return decorated node
+     */
+    public Node getNodeByUUID(String uuid) throws ItemNotFoundException,
+            RepositoryException {
+        Node node = session.getNodeByUUID(uuid);
+        return factory.getNodeDecorator(session, node);
+    }
+
+    /**
+     * Forwards the method call to the underlying session. The returned
+     * item is wrapped into a node, property, or item decorator using
+     * the decorator factory. The decorator type depends on the type
+     * of the underlying item.
+     * 
+     * @return decorated item, property, or node
+     */
+    public Item getItem(String absPath) throws PathNotFoundException,
+            RepositoryException {
+        Item item = session.getItem(absPath);
+        if (item instanceof Node) {
+            return factory.getNodeDecorator(session, (Node) item);
+        } else if (item instanceof Property) {
+            return factory.getPropertyDecorator(session, (Property) item);
+        } else {
+            return factory.getItemDecorator(session, item);
+        }
+    }
+
+    /**
+     * Forwards the method call to the underlying session.
+     */
+    public boolean itemExists(String path) {
+        return session.itemExists(path);
+    }
+
+    /**
+     * Forwards the method call to the underlying session.
+     */
+    public void move(String srcAbsPath, String destAbsPath) throws
+            ItemExistsException, PathNotFoundException, VersionException,
+            RepositoryException {
+        session.move(srcAbsPath, destAbsPath);
+    }
+
+    /**
+     * Forwards the method call to the underlying session.
+     */
+    public void save() throws AccessDeniedException,
+            ConstraintViolationException, InvalidItemStateException,
+            VersionException, LockException, RepositoryException {
+        session.save();
+    }
+
+    /**
+     * Forwards the method call to the underlying session.
+     */
+    public void refresh(boolean keepChanges) throws RepositoryException {
+        session.refresh(keepChanges);
+    }
+
+    /**
+     * Forwards the method call to the underlying session.
+     */
+    public boolean hasPendingChanges() throws RepositoryException {
+        return session.hasPendingChanges();
+    }
+
+    /**
+     * Forwards the method call to the underlying session.
+     */
+    public void checkPermission(String absPath, String actions)
+            throws AccessControlException {
+        session.checkPermission(absPath, actions);
+    }
+
+    /**
+     * Forwards the method call to the underlying session.
+     */
+    public ContentHandler getImportContentHandler(String parentAbsPath)
+            throws PathNotFoundException, ConstraintViolationException,
+            VersionException, LockException, RepositoryException {
+        return session.getImportContentHandler(parentAbsPath);
+    }
+
+    /**
+     * Forwards the method call to the underlying session.
+     */
+    public void importXML(String parentAbsPath, InputStream in) throws
+            IOException, PathNotFoundException, ItemExistsException,
+            ConstraintViolationException, VersionException,
+            InvalidSerializedDataException, LockException, RepositoryException {
+        session.importXML(parentAbsPath, in);
+    }
+
+    /**
+     * Forwards the method call to the underlying session.
+     */
+    public void exportSysView(String absPath, ContentHandler contentHandler,
+            boolean binaryAsLink, boolean noRecurse) throws
+            PathNotFoundException, SAXException, RepositoryException {
+        session.exportSysView(absPath, contentHandler, binaryAsLink, noRecurse);
+    }
+
+    /**
+     * Forwards the method call to the underlying session.
+     */
+    public void exportSysView(String absPath, OutputStream out,
+            boolean binaryAsLink, boolean noRecurse) throws IOException,
+            PathNotFoundException, RepositoryException {
+        session.exportDocView(absPath, out, binaryAsLink, noRecurse);
+    }
+
+    /**
+     * Forwards the method call to the underlying session.
+     */
+    public void exportDocView(String absPath, ContentHandler contentHandler,
+            boolean binaryAsLink, boolean noRecurse) throws 
+            InvalidSerializedDataException, PathNotFoundException,
+            SAXException, RepositoryException {
+        session.exportDocView(absPath, contentHandler, binaryAsLink, noRecurse);
+    }
+
+    /**
+     * Forwards the method call to the underlying session.
+     */
+    public void exportDocView(String absPath, OutputStream out,
+            boolean binaryAsLink, boolean noRecurse) throws 
+            InvalidSerializedDataException, IOException, PathNotFoundException,
+            RepositoryException {
+        session.exportDocView(absPath, out, binaryAsLink, noRecurse);
+    }
+
+    /**
+     * Forwards the method call to the underlying session.
+     */
+    public void setNamespacePrefix(String prefix, String uri)
+            throws NamespaceException, RepositoryException {
+        session.setNamespacePrefix(prefix, uri);
+    }
+
+    /**
+     * Forwards the method call to the underlying session.
+     */
+    public String[] getNamespacePrefixes() throws RepositoryException {
+        return session.getNamespacePrefixes();
+    }
+
+    /**
+     * Forwards the method call to the underlying session.
+     */
+    public String getNamespaceURI(String prefix) throws NamespaceException,
+            RepositoryException {
+        return session.getNamespacePrefix(prefix);
+    }
+
+    /**
+     * Forwards the method call to the underlying session.
+     */
+    public String getNamespacePrefix(String uri) throws NamespaceException,
+            RepositoryException {
+        return session.getNamespacePrefix(uri);
+    }
+
+    /**
+     * Forwards the method call to the underlying session.
+     */
+    public void logout() {
+        session.logout();
+    }
+
+    /**
+     * Forwards the method call to the underlying session.
+     */
+    public void addLockToken(String lt) {
+        session.addLockToken(lt);
+    }
+
+    /**
+     * Forwards the method call to the underlying session.
+     */
+    public String[] getLockTokens() {
+        return session.getLockTokens();
+    }
+
+    /**
+     * Forwards the method call to the underlying session.
+     */
+    public void removeLockToken(String lt) {
+        session.removeLockToken(lt);
+    }
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/SimpleDecoratorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/SimpleDecoratorFactory.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/SimpleDecoratorFactory.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/SimpleDecoratorFactory.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,67 @@
+/*
+ * 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.decorator;
+
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.Repository;
+import javax.jcr.Session;
+import javax.jcr.Workspace;
+
+/**
+ * TODO
+ */
+public class SimpleDecoratorFactory implements DecoratorFactory {
+
+    /** {@inheritDoc} */
+    public Repository getRepositoryDecorator(Repository repository) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    public Session getSessionDecorator(Repository repository, Session session) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    public Workspace getWorkspaceDecorator(Session session, Workspace workspace) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    public Node getNodeDecorator(Session session, Node node) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    public Property getPropertyDecorator(Session session, Property property) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    public Item getItemDecorator(Session session, Item item) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/WorkspaceDecorator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/WorkspaceDecorator.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/WorkspaceDecorator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/WorkspaceDecorator.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,182 @@
+/*
+ * 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.decorator;
+
+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 org.xml.sax.ContentHandler;
+
+/**
+ * TODO
+ */
+public class WorkspaceDecorator implements Workspace {
+
+    private DecoratorFactory factory;
+    
+    private Session session;
+    
+    private Workspace workspace;
+    
+    public WorkspaceDecorator(
+            DecoratorFactory factory, Session session, Workspace workspace) {
+        this.factory = factory;
+        this.session = session;
+        this.workspace = workspace;
+    }
+
+    
+    /** {@inheritDoc} */
+    public Session getSession() {
+        return session;
+    }
+
+    /**
+     * Forwards the method call to the underlying workspace.
+     */
+    public String getName() {
+        return workspace.getName();
+    }
+
+    /**
+     * Forwards the method call to the underlying workspace.
+     */
+    public void copy(String srcAbsPath, String destAbsPath)
+            throws ConstraintViolationException, VersionException,
+            AccessDeniedException, PathNotFoundException, ItemExistsException,
+            LockException, RepositoryException {
+        workspace.copy(srcAbsPath, destAbsPath);
+    }
+
+    /**
+     * Forwards the method call to the underlying workspace.
+     */
+    public void copy(String srcWorkspace, String srcAbsPath, String destAbsPath)
+            throws NoSuchWorkspaceException, ConstraintViolationException,
+            VersionException, AccessDeniedException, PathNotFoundException,
+            ItemExistsException, LockException, RepositoryException {
+        workspace.copy(srcWorkspace, srcAbsPath, destAbsPath);
+    }
+
+    /**
+     * Forwards the method call to the underlying workspace.
+     */
+    public void clone(String srcWorkspace, String srcAbsPath,
+            String destAbsPath, boolean removeExisting)
+            throws NoSuchWorkspaceException, ConstraintViolationException,
+            VersionException, AccessDeniedException, PathNotFoundException,
+            ItemExistsException, LockException, RepositoryException {
+        workspace.clone(srcWorkspace, srcAbsPath, destAbsPath, removeExisting);
+    }
+
+    /**
+     * Forwards the method call to the underlying workspace.
+     */
+    public void move(String srcAbsPath, String destAbsPath)
+            throws ConstraintViolationException, VersionException,
+            AccessDeniedException, PathNotFoundException, ItemExistsException,
+            LockException, RepositoryException {
+        workspace.move(srcAbsPath, destAbsPath);
+    }
+
+    /**
+     * Forwards the method call to the underlying workspace.
+     */
+    public void restore(Version[] versions, boolean removeExisting)
+            throws ItemExistsException,
+            UnsupportedRepositoryOperationException, VersionException,
+            LockException, InvalidItemStateException, RepositoryException {
+        workspace.restore(versions, removeExisting);
+    }
+
+    /**
+     * Forwards the method call to the underlying workspace.
+     */
+    public QueryManager getQueryManager() throws RepositoryException {
+        return workspace.getQueryManager();
+    }
+
+    /**
+     * Forwards the method call to the underlying workspace.
+     */
+    public NamespaceRegistry getNamespaceRegistry() throws RepositoryException {
+        return workspace.getNamespaceRegistry();
+    }
+
+    /**
+     * Forwards the method call to the underlying workspace.
+     */
+    public NodeTypeManager getNodeTypeManager() throws RepositoryException {
+        return workspace.getNodeTypeManager();
+    }
+
+    /**
+     * Forwards the method call to the underlying workspace.
+     */
+    public ObservationManager getObservationManager() throws
+            UnsupportedRepositoryOperationException, RepositoryException {
+        return workspace.getObservationManager();
+    }
+
+    /**
+     * Forwards the method call to the underlying workspace.
+     */
+    public String[] getAccessibleWorkspaceNames() throws RepositoryException {
+        return workspace.getAccessibleWorkspaceNames();
+    }
+
+    /**
+     * Forwards the method call to the underlying workspace.
+     */
+    public ContentHandler getImportContentHandler(
+            String parentAbsPath, int uuidBehaviour)
+            throws PathNotFoundException, ConstraintViolationException,
+            VersionException, LockException, RepositoryException {
+        return workspace.getImportContentHandler(parentAbsPath, uuidBehaviour);
+    }
+
+    /**
+     * Forwards the method call to the underlying workspace.
+     */
+    public void importXML(
+            String parentAbsPath, InputStream in, int uuidBehaviour)
+            throws IOException, PathNotFoundException, ItemExistsException,
+            ConstraintViolationException, InvalidSerializedDataException,
+            LockException, RepositoryException {
+        workspace.importXML(parentAbsPath, in, uuidBehaviour);
+    }
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/package.html
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/package.html?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/package.html (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/package.html Fri Apr 15 22:46:17 2005
@@ -0,0 +1,69 @@
+<body>
+Generic JCR decorator layer.
+<p>
+This package implements a generic decorator layer for the Content Repository
+for Java technology API (JCR). This layer can be used to add various extra
+functionality and responsibilities to existing JCR implementations without
+having to modify or even access the original source code. The decorator layer
+implemented by this package functions entirely on the JCR API level without
+any dependencies to an underlying implementation.
+<p>
+This decorator layer implements the Decorator design pattern on a package
+level for the entire javax.jcr package. A client only needs to decorate
+a top level Repository instance, and the decorator layer will automatically
+handle the decoration of all Session, Node, and other JCR objects acquired
+using the decorated repository.
+
+<h2>Usage of the decorator layer</h2>
+<p>
+To use the decorator layer, a client should first acquire a Repository
+reference using whatever mechanism supported by the repository implementation
+in use. Then the client needs to create a DecoratorFactory instance and use
+it to decorate the repository. The resulting repository decorator can then
+be used as a normal repository instance. All other decorator instantiation
+will then be handled internally by the decorator layer using the given
+decorator factory.
+<p>
+The following example code illustrates how the decorator layer is instantiated
+and used.
+<pre>
+    // Acquire a repository instance normally
+    Repository repo = ...;
+    
+    // Create the decorator layer
+    DecoratorFactory factory = ...;
+    Repository deco = factory.getRepositoryDecorator(repo);
+    
+    // Use the decorated repository via the normal JCR API
+    Session session = deco.login();
+    Node root = session.getRootNode();
+    Node node = root.getNode(...);
+    Property prop = node.getProperty(...);
+</pre>
+<p>
+The diagram below shows the object instances created by default
+by the above code.
+<p align="center">
+<img src="doc-files/instances.jpg">
+</p>
+
+<h2>Extending the decorator layer</h2>
+<p>
+The Factory design pattern used in the DecoratorFactory interface and the
+default decorator classes makes it easy to extend the functionality of the
+decorator layer. Specific decorator functionality can be added by subclassing
+the default decorators included in this package and providing a custom
+DecoratorFactory that uses these specific decorator classes instead of the
+defaults.
+<p>
+For example, a decorator for mapping user accounts between authentication
+realms could subclass the RepositoryDecorator and SessionDecorator classes
+and override the login() and impersonate() methods with custom functionality.
+The decorator implementation would also provide a customized DecoratorFactory
+for creating a decorator layer that uses the user account mapping
+functionality. The layer can then be wrapped on top of an existing
+repository implementation.
+<p>
+See the org.apache.jackrabbit.cache and org.apache.jackrabbit.trace packages
+for examples of such decorator implementations.
+</body>

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

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/ArrayIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/ArrayIterator.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/ArrayIterator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/ArrayIterator.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,78 @@
+/*
+ * 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.iterator;
+
+import javax.jcr.RangeIterator;
+
+/**
+ * Array implementation of the JCR
+ * {@link javax.jcr.RangeIterator RangeIterator} interface. This class
+ * implements the RangeIterator functionality for an underlying array
+ * of objects. Used as the base class for the type-specific iterator
+ * classes defined in this package.
+ * 
+ * @author Jukka Zitting
+ */
+public class ArrayIterator implements RangeIterator {
+
+    /** The current iterator position. */
+    private int position;
+    
+    /** The underlying array of objects. */
+    private Object[] array;
+    
+    /**
+     * Creates an iterator for the given array of objects.
+     * 
+     * @param array the objects to iterate
+     */
+    public ArrayIterator(Object[] array) {
+        this.position = 0;
+        this.array = array;
+    }
+    
+    /** {@inheritDoc} */
+    public boolean hasNext() {
+        return (position < array.length);
+    }
+
+    /** {@inheritDoc} */
+    public Object next() {
+        return array[position++];
+    }
+
+    /** {@inheritDoc} */
+    public void remove() {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    public void skip(long items) {
+        position += items;
+    }
+
+    /** {@inheritDoc} */
+    public long getSize() {
+        return array.length;
+    }
+
+    /** {@inheritDoc} */
+    public long getPos() {
+        return position;
+    }
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/ArrayNodeIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/ArrayNodeIterator.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/ArrayNodeIterator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/ArrayNodeIterator.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,46 @@
+/*
+ * 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.iterator;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+
+/**
+ * Array implementation of the JCR
+ * {@link javax.jcr.NodeIterator NodeIterator} interface.
+ * This class is used by the JCR-RMI client adapters to convert
+ * node arrays to iterators.
+ * 
+ * @author Jukka Zitting
+ */
+public class ArrayNodeIterator extends ArrayIterator implements NodeIterator {
+    
+    /**
+     * Creates an iterator for the given array of nodes.
+     * 
+     * @param nodes the nodes to iterate
+     */
+    public ArrayNodeIterator(Node[] nodes) {
+        super(nodes);
+    }
+    
+    /** {@inheritDoc} */
+    public Node nextNode() {
+        return (Node) next();
+    }
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/ArrayNodeTypeIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/ArrayNodeTypeIterator.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/ArrayNodeTypeIterator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/ArrayNodeTypeIterator.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,47 @@
+/*
+ * 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.iterator;
+
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NodeTypeIterator;
+
+/**
+ * Array implementation of the JCR
+ * {@link javax.jcr.NodeTypeIterator NodeTypeIterator} interface.
+ * This class is used by the JCR-RMI client adapters to convert
+ * node type arrays to iterators.
+ * 
+ * @author Jukka Zitting
+ */
+public class ArrayNodeTypeIterator extends ArrayIterator implements
+        NodeTypeIterator {
+    
+    /**
+     * Creates an iterator for the given array of node types.
+     * 
+     * @param types the node types to iterate
+     */
+    public ArrayNodeTypeIterator(NodeType[] types) {
+        super(types);
+    }
+
+    /** {@inheritDoc} */
+    public NodeType nextNodeType() {
+        return (NodeType) next();
+    }
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/ArrayPropertyIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/ArrayPropertyIterator.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/ArrayPropertyIterator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/ArrayPropertyIterator.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,47 @@
+/*
+ * 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.iterator;
+
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+
+/**
+ * Array implementation of the JCR
+ * {@link javax.jcr.PropertyIterator PropertyIterator} interface.
+ * This class is used by the JCR-RMI client adapters to convert
+ * property arrays to iterators.
+ * 
+ * @author Jukka Zitting
+ */
+public class ArrayPropertyIterator extends ArrayIterator
+        implements PropertyIterator {
+    
+    /**
+     * Creates an iterator for the given array of properties.
+     * 
+     * @param properties the properties to iterate
+     */
+    public ArrayPropertyIterator(Property[] properties) {
+        super(properties);
+    }
+    
+    /** {@inheritDoc} */
+    public Property nextProperty() {
+        return (Property) next();
+    }
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/package.html
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/package.html?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/package.html (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/iterator/package.html Fri Apr 15 22:46:17 2005
@@ -0,0 +1,7 @@
+<body>
+Utility classes for implementing JCR iterators based on static arrays.
+<p>
+This package contains array-based implementations of the JCR
+{@link javax.jcr.RangeIterator RangeIterator} interfaces.
+This package depends only on the standard JCR and J2SE APIs.
+</body>

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

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteItem.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteItem.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteItem.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteItem.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,97 @@
+/*
+ * 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.lite;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.Item;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.Node;
+import javax.jcr.ReferentialIntegrityException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.version.VersionException;
+
+import org.apache.jackrabbit.base.BaseItem;
+import org.apache.jackrabbit.name.Name;
+
+/**
+ * TODO
+ */
+public class LiteItem extends BaseItem {
+
+    private final Session session;
+
+    private final Node parent;
+
+    private final Name name;
+
+    protected LiteItem(Session session, Node parent, Name name) {
+        this.session = session;
+        this.parent = parent;
+        this.name = name;
+    }
+
+    public Session getSession() throws RepositoryException {
+        return session;
+    }
+
+    public String getName() throws RepositoryException {
+        return name.toJCRName(getSession());
+    }
+
+    public Node getParent() throws ItemNotFoundException,
+            AccessDeniedException, RepositoryException {
+        return parent;
+    }
+
+    public boolean isModified() {
+        return false;
+    }
+
+    public boolean isNew() {
+        return false;
+    }
+
+    public boolean isSame(Item otherItem) {
+        try {
+            return getPath().equals(otherItem.getPath());
+        } catch (RepositoryException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public void refresh(boolean keepChanges) throws InvalidItemStateException,
+            RepositoryException {
+        // do nothing
+    }
+
+    public void remove() throws VersionException, LockException,
+            RepositoryException {
+        // do nothing
+    }
+
+    public void save() throws AccessDeniedException,
+            ConstraintViolationException, InvalidItemStateException,
+            ReferentialIntegrityException, VersionException, LockException,
+            RepositoryException {
+        // do nothing
+    }
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteNamedNode.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteNamedNode.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteNamedNode.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteNamedNode.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,53 @@
+/*
+ * 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.lite;
+
+import javax.jcr.NamespaceException;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeDef;
+import javax.jcr.nodetype.NodeType;
+
+import org.apache.jackrabbit.name.Name;
+
+/**
+ * TODO
+ */
+public class LiteNamedNode extends LiteNode {
+
+    private final Node parent;
+
+    private final Name name;
+
+    public LiteNamedNode(
+            Session session, Node parent, Name name,
+            NodeDef definition, NodeType type) {
+        super(session, definition, type);
+        this.parent = parent;
+        this.name = name;
+    }
+
+    public String getName() throws RepositoryException {
+        return name.toJCRName(getSession());
+    }
+
+    public Node getParent() {
+        return parent;
+    }
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteNamespaceRegistry.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteNamespaceRegistry.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteNamespaceRegistry.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteNamespaceRegistry.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,111 @@
+/*
+ * 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.lite;
+
+import java.util.Properties;
+
+import javax.jcr.NamespaceException;
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.base.BaseNamespaceRegistry;
+
+/**
+ * TODO
+ */
+public class LiteNamespaceRegistry extends BaseNamespaceRegistry {
+
+    /** Mapping from registered namespace prefixes to URIs. */
+    private final Properties prefixToURI;
+
+    /** Mapping from registered namespace URIs to prefixes. */
+    private final Properties uriToPrefix;
+
+    public LiteNamespaceRegistry() {
+        this.prefixToURI = new Properties();
+        this.uriToPrefix = new Properties();
+
+        setNamespace("jcr", "http://www.jcp.org/jcr/1.0");
+        setNamespace("nt", "http://www.jcp.org/jcr/nt/1.0");
+        setNamespace("mix", "http://www.jcp.org/jcr/mix/1.0");
+        setNamespace("sv", "http://www.jcp.org/jcr/sv/1.0");
+        setNamespace("", "");
+    }
+
+    protected void setNamespace(String prefix, String uri) {
+        prefixToURI.setProperty(prefix, uri);
+        uriToPrefix.setProperty(uri, prefix);
+    }
+
+    /**
+     * Returns the namespace prefix associated with the given URI.
+     *
+     * @param uri namespace URI
+     * @return namespace prefix
+     * @throws NamespaceException if the namespace is not registered
+     * @throws RepositoryException on repository errors
+     */
+    public String getPrefix(String uri) throws NamespaceException,
+            RepositoryException {
+        String prefix = uriToPrefix.getProperty(uri);
+        if (prefix != null) {
+            return prefix;
+        } else {
+            throw new NamespaceException(
+                    "Namespace URI " + uri + " is not registered");
+        }
+    }
+
+    /**
+     * Returns the namespace URI associated with the given prefix.
+     *
+     * @param prefix namespace prefix
+     * @return namespace URI
+     * @throws NamespaceException if the namespace is not registered
+     * @throws RepositoryException on repository errors
+     */
+    public String getURI(String prefix) throws NamespaceException,
+            RepositoryException {
+        String uri = prefixToURI.getProperty(prefix);
+        if (uri != null) {
+            return uri;
+        } else {
+            throw new NamespaceException(
+                    "Namespace prefix " + prefix + " is not registered");
+        }
+    }
+
+    /**
+     * Returns the registered namespace prefixes.
+     *
+     * @return namespace prefixes
+     * @throws RepositoryException on repository errors
+     */
+    public String[] getPrefixes() throws RepositoryException {
+        return (String[]) prefixToURI.keySet().toArray(new String[0]);
+    }
+
+    /**
+     * Returns the registered namespace URIs.
+     *
+     * @return namespace URIs
+     * @throws RepositoryException on repository errors
+     */
+    public String[] getURIs() throws RepositoryException {
+        return (String[]) uriToPrefix.keySet().toArray(new String[0]);
+    }
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteNode.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteNode.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteNode.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteNode.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,72 @@
+/*
+ * 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.lite;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeDef;
+import javax.jcr.nodetype.NodeType;
+
+import org.apache.jackrabbit.base.BaseNode;
+import org.apache.jackrabbit.iterator.ArrayNodeIterator;
+import org.apache.jackrabbit.iterator.ArrayPropertyIterator;
+
+/**
+ * TODO
+ */
+public class LiteNode extends BaseNode {
+
+    private final Session session;
+
+    private final NodeDef definition;
+
+    private final NodeType type;
+
+    protected LiteNode(Session session, NodeDef definition, NodeType type) {
+        this.session = session;
+        this.definition = definition;
+        this.type = type;
+    }
+
+    public Session getSession() {
+        return session;
+    }
+
+    public int getIndex() throws RepositoryException {
+        return 1;
+    }
+    
+    public NodeIterator getNodes() throws RepositoryException {
+        return new ArrayNodeIterator(new Node[0]);
+    }
+
+    public PropertyIterator getProperties() throws RepositoryException {
+        return new ArrayPropertyIterator(new Property[0]);
+    }
+
+    public NodeDef getDefinition() throws RepositoryException {
+        return definition;
+    }
+
+    public NodeType getPrimaryNodeType() throws RepositoryException {
+        return type;
+    }
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteProperty.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteProperty.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteProperty.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,88 @@
+/*
+ * 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.lite;
+
+import javax.jcr.Item;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.PropertyDef;
+import javax.jcr.version.VersionException;
+
+import org.apache.jackrabbit.base.BaseProperty;
+
+/**
+ * TODO
+ */
+public class LiteProperty extends BaseProperty {
+
+    private Value value;
+
+    private Value[] values;
+
+    private final PropertyDef definition;
+
+    protected LiteProperty(Item item, Value value, PropertyDef definition) {
+        super(item);
+        this.value = value;
+        this.values = null;
+        this.definition = definition;
+    }
+
+    protected LiteProperty(Item item, Value[] values, PropertyDef definition) {
+        super(item);
+        this.value = null;
+        this.values = values;
+        this.definition = definition;
+    }
+
+    public Value getValue() throws ValueFormatException, RepositoryException {
+        if (value != null) {
+            return value;
+        } else {
+            throw new ValueFormatException("This property is multi-valued");
+        }
+    }
+
+    public Value[] getValues() throws ValueFormatException, RepositoryException {
+        if (values != null) {
+            return values;
+        } else {
+            throw new ValueFormatException("This property is not multi-valued");
+        }
+    }
+
+    public void setValue(Value value) throws ValueFormatException,
+            VersionException, LockException, RepositoryException {
+        if (value != null) {
+            this.value = value;
+        } else {
+            throw new ValueFormatException("This property is multi-valued");
+        }
+    }
+
+    public void setValue(Value[] values) throws ValueFormatException,
+            VersionException, LockException, RepositoryException {
+        if (values != null) {
+            this.values = values;
+        } else {
+            throw new ValueFormatException("This property is not multi-valued");
+        }
+    }
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteRepository.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteRepository.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteRepository.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteRepository.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,96 @@
+/*
+ * 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.lite;
+
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Properties;
+
+import org.apache.jackrabbit.base.BaseRepository;
+
+/**
+ * Lightweight implementation of the JCR Repository interface.
+ * <p>
+ * The repository descriptors are managed as a private property
+ * collection that subclasses can modify using the protected
+ * {@link #setDescriptor(String, String) setDescriptor} method.
+ * <p>
+ * A subclass needs to also implement the login method to make
+ * this class useful.
+ */
+public class LiteRepository extends BaseRepository {
+
+    /** Repository descriptors. */
+    private final Properties descriptors;
+
+    /**
+     * Initializes the repository by adding the standard repository
+     * descriptors. The constructor is protected to signify that
+     * this class needs to be subclassed to be of any real use.
+     */
+    protected LiteRepository() {
+        descriptors = new Properties();
+
+        // JCR specification information
+        setDescriptor(SPEC_NAME_DESC,
+                "Content Repository API for Java(TM) Technology Specification");
+        setDescriptor(SPEC_VERSION_DESC, "0.16.2");
+
+        // addDescriptor(LEVEL_1_SUPPORTED, "true"); // TODO required!
+        // addDescriptor(LEVEL_2_SUPPORTED, "true");
+        // addDescriptor(OPTION_LOCKING_SUPPORTED, "true");
+        // addDescriptor(OPTION_OBSERVATION_SUPPORTED, "true");
+        // addDescriptor(OPTION_QUERY_SQL_SUPPORTED, "true");
+        // addDescriptor(OPTION_TRANSACTIONS_SUPPORTED, "true");
+        // addDescriptor(OPTION_VERSIONING_SUPPORTED, "true");
+        // addDescriptor(QUERY_JCRPATH, "true");
+        // addDescriptor(QUERY_JCRSCORE, "true");
+        // addDescriptor(QUERY_XPATH_DOC_ORDER, "true");
+        // addDescriptor(QUERY_XPATH_POS_INDEX, "true");
+    }
+
+    /**
+     * Adds a repository descriptor.
+     *
+     * @param key descriptor key
+     * @param value descriptor value
+     */
+    protected void setDescriptor(String key, String value) {
+        descriptors.setProperty(key, value);
+    }
+
+    /**
+     * Returns the value of the identified repository descriptor.
+     *
+     * @param key descriptor key
+     * @return descriptor value
+     */
+    public String getDescriptor(String key) {
+        return descriptors.getProperty(key);
+    }
+
+    /**
+     * Returns the repository descriptor keys.
+     *
+     * @return descriptor keys
+     */
+    public String[] getDescriptorKeys() {
+        Enumeration keys = descriptors.propertyNames();
+        return (String[]) Collections.list(keys).toArray(new String[0]);
+    }
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteRootNode.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteRootNode.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteRootNode.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteRootNode.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,113 @@
+/*
+ * 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.lite;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.Item;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.version.VersionException;
+
+import org.apache.jackrabbit.lite.nodetype.LiteNodeDef;
+
+/**
+ * TODO
+ */
+public class LiteRootNode extends LiteNode {
+
+    protected LiteRootNode(Session session) {
+        super(session,
+                new LiteNodeDef(session, null, null, 0, false, false, false),
+                null);
+    }
+
+    
+    public void addMixin(String mixinName) throws NoSuchNodeTypeException,
+            VersionException, ConstraintViolationException, LockException,
+            RepositoryException {
+        throw new ConstraintViolationException(
+                "Unable to change root node type");
+    }
+
+    public boolean canAddMixin(String mixinName) throws RepositoryException {
+        return false;
+    }
+
+    public String getName() throws RepositoryException {
+        return "";
+    }
+
+    public String getPath() throws RepositoryException {
+        return "/";
+    }
+
+
+    public int getDepth() throws RepositoryException {
+        return 0;
+    }
+
+    public Node getParent() throws ItemNotFoundException,
+            AccessDeniedException, RepositoryException {
+        throw new ItemNotFoundException("The root node has no parent");
+    }
+
+    public boolean hasProperties() throws RepositoryException {
+        return false;
+    }
+
+    public void removeMixin(String mixinName) throws NoSuchNodeTypeException,
+            VersionException, ConstraintViolationException, LockException,
+            RepositoryException {
+        throw new RepositoryException("The root node is not modifiable");
+    }
+
+    public Property setProperty(String name, Value value)
+            throws ValueFormatException, VersionException, LockException,
+            RepositoryException {
+        throw new RepositoryException("The root node is not modifiable");
+    }
+
+    public Property setProperty(String name, Value[] values, int type)
+            throws ValueFormatException, VersionException, LockException,
+            RepositoryException {
+        throw new RepositoryException("The root node is not modifiable");
+    }
+
+    public Property setProperty(String name, Value[] values)
+            throws ValueFormatException, VersionException, LockException,
+            RepositoryException {
+        throw new RepositoryException("The root node is not modifiable");
+    }
+
+    public Item getAncestor(int depth) throws ItemNotFoundException,
+            AccessDeniedException, RepositoryException {
+        if (depth == 0) {
+            return this;
+        } else {
+            throw new ItemNotFoundException("Invalid ancestor depth " + depth);
+        }
+    }
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteRootNodeType.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteRootNodeType.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteRootNodeType.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteRootNodeType.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,26 @@
+/*
+ * 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.lite;
+
+import org.apache.jackrabbit.base.nodetype.BaseNodeType;
+
+/**
+ * TODO
+ */
+public class LiteRootNodeType extends BaseNodeType {
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteSession.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteSession.java?view=auto&rev=161553
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteSession.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/lite/LiteSession.java Fri Apr 15 22:46:17 2005
@@ -0,0 +1,282 @@
+/*
+ * 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.lite;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.jcr.InvalidSerializedDataException;
+import javax.jcr.Item;
+import javax.jcr.NamespaceException;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.version.VersionException;
+
+import org.apache.jackrabbit.base.BaseSession;
+import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.xml.DocumentViewExportVisitor;
+import org.apache.jackrabbit.xml.SystemViewExportVisitor;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+/**
+ * Lightweight implementation of the JCR Session interface.
+ * <p>
+ * The session attributes are managed as a private hash map
+ * that subclasses can modify using the protected
+ * {@link #addAttribute(String, Object) addAttribute} method.
+ * <p>
+ * The session namespace mappings are managed using two property
+ * mappings (one for prefixes, the other for URIs). If a namespace
+ * mapping is not registered in the session, then it is looked up
+ * using the namespace registry given by
+ * <code>getWorkspace().getNamespaceRegistry()</code>.
+ */
+public class LiteSession extends BaseSession {
+
+    /** The content repository associated with this session. */
+    private final Repository repository;
+
+    /** The user id associated with this session. */
+    private final String userId;
+
+    /** Session attributes. */
+    private final Map attributes;
+
+    /** The namespace prefix to URI mappings of this session. */
+    private final Properties prefixToURI;
+
+    /** The namespace URI to prefix mappings of this session. */
+    private final Properties uriToPrefix;
+
+    /**
+     * Initializes a session. The constructor is protected to signify
+     * that this class needs to be subclassed to be of any real use.
+     *
+     * @param repository the content repository associated with this session
+     * @param userId the user id associated with this session
+     */
+    protected LiteSession(Repository repository, String userId) {
+        this.repository = repository;
+        this.userId = userId;
+        this.attributes = new HashMap();
+        this.prefixToURI = new Properties();
+        this.uriToPrefix = new Properties();
+    }
+
+    /**
+     * Returns the content repository associated with this session.
+     *
+     * @return content repository
+     */
+    public Repository getRepository() {
+        return repository;
+    }
+
+    /**
+     * Returns the user id associated with this session.
+     *
+     * @return user id
+     */
+    public String getUserId() {
+        return userId;
+    }
+
+    /**
+     * Adds a session attribute.
+     *
+     * @param name attribute name
+     * @param value attribute value
+     */
+    protected void addAttribute(String name, Object value) {
+        attributes.put(name, value);
+    }
+
+    /**
+     * Returns the value of the identified session attribute.
+     *
+     * @param name attribute name
+     * @return attribute value
+     */
+    public Object getAttribute(String name) {
+        return attributes.get(name);
+    }
+
+    /**
+     * Returns the names of available session attributes.
+     *
+     * @return session attribute names
+     */
+    public String[] getAttributeNames() {
+        return (String[]) attributes.keySet().toArray(new String[0]);
+    }
+
+    public Item getItem(String absPath) throws PathNotFoundException,
+            RepositoryException {
+        Path path = Path.parseJCRPath(this, absPath);
+        return path.walk(getRootNode());
+    }
+
+    /**
+     * Returns the prefix that is mapped to the given namespace URI.
+     * Implemented by first looking up the local session namespaces and
+     * then the workspace namespace registry given by
+     * <code>getWorkspace().getNamespaceRegistry()</code>.
+     *
+     * @param uri namespace URI
+     * @return namespace prefix
+     * @throws NamespaceException if the namespace is not registred
+     * @throws RepositoryException on repository errors
+     */
+    public String getNamespacePrefix(String uri) throws NamespaceException,
+            RepositoryException {
+        String prefix = uriToPrefix.getProperty(uri);
+        if (prefix != null) {
+            return prefix;
+        } else {
+            return getWorkspace().getNamespaceRegistry().getPrefix(uri);
+        }
+    }
+
+    /**
+     * Returns the URI that is mapped to the given namespace prefix.
+     * Implemented by first looking up the local session namespaces and
+     * then the workspace namespace registry given by
+     * <code>getWorkspace().getNamespaceRegistry()</code>.
+     *
+     * @param prefix namespace prefix
+     * @return namespace URI
+     * @throws NamespaceException if the namespace is not registred
+     * @throws RepositoryException on repository errors
+     */
+    public String getNamespaceURI(String prefix) throws NamespaceException,
+            RepositoryException {
+        String uri = uriToPrefix.getProperty(prefix);
+        if (uri != null) {
+            return uri;
+        } else {
+            return getWorkspace().getNamespaceRegistry().getURI(prefix);
+        }
+    }
+
+    /**
+     * Returns all namespace prefixes of this session. Implemented by
+     * combining the namespace prefixes returned by
+     * <code>getWorkspace().getNamespaceRegistry().getPrefixes()</code>
+     * with the local session namespace prefixes.
+     *
+     * @return namespace prefixes
+     * @throws RepositoryException on repository errors
+     */
+    public String[] getNamespacePrefixes() throws RepositoryException {
+        Set prefixes = new HashSet();
+        prefixes.addAll(Arrays.asList(
+                getWorkspace().getNamespaceRegistry().getPrefixes()));
+        prefixes.addAll(prefixToURI.keySet());
+        return (String[]) prefixes.toArray(new String[0]);
+    }
+
+    /**
+     * Registers the given namespace with a new prefix during this session.
+     * The given namespace URI must already be registered in the workspace
+     * and no other namespace must already be registered for the same
+     * prefix.
+     *
+     * @param prefix namespace prefix
+     * @param uri namespace URI
+     * @throws NamespaceException if the URI is not registered in workspace,
+     *                            if the prefix is already registered to
+     *                            another namespace URI, or if the prefix
+     *                            is reserved
+     * @throws RepositoryException on repository errors
+     */
+    public void setNamespacePrefix(String prefix, String uri)
+            throws NamespaceException, RepositoryException {
+        if (prefix.length() >= 3
+                && prefix.substring(0, 3).equalsIgnoreCase("xml")) {
+            throw new NamespaceException(
+                    "Unable to register the reserved prefix " + prefix);
+        } else {
+            NamespaceRegistry registry = getWorkspace().getNamespaceRegistry();
+            String registeredPrefix = registry.getPrefix(uri);
+            if (!registeredPrefix.equals(prefix)) {
+                try {
+                    registry.getURI(prefix);
+                } catch (NamespaceException e) {
+                    // Prefix not already registered, register for session
+                    prefixToURI.setProperty(prefix, uri);
+                    uriToPrefix.setProperty(uri, prefix);
+                    return;
+                }
+                throw new NamespaceException(
+                        "Prefix " + prefix + " is already registered");
+            }
+        }
+    }
+
+    /**
+     * Serialized the identified subtree using the document view XML format.
+     * Implemented using the
+     * {@link DocumentViewExportVisitor DocumentViewExportVisitor} class.
+     * {@inheritDoc}
+     */
+    public void exportDocView(String absPath, ContentHandler contentHandler,
+            boolean skipBinary, boolean noRecurse)
+            throws InvalidSerializedDataException, PathNotFoundException,
+            SAXException, RepositoryException {
+        Item item = getItem(absPath);
+        if (item.isNode()) {
+            item.accept(new DocumentViewExportVisitor(
+                    contentHandler, skipBinary, noRecurse));
+        } else {
+            throw new PathNotFoundException("Invalid node path " + absPath);
+        }
+    }
+
+    /**
+     * Serialized the identified subtree using the system view XML format.
+     * Implemented using the
+     * {@link SystemViewExportVisitor SystemViewExportVisitor} class.
+     * {@inheritDoc}
+     */
+    public void exportSysView(String absPath, ContentHandler contentHandler,
+            boolean skipBinary, boolean noRecurse)
+            throws PathNotFoundException, SAXException, RepositoryException {
+        Item item = getItem(absPath);
+        if (item.isNode()) {
+            item.accept(new SystemViewExportVisitor(
+                    contentHandler, skipBinary, noRecurse));
+        } else {
+            throw new PathNotFoundException("Invalid node path " + absPath);
+        }
+    }
+
+    public ContentHandler getImportContentHandler(String parentAbsPath)
+            throws PathNotFoundException, ConstraintViolationException,
+            VersionException, LockException, RepositoryException {
+        // TODO Auto-generated method stub
+        return super.getImportContentHandler(parentAbsPath);
+    }
+}

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



Mime
View raw message