Improve inital Jackrabbit login
[lgpl/argeo-commons.git] / server / runtime / org.argeo.server.jackrabbit / src / main / java / org / argeo / jackrabbit / JackrabbitContainer.java
index 6f50f735821d5821417ea871b75a5b0972788513..0ad12327fc47f5168133d208892c99dd94c3984a 100644 (file)
@@ -90,6 +90,12 @@ public class JackrabbitContainer implements InitializingBean, DisposableBean,
        private Credentials adminCredentials;
 
        public void afterPropertiesSet() throws Exception {
+               if (repository != null) {
+                       // we are just wrapping another repository
+                       importNodeTypeDefinitions(repository);
+                       return;
+               }
+
                // remote repository
                if (uri != null && !uri.trim().equals("")) {
                        Map<String, String> params = new HashMap<String, String>();
@@ -171,9 +177,11 @@ public class JackrabbitContainer implements InitializingBean, DisposableBean,
        protected void importNodeTypeDefinitions(final Repository repository) {
                final Credentials credentialsToUse;
                if (systemExecutor == null) {
-                       if (adminCredentials == null)
-                               throw new ArgeoException(
-                                               "No system executor or admin credentials found");
+                       if (adminCredentials == null) {
+                               log.error("No system executor or admin credentials found,"
+                                               + " cannot import node types");
+                               return;
+                       }
                        credentialsToUse = adminCredentials;
                } else {
                        credentialsToUse = null;
@@ -371,4 +379,8 @@ public class JackrabbitContainer implements InitializingBean, DisposableBean,
                this.adminCredentials = adminCredentials;
        }
 
+       public void setRepository(Repository repository) {
+               this.repository = repository;
+       }
+
 }