jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r789706 - in /jackrabbit/branches/1.x: ./ jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/ jackrabbit-jca/src/test/java/org/apache/jackrabbit/jca/test/
Date Tue, 30 Jun 2009 13:13:46 GMT
Author: jukka
Date: Tue Jun 30 13:13:46 2009
New Revision: 789706

URL: http://svn.apache.org/viewvc?rev=789706&view=rev
Log:
1.x: Merged revisions 779032 and 779040 (JCR-1665 and JCR-1597)

Added:
    jackrabbit/branches/1.x/jackrabbit-jca/src/test/java/org/apache/jackrabbit/jca/test/ConnectionRequestInfoTest.java
      - copied unchanged from r779032, jackrabbit/trunk/jackrabbit-jca/src/test/java/org/apache/jackrabbit/jca/test/ConnectionRequestInfoTest.java
Modified:
    jackrabbit/branches/1.x/   (props changed)
    jackrabbit/branches/1.x/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAConnectionRequestInfo.java
    jackrabbit/branches/1.x/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCARepositoryHandle.java
    jackrabbit/branches/1.x/jackrabbit-jca/src/test/java/org/apache/jackrabbit/jca/test/ConnectionFactoryTest.java

Propchange: jackrabbit/branches/1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun 30 13:13:46 2009
@@ -1 +1 @@
-/jackrabbit/trunk:770143-773197,773483,773525-773554,773584,773588,773828,773835-775756,775833,775836,775840,775868,775981,775986,776036,776256,776310,776313,776321-776322,776332,776356-776357,776362,776373,776650-776693,776737,776757,776776-776777,777024,777029,777034,777478,777509,777541,777548,777936,778445,778613,778616,778621,778645,778720,778802
+/jackrabbit/trunk:770143-773197,773483,773525-773554,773584,773588,773828,773835-775756,775833,775836,775840,775868,775981,775986,776036,776256,776310,776313,776321-776322,776332,776356-776357,776362,776373,776650-776693,776737,776757,776776-776777,777024,777029,777034,777478,777509,777541,777548,777936,778445,778613,778616,778621,778645,778720,778802,779032,779040

Modified: jackrabbit/branches/1.x/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAConnectionRequestInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.x/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAConnectionRequestInfo.java?rev=789706&r1=789705&r2=789706&view=diff
==============================================================================
--- jackrabbit/branches/1.x/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAConnectionRequestInfo.java
(original)
+++ jackrabbit/branches/1.x/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAConnectionRequestInfo.java
Tue Jun 30 13:13:46 2009
@@ -72,7 +72,7 @@
      */
     public int hashCode() {
         int hash1 = workspace != null ? workspace.hashCode() : 0;
-        int hash2 = creds != null ? creds.hashCode() : 0;
+        int hash2 = creds != null ? computeCredsHashCode(creds) : 0;
         return hash1 ^ hash2;
     }
 
@@ -170,4 +170,33 @@
 
         return map;
     }
+
+    /**
+     * Returns Credentials instance hash code. Handles instances of
+     * SimpleCredentials in a special way.
+     */
+    private int computeCredsHashCode(Credentials c) {
+        if (c instanceof SimpleCredentials) {
+            return computeSimpleCredsHashCode((SimpleCredentials) c);
+        }
+        return c.hashCode();
+    }
+
+    /**
+     * Computes hash code of a SimpleCredentials instance. Ignores its own
+     * hashCode() method because it's not overridden in SimpleCredentials.
+     */
+    private int computeSimpleCredsHashCode(SimpleCredentials c) {
+        String userID = c.getUserID();
+        char[] password = c.getPassword();
+        Map m = getAttributeMap(c);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((userID == null) ? 0 : userID.hashCode());
+        for (int i = 0; i < password.length; i++) {
+            result = prime * result + password[i];
+        }
+        result = prime * result + ((m == null) ? 0 : m.hashCode());
+        return result;
+    }
 }

Modified: jackrabbit/branches/1.x/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCARepositoryHandle.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.x/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCARepositoryHandle.java?rev=789706&r1=789705&r2=789706&view=diff
==============================================================================
--- jackrabbit/branches/1.x/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCARepositoryHandle.java
(original)
+++ jackrabbit/branches/1.x/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCARepositoryHandle.java
Tue Jun 30 13:13:46 2009
@@ -98,7 +98,9 @@
             return (Session) cm.allocateConnection(mcf, cri);
         } catch (ResourceException e) {
             Throwable cause = e.getCause();
-
+            if (cause == null) {
+                cause = e.getLinkedException();
+            }
             if (cause instanceof LoginException) {
                 throw (LoginException) cause;
             } else if (cause instanceof NoSuchWorkspaceException) {

Modified: jackrabbit/branches/1.x/jackrabbit-jca/src/test/java/org/apache/jackrabbit/jca/test/ConnectionFactoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.x/jackrabbit-jca/src/test/java/org/apache/jackrabbit/jca/test/ConnectionFactoryTest.java?rev=789706&r1=789705&r2=789706&view=diff
==============================================================================
--- jackrabbit/branches/1.x/jackrabbit-jca/src/test/java/org/apache/jackrabbit/jca/test/ConnectionFactoryTest.java
(original)
+++ jackrabbit/branches/1.x/jackrabbit-jca/src/test/java/org/apache/jackrabbit/jca/test/ConnectionFactoryTest.java
Tue Jun 30 13:13:46 2009
@@ -16,17 +16,19 @@
  */
 package org.apache.jackrabbit.jca.test;
 
-import org.apache.jackrabbit.api.XASession;
-import org.apache.jackrabbit.jca.JCAConnectionRequestInfo;
-import org.apache.jackrabbit.jca.JCARepositoryHandle;
-import org.apache.jackrabbit.jca.JCASessionHandle;
+import java.io.Serializable;
+import java.util.HashSet;
 
+import javax.jcr.NoSuchWorkspaceException;
 import javax.jcr.Repository;
 import javax.jcr.Session;
 import javax.naming.Referenceable;
 import javax.resource.spi.ManagedConnection;
-import java.io.Serializable;
-import java.util.HashSet;
+
+import org.apache.jackrabbit.api.XASession;
+import org.apache.jackrabbit.jca.JCAConnectionRequestInfo;
+import org.apache.jackrabbit.jca.JCARepositoryHandle;
+import org.apache.jackrabbit.jca.JCASessionHandle;
 
 /**
  * This case executes tests on the connection factory.
@@ -118,5 +120,18 @@
         assertTrue(session instanceof XASession);
         session.logout();
     }
+    
+    /**
+     * Tests if a NoSuchWorkspaceException is thrown if a wrong workspace name is given to
login
+     */
+    public void testExceptionHandling() throws Exception {
+        Object cf = mcf.createConnectionFactory();
+        Repository repository = (Repository) cf;
+        try {
+            repository.login(JCR_SUPERUSER, "xxx");
+        } catch (Exception e) {
+            assertTrue(e instanceof NoSuchWorkspaceException);
+        }
+    }
 
 }



Mime
View raw message