Author: jverhaeg(a)redhat.com
Date: 2008-08-08 17:11:12 -0400 (Fri, 08 Aug 2008)
New Revision: 405
Added:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrProperty.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/GraphTools.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrExecutionContext.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNamespaceRegistry.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNode.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrProperty.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRootNode.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrWorkspace.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrNodeTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrPropertyTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNamespaceRegistryTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNodeTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrPropertyTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRepositoryTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRootNodeTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java
Removed:
trunk/dna-jcr/.settings/
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaNamespaceRegistry.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaRepository.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaSession.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaWorkspace.java
Modified:
trunk/dna-jcr/pom.xml
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java
trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties
Log:
DNA-178: Completed basic functionality up to retrieving a skeleton root node.
Modified: trunk/dna-jcr/pom.xml
===================================================================
--- trunk/dna-jcr/pom.xml 2008-08-08 20:43:42 UTC (rev 404)
+++ trunk/dna-jcr/pom.xml 2008-08-08 21:11:12 UTC (rev 405)
@@ -46,12 +46,14 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-library</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
- <scope>test</scope>
</dependency>
<!--
Logging (require SLF4J API for compiling, but use Log4J and its SLF4J binding for
testing)
Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java
(rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java 2008-08-08 21:11:12
UTC (rev 405)
@@ -0,0 +1,717 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import java.io.InputStream;
+import java.util.Calendar;
+import java.util.HashSet;
+import java.util.Set;
+import javax.jcr.Item;
+import javax.jcr.ItemVisitor;
+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.Value;
+import javax.jcr.lock.Lock;
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionHistory;
+import net.jcip.annotations.NotThreadSafe;
+import org.jboss.dna.common.util.ArgCheck;
+
+/**
+ * @author jverhaeg
+ */
+@NotThreadSafe
+abstract class AbstractJcrNode implements Node {
+
+ private final Session session;
+ private final Set<Property> properties;
+
+ AbstractJcrNode( Session session,
+ Set<Property> properties ) {
+ assert session != null;
+ this.session = session;
+ this.properties = (properties == null ? new HashSet<Property>() :
properties);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#accept(javax.jcr.ItemVisitor)
+ */
+ public void accept( ItemVisitor visitor ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#addMixin(java.lang.String)
+ */
+ public void addMixin( String mixinName ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#addNode(java.lang.String)
+ */
+ public Node addNode( String relPath ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#addNode(java.lang.String, java.lang.String)
+ */
+ public Node addNode( String relPath,
+ String primaryNodeTypeName ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#canAddMixin(java.lang.String)
+ */
+ public boolean canAddMixin( String mixinName ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#cancelMerge(javax.jcr.version.Version)
+ */
+ public void cancelMerge( Version version ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#checkin()
+ */
+ public Version checkin() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#checkout()
+ */
+ public void checkout() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#doneMerge(javax.jcr.version.Version)
+ */
+ public void doneMerge( Version version ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#getAncestor(int)
+ */
+ public Item getAncestor( int depth ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#getBaseVersion()
+ */
+ public Version getBaseVersion() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#getCorrespondingNodePath(java.lang.String)
+ */
+ public String getCorrespondingNodePath( String workspaceName ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#getDefinition()
+ */
+ public NodeDefinition getDefinition() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#getDepth()
+ */
+ public int getDepth() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#getIndex()
+ */
+ public int getIndex() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#getLock()
+ */
+ public Lock getLock() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#getMixinNodeTypes()
+ */
+ public NodeType[] getMixinNodeTypes() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#getNode(java.lang.String)
+ */
+ public Node getNode( String relPath ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#getNodes()
+ */
+ public NodeIterator getNodes() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#getNodes(java.lang.String)
+ */
+ public NodeIterator getNodes( String namePattern ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#getPath()
+ */
+ public String getPath() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#getPrimaryItem()
+ */
+ public Item getPrimaryItem() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#getPrimaryNodeType()
+ */
+ public NodeType getPrimaryNodeType() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#getProperties()
+ */
+ public PropertyIterator getProperties() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#getProperties(java.lang.String)
+ */
+ public PropertyIterator getProperties( String namePattern ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#getProperty(java.lang.String)
+ */
+ public Property getProperty( String relativePath ) throws RepositoryException {
+ ArgCheck.isNotEmpty(relativePath, "relativePath");
+ // TODO: Handle multi-segment paths
+ for (Property property : properties) {
+ if (relativePath.equals(property.getName())) {
+ return property;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#getReferences()
+ */
+ public PropertyIterator getReferences() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#getSession()
+ */
+ public Session getSession() {
+ return session;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#getUUID()
+ */
+ public String getUUID() throws RepositoryException {
+ // TODO: Check if node is referenceable
+ Property prop = getProperty("jcr:uuid");
+ return (prop == null ? null : prop.getValue().getString());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#getVersionHistory()
+ */
+ public VersionHistory getVersionHistory() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#hasNode(java.lang.String)
+ */
+ public boolean hasNode( String relPath ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#hasNodes()
+ */
+ public boolean hasNodes() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#hasProperties()
+ */
+ public boolean hasProperties() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#hasProperty(java.lang.String)
+ */
+ public boolean hasProperty( String relPath ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#holdsLock()
+ */
+ public boolean holdsLock() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#isCheckedOut()
+ */
+ public boolean isCheckedOut() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#isLocked()
+ */
+ public boolean isLocked() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#isModified()
+ */
+ public boolean isModified() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#isNew()
+ */
+ public boolean isNew() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#isNode()
+ */
+ public boolean isNode() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#isNodeType(java.lang.String)
+ */
+ public boolean isNodeType( String nodeTypeName ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#isSame(javax.jcr.Item)
+ */
+ public boolean isSame( Item otherItem ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#lock(boolean, boolean)
+ */
+ public Lock lock( boolean isDeep,
+ boolean isSessionScoped ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#merge(java.lang.String, boolean)
+ */
+ public NodeIterator merge( String srcWorkspace,
+ boolean bestEffort ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#orderBefore(java.lang.String, java.lang.String)
+ */
+ public void orderBefore( String srcChildRelPath,
+ String destChildRelPath ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#refresh(boolean)
+ */
+ public void refresh( boolean keepChanges ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#remove()
+ */
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#removeMixin(java.lang.String)
+ */
+ public void removeMixin( String mixinName ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#restore(java.lang.String, boolean)
+ */
+ public void restore( String versionName,
+ boolean removeExisting ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#restore(javax.jcr.version.Version, boolean)
+ */
+ public void restore( Version version,
+ boolean removeExisting ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#restore(javax.jcr.version.Version, java.lang.String, boolean)
+ */
+ public void restore( Version version,
+ String relPath,
+ boolean removeExisting ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#restoreByLabel(java.lang.String, boolean)
+ */
+ public void restoreByLabel( String versionLabel,
+ boolean removeExisting ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#save()
+ */
+ public void save() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#setProperty(java.lang.String, boolean)
+ */
+ public Property setProperty( String name,
+ boolean value ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#setProperty(java.lang.String, java.util.Calendar)
+ */
+ public Property setProperty( String name,
+ Calendar value ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#setProperty(java.lang.String, double)
+ */
+ public Property setProperty( String name,
+ double value ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#setProperty(java.lang.String, java.io.InputStream)
+ */
+ public Property setProperty( String name,
+ InputStream value ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#setProperty(java.lang.String, long)
+ */
+ public Property setProperty( String name,
+ long value ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#setProperty(java.lang.String, javax.jcr.Node)
+ */
+ public Property setProperty( String name,
+ Node value ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#setProperty(java.lang.String, java.lang.String)
+ */
+ public Property setProperty( String name,
+ String value ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#setProperty(java.lang.String, java.lang.String, int)
+ */
+ public Property setProperty( String name,
+ String value,
+ int type ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#setProperty(java.lang.String, java.lang.String[])
+ */
+ public Property setProperty( String name,
+ String[] values ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#setProperty(java.lang.String, java.lang.String[], int)
+ */
+ public Property setProperty( String name,
+ String[] values,
+ int type ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#setProperty(java.lang.String, javax.jcr.Value)
+ */
+ public Property setProperty( String name,
+ Value value ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#setProperty(java.lang.String, javax.jcr.Value, int)
+ */
+ public Property setProperty( String name,
+ Value value,
+ int type ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#setProperty(java.lang.String, javax.jcr.Value[])
+ */
+ public Property setProperty( String name,
+ Value[] values ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#setProperty(java.lang.String, javax.jcr.Value[], int)
+ */
+ public Property setProperty( String name,
+ Value[] values,
+ int type ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#unlock()
+ */
+ public void unlock() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#update(java.lang.String)
+ */
+ public void update( String srcWorkspaceName ) {
+ throw new UnsupportedOperationException();
+ }
+}
Property changes on: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrProperty.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrProperty.java
(rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrProperty.java 2008-08-08
21:11:12 UTC (rev 405)
@@ -0,0 +1,375 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import java.io.InputStream;
+import java.util.Calendar;
+import javax.jcr.Item;
+import javax.jcr.ItemVisitor;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.Session;
+import javax.jcr.Value;
+import javax.jcr.nodetype.PropertyDefinition;
+import net.jcip.annotations.NotThreadSafe;
+
+/**
+ * @author jverhaeg
+ */
+@NotThreadSafe
+abstract class AbstractJcrProperty implements Property {
+
+ private final Session session;
+ private final String name;
+
+ AbstractJcrProperty( Session session,
+ String name ) {
+ assert session != null;
+ this.session = session;
+ assert name != null && name.length() > 0;
+ this.name = name;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Property#getDate()
+ */
+ public Calendar getDate() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Property#getDefinition()
+ */
+ public PropertyDefinition getDefinition() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Property#getDouble()
+ */
+ public double getDouble() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Property#getLength()
+ */
+ public long getLength() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Property#getLengths()
+ */
+ public long[] getLengths() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Property#getLong()
+ */
+ public long getLong() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Property#getNode()
+ */
+ public Node getNode() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Property#getStream()
+ */
+ public InputStream getStream() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Property#getString()
+ */
+ public String getString() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Property#getType()
+ */
+ public int getType() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Property#getValue()
+ */
+ public Value getValue() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Property#getValues()
+ */
+ public Value[] getValues() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Property#setValue(javax.jcr.Value)
+ */
+ public void setValue( Value value ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Property#setValue(javax.jcr.Value[])
+ */
+ public void setValue( Value[] values ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Property#setValue(java.lang.String)
+ */
+ public void setValue( String value ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Property#setValue(java.lang.String[])
+ */
+ public void setValue( String[] values ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Property#setValue(java.io.InputStream)
+ */
+ public void setValue( InputStream value ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Property#setValue(long)
+ */
+ public void setValue( long value ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Property#setValue(double)
+ */
+ public void setValue( double value ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Property#setValue(java.util.Calendar)
+ */
+ public void setValue( Calendar value ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Property#setValue(boolean)
+ */
+ public void setValue( boolean value ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Property#setValue(javax.jcr.Node)
+ */
+ public void setValue( Node value ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#accept(javax.jcr.ItemVisitor)
+ */
+ public void accept( ItemVisitor visitor ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#getAncestor(int)
+ */
+ public Item getAncestor( int depth ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#getDepth()
+ */
+ public int getDepth() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#getParent()
+ */
+ public Node getParent() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#getPath()
+ */
+ public String getPath() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#getSession()
+ */
+ public Session getSession() {
+ return session;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#isModified()
+ */
+ public boolean isModified() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#isNew()
+ */
+ public boolean isNew() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#isNode()
+ */
+ public boolean isNode() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#isSame(javax.jcr.Item)
+ */
+ public boolean isSame( Item otherItem ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#refresh(boolean)
+ */
+ public void refresh( boolean keepChanges ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#remove()
+ */
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#save()
+ */
+ public void save() {
+ throw new UnsupportedOperationException();
+ }
+}
Property changes on:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrProperty.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaNamespaceRegistry.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaNamespaceRegistry.java 2008-08-08
20:43:42 UTC (rev 404)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaNamespaceRegistry.java 2008-08-08
21:11:12 UTC (rev 405)
@@ -1,83 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.dna.jcr;
-
-import javax.jcr.AccessDeniedException;
-import javax.jcr.NamespaceException;
-import javax.jcr.NamespaceRegistry;
-import javax.jcr.RepositoryException;
-import javax.jcr.UnsupportedRepositoryOperationException;
-
-
-/**
- *
- * @author Randall Hauch
- */
-public class DnaNamespaceRegistry implements NamespaceRegistry {
-
- /**
- *
- */
- public DnaNamespaceRegistry() {
- }
-
- /**
- * {@inheritDoc}
- */
- public String getPrefix( String uri ) throws NamespaceException, RepositoryException
{
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public String[] getPrefixes() throws RepositoryException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getURI( String prefix ) throws NamespaceException, RepositoryException
{
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public String[] getURIs() throws RepositoryException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public void registerNamespace( String prefix, String uri ) throws NamespaceException,
UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException {
- }
-
- /**
- * {@inheritDoc}
- */
- public void unregisterNamespace( String prefix ) throws NamespaceException,
UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException {
- }
-
-}
Deleted: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaRepository.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaRepository.java 2008-08-08 20:43:42
UTC (rev 404)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaRepository.java 2008-08-08 21:11:12
UTC (rev 405)
@@ -1,91 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.dna.jcr;
-
-import javax.jcr.Credentials;
-import javax.jcr.LoginException;
-import javax.jcr.NoSuchWorkspaceException;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-/**
- * @author Randall Hauch
- */
-public class DnaRepository implements Repository {
-
- /**
- *
- */
- public DnaRepository() {
- }
-
- /**
- * {@inheritDoc}
- */
- public String getDescriptor( String key ) {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public String[] getDescriptorKeys() {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public Session login() throws LoginException, RepositoryException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public Session login( Credentials credentials ) throws LoginException,
RepositoryException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public Session login( String workspaceName ) throws LoginException,
NoSuchWorkspaceException, RepositoryException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public Session login( Credentials credentials, String workspaceName ) throws
LoginException, NoSuchWorkspaceException, RepositoryException {
- return null;
- }
-
- protected void logout( DnaSession session ) {
-
- }
-
- protected String[] getWorkspaceNamesAccessibleBy( String username, Credentials
credentials ) throws RepositoryException {
- throw new UnsupportedOperationException();
- }
-}
Deleted: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaSession.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaSession.java 2008-08-08 20:43:42 UTC
(rev 404)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaSession.java 2008-08-08 21:11:12 UTC
(rev 405)
@@ -1,312 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.dna.jcr;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.security.AccessControlException;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-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.ValueFactory;
-import javax.jcr.Workspace;
-import javax.jcr.lock.LockException;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
-import javax.jcr.version.VersionException;
-import net.jcip.annotations.GuardedBy;
-import net.jcip.annotations.ThreadSafe;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * @author Randall Hauch
- */
-@ThreadSafe
-public class DnaSession implements Session {
-
- private final DnaWorkspace workspace;
- private final DnaRepository repository;
- private final String username;
- private final Credentials credentials;
- private final ReadWriteLock sessionLock = new ReentrantReadWriteLock();
- @GuardedBy( "sessionLock" )
- private boolean connected;
-
- /**
- * @param repository the {@link DnaRepository} that owns this session; may not be
null
- * @param workspaceName the name of the workspace to which this session is connected;
may not be null
- * @param credentials the credentials that were used to authentiate this session; may
not be null
- * @param username the username used to create this session; may not be null
- */
- /* package */DnaSession( DnaRepository repository, String workspaceName, Credentials
credentials, String username ) {
- assert repository != null;
- assert workspaceName != null;
- assert credentials != null;
- assert username != null;
- this.workspace = new DnaWorkspace(repository, workspaceName, this);
- this.repository = repository;
- this.credentials = credentials;
- this.username = username;
- this.connected = true;
- }
-
- /* package */Credentials getCredentials() {
- return this.credentials;
- }
-
- /**
- * {@inheritDoc}
- */
- public void addLockToken( String lt ) throws LockException, RepositoryException {
- }
-
- /**
- * {@inheritDoc}
- */
- public void checkPermission( String absPath, String actions ) throws
AccessControlException, RepositoryException {
- }
-
- /**
- * {@inheritDoc}
- */
- public void exportDocumentView( String absPath, ContentHandler contentHandler,
boolean skipBinary, boolean noRecurse ) throws PathNotFoundException, SAXException,
RepositoryException {
- }
-
- /**
- * {@inheritDoc}
- */
- public void exportDocumentView( String absPath, OutputStream out, boolean skipBinary,
boolean noRecurse ) throws IOException, PathNotFoundException, RepositoryException {
- }
-
- /**
- * {@inheritDoc}
- */
- public void exportSystemView( String absPath, ContentHandler contentHandler, boolean
skipBinary, boolean noRecurse ) throws PathNotFoundException, SAXException,
RepositoryException {
- }
-
- /**
- * {@inheritDoc}
- */
- public void exportSystemView( String absPath, OutputStream out, boolean skipBinary,
boolean noRecurse ) throws IOException, PathNotFoundException, RepositoryException {
- }
-
- /**
- * {@inheritDoc}
- */
- public Object getAttribute( String name ) {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public String[] getAttributeNames() {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public ContentHandler getImportContentHandler( String parentAbsPath, int uuidBehavior
)
- throws PathNotFoundException, ConstraintViolationException, VersionException,
LockException, RepositoryException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public Item getItem( String absPath ) throws PathNotFoundException,
RepositoryException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public String[] getLockTokens() {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getNamespacePrefix( String uri ) throws NamespaceException,
RepositoryException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public String[] getNamespacePrefixes() throws RepositoryException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getNamespaceURI( String prefix ) throws NamespaceException,
RepositoryException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public Node getNodeByUUID( String uuid ) throws ItemNotFoundException,
RepositoryException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public Repository getRepository() {
- return this.repository;
- }
-
- /**
- * {@inheritDoc}
- */
- public Node getRootNode() throws RepositoryException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getUserID() {
- return this.username;
- }
-
- /**
- * {@inheritDoc}
- */
- public ValueFactory getValueFactory() throws UnsupportedRepositoryOperationException,
RepositoryException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public Workspace getWorkspace() {
- return this.workspace;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean hasPendingChanges() throws RepositoryException {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public Session impersonate( Credentials credentials ) throws LoginException,
RepositoryException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public void importXML( String parentAbsPath, InputStream in, int uuidBehavior )
- throws IOException, PathNotFoundException, ItemExistsException,
ConstraintViolationException, VersionException, InvalidSerializedDataException,
LockException, RepositoryException {
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isLive() {
- Lock lock = this.sessionLock.readLock();
- try {
- return connected;
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean itemExists( String absPath ) throws RepositoryException {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public void logout() {
- Lock lock = this.sessionLock.writeLock();
- try {
- repository.logout(this);
- connected = false;
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void move( String srcAbsPath, String destAbsPath ) throws ItemExistsException,
PathNotFoundException, VersionException, ConstraintViolationException, LockException,
RepositoryException {
- }
-
- /**
- * {@inheritDoc}
- */
- public void refresh( boolean keepChanges ) throws RepositoryException {
- }
-
- /**
- * {@inheritDoc}
- */
- public void removeLockToken( String lt ) {
- }
-
- /**
- * {@inheritDoc}
- */
- public void save()
- throws AccessDeniedException, ItemExistsException, ConstraintViolationException,
InvalidItemStateException, VersionException, LockException, NoSuchNodeTypeException,
RepositoryException {
- }
-
- /**
- * {@inheritDoc}
- */
- public void setNamespacePrefix( String newPrefix, String existingUri ) throws
NamespaceException, RepositoryException {
- }
-
-}
Deleted: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaWorkspace.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaWorkspace.java 2008-08-08 20:43:42
UTC (rev 404)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaWorkspace.java 2008-08-08 21:11:12
UTC (rev 405)
@@ -1,170 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.dna.jcr;
-
-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 net.jcip.annotations.ThreadSafe;
-import org.xml.sax.ContentHandler;
-
-/**
- * @author Randall Hauch
- */
-@ThreadSafe
-public class DnaWorkspace implements Workspace {
-
- private final String name;
- private final DnaSession session;
- private final DnaRepository repository;
-
- /**
- * @param repository the repository instance that owns this workspace; may not be
null
- * @param name the name of the workspace; may not be null
- * @param session the session that owns this workspace; may not be null
- */
- /* package */DnaWorkspace( DnaRepository repository, String name, DnaSession session
) {
- assert repository != null;
- assert session != null;
- assert name != null;
- this.repository = repository;
- this.session = session;
- this.name = name;
- }
-
- /**
- * {@inheritDoc}
- */
- public void clone( String srcWorkspace, String srcAbsPath, String destAbsPath,
boolean removeExisting )
- throws NoSuchWorkspaceException, ConstraintViolationException, VersionException,
AccessDeniedException, PathNotFoundException, ItemExistsException, LockException,
RepositoryException {
- }
-
- /**
- * {@inheritDoc}
- */
- public void copy( String srcAbsPath, String destAbsPath )
- throws ConstraintViolationException, VersionException, AccessDeniedException,
PathNotFoundException, ItemExistsException, LockException, RepositoryException {
- }
-
- /**
- * {@inheritDoc}
- */
- public void copy( String srcWorkspace, String srcAbsPath, String destAbsPath )
- throws NoSuchWorkspaceException, ConstraintViolationException, VersionException,
AccessDeniedException, PathNotFoundException, ItemExistsException, LockException,
RepositoryException {
- }
-
- /**
- * {@inheritDoc}
- */
- public String[] getAccessibleWorkspaceNames() throws RepositoryException {
- return repository.getWorkspaceNamesAccessibleBy(session.getUserID(),
session.getCredentials());
- }
-
- /**
- * {@inheritDoc}
- */
- public ContentHandler getImportContentHandler( String parentAbsPath, int uuidBehavior
)
- throws PathNotFoundException, ConstraintViolationException, VersionException,
LockException, AccessDeniedException, RepositoryException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getName() {
- return name;
- }
-
- /**
- * {@inheritDoc}
- */
- public NamespaceRegistry getNamespaceRegistry() throws RepositoryException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public NodeTypeManager getNodeTypeManager() throws RepositoryException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public ObservationManager getObservationManager() throws
UnsupportedRepositoryOperationException, RepositoryException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public QueryManager getQueryManager() throws RepositoryException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public Session getSession() {
- return this.session;
- }
-
- /**
- * {@inheritDoc}
- */
- public void importXML( String parentAbsPath, InputStream in, int uuidBehavior )
- throws IOException, PathNotFoundException, ItemExistsException,
ConstraintViolationException, InvalidSerializedDataException, LockException,
AccessDeniedException, RepositoryException {
- }
-
- /**
- * {@inheritDoc}
- */
- public void move( String srcAbsPath, String destAbsPath )
- throws ConstraintViolationException, VersionException, AccessDeniedException,
PathNotFoundException, ItemExistsException, LockException, RepositoryException {
- }
-
- /**
- * {@inheritDoc}
- */
- public void restore( Version[] versions, boolean removeExisting )
- throws ItemExistsException, UnsupportedRepositoryOperationException,
VersionException, LockException, InvalidItemStateException, RepositoryException {
- }
-
-}
Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/GraphTools.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/GraphTools.java
(rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/GraphTools.java 2008-08-08 21:11:12 UTC
(rev 405)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+import org.jboss.dna.spi.ExecutionContext;
+import org.jboss.dna.spi.connector.RepositoryConnection;
+import org.jboss.dna.spi.graph.NameFactory;
+import org.jboss.dna.spi.graph.Path;
+import org.jboss.dna.spi.graph.PathFactory;
+import org.jboss.dna.spi.graph.PropertyType;
+import org.jboss.dna.spi.graph.ValueFactories;
+import org.jboss.dna.spi.graph.commands.GraphCommand;
+import org.jboss.dna.spi.graph.commands.impl.BasicGetNodeCommand;
+
+/**
+ * @author jverhaeg
+ */
+class GraphTools {
+
+ private final ExecutionContext executionContext;
+ private Session session;
+ private final RepositoryConnection connection;
+
+ GraphTools( ExecutionContext executionContext,
+ RepositoryConnection connection ) {
+ assert executionContext != null;
+ assert connection != null;
+ this.executionContext = executionContext;
+ this.connection = connection;
+ }
+
+ private void execute( GraphCommand... commands ) throws RepositoryException {
+ try {
+ connection.execute(executionContext, commands);
+ } catch (RuntimeException error) {
+ throw error;
+ } catch (Exception error) {
+ throw new RepositoryException(error);
+ }
+ }
+
+ /**
+ * @return connection
+ */
+ public RepositoryConnection getConnection() {
+ return connection;
+ }
+
+ NodeContent getNodeContent( Path path ) throws RepositoryException {
+ assert session != null;
+ assert path != null;
+ // Get root node from source
+ ValueFactories valueFactories = executionContext.getValueFactories();
+ PathFactory pathFactory = valueFactories.getPathFactory();
+ BasicGetNodeCommand getRootNodeCommand = new BasicGetNodeCommand(path);
+ execute(getRootNodeCommand);
+ // Get primary type
+ NameFactory nameFactory = valueFactories.getNameFactory();
+ org.jboss.dna.spi.graph.Property primaryTypeProp =
getRootNodeCommand.getProperties().get(nameFactory.create("jcr:primaryType"));
+ org.jboss.dna.spi.graph.ValueFactory<String> stringFactory =
valueFactories.getStringFactory();
+ String primaryType = stringFactory.create(primaryTypeProp.getValues()).next();
+ // Process node's properties
+ NodeContent content = new NodeContent();
+ org.jboss.dna.spi.graph.ValueFactory<Boolean> booleanFactory =
valueFactories.getBooleanFactory();
+ for (org.jboss.dna.spi.graph.Property prop :
getRootNodeCommand.getPropertyIterator()) {
+ // Get property definition from node's primary type
+ BasicGetNodeCommand getPropDefCommand = new
BasicGetNodeCommand(pathFactory.create("/dna:system/dna:jcr/"
+
+ primaryType + "/"
+
+ prop.getName()));
+ execute(getPropDefCommand);
+ // Create either a single- or multiple-valued property, as defined by the
property definition
+ org.jboss.dna.spi.graph.Property isMultipleProp =
getPropDefCommand.getProperties().get(nameFactory.create("jcr:multiple"));
+ org.jboss.dna.spi.graph.Property requiredTypeProp =
getPropDefCommand.getProperties().get(nameFactory.create("jcr:requiredType"));
+ String type = stringFactory.create(requiredTypeProp.getValues()).next();
+ if (booleanFactory.create(isMultipleProp.getValues()).next().booleanValue())
{
+ // jcrProps.add(new JcrMultiValuedProperty(dnaProp.getName(), type,
dnaProp.getValues()));
+ } else {
+ Value jcrValue;
+ ValueFactory jcrValueFactory = session.getValueFactory();
+ if (PropertyType.BINARY.equals(type)) {
+ jcrValue =
jcrValueFactory.createValue(valueFactories.getBinaryFactory().create(prop.getValues()).next().getStream());
+ } else {
+ assert PropertyType.UUID.equals(type);
+ jcrValue =
jcrValueFactory.createValue(valueFactories.getStringFactory().create(prop.getValues()).next());
+ }
+ content.properties.add(new JcrProperty(session,
prop.getName().toString(), jcrValue));
+ }
+ }
+ return content;
+ }
+
+ void setSession( Session session ) {
+ assert session != null;
+ this.session = session;
+ }
+
+ class NodeContent {
+
+ Set<Property> properties = new HashSet<Property>();
+ }
+}
Property changes on: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/GraphTools.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrExecutionContext.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrExecutionContext.java
(rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrExecutionContext.java 2008-08-08
21:11:12 UTC (rev 405)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import java.security.AccessControlContext;
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginContext;
+import net.jcip.annotations.NotThreadSafe;
+import org.jboss.dna.spi.ExecutionContext;
+import org.jboss.dna.spi.connector.RepositoryConnection;
+import org.jboss.dna.spi.graph.NamespaceRegistry;
+import org.jboss.dna.spi.graph.PropertyFactory;
+import org.jboss.dna.spi.graph.ValueFactories;
+
+/**
+ * @author jverhaeg
+ */
+@NotThreadSafe
+class JcrExecutionContext implements ExecutionContext {
+
+ private final ExecutionContext delegate;
+ private final GraphTools tools;
+
+ JcrExecutionContext( ExecutionContext delegate,
+ RepositoryConnection connection ) {
+ assert delegate != null;
+ assert connection != null;
+ this.delegate = delegate;
+ tools = new GraphTools(delegate, connection);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.ExecutionContext#getAccessControlContext()
+ */
+ public AccessControlContext getAccessControlContext() {
+ return delegate.getAccessControlContext();
+ }
+
+ GraphTools getGraphTools() {
+ return tools;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.ExecutionContext#getLoginContext()
+ */
+ public LoginContext getLoginContext() {
+ return delegate.getLoginContext();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.ExecutionContext#getNamespaceRegistry()
+ */
+ public NamespaceRegistry getNamespaceRegistry() {
+ return delegate.getNamespaceRegistry();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.ExecutionContext#getPropertyFactory()
+ */
+ public PropertyFactory getPropertyFactory() {
+ return delegate.getPropertyFactory();
+ }
+
+ RepositoryConnection getRepositoryConnection() {
+ return tools.getConnection();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.ExecutionContext#getSubject()
+ */
+ public Subject getSubject() {
+ return delegate.getSubject();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.ExecutionContext#getValueFactories()
+ */
+ public ValueFactories getValueFactories() {
+ return delegate.getValueFactories();
+ }
+}
Property changes on:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrExecutionContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java 2008-08-08 20:43:42 UTC
(rev 404)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java 2008-08-08 21:11:12 UTC
(rev 405)
@@ -26,12 +26,22 @@
import org.jboss.dna.common.i18n.I18n;
/**
+ * @author John Verhaeg
* @author Randall Hauch
*/
public final class JcrI18n {
- // public static I18n invalidStateString;
+ public static I18n credentialsMustProvideJaasMethod;
+ public static I18n credentialsMustReturnAccessControlContext;
+ public static I18n credentialsMustReturnLoginContext;
+ public static I18n defaultWorkspaceName;
+ public static I18n repositoryMustBeConfigured;
+ public static I18n sourceInUse;
+ public static I18n REP_NAME_DESC;
+ public static I18n REP_VENDOR_DESC;
+ public static I18n SPEC_NAME_DESC;
+
static {
try {
I18n.initialize(JcrI18n.class);
Copied: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNamespaceRegistry.java (from rev
375, trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaNamespaceRegistry.java)
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNamespaceRegistry.java
(rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNamespaceRegistry.java 2008-08-08
21:11:12 UTC (rev 405)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import javax.jcr.NamespaceException;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import net.jcip.annotations.Immutable;
+import org.jboss.dna.common.util.ArgCheck;
+
+/**
+ * @author John Verhaeg
+ * @author Randall Hauch
+ */
+@Immutable
+class JcrNamespaceRegistry implements NamespaceRegistry {
+
+ private Map<String, String> prefix2UriMap = new HashMap<String,
String>();
+
+ JcrNamespaceRegistry() {
+ prefix2UriMap.put("", "");
+ prefix2UriMap.put("dna", "http://www.jboss.org/dna/1.0");
+ prefix2UriMap.put("jcr", "http://www.jcp.org/jcr/1.0");
+ prefix2UriMap.put("mix", "http://www.jcp.org/jcr/mix/1.0");
+ prefix2UriMap.put("nt", "http://www.jcp.org/jcr/nt/1.0");
+ prefix2UriMap.put("xml",
"http://www.w3.org/XML/1998/namespace");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getPrefix( String uri ) throws NamespaceException {
+ ArgCheck.isNotNull(uri, "uri");
+ for (Entry<String, String> entry : prefix2UriMap.entrySet()) {
+ if (uri.equals(entry.getValue())) {
+ return entry.getKey();
+ }
+ }
+ throw new NamespaceException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String[] getPrefixes() {
+ String[] prefixes = prefix2UriMap.keySet().toArray(new
String[prefix2UriMap.size()]);
+ Arrays.sort(prefixes);
+ return prefixes;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getURI( String prefix ) throws NamespaceException {
+ ArgCheck.isNotNull(prefix, "prefix");
+ String uri = prefix2UriMap.get(prefix);
+ if (uri == null) throw new NamespaceException();
+ return uri;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String[] getURIs() {
+ String[] uris = prefix2UriMap.values().toArray(new
String[prefix2UriMap.size()]);
+ Arrays.sort(uris);
+ return uris;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void registerNamespace( String prefix,
+ String uri ) throws
UnsupportedRepositoryOperationException {
+ throw new UnsupportedRepositoryOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void unregisterNamespace( String prefix ) throws
UnsupportedRepositoryOperationException {
+ throw new UnsupportedRepositoryOperationException();
+ }
+}
Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNode.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNode.java
(rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNode.java 2008-08-08 21:11:12 UTC
(rev 405)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import java.util.Set;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import net.jcip.annotations.NotThreadSafe;
+
+/**
+ * @author jverhaeg
+ */
+@NotThreadSafe
+final class JcrNode extends AbstractJcrNode {
+
+ JcrNode( Session session,
+ Set<Property> properties ) {
+ super(session, properties);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#getName()
+ */
+ public String getName() throws RepositoryException {
+ Property prop = getProperty("jcr:name");
+ assert prop != null;
+ assert prop.getValue() != null;
+ return prop.getValue().getString();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#getParent()
+ */
+ public Node getParent() {
+ throw new UnsupportedOperationException();
+ }
+}
Property changes on: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrProperty.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrProperty.java
(rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrProperty.java 2008-08-08 21:11:12 UTC
(rev 405)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Value;
+
+/**
+ * @author jverhaeg
+ */
+final class JcrProperty extends AbstractJcrProperty {
+
+ private Value value;
+
+ JcrProperty( Session session,
+ String name,
+ Value value ) {
+ super(session, name);
+ assert value != null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Property#getBoolean()
+ */
+ public boolean getBoolean() throws RepositoryException {
+ return value.getBoolean();
+ }
+}
Property changes on: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrProperty.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java (from rev 375,
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaRepository.java)
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
(rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java 2008-08-08 21:11:12
UTC (rev 405)
@@ -0,0 +1,256 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import java.lang.reflect.Method;
+import java.security.AccessControlContext;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import javax.jcr.Credentials;
+import javax.jcr.LoginException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.security.auth.login.LoginContext;
+import net.jcip.annotations.ThreadSafe;
+import org.jboss.dna.common.util.ArgCheck;
+import org.jboss.dna.spi.ExecutionContext;
+import org.jboss.dna.spi.ExecutionContextFactory;
+import org.jboss.dna.spi.connector.RepositoryConnection;
+import org.jboss.dna.spi.connector.RepositoryConnectionFactory;
+
+/**
+ * Creates JCR {@link Session sessions} to an underlying repository (which may be a
federated repository).
+ * <p>
+ * This JCR repository must be configured with the ability to connect to a repository via
a supplied
+ * {@link RepositoryConnectionFactory repository connection factory} and repository
source name. An
+ * {@link ExecutionContextFactory execution context factory} must also be supplied to
enable working with the underlying DNA graph
+ * implementation to which this JCR implementation delegates.
+ * </p>
+ * <p>
+ * If {@link Credentials} are used to login, implementations <em>must</em>
also implement one of the following methods:
+ *
+ * <pre>
+ * public {@link AccessControlContext} getAccessControlContext();
+ * public {@link LoginContext} getLoginContext();
+ * </pre>
+ *
+ * </p>
+ *
+ * @author John Verhaeg
+ * @author Randall Hauch
+ */
+@ThreadSafe
+public class JcrRepository implements Repository {
+
+ private final Map<String, String> descriptors;
+ private final ExecutionContextFactory executionContextFactory;
+ private final RepositoryConnectionFactory connectionFactory;
+
+ /**
+ * Creates a JCR repository that uses the supplied {@link RepositoryConnectionFactory
repository connection factory} to
+ * establish {@link Session sessions} to the underlying repository source upon {@link
#login() login}.
+ *
+ * @param executionContextFactory An execution context factory.
+ * @param connectionFactory A repository connection factory.
+ * @throws IllegalArgumentException If
<code>executionContextFactory</code> or
<code>connectionFactory</code> is
+ * <code>null</code>.
+ */
+ public JcrRepository( ExecutionContextFactory executionContextFactory,
+ RepositoryConnectionFactory connectionFactory ) {
+ this(null, executionContextFactory, connectionFactory);
+ }
+
+ /**
+ * Creates a JCR repository that uses the supplied {@link RepositoryConnectionFactory
repository connection factory} to
+ * establish {@link Session sessions} to the underlying repository source upon {@link
#login() login}.
+ *
+ * @param descriptors The {@link #getDescriptorKeys() descriptors} for this
repository; may be <code>null</code>.
+ * @param executionContextFactory An execution context factory.
+ * @param connectionFactory A repository connection factory.
+ * @throws IllegalArgumentException If
<code>executionContextFactory</code> or
<code>connectionFactory</code> is
+ * <code>null</code>.
+ */
+ public JcrRepository( Map<String, String> descriptors,
+ ExecutionContextFactory executionContextFactory,
+ RepositoryConnectionFactory connectionFactory ) {
+ ArgCheck.isNotNull(executionContextFactory,
"executionContextFactory");
+ ArgCheck.isNotNull(connectionFactory, "connectionFactory");
+ this.executionContextFactory = executionContextFactory;
+ this.connectionFactory = connectionFactory;
+ Map<String, String> modifiableDescriptors;
+ if (descriptors == null) {
+ modifiableDescriptors = new HashMap<String, String>();
+ } else {
+ modifiableDescriptors = new HashMap<String, String>(descriptors);
+ }
+ // Initialize required JCR descriptors.
+ modifiableDescriptors.put(Repository.LEVEL_1_SUPPORTED, "true");
+ // TODO: Change to true once level 2 supported
+ modifiableDescriptors.put(Repository.LEVEL_2_SUPPORTED, "false");
+ // TODO: Change to true once locking supported
+ modifiableDescriptors.put(Repository.OPTION_LOCKING_SUPPORTED,
"false");
+ // TODO: Change to true once observation supported
+ modifiableDescriptors.put(Repository.OPTION_OBSERVATION_SUPPORTED,
"false");
+ // TODO: Change to true once query SQL supported
+ modifiableDescriptors.put(Repository.OPTION_QUERY_SQL_SUPPORTED,
"false");
+ // TODO: Change to true once transactions supported
+ modifiableDescriptors.put(Repository.OPTION_TRANSACTIONS_SUPPORTED,
"false");
+ // TODO: Change to true once versioning supported
+ modifiableDescriptors.put(Repository.OPTION_VERSIONING_SUPPORTED,
"false");
+ modifiableDescriptors.put(Repository.QUERY_XPATH_DOC_ORDER, "true");
+ modifiableDescriptors.put(Repository.QUERY_XPATH_POS_INDEX, "true");
+ // Vendor-specific descriptors (REP_XXX) will only be initialized if not already
present, allowing for customer branding.
+ // TODO: Should allow for branding via configuration
+ if (!modifiableDescriptors.containsKey(Repository.REP_NAME_DESC)) {
+ modifiableDescriptors.put(Repository.REP_NAME_DESC,
JcrI18n.REP_NAME_DESC.text());
+ }
+ if (!modifiableDescriptors.containsKey(Repository.REP_VENDOR_DESC)) {
+ modifiableDescriptors.put(Repository.REP_VENDOR_DESC,
JcrI18n.REP_VENDOR_DESC.text());
+ }
+ if (!modifiableDescriptors.containsKey(Repository.REP_VENDOR_URL_DESC)) {
+ modifiableDescriptors.put(Repository.REP_VENDOR_URL_DESC,
"http://www.jboss.org/dna");
+ }
+ if (!modifiableDescriptors.containsKey(Repository.REP_VERSION_DESC)) {
+ // TODO: Permanent to-do to update the version for each release
+ modifiableDescriptors.put(Repository.REP_VERSION_DESC, "0.2");
+ }
+ modifiableDescriptors.put(Repository.SPEC_NAME_DESC,
JcrI18n.SPEC_NAME_DESC.text());
+ modifiableDescriptors.put(Repository.SPEC_VERSION_DESC, "1.0");
+ this.descriptors = Collections.unmodifiableMap(modifiableDescriptors);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Repository#getDescriptor(java.lang.String)
+ */
+ public String getDescriptor( String key ) {
+ return descriptors.get(key);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Repository#getDescriptorKeys()
+ */
+ public String[] getDescriptorKeys() {
+ return descriptors.keySet().toArray(new String[descriptors.size()]);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Repository#login()
+ */
+ public synchronized Session login() throws RepositoryException {
+ return login(null, null);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Repository#login(javax.jcr.Credentials)
+ */
+ public synchronized Session login( Credentials credentials ) throws
RepositoryException {
+ return login(credentials, null);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Repository#login(java.lang.String)
+ */
+ public synchronized Session login( String workspaceName ) throws RepositoryException
{
+ return login(null, workspaceName);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Repository#login(javax.jcr.Credentials, java.lang.String)
+ */
+ public synchronized Session login( Credentials credentials,
+ String workspaceName ) throws RepositoryException
{
+ // Ensure credentials are either null or provide a JAAS method
+ ExecutionContext execContext;
+ if (credentials == null) {
+ execContext = executionContextFactory.create();
+ } else {
+ try {
+ // Check if credentials provide a login context
+ try {
+ Method method =
credentials.getClass().getMethod("getLoginContext");
+ if (method.getReturnType() != LoginContext.class) {
+ throw new
IllegalArgumentException(JcrI18n.credentialsMustReturnLoginContext.text(credentials.getClass()));
+ }
+ LoginContext loginContext =
(LoginContext)method.invoke(credentials);
+ if (loginContext == null) {
+ throw new
IllegalArgumentException(JcrI18n.credentialsMustReturnLoginContext.text(credentials.getClass()));
+ }
+ execContext = executionContextFactory.create(loginContext);
+ } catch (NoSuchMethodException error) {
+ // Check if credentials provide an access control context
+ try {
+ Method method =
credentials.getClass().getMethod("getAccessControlContext");
+ if (method.getReturnType() != AccessControlContext.class) {
+ throw new IllegalArgumentException(
+
JcrI18n.credentialsMustReturnAccessControlContext.text(credentials.getClass()));
+ }
+ AccessControlContext accessControlContext =
(AccessControlContext)method.invoke(credentials);
+ if (accessControlContext == null) {
+ throw new IllegalArgumentException(
+
JcrI18n.credentialsMustReturnAccessControlContext.text(credentials.getClass()));
+ }
+ execContext =
executionContextFactory.create(accessControlContext);
+ } catch (NoSuchMethodException error2) {
+ throw new
IllegalArgumentException(JcrI18n.credentialsMustProvideJaasMethod.text(credentials.getClass()),
+ error2);
+ }
+ }
+ } catch (RuntimeException error) {
+ throw error;
+ } catch (Exception error) {
+ throw new RepositoryException(error);
+ }
+ }
+ // Authenticate
+ try {
+ assert execContext != null;
+ assert execContext.getLoginContext() != null;
+ execContext.getLoginContext().login();
+ } catch (javax.security.auth.login.LoginException error) {
+ throw new LoginException(error);
+ }
+ // Ensure valid workspace name
+ if (workspaceName == null) workspaceName = JcrI18n.defaultWorkspaceName.text();
+ // Create session
+ try {
+ RepositoryConnection connection =
connectionFactory.createConnection(workspaceName);
+ assert connection != null;
+ return new JcrSession(this, new JcrExecutionContext(execContext, connection),
workspaceName);
+ } catch (InterruptedException error) {
+ throw new RepositoryException(error);
+ }
+ }
+}
Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRootNode.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRootNode.java
(rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRootNode.java 2008-08-08 21:11:12 UTC
(rev 405)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import java.util.Set;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.Session;
+import net.jcip.annotations.NotThreadSafe;
+
+/**
+ * @author jverhaeg
+ */
+@NotThreadSafe
+final class JcrRootNode extends AbstractJcrNode {
+
+ JcrRootNode( Session session,
+ Set<Property> properties ) {
+ super(session, properties);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#getName()
+ */
+ public String getName() {
+ return "";
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Item#getParent()
+ */
+ public Node getParent() throws ItemNotFoundException {
+ throw new ItemNotFoundException();
+ }
+}
Property changes on: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRootNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java (from rev 375,
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaSession.java)
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
(rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java 2008-08-08 21:11:12 UTC
(rev 405)
@@ -0,0 +1,392 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.Principal;
+import java.util.Set;
+import javax.jcr.Credentials;
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.ValueFactory;
+import javax.jcr.Workspace;
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginException;
+import net.jcip.annotations.NotThreadSafe;
+import org.jboss.dna.jcr.GraphTools.NodeContent;
+import org.xml.sax.ContentHandler;
+
+/**
+ * @author John Verhaeg
+ * @author Randall Hauch
+ */
+@NotThreadSafe
+final class JcrSession implements Session {
+
+ private final JcrRepository repository;
+ private final JcrExecutionContext executionContext;
+ private boolean isLive;
+ private JcrWorkspace workspace;
+ private Node rootNode;
+
+ // private final Map<String, Node> uuid2NodeMap = new HashMap<String,
Node>();
+
+ JcrSession( JcrRepository repository,
+ JcrExecutionContext executionContext,
+ String workspaceName ) throws RepositoryException {
+ assert repository != null;
+ assert executionContext != null;
+ assert workspaceName != null;
+ this.repository = repository;
+ this.executionContext = executionContext;
+ executionContext.getGraphTools().setSession(this);
+ this.isLive = true;
+ // Following must be initialized after session's state is initialized
+ this.workspace = new JcrWorkspace(this, workspaceName);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#addLockToken(java.lang.String)
+ */
+ public void addLockToken( String lt ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#checkPermission(java.lang.String, java.lang.String)
+ */
+ public void checkPermission( String absPath,
+ String actions ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#exportDocumentView(java.lang.String,
org.xml.sax.ContentHandler, boolean, boolean)
+ */
+ public void exportDocumentView( String absPath,
+ ContentHandler contentHandler,
+ boolean skipBinary,
+ boolean noRecurse ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#exportDocumentView(java.lang.String, java.io.OutputStream,
boolean, boolean)
+ */
+ public void exportDocumentView( String absPath,
+ OutputStream out,
+ boolean skipBinary,
+ boolean noRecurse ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#exportSystemView(java.lang.String,
org.xml.sax.ContentHandler, boolean, boolean)
+ */
+ public void exportSystemView( String absPath,
+ ContentHandler contentHandler,
+ boolean skipBinary,
+ boolean noRecurse ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#exportSystemView(java.lang.String, java.io.OutputStream,
boolean, boolean)
+ */
+ public void exportSystemView( String absPath,
+ OutputStream out,
+ boolean skipBinary,
+ boolean noRecurse ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#getAttribute(java.lang.String)
+ */
+ public Object getAttribute( String name ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#getAttributeNames()
+ */
+ public String[] getAttributeNames() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#getImportContentHandler(java.lang.String, int)
+ */
+ public ContentHandler getImportContentHandler( String parentAbsPath,
+ int uuidBehavior ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#getItem(java.lang.String)
+ */
+ public Item getItem( String absPath ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#getLockTokens()
+ */
+ public String[] getLockTokens() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#getNamespacePrefix(java.lang.String)
+ */
+ public String getNamespacePrefix( String uri ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#getNamespacePrefixes()
+ */
+ public String[] getNamespacePrefixes() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#getNamespaceURI(java.lang.String)
+ */
+ public String getNamespaceURI( String prefix ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#getNodeByUUID(java.lang.String)
+ */
+ public Node getNodeByUUID( String uuid ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#getRepository()
+ */
+ public Repository getRepository() {
+ return this.repository;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#getRootNode()
+ */
+ public Node getRootNode() throws RepositoryException {
+ // If root has no UUID, populate its contents from source
+ if (rootNode != null) {
+ return rootNode;
+ }
+ // Get root node from source
+ assert executionContext.getGraphTools() != null;
+ assert executionContext.getValueFactories() != null;
+ assert executionContext.getValueFactories().getPathFactory() != null;
+ NodeContent content =
executionContext.getGraphTools().getNodeContent(executionContext.getValueFactories().getPathFactory().createRootPath());
+ rootNode = new JcrRootNode(this, content.properties);
+ return rootNode;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#getUserID()
+ */
+ public String getUserID() {
+ Subject subject = executionContext.getSubject();
+ if (subject == null) return null;
+ Set<Principal> principals = subject.getPrincipals();
+ if (principals == null || principals.isEmpty()) return null;
+ return principals.iterator().next().getName();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#getValueFactory()
+ */
+ public ValueFactory getValueFactory() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#getWorkspace()
+ */
+ public Workspace getWorkspace() {
+ return this.workspace;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#hasPendingChanges()
+ */
+ public boolean hasPendingChanges() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#impersonate(javax.jcr.Credentials)
+ */
+ public Session impersonate( Credentials credentials ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#importXML(java.lang.String, java.io.InputStream, int)
+ */
+ public void importXML( String parentAbsPath,
+ InputStream in,
+ int uuidBehavior ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#isLive()
+ */
+ public boolean isLive() {
+ return isLive;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#itemExists(java.lang.String)
+ */
+ public boolean itemExists( String absPath ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#logout()
+ */
+ public void logout() {
+ try {
+ if (executionContext.getRepositoryConnection() != null) {
+ executionContext.getRepositoryConnection().close();
+ }
+ assert executionContext.getLoginContext() != null;
+ executionContext.getLoginContext().logout();
+ isLive = false;
+ } catch (InterruptedException error) {
+ // TODO: Change to DnaException once DNA-180 is addressed
+ throw new RuntimeException(error);
+ } catch (LoginException error) {
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#move(java.lang.String, java.lang.String)
+ */
+ public void move( String srcAbsPath,
+ String destAbsPath ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#refresh(boolean)
+ */
+ public void refresh( boolean keepChanges ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#removeLockToken(java.lang.String)
+ */
+ public void removeLockToken( String lt ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#save()
+ */
+ public void save() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Session#setNamespacePrefix(java.lang.String, java.lang.String)
+ */
+ public void setNamespacePrefix( String newPrefix,
+ String existingUri ) {
+ throw new UnsupportedOperationException();
+ }
+}
Copied: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrWorkspace.java (from rev 375,
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaWorkspace.java)
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrWorkspace.java
(rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrWorkspace.java 2008-08-08 21:11:12
UTC (rev 405)
@@ -0,0 +1,197 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import java.io.InputStream;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Workspace;
+import javax.jcr.nodetype.NodeTypeManager;
+import javax.jcr.observation.ObservationManager;
+import javax.jcr.query.QueryManager;
+import javax.jcr.version.Version;
+import org.xml.sax.ContentHandler;
+
+/**
+ * @author John Verhaeg
+ * @author Randall Hauch
+ */
+final class JcrWorkspace implements Workspace {
+
+ private final String name;
+ private final JcrSession session;
+
+ /**
+ * @param session the session that owns this workspace; may not be null
+ * @param name the name of the workspace; may not be null
+ * @throws RepositoryException
+ */
+ JcrWorkspace( JcrSession session,
+ String name ) throws RepositoryException {
+ assert session != null;
+ assert name != null;
+ this.session = session;
+ this.name = name;
+ // Ensure workspace with supplied name is accessible
+ // if (name == null) name =
session.getDnaRepository().getSource(session.getSubject()).getName();
+ // String matchedName = null;
+ // for (String accessibleName : getAccessibleWorkspaceNames()) {
+ // if (name.equalsIgnoreCase(accessibleName)) {
+ // matchedName = name;
+ // break;
+ // }
+ // }
+ // if (matchedName == null) {
+ // throw new LoginException();
+ // }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void clone( String srcWorkspace,
+ String srcAbsPath,
+ String destAbsPath,
+ boolean removeExisting ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void copy( String srcAbsPath,
+ String destAbsPath ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void copy( String srcWorkspace,
+ String srcAbsPath,
+ String destAbsPath ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String[] getAccessibleWorkspaceNames() {
+ // try {
+ // Node node = session.getRootNode().getNode("dna:jcr");
+ // if (node != null) {
+ // Property property = node.getProperty("dna:workspaceNames");
+ // if (property != null) {
+ // Value[] values = property.getValues();
+ // if (values.length > 0) {
+ // String[] names = new String[values.length];
+ // for (int ndx = values.length; --ndx >= 0;) {
+ // names[ndx] = values[ndx].getString();
+ // }
+ // return names;
+ // }
+ // }
+ // }
+ // } catch (PathNotFoundException meansOnlyDefaultWorkspaceNameAvailable) {
+ // // TODO: Check permissions and, if writable, create node & property and,
if allowed, set to include this source's name
+ // }
+ // // Repository is read-only, so just return this source's name
+ // return new String[]
{session.getDnaRepository().getSource(session.getSubject()).getName()};
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ContentHandler getImportContentHandler( String parentAbsPath,
+ int uuidBehavior ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public NamespaceRegistry getNamespaceRegistry() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public NodeTypeManager getNodeTypeManager() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ObservationManager getObservationManager() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public QueryManager getQueryManager() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Session getSession() {
+ return this.session;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void importXML( String parentAbsPath,
+ InputStream in,
+ int uuidBehavior ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void move( String srcAbsPath,
+ String destAbsPath ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void restore( Version[] versions,
+ boolean removeExisting ) {
+ throw new UnsupportedOperationException();
+ }
+}
Modified: trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties
===================================================================
--- trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties 2008-08-08
20:43:42 UTC (rev 404)
+++ trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties 2008-08-08
21:11:12 UTC (rev 405)
@@ -19,3 +19,13 @@
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
#
+credentialsMustProvideJaasMethod = The Credentials class "{0}" must implement
either "public LoginContext getLoginContext();" or "public
AccessControlContext getAccessControlContext();".
+credentialsMustReturnAccessControlContext = The "getAccessControlContext()"
method in Credentials class "{0}" must not return a null.
+credentialsMustReturnLoginContext = The "getLoginContext()" method in
Credentials class "{0}" must not return a null.
+defaultWorkspaceName = Default
+repositoryMustBeConfigured = DNA repositories must be configured with either a repository
source factory or a repository source.
+sourceInUse = All sessions must end before a new repository source can be set.
+
+REP_NAME_DESC = DNA Repository
+REP_VENDOR_DESC = JBoss - A division of Red Hat Middleware LLC
+SPEC_NAME_DESC = Content Repository for Java Technology API
\ No newline at end of file
Added: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrNodeTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrNodeTest.java
(rev 0)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrNodeTest.java 2008-08-08
21:11:12 UTC (rev 405)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.stub;
+import java.util.HashSet;
+import java.util.Set;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.Session;
+import javax.jcr.Value;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.mockito.MockitoAnnotations.Mock;
+
+/**
+ * @author jverhaeg
+ */
+public class AbstractJcrNodeTest {
+
+ private AbstractJcrNode node;
+ @Mock
+ private Session session;
+ private Set<Property> properties;
+
+ @Before
+ public void before() {
+ MockitoAnnotations.initMocks(this);
+ properties = new HashSet<Property>();
+ node = new AbstractJcrNode(session, properties) {
+
+ public String getName() {
+ return null;
+ }
+
+ public Node getParent() {
+ return null;
+ }
+ };
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowNoSession() throws Exception {
+ new AbstractJcrNode(null, properties) {
+
+ public String getName() {
+ return null;
+ }
+
+ public Node getParent() {
+ return null;
+ }
+ };
+ }
+
+ @Test
+ public void shouldProvideSession() throws Exception {
+ assertThat(node.getSession(), is(session));
+ }
+
+ @Test
+ public void shouldProvideUuid() throws Exception {
+ Property property = Mockito.mock(Property.class);
+ stub(property.getName()).toReturn("jcr:uuid");
+ Value value = Mockito.mock(Value.class);
+ stub(value.getString()).toReturn("uuid");
+ stub(property.getValue()).toReturn(value);
+ properties.add(property);
+ assertThat(node.getUUID(), is("uuid"));
+ }
+
+ @Test
+ public void shouldProvideNamedProperty() throws Exception {
+ Property property = Mockito.mock(Property.class);
+ stub(property.getName()).toReturn("test");
+ properties.add(property);
+ assertThat(node.getProperty("test"), is(property));
+ }
+}
Property changes on:
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrNodeTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrPropertyTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrPropertyTest.java
(rev 0)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrPropertyTest.java 2008-08-08
21:11:12 UTC (rev 405)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+import javax.jcr.Session;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.MockitoAnnotations;
+import org.mockito.MockitoAnnotations.Mock;
+
+/**
+ * @author jverhaeg
+ */
+public class AbstractJcrPropertyTest {
+
+ private AbstractJcrProperty prop;
+ @Mock
+ private Session session;
+
+ @Before
+ public void before() {
+ MockitoAnnotations.initMocks(this);
+ prop = new AbstractJcrProperty(session, "name") {
+
+ public boolean getBoolean() {
+ return false;
+ }
+ };
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowNoSession() throws Exception {
+ new AbstractJcrProperty(null, "name") {
+
+ public boolean getBoolean() {
+ return false;
+ }
+ };
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowNoName() throws Exception {
+ new AbstractJcrProperty(session, null) {
+
+ public boolean getBoolean() {
+ return false;
+ }
+ };
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowEmptyName() throws Exception {
+ new AbstractJcrProperty(session, "") {
+
+ public boolean getBoolean() {
+ return false;
+ }
+ };
+ }
+
+ @Test
+ public void shouldProvideSession() throws Exception {
+ assertThat(prop.getSession(), is(session));
+ }
+
+ @Test
+ public void shouldProvideName() throws Exception {
+ assertThat(prop.getName(), is("name"));
+ }
+}
Property changes on:
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrPropertyTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNamespaceRegistryTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNamespaceRegistryTest.java
(rev 0)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNamespaceRegistryTest.java 2008-08-08
21:11:12 UTC (rev 405)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import static org.hamcrest.collection.IsArrayContaining.hasItemInArray;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.junit.Assert.assertThat;
+import javax.jcr.NamespaceException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author jverhaeg
+ */
+public class JcrNamespaceRegistryTest {
+
+ private JcrNamespaceRegistry registry;
+
+ @Before
+ public void before() {
+ registry = new JcrNamespaceRegistry();
+ }
+
+ @Test
+ public void shouldProvidePrefixes() {
+ String[] prefixes = registry.getPrefixes();
+ assertThat(prefixes, notNullValue());
+ assertThat(prefixes.length, is(6));
+ assertThat(prefixes, hasItemInArray(""));
+ assertThat(prefixes, hasItemInArray("dna"));
+ assertThat(prefixes, hasItemInArray("jcr"));
+ assertThat(prefixes, hasItemInArray("mix"));
+ assertThat(prefixes, hasItemInArray("nt"));
+ assertThat(prefixes, hasItemInArray("xml"));
+ }
+
+ @Test
+ public void shouldProvideUris() {
+ String[] uris = registry.getURIs();
+ assertThat(uris, notNullValue());
+ assertThat(uris.length, is(6));
+ assertThat(uris, hasItemInArray(""));
+ assertThat(uris,
hasItemInArray("http://www.jboss.org/dna/1.0"));
+ assertThat(uris,
hasItemInArray("http://www.jcp.org/jcr/1.0"));
+ assertThat(uris,
hasItemInArray("http://www.jcp.org/jcr/mix/1.0"));
+ assertThat(uris,
hasItemInArray("http://www.jcp.org/jcr/nt/1.0"));
+ assertThat(uris,
hasItemInArray("http://www.w3.org/XML/1998/namespace"));
+ }
+
+ @Test( expected = UnsupportedRepositoryOperationException.class )
+ public void shouldNotAllowRegisterNamespace() throws Exception {
+ registry.registerNamespace(null, null);
+ }
+
+ @Test( expected = UnsupportedRepositoryOperationException.class )
+ public void shouldNotAllowUnregisterNamespace() throws Exception {
+ registry.unregisterNamespace(null);
+ }
+
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldNotAllowNullPrefix() throws Exception {
+ registry.getURI(null);
+ }
+
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldNotAllowNullUri() throws Exception {
+ registry.getPrefix(null);
+ }
+
+ @Test
+ public void shouldProvideUriForRegisteredPrefix() throws Exception {
+ assertThat(registry.getPrefix(""), is(""));
+
assertThat(registry.getPrefix("http://www.jboss.org/dna/1.0"),
is("dna"));
+
assertThat(registry.getPrefix("http://www.jcp.org/jcr/1.0"),
is("jcr"));
+
assertThat(registry.getPrefix("http://www.jcp.org/jcr/mix/1.0"),
is("mix"));
+
assertThat(registry.getPrefix("http://www.jcp.org/jcr/nt/1.0"),
is("nt"));
+
assertThat(registry.getPrefix("http://www.w3.org/XML/1998/namespace&...,
is("xml"));
+ }
+
+ @Test
+ public void shouldProvidePrefixForRegisteredUri() throws Exception {
+ assertThat(registry.getURI(""), is(""));
+ assertThat(registry.getURI("dna"),
is("http://www.jboss.org/dna/1.0"));
+ assertThat(registry.getURI("jcr"),
is("http://www.jcp.org/jcr/1.0"));
+ assertThat(registry.getURI("mix"),
is("http://www.jcp.org/jcr/mix/1.0"));
+ assertThat(registry.getURI("nt"),
is("http://www.jcp.org/jcr/nt/1.0"));
+ assertThat(registry.getURI("xml"),
is("http://www.w3.org/XML/1998/namespace"));
+ }
+
+ @Test( expected = NamespaceException.class )
+ public void shouldNotAllowUnregisteredPrefix() throws Exception {
+ registry.getURI("bogus");
+ }
+
+ @Test( expected = NamespaceException.class )
+ public void shouldNotAllowUnregisteredUri() throws Exception {
+ registry.getPrefix("bogus");
+ }
+}
Property changes on:
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNamespaceRegistryTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNodeTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNodeTest.java
(rev 0)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNodeTest.java 2008-08-08 21:11:12 UTC
(rev 405)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.stub;
+import java.util.HashSet;
+import java.util.Set;
+import javax.jcr.Property;
+import javax.jcr.Session;
+import javax.jcr.Value;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.mockito.MockitoAnnotations.Mock;
+
+/**
+ * @author jverhaeg
+ */
+public class JcrNodeTest {
+
+ private JcrNode node;
+ @Mock
+ private Session session;
+ private Set<Property> properties;
+
+ @Before
+ public void before() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ properties = new HashSet<Property>();
+ node = new JcrNode(session, properties);
+ }
+
+ @Test
+ public void shouldProvideName() throws Exception {
+ Property property = Mockito.mock(Property.class);
+ stub(property.getName()).toReturn("jcr:name");
+ Value value = Mockito.mock(Value.class);
+ stub(value.getString()).toReturn("name");
+ stub(property.getValue()).toReturn(value);
+ properties.add(property);
+ assertThat(node.getName(), is("name"));
+ }
+}
Property changes on: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNodeTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrPropertyTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrPropertyTest.java
(rev 0)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrPropertyTest.java 2008-08-08 21:11:12
UTC (rev 405)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+
+/**
+ * @author jverhaeg
+ */
+public class JcrPropertyTest {
+ //
+ // private AbstractJcrProperty prop;
+ // @Mock
+ // private Session session;
+ //
+ // @Before
+ // public void before() {
+ // MockitoAnnotations.initMocks(this);
+ // prop = new AbstractJcrProperty(session, "name") {};
+ // }
+ //
+ // @Test( expected = AssertionError.class )
+ // public void shouldNotAllowNoSession() throws Exception {
+ // new AbstractJcrProperty(null, "name") {};
+ // }
+ //
+ // @Test( expected = AssertionError.class )
+ // public void shouldNotAllowNoName() throws Exception {
+ // new AbstractJcrProperty(session, null) {};
+ // }
+ //
+ // @Test( expected = AssertionError.class )
+ // public void shouldNotAllowEmptyName() throws Exception {
+ // new AbstractJcrProperty(session, "") {};
+ // }
+ //
+ // @Test
+ // public void shouldProvideSession() throws Exception {
+ // assertThat(prop.getSession(), is(session));
+ // }
+ //
+ // @Test
+ // public void shouldProvideName() throws Exception {
+ // assertThat(prop.getName(), is("name"));
+ // }
+}
Property changes on: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrPropertyTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRepositoryTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRepositoryTest.java
(rev 0)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRepositoryTest.java 2008-08-08
21:11:12 UTC (rev 405)
@@ -0,0 +1,235 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import static org.hamcrest.collection.IsArrayContaining.hasItemInArray;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.stub;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.util.HashMap;
+import java.util.Map;
+import javax.jcr.Credentials;
+import javax.jcr.Repository;
+import javax.jcr.Session;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+import org.jboss.dna.spi.ExecutionContext;
+import org.jboss.dna.spi.ExecutionContextFactory;
+import org.jboss.dna.spi.connector.RepositoryConnection;
+import org.jboss.dna.spi.connector.RepositoryConnectionFactory;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.mockito.MockitoAnnotations.Mock;
+
+/**
+ * @author jverhaeg
+ */
+public class JcrRepositoryTest {
+
+ private Repository repository;
+ @Mock
+ private Map<String, String> descriptors;
+ @Mock
+ private ExecutionContextFactory executionContextFactory;
+ @Mock
+ private RepositoryConnectionFactory connectionFactory;
+ @Mock
+ private ExecutionContext executionContext;
+ @Mock
+ LoginContext loginContext;
+ @Mock
+ private RepositoryConnection connection;
+ AccessControlContext accessControlContext = AccessController.getContext();
+ private Credentials credentials = new Credentials() {
+
+ private static final long serialVersionUID = 1L;
+
+ @SuppressWarnings( "unused" )
+ public AccessControlContext getAccessControlContext() {
+ return accessControlContext;
+ }
+ };
+
+ @Before
+ public void before() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ stub(executionContext.getLoginContext()).toReturn(loginContext);
+ stub(executionContextFactory.create()).toReturn(executionContext);
+
stub(executionContextFactory.create(accessControlContext)).toReturn(executionContext);
+
stub(connectionFactory.createConnection(JcrI18n.defaultWorkspaceName.text())).toReturn(connection);
+ repository = new JcrRepository(descriptors, executionContextFactory,
connectionFactory);
+ }
+
+ @Test
+ public void shouldAllowNoDescriptors() {
+ new JcrRepository(descriptors, executionContextFactory, connectionFactory);
+ }
+
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldNotAllowNoExecutionContextFactory() throws Exception {
+ new JcrRepository(null, connectionFactory);
+ }
+
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldNotAllowNoConnectionFactories() throws Exception {
+ new JcrRepository(executionContextFactory, null);
+ }
+
+ @Test
+ public void shouldProvideBuiltInDescriptorKeys() {
+ testDescriptorKeys(repository);
+ }
+
+ @Test
+ public void shouldProvideDescriptorValues() {
+ testDescriptorValues(repository);
+ }
+
+ @Test
+ public void shouldProvideBuiltInDescriptorsWhenNotSuppliedDescriptors() {
+ Repository repository = new JcrRepository(descriptors, executionContextFactory,
connectionFactory);
+ testDescriptorKeys(repository);
+ testDescriptorValues(repository);
+ }
+
+ @Test
+ public void shouldProvideUserSuppliedDescriptors() {
+ Map<String, String> descriptors = new HashMap<String, String>();
+ descriptors.put("property", "value");
+ Repository repository = new JcrRepository(descriptors, executionContextFactory,
connectionFactory);
+ testDescriptorKeys(repository);
+ testDescriptorValues(repository);
+ assertThat(repository.getDescriptor("property"),
is("value"));
+ }
+
+ @Test
+ public void shouldAllowLoginWithNoCredentials() throws Exception {
+ Session session = repository.login();
+ assertThat(session, notNullValue());
+ session.logout();
+ session = repository.login((Credentials)null);
+ assertThat(session, notNullValue());
+ session.logout();
+ session = repository.login(null, JcrI18n.defaultWorkspaceName.text());
+ assertThat(session, notNullValue());
+ }
+
+ @Test
+ public void shouldAllowLoginWithProperCredentials() throws Exception {
+ repository.login(credentials);
+ stub(executionContextFactory.create(loginContext)).toReturn(executionContext);
+ repository.login(new Credentials() {
+
+ private static final long serialVersionUID = 1L;
+
+ @SuppressWarnings( "unused" )
+ public LoginContext getLoginContext() throws LoginException {
+ return loginContext;
+ }
+ });
+ }
+
+ @Test
+ public void shouldAllowLoginWithNoWorkspaceName() throws Exception {
+ Session session = repository.login((String)null);
+ assertThat(session, notNullValue());
+ session.logout();
+ session = repository.login(credentials, null);
+ assertThat(session, notNullValue());
+ session.logout();
+ }
+
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldNotAllowLoginIfCredentialsDoNotProvideJaasMethod() throws Exception
{
+ repository.login(Mockito.mock(Credentials.class));
+ }
+
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldNotAllowLoginIfCredentialsReturnNoAccessControlContext() throws
Exception {
+ repository.login(new Credentials() {
+
+ private static final long serialVersionUID = 1L;
+
+ @SuppressWarnings( "unused" )
+ public AccessControlContext getAccessControlContext() {
+ return null;
+ }
+ });
+ }
+
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldNotAllowLoginIfCredentialsReturnNoLoginContext() throws Exception
{
+ repository.login(new Credentials() {
+
+ private static final long serialVersionUID = 1L;
+
+ @SuppressWarnings( "unused" )
+ public LoginContext getLoginContext() {
+ return null;
+ }
+ });
+ }
+
+ private void testDescriptorKeys( Repository repository ) {
+ String[] keys = repository.getDescriptorKeys();
+ assertThat(keys, notNullValue());
+ assertThat(keys.length >= 15, is(true));
+ assertThat(keys, hasItemInArray(Repository.LEVEL_1_SUPPORTED));
+ assertThat(keys, hasItemInArray(Repository.LEVEL_2_SUPPORTED));
+ assertThat(keys, hasItemInArray(Repository.OPTION_LOCKING_SUPPORTED));
+ assertThat(keys, hasItemInArray(Repository.OPTION_OBSERVATION_SUPPORTED));
+ assertThat(keys, hasItemInArray(Repository.OPTION_QUERY_SQL_SUPPORTED));
+ assertThat(keys, hasItemInArray(Repository.OPTION_TRANSACTIONS_SUPPORTED));
+ assertThat(keys, hasItemInArray(Repository.OPTION_VERSIONING_SUPPORTED));
+ assertThat(keys, hasItemInArray(Repository.QUERY_XPATH_DOC_ORDER));
+ assertThat(keys, hasItemInArray(Repository.QUERY_XPATH_POS_INDEX));
+ assertThat(keys, hasItemInArray(Repository.REP_NAME_DESC));
+ assertThat(keys, hasItemInArray(Repository.REP_VENDOR_DESC));
+ assertThat(keys, hasItemInArray(Repository.REP_VENDOR_URL_DESC));
+ assertThat(keys, hasItemInArray(Repository.REP_VERSION_DESC));
+ assertThat(keys, hasItemInArray(Repository.SPEC_NAME_DESC));
+ assertThat(keys, hasItemInArray(Repository.SPEC_VERSION_DESC));
+ }
+
+ private void testDescriptorValues( Repository repository ) {
+ assertThat(repository.getDescriptor(Repository.LEVEL_1_SUPPORTED),
is("true"));
+ assertThat(repository.getDescriptor(Repository.LEVEL_2_SUPPORTED),
is("false"));
+ assertThat(repository.getDescriptor(Repository.OPTION_LOCKING_SUPPORTED),
is("false"));
+ assertThat(repository.getDescriptor(Repository.OPTION_OBSERVATION_SUPPORTED),
is("false"));
+ assertThat(repository.getDescriptor(Repository.OPTION_QUERY_SQL_SUPPORTED),
is("false"));
+ assertThat(repository.getDescriptor(Repository.OPTION_TRANSACTIONS_SUPPORTED),
is("false"));
+ assertThat(repository.getDescriptor(Repository.OPTION_VERSIONING_SUPPORTED),
is("false"));
+ assertThat(repository.getDescriptor(Repository.QUERY_XPATH_DOC_ORDER),
is("true"));
+ assertThat(repository.getDescriptor(Repository.QUERY_XPATH_POS_INDEX),
is("true"));
+ assertThat(repository.getDescriptor(Repository.REP_NAME_DESC),
is(JcrI18n.REP_NAME_DESC.text()));
+ assertThat(repository.getDescriptor(Repository.REP_VENDOR_DESC),
is(JcrI18n.REP_VENDOR_DESC.text()));
+ assertThat(repository.getDescriptor(Repository.REP_VENDOR_URL_DESC),
is("http://www.jboss.org/dna"));
+ assertThat(repository.getDescriptor(Repository.REP_VERSION_DESC),
is("0.2"));
+ assertThat(repository.getDescriptor(Repository.SPEC_NAME_DESC),
is(JcrI18n.SPEC_NAME_DESC.text()));
+ assertThat(repository.getDescriptor(Repository.SPEC_VERSION_DESC),
is("1.0"));
+ }
+}
Property changes on: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRepositoryTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRootNodeTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRootNodeTest.java
(rev 0)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRootNodeTest.java 2008-08-08 21:11:12
UTC (rev 405)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.junit.Assert.assertThat;
+import java.util.HashSet;
+import java.util.Set;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.Property;
+import javax.jcr.Session;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.MockitoAnnotations;
+import org.mockito.MockitoAnnotations.Mock;
+
+/**
+ * @author jverhaeg
+ */
+public class JcrRootNodeTest {
+
+ private JcrRootNode root;
+ @Mock
+ private Session session;
+ private Set<Property> properties;
+
+ @Before
+ public void before() {
+ MockitoAnnotations.initMocks(this);
+ properties = new HashSet<Property>();
+ root = new JcrRootNode(session, properties);
+ }
+
+ @Test
+ public void shouldHaveEmptyName() {
+ String name = root.getName();
+ assertThat(name, notNullValue());
+ assertThat(name.length(), is(0));
+ }
+
+ @Test( expected = ItemNotFoundException.class )
+ public void shouldHaveNoParent() throws Exception {
+ root.getParent();
+ }
+}
Property changes on: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRootNodeTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java
(rev 0)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java 2008-08-08 21:11:12
UTC (rev 405)
@@ -0,0 +1,128 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.hamcrest.core.IsNull.nullValue;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.stub;
+import java.security.Principal;
+import java.util.Collections;
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginContext;
+import org.jboss.dna.jcr.GraphTools.NodeContent;
+import org.jboss.dna.spi.graph.PathFactory;
+import org.jboss.dna.spi.graph.ValueFactories;
+import org.jboss.dna.spi.graph.impl.BasicPath;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.mockito.MockitoAnnotations.Mock;
+
+/**
+ * @author jverhaeg
+ */
+public class JcrSessionTest {
+
+ private JcrSession session;
+ @Mock
+ private JcrRepository repository;
+ @Mock
+ private JcrExecutionContext executionContext;
+ @Mock
+ private GraphTools tools;
+ @Mock
+ private LoginContext loginContext;
+
+ @Before
+ public void before() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ stub(executionContext.getLoginContext()).toReturn(loginContext);
+ stub(executionContext.getGraphTools()).toReturn(tools);
+ session = new JcrSession(repository, executionContext,
JcrI18n.defaultWorkspaceName.text());
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowNoRepository() throws Exception {
+ new JcrSession(null, executionContext, JcrI18n.defaultWorkspaceName.text());
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowNoExecutionContext() throws Exception {
+ new JcrSession(repository, null, JcrI18n.defaultWorkspaceName.text());
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowNoWorkspaceName() throws Exception {
+ new JcrSession(repository, executionContext, null);
+ }
+
+ @Test
+ public void shouldProvideAccessToRepository() throws Exception {
+ assertThat((JcrRepository)session.getRepository(), is(repository));
+ }
+
+ @Test
+ public void shouldProvideAccessToWorkspace() throws Exception {
+ assertThat(session.getWorkspace(), notNullValue());
+ }
+
+ @Test
+ public void shouldBeLiveBeforeLogout() throws Exception {
+ assertThat(session.isLive(), is(true));
+ }
+
+ @Test
+ public void shouldAllowLogout() throws Exception {
+ session.logout();
+ }
+
+ @Test
+ public void shouldNotBeLiveAfterLogout() throws Exception {
+ session.logout();
+ assertThat(session.isLive(), is(false));
+ }
+
+ @Test
+ public void shouldProvideUserId() throws Exception {
+ assertThat(session.getUserID(), nullValue());
+ Principal principal = Mockito.mock(Principal.class);
+ stub(principal.getName()).toReturn("name");
+ Subject subject = new Subject(false, Collections.singleton(principal),
Collections.EMPTY_SET, Collections.EMPTY_SET);
+ stub(executionContext.getSubject()).toReturn(subject);
+ assertThat(session.getUserID(), is("name"));
+ }
+
+ @Test
+ public void shouldProvideRootNode() throws Exception {
+ ValueFactories valueFactories = Mockito.mock(ValueFactories.class);
+ PathFactory pathFactory = Mockito.mock(PathFactory.class);
+ stub(pathFactory.createRootPath()).toReturn(BasicPath.ROOT);
+ stub(valueFactories.getPathFactory()).toReturn(pathFactory);
+ stub(executionContext.getValueFactories()).toReturn(valueFactories);
+ NodeContent content = tools.new NodeContent();
+ stub(tools.getNodeContent(BasicPath.ROOT)).toReturn(content);
+ assertThat(session.getRootNode(), notNullValue());
+ }
+}
Property changes on: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain