[dna-commits] DNA SVN: r956 - in trunk/dna-jcr/src/main: resources/org/jboss/dna/jcr and 1 other directory.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Tue Jun 2 15:52:50 EDT 2009


Author: bcarothers
Date: 2009-06-02 15:52:50 -0400 (Tue, 02 Jun 2009)
New Revision: 956

Modified:
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
   trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties
Log:
DNA-370 JcrWorkspace.clone Is Not Implemented

Committed changes to AbstractJcrNode.getCorrespondingNodePath(String) and .update(String) to handle error checking as per spec.


Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java	2009-06-02 19:30:41 UTC (rev 955)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java	2009-06-02 19:52:50 UTC (rev 956)
@@ -25,6 +25,7 @@
 
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Collection;
 import java.util.Collections;
@@ -40,6 +41,7 @@
 import javax.jcr.ItemExistsException;
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.ItemVisitor;
+import javax.jcr.NoSuchWorkspaceException;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 import javax.jcr.PathNotFoundException;
@@ -99,7 +101,7 @@
     final UUID internalUuid() {
         return nodeUuid;
     }
-    
+
     final Name name() throws RepositoryException {
         return cache.getNameOf(nodeUuid);
     }
@@ -711,8 +713,7 @@
                 JcrNodeDefinition match = this.cache.nodeTypes().findChildNodeDefinition(mixinCandidateType.getInternalName(),
                                                                                          Collections.<Name>emptyList(),
                                                                                          nodeName,
-                                                                                         childNode.getPrimaryNodeType()
-                                                                                                  .getInternalName(),
+                                                                                         childNode.getPrimaryNodeType().getInternalName(),
                                                                                          snsCount,
                                                                                          false);
 
@@ -996,11 +997,21 @@
     /**
      * {@inheritDoc}
      * 
-     * @throws UnsupportedOperationException always
      * @see javax.jcr.Node#update(java.lang.String)
      */
-    public final void update( String srcWorkspaceName ) {
-        throw new UnsupportedOperationException();
+    public final void update( String srcWorkspaceName ) throws NoSuchWorkspaceException, RepositoryException {
+        String[] workspaces = this.session().workspace().getAccessibleWorkspaceNames();
+
+        if (!Arrays.asList(workspaces).contains(srcWorkspaceName)) {
+            JcrRepository repo = session().repository();
+            throw new NoSuchWorkspaceException(JcrI18n.workspaceNameIsInvalid.text(srcWorkspaceName, repo.getName()));
+        }
+
+        if (session().hasPendingChanges()) {
+            throw new InvalidItemStateException(JcrI18n.noPendingChangesAllowed.text());
+        }
+        
+        if (true) throw new UnsupportedOperationException();
     }
 
     protected final Property removeExistingValuedProperty( String name ) throws ConstraintViolationException, RepositoryException {
@@ -1363,10 +1374,19 @@
     /**
      * {@inheritDoc}
      * 
-     * @throws UnsupportedOperationException always
      * @see javax.jcr.Node#getCorrespondingNodePath(java.lang.String)
      */
-    public final String getCorrespondingNodePath( String workspaceName ) {
+    public final String getCorrespondingNodePath( String workspaceName ) throws NoSuchWorkspaceException, RepositoryException {
+        
+        String[] workspaces = this.session().workspace().getAccessibleWorkspaceNames();
+
+        if (!Arrays.asList(workspaces).contains(workspaceName)) {
+            JcrRepository repo = session().repository();
+            throw new NoSuchWorkspaceException(JcrI18n.workspaceNameIsInvalid.text(workspaceName, repo.getName()));
+        }
+
+        // TODO:Check permissions on workspace
+        
         throw new UnsupportedOperationException();
     }
 
@@ -1473,7 +1493,7 @@
             if (destPath.isAbsolute() || destPath.size() != 1) {
                 throw new ItemNotFoundException();
             }
-            
+
             destSegment = destPath.getLastSegment();
 
             // getLastSegment should return the only segment, since we verified that size() == 1
@@ -1483,7 +1503,7 @@
                 throw new ItemNotFoundException(JcrI18n.pathNotFound.text(destPath, workspaceName));
             }
         }
-        
+
         this.editor().orderChildBefore(sourceSegment, destSegment);
 
     }
@@ -1565,17 +1585,16 @@
 
     @Override
     public String toString() {
-        
+
         try {
             PropertyIterator iter = this.getProperties();
             StringBuffer propertyBuff = new StringBuffer();
             while (iter.hasNext()) {
-                AbstractJcrProperty prop = (AbstractJcrProperty) iter.nextProperty();
+                AbstractJcrProperty prop = (AbstractJcrProperty)iter.nextProperty();
                 propertyBuff.append(prop.toString()).append(", ");
             }
             return this.getPath() + " {" + propertyBuff.toString() + "}";
-        }
-        catch (RepositoryException re) {
+        } catch (RepositoryException re) {
             return re.getMessage();
         }
     }

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	2009-06-02 19:30:41 UTC (rev 955)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java	2009-06-02 19:52:50 UTC (rev 956)
@@ -136,6 +136,7 @@
     public static I18n allNodeTypeTemplatesMustComeFromSameSession;
 
     public static I18n nodeNotReferenceable;
+    public static I18n noPendingChangesAllowed;
 
     static {
         try {

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java	2009-06-02 19:30:41 UTC (rev 955)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java	2009-06-02 19:52:50 UTC (rev 956)
@@ -415,4 +415,13 @@
         JcrWorkspace workspace = new JcrWorkspace(this, workspaceName, execContext, sessionAttributes);
         return workspace.getSession();
     }
+
+    /**
+     * Returns the name of this repository
+     * @return the name of this repository
+     * @see #sourceName
+     */
+    String getName() {
+        return this.sourceName;
+    }
 }

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java	2009-06-02 19:30:41 UTC (rev 955)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java	2009-06-02 19:52:50 UTC (rev 956)
@@ -210,6 +210,10 @@
         return this.workspace;
     }
 
+    JcrRepository repository() {
+        return this.repository;
+    }
+
     Graph.Batch createBatch() {
         return graph.batch();
     }

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	2009-06-02 19:30:41 UTC (rev 955)
+++ trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties	2009-06-02 19:52:50 UTC (rev 956)
@@ -120,4 +120,5 @@
 
 allNodeTypeTemplatesMustComeFromSameSession=All node type templates must be created from the same javax.jcr.Session
 
-nodeNotReferenceable=Only referenceable nodes may be the value of reference properties.
\ No newline at end of file
+nodeNotReferenceable=Only referenceable nodes may be the value of reference properties
+noPendingChangesAllowed=This operation cannot be performed when the session has pending changes
\ No newline at end of file




More information about the dna-commits mailing list