X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Finternal%2Fkernel%2FNodeRepositoryFactory.java;h=a0dd38e3e9779088066450e61fc3937a35e1f535;hb=fb22feb37b0c2340d3d846dce4b6f47d0f728efb;hp=b59b5e29c29ef23f8307b8b95e2719ff08717ee5;hpb=8500cae34c6596f6f3532db4431170d4a636f78c;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/internal/kernel/NodeRepositoryFactory.java b/org.argeo.cms/src/org/argeo/cms/internal/kernel/NodeRepositoryFactory.java index b59b5e29c..a0dd38e3e 100644 --- a/org.argeo.cms/src/org/argeo/cms/internal/kernel/NodeRepositoryFactory.java +++ b/org.argeo.cms/src/org/argeo/cms/internal/kernel/NodeRepositoryFactory.java @@ -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.cms.internal.kernel; import java.net.URI; @@ -28,13 +13,13 @@ import javax.jcr.RepositoryFactory; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.jackrabbit.jcr2dav.Jcr2davRepositoryFactory; +import org.argeo.api.NodeConstants; +import org.argeo.cms.internal.jcr.RepoConf; import org.argeo.jcr.ArgeoJcrException; -import org.argeo.node.NodeConstants; import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; import org.osgi.framework.InvalidSyntaxException; import org.osgi.framework.ServiceReference; -import org.springframework.core.io.Resource; /** * OSGi-aware Jackrabbit repository factory which can retrieve/publish @@ -50,7 +35,7 @@ class NodeRepositoryFactory implements RepositoryFactory { protected Repository getRepositoryByAlias(String alias) { try { Collection> srs = bundleContext.getServiceReferences(Repository.class, - "(" + NodeConstants.JCR_REPOSITORY_ALIAS + "=" + alias + ")"); + "(" + NodeConstants.CN + "=" + alias + ")"); if (srs.size() == 0) throw new ArgeoJcrException("No repository with alias " + alias + " found in OSGi registry"); else if (srs.size() > 1) @@ -84,15 +69,16 @@ class NodeRepositoryFactory implements RepositoryFactory { // check if remote Repository repository; String uri = null; - if (parameters.containsKey(NodeConstants.JCR_REPOSITORY_URI)) - uri = parameters.get(NodeConstants.JCR_REPOSITORY_URI).toString(); + if (parameters.containsKey(RepoConf.labeledUri.name())) + uri = parameters.get(NodeConstants.LABELED_URI).toString(); else if (parameters.containsKey(KernelConstants.JACKRABBIT_REPOSITORY_URI)) uri = parameters.get(KernelConstants.JACKRABBIT_REPOSITORY_URI).toString(); if (uri != null) { - if (uri.startsWith("http"))// http, https - repository = createRemoteRepository(uri); - else if (uri.startsWith("file"))// http, https + if (uri.startsWith("http")) {// http, https + Object defaultWorkspace = parameters.get(RepoConf.defaultWorkspace.name()); + repository = createRemoteRepository(uri, defaultWorkspace != null ? defaultWorkspace.toString() : null); + } else if (uri.startsWith("file"))// http, https repository = createFileRepository(uri, parameters); else if (uri.startsWith("vm")) { // log.warn("URI " + uri + " should have been managed by generic @@ -103,10 +89,10 @@ class NodeRepositoryFactory implements RepositoryFactory { } - else if (parameters.containsKey(NodeConstants.JCR_REPOSITORY_ALIAS)) { + else if (parameters.containsKey(NodeConstants.CN)) { // Properties properties = new Properties(); // properties.putAll(parameters); - String alias = parameters.get(NodeConstants.JCR_REPOSITORY_ALIAS).toString(); + String alias = parameters.get(NodeConstants.CN).toString(); // publish(alias, repository, properties); // log.info("Registered JCR repository under alias '" + alias + "' // with properties " + properties); @@ -120,9 +106,11 @@ class NodeRepositoryFactory implements RepositoryFactory { return repository; } - protected Repository createRemoteRepository(String uri) throws RepositoryException { + protected Repository createRemoteRepository(String uri, String defaultWorkspace) throws RepositoryException { Map params = new HashMap(); params.put(KernelConstants.JACKRABBIT_REPOSITORY_URI, uri); + if (defaultWorkspace != null) + params.put(KernelConstants.JACKRABBIT_REMOTE_DEFAULT_WORKSPACE, defaultWorkspace); Repository repository = new Jcr2davRepositoryFactory().getRepository(params); if (repository == null) throw new ArgeoJcrException("Remote Davex repository " + uri + " not found"); @@ -190,16 +178,10 @@ class NodeRepositoryFactory implements RepositoryFactory { } /** - * Called after the repository has been initialised. Does nothing by - * default. + * Called after the repository has been initialised. Does nothing by default. */ @SuppressWarnings("rawtypes") protected void postInitialization(Repository repository, Map parameters) { } - - public void setFileRepositoryConfiguration(Resource fileRepositoryConfiguration) { -// this.fileRepositoryConfiguration = fileRepositoryConfiguration; - } - }