X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=server%2Fruntime%2Forg.argeo.server.jackrabbit%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fjackrabbit%2FJackrabbitRepositoryFactory.java;h=1f2ec2ae2c16716ad020af4cb576be50bc043b1d;hb=d911416648a69f8140e03aa7248c4eb38e96e90f;hp=65bdf29393478ae0b1b99371ed441e54288e9762;hpb=f4ef63b879433249c89bc031cd03e34864f73bfa;p=lgpl%2Fargeo-commons.git diff --git a/server/runtime/org.argeo.server.jackrabbit/src/main/java/org/argeo/jackrabbit/JackrabbitRepositoryFactory.java b/server/runtime/org.argeo.server.jackrabbit/src/main/java/org/argeo/jackrabbit/JackrabbitRepositoryFactory.java index 65bdf2939..1f2ec2ae2 100644 --- a/server/runtime/org.argeo.server.jackrabbit/src/main/java/org/argeo/jackrabbit/JackrabbitRepositoryFactory.java +++ b/server/runtime/org.argeo.server.jackrabbit/src/main/java/org/argeo/jackrabbit/JackrabbitRepositoryFactory.java @@ -1,5 +1,22 @@ +/* + * Copyright (C) 2007-2012 Mathieu Baudier + * + * 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.jackrabbit; +import java.net.URI; +import java.net.URISyntaxException; import java.util.HashMap; import java.util.Map; import java.util.Properties; @@ -39,9 +56,25 @@ public class JackrabbitRepositoryFactory extends DefaultRepositoryFactory else if (parameters.containsKey(JcrUtils.REPOSITORY_URI)) uri = parameters.get(JcrUtils.REPOSITORY_URI).toString(); - if (uri == null) - repository = createRemoteRepository(uri); + if (uri != null) { + if (uri.startsWith("http"))// http, https + repository = createRemoteRepository(uri); + else if (uri.startsWith("vm")) { + try { + URI uriObj = new URI(uri); + String alias = uriObj.getPath(); + if (alias.charAt(0) == '/') + alias = alias.substring(1); + if (alias.charAt(alias.length() - 1) == '/') + alias = alias.substring(0, alias.length() - 1); + repository = getRepositoryByAlias(alias); + } catch (URISyntaxException e) { + throw new ArgeoException("Cannot interpret URI " + uri, e); + } + } + } + // publish under alias if (parameters.containsKey(JCR_REPOSITORY_ALIAS)) { Properties properties = new Properties(); properties.putAll(parameters); @@ -68,7 +101,7 @@ public class JackrabbitRepositoryFactory extends DefaultRepositoryFactory } /** - * Called after the repository has been initialized. Does nothing by + * Called after the repository has been initialised. Does nothing by * default. */ @SuppressWarnings("rawtypes")