Refactor JCR exceptions.
[lgpl/argeo-commons.git] / org.argeo.jcr / src / org / argeo / jcr / ThreadBoundJcrSessionFactory.java
index 281bd015c4d7f5fad90878695def317ee0173a98..1e23338b54660816148c68f546e5594958d01fb5 100644 (file)
@@ -1,18 +1,3 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
 package org.argeo.jcr;
 
 import java.lang.reflect.InvocationHandler;
@@ -69,7 +54,7 @@ public abstract class ThreadBoundJcrSessionFactory {
        /** Logs in to the repository using various strategies. */
        protected synchronized Session login() {
                if (!isActive())
-                       throw new ArgeoJcrException("Thread bound session factory inactive");
+                       throw new IllegalStateException("Thread bound session factory inactive");
 
                // discard session previously attached to this thread
                Thread thread = Thread.currentThread();
@@ -91,7 +76,7 @@ public abstract class ThreadBoundJcrSessionFactory {
                                // invalid credentials, go to the next step
                        } catch (RepositoryException e1) {
                                // other kind of exception, fail
-                               throw new ArgeoJcrException("Cannot log in to repository", e1);
+                               throw new JcrException("Cannot log in to repository", e1);
                        }
 
                // log using default username / password (useful for testing purposes)
@@ -100,7 +85,7 @@ public abstract class ThreadBoundJcrSessionFactory {
                                SimpleCredentials sc = new SimpleCredentials(defaultUsername, defaultPassword.toCharArray());
                                newSession = repository().login(sc, workspace);
                        } catch (RepositoryException e) {
-                               throw new ArgeoJcrException("Cannot log in to repository", e);
+                               throw new JcrException("Cannot log in to repository", e);
                        }
 
                session.set(newSession);
@@ -188,9 +173,9 @@ public abstract class ThreadBoundJcrSessionFactory {
        }
 
        /**
-        * Called before a method is actually called, allowing to check the session
-        * or re-login it (e.g. if authentication has changed). The default
-        * implementation returns the session.
+        * Called before a method is actually called, allowing to check the session or
+        * re-login it (e.g. if authentication has changed). The default implementation
+        * returns the session.
         */
        protected Session preCall(Session session) {
                return session;
@@ -205,7 +190,7 @@ public abstract class ThreadBoundJcrSessionFactory {
                        if (it.hasNext())
                                return it.next();
                }
-               throw new ArgeoJcrException("No repository injected");
+               throw new IllegalStateException("No repository injected");
        }
 
        // /** Useful for declarative registration of OSGi services (blueprint) */