You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@karaf.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/08/28 14:06:00 UTC

[jira] [Commented] (KARAF-5661) Be able to use proxy or storage in Cave Maven

    [ https://issues.apache.org/jira/browse/KARAF-5661?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16595011#comment-16595011 ] 

ASF GitHub Bot commented on KARAF-5661:
---------------------------------------

jbonofre closed pull request #10: [KARAF-5661] Add Maven repository support for Cave repositories
URL: https://github.com/apache/karaf-cave/pull/10
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/server/api/src/main/java/org/apache/karaf/cave/server/api/CaveMavenRepositoryListener.java b/server/api/src/main/java/org/apache/karaf/cave/server/api/CaveMavenRepositoryListener.java
new file mode 100644
index 0000000..f878bb1
--- /dev/null
+++ b/server/api/src/main/java/org/apache/karaf/cave/server/api/CaveMavenRepositoryListener.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.karaf.cave.server.api;
+
+/**
+ * Service registering Caven repository as Maven repository.
+ */
+public interface CaveMavenRepositoryListener {
+
+    void addRepository(String name, String location) throws Exception;
+
+    void removeRepository(String name);
+
+}
diff --git a/server/api/src/main/java/org/apache/karaf/cave/server/api/CaveRepository.java b/server/api/src/main/java/org/apache/karaf/cave/server/api/CaveRepository.java
index e4ccb9d..ec903ab 100644
--- a/server/api/src/main/java/org/apache/karaf/cave/server/api/CaveRepository.java
+++ b/server/api/src/main/java/org/apache/karaf/cave/server/api/CaveRepository.java
@@ -27,24 +27,33 @@
 
     /**
      * Get the name of the repository.
-     *
-     * @return the name of the repository
      */
-    public String getName();
+    String getName();
 
     /**
      * Get the location (filesystem) of this repository.
-     *
-     * @return the location of this repository.
      */
-    public String getLocation();
+    String getLocation();
 
     /**
      * Get the last modification date of this repository.
-     *
-     * @return the last modification date.
      */
-    public long getIncrement();
+    long getIncrement();
+
+    /**
+     * Get the JAAS realm used to control access to this repository.
+     */
+    String getRealm();
+
+    /**
+     * Get the JAAS users role to download artifacts from this repository.
+     */
+    String getDownloadRole();
+
+    /**
+     * Get the JAAS users role to upload artifacts to this repository.
+     */
+    String getUploadRole();
 
     /**
      * Upload an artifact from the given URL into the repository.
diff --git a/server/api/src/main/java/org/apache/karaf/cave/server/api/CaveRepositoryService.java b/server/api/src/main/java/org/apache/karaf/cave/server/api/CaveRepositoryService.java
index 2b247ec..89aa4ed 100644
--- a/server/api/src/main/java/org/apache/karaf/cave/server/api/CaveRepositoryService.java
+++ b/server/api/src/main/java/org/apache/karaf/cave/server/api/CaveRepositoryService.java
@@ -36,11 +36,14 @@
      *
      * @param name the name of the repository.
      * @param location the storage location of the repository.
+     * @param realm the JAAS realm to use to control access to this repository.
+     * @param downloadRole the users role to download artifacts from this repository.
+     * @param uploadRole the users role to upload artifacts to this repository.
      * @param scan if true, the repository is scanned at creation time, and the repository metadata are created.
      * @return the Cave repository.
      * @throws Exception in case of creation failure.
      */
-    CaveRepository create(String name, String location, boolean scan) throws Exception;
+    CaveRepository create(String name, String location, String realm, String downloadRole, String uploadRole, boolean scan) throws Exception;
 
     /**
      * Uninstall a Cave repository from the repository service.
diff --git a/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryCreateCommand.java b/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryCreateCommand.java
index a7af6b6..1bbbc10 100644
--- a/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryCreateCommand.java
+++ b/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryCreateCommand.java
@@ -32,6 +32,15 @@
     @Option(name = "-l", aliases = {"--location"}, description = "Location of the repository on the file system", required = false, multiValued = false)
     String location;
 
+    @Option(name = "-r", aliases = {"--realm"}, description = "JAAS realm to use for repository security", required = false, multiValued = false)
+    String realm;
+
+    @Option(name = "-d", aliases = {"--download-role"}, description = "Users role allowed to download artifacts", required = false, multiValued = false)
+    String downloadRole;
+
+    @Option(name = "-u", aliases = {"--upload-role"}, description = "Users role allowed to upload artifacts", required = false, multiValued = false)
+    String uploadRole;
+
     @Option(name = "-no", aliases = {"--no-generate"}, description = "Do not generate repository metadata", required = false, multiValued = false)
     boolean noGenerate = false;
 
@@ -47,7 +56,7 @@ protected Object doExecute() throws Exception {
             return null;
         }
         if (location != null) {
-            getCaveRepositoryService().create(name, location, false);
+            getCaveRepositoryService().create(name, location, realm, downloadRole, uploadRole, false);
         } else {
             getCaveRepositoryService().create(name, false);
         }
diff --git a/server/management/src/main/java/org/apache/karaf/cave/server/management/CaveRepositoryMBean.java b/server/management/src/main/java/org/apache/karaf/cave/server/management/CaveRepositoryMBean.java
index ec47daa..4e2bf32 100644
--- a/server/management/src/main/java/org/apache/karaf/cave/server/management/CaveRepositoryMBean.java
+++ b/server/management/src/main/java/org/apache/karaf/cave/server/management/CaveRepositoryMBean.java
@@ -22,7 +22,7 @@
 
     TabularData getCaveRepositories() throws Exception;
 
-    void createRepository(String name, String location, boolean generate, boolean install) throws Exception;
+    void createRepository(String name, String location, String realm, String downloadRole, String uploadRole, boolean generate, boolean install) throws Exception;
     void destroyRepository(String name) throws Exception;
     void installRepository(String name) throws Exception;
     void uninstallRepository(String name) throws Exception;
diff --git a/server/management/src/main/java/org/apache/karaf/cave/server/management/internal/CaveRepositoryMBeanImpl.java b/server/management/src/main/java/org/apache/karaf/cave/server/management/internal/CaveRepositoryMBeanImpl.java
index 95f71aa..94a08aa 100644
--- a/server/management/src/main/java/org/apache/karaf/cave/server/management/internal/CaveRepositoryMBeanImpl.java
+++ b/server/management/src/main/java/org/apache/karaf/cave/server/management/internal/CaveRepositoryMBeanImpl.java
@@ -67,12 +67,12 @@ public TabularData getCaveRepositories() throws Exception {
         return table;
     }
 
-    public void createRepository(String name, String location, boolean generate, boolean install) throws Exception {
+    public void createRepository(String name, String location, String realm, String downloadRole, String uploadRole, boolean generate, boolean install) throws Exception {
         if (getCaveRepositoryService().getRepository(name) != null) {
             throw new IllegalArgumentException("Cave repository " + name + " already exists");
         }
         if (location != null) {
-            getCaveRepositoryService().create(name, location, false);
+            getCaveRepositoryService().create(name, location, realm, downloadRole, uploadRole, false);
         } else {
             getCaveRepositoryService().create(name, false);
         }
diff --git a/server/maven/pom.xml b/server/maven/pom.xml
index 96b58e4..0fb151c 100644
--- a/server/maven/pom.xml
+++ b/server/maven/pom.xml
@@ -65,6 +65,10 @@
     </build>
 
     <dependencies>
+        <dependency>
+            <groupId>org.apache.karaf.cave.server</groupId>
+            <artifactId>org.apache.karaf.cave.server.api</artifactId>
+        </dependency>
         <dependency>
             <groupId>${servlet.spec.groupId}</groupId>
             <artifactId>${servlet.spec.artifactId}</artifactId>
diff --git a/server/maven/src/main/java/org/apache/karaf/cave/server/maven/Activator.java b/server/maven/src/main/java/org/apache/karaf/cave/server/maven/Activator.java
index 2ae3c44..8d73d64 100644
--- a/server/maven/src/main/java/org/apache/karaf/cave/server/maven/Activator.java
+++ b/server/maven/src/main/java/org/apache/karaf/cave/server/maven/Activator.java
@@ -16,12 +16,13 @@
  */
 package org.apache.karaf.cave.server.maven;
 
-import java.io.IOException;
 import java.util.Enumeration;
 import java.util.Hashtable;
 
+import org.apache.karaf.cave.server.api.CaveMavenRepositoryListener;
 import org.apache.karaf.util.tracker.BaseActivator;
 import org.apache.karaf.util.tracker.annotation.Managed;
+import org.apache.karaf.util.tracker.annotation.ProvideService;
 import org.apache.karaf.util.tracker.annotation.RequireService;
 import org.apache.karaf.util.tracker.annotation.Services;
 import org.ops4j.pax.url.mvn.MavenResolver;
@@ -30,7 +31,8 @@
 import org.osgi.service.http.HttpService;
 
 @Services(
-        requires = @RequireService(HttpService.class)
+        requires = @RequireService(HttpService.class),
+        provides = @ProvideService(CaveMavenRepositoryListener.class)
 )
 @Managed("org.apache.karaf.cave.server.maven")
 public class Activator extends BaseActivator implements ManagedService {
@@ -48,10 +50,10 @@ protected void doStart() throws Exception {
         }
 
         String pid = getString("cave.maven.pid", "org.ops4j.pax.url.mvn");
-        String alias = getString("cave.maven.alias", "/cave/maven");
+        String alias = getString("cave.maven.alias", "/cave/maven/proxy");
         String realm = getString("cave.maven.realm", "karaf");
         String downloadRole = getString("cave.maven.downloadRole", null);
-        String uploadRole = getString("cave.maven.uploadRole", "karaf");
+        String uploadRole = getString("cave.maven.uploadRole", null);
         int poolSize = getInt("cave.maven.poolSize", 8);
         Hashtable<String, String> config = new Hashtable<>();
         if (getConfiguration() != null) {
@@ -65,6 +67,10 @@ protected void doStart() throws Exception {
         this.alias = alias;
         this.servlet = new CaveMavenServlet(this.resolver, poolSize, realm, downloadRole, uploadRole);
         this.httpService.registerServlet(this.alias, this.servlet, config, null);
+
+        CaveMavenRepositoryListenerImpl repositoryListener = new CaveMavenRepositoryListenerImpl(httpService,
+                poolSize, realm, downloadRole, uploadRole);
+        register(CaveMavenRepositoryListener.class, repositoryListener);
     }
 
     @Override
@@ -72,12 +78,13 @@ protected void doStop() {
         if (httpService != null) {
             try {
                 httpService.unregister(alias);
+                httpService.unregister("/cave/maven/repositories/test");
             } catch (Throwable t) {
                 logger.debug("Exception caught while stopping", t);
             } finally {
                 httpService = null;
             }
-            }
+        }
         if (servlet != null) {
             try {
                 servlet.destroy();
@@ -86,7 +93,7 @@ protected void doStop() {
             } finally {
                 servlet = null;
             }
-            }
+        }
         if (resolver != null) {
             try {
                 resolver.close();
diff --git a/server/maven/src/main/java/org/apache/karaf/cave/server/maven/CaveMavenRepositoryListenerImpl.java b/server/maven/src/main/java/org/apache/karaf/cave/server/maven/CaveMavenRepositoryListenerImpl.java
new file mode 100644
index 0000000..d7af7e3
--- /dev/null
+++ b/server/maven/src/main/java/org/apache/karaf/cave/server/maven/CaveMavenRepositoryListenerImpl.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.karaf.cave.server.maven;
+
+import org.apache.karaf.cave.server.api.CaveMavenRepositoryListener;
+import org.ops4j.pax.url.mvn.MavenResolver;
+import org.ops4j.pax.url.mvn.MavenResolvers;
+import org.osgi.service.http.HttpService;
+
+import java.util.Hashtable;
+
+public class CaveMavenRepositoryListenerImpl implements CaveMavenRepositoryListener {
+
+    private int poolSize;
+    private String realm;
+    private String downloadRole;
+    private String uploadRole;
+    private HttpService httpService;
+
+    public CaveMavenRepositoryListenerImpl(HttpService httpService, int poolSize, String realm, String downloadRole, String uploadRole) {
+        this.httpService = httpService;
+        this.poolSize = poolSize;
+        this.realm = realm;
+        this.downloadRole = downloadRole;
+        this.uploadRole = uploadRole;
+    }
+
+    @Override
+    public void addRepository(String name, String location) throws Exception {
+        Hashtable<String, String> config = new Hashtable<>();
+        config.put("defaultRepositories", "file:" + location + "@id=cave@snapshots");
+        config.put("defaultLocalRepoAsRemote", "false");
+        config.put("useFallbackRepositories", "false");
+        config.put("localRepository", location);
+        config.put("repositories", "file:" + location + "@id=" + name + "@snapshots");
+        MavenResolver resolver = MavenResolvers.createMavenResolver(config, null);
+        CaveMavenServlet servlet = new CaveMavenServlet(resolver, poolSize, realm, downloadRole, uploadRole);
+        httpService.registerServlet("/cave/maven/repositories/" + name, servlet, null, null);
+    }
+
+    @Override
+    public void removeRepository(String name) {
+        httpService.unregister("/cave/maven/repositories/" + name);
+    }
+
+}
diff --git a/server/rest/src/main/java/org/apache/karaf/cave/server/rest/Service.java b/server/rest/src/main/java/org/apache/karaf/cave/server/rest/Service.java
index f2b7fd6..bc659a2 100644
--- a/server/rest/src/main/java/org/apache/karaf/cave/server/rest/Service.java
+++ b/server/rest/src/main/java/org/apache/karaf/cave/server/rest/Service.java
@@ -59,6 +59,9 @@ public Repository create(@QueryParam(value = "name") String name, @QueryParam(va
      *
      * @param name the name of the repository.
      * @param location the storage location of the repository.
+     * @param realm the JAAS realm
+     * @param downloadRole the users role allowed to download
+     * @param uploadRole the users role allowed to upload
      * @param scan if true, the repository is scanned at creation time, and the repository metadata are created.
      * @return the Cave repository.
      * @throws Exception in case of creation failure.
@@ -66,8 +69,13 @@ public Repository create(@QueryParam(value = "name") String name, @QueryParam(va
     @POST
     @Path("/repositories")
     @Produces("application/json")
-    public Repository create(@QueryParam(value = "name") String name, @QueryParam(value = "location") String location, @QueryParam(value = "scan") boolean scan) throws Exception {
-        return new Repository(service.create(name, location, scan));
+    public Repository create(@QueryParam(value = "name") String name,
+                             @QueryParam(value = "location") String location,
+                             @QueryParam(value = "realm") String realm,
+                             @QueryParam(value = "downloadRole") String downloadRole,
+                             @QueryParam(value = "uploadRole") String uploadRole,
+                             @QueryParam(value = "scan") boolean scan) throws Exception {
+        return new Repository(service.create(name, location, realm, downloadRole, uploadRole, scan));
     }
 
     /**
diff --git a/server/storage/src/main/java/org/apache/karaf/cave/server/storage/CaveRepositoryImpl.java b/server/storage/src/main/java/org/apache/karaf/cave/server/storage/CaveRepositoryImpl.java
index 354e2a0..6dfcc98 100644
--- a/server/storage/src/main/java/org/apache/karaf/cave/server/storage/CaveRepositoryImpl.java
+++ b/server/storage/src/main/java/org/apache/karaf/cave/server/storage/CaveRepositoryImpl.java
@@ -49,9 +49,7 @@
 import org.apache.karaf.features.internal.resolver.ResourceBuilder;
 import org.apache.karaf.features.internal.resolver.ResourceImpl;
 import org.apache.karaf.features.internal.resolver.ResourceUtils;
-import org.jsoup.Connection;
 import org.jsoup.Jsoup;
-import org.jsoup.UnsupportedMimeTypeException;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
 import org.osgi.framework.BundleException;
@@ -75,13 +73,20 @@
 
     private String name;
     private String location;
+    private String realm;
+    private String downloadRole;
+    private String uploadRole;
+
     private OsgiRepository repository;
 
-    public CaveRepositoryImpl(String name, String location, boolean scan) throws Exception {
+    public CaveRepositoryImpl(String name, String location, String realm, String downloadRole, String uploadRole, boolean scan) throws Exception {
         super();
 
         this.name = name;
         this.location = location;
+        this.realm = realm;
+        this.downloadRole = downloadRole;
+        this.uploadRole = uploadRole;
 
         createRepositoryDirectory();
         if (scan) {
@@ -111,6 +116,33 @@ public void setLocation(String location) {
         this.location = location;
     }
 
+    @Override
+    public String getRealm() {
+        return realm;
+    }
+
+    public void setRealm(String realm) {
+        this.realm = realm;
+    }
+
+    @Override
+    public String getDownloadRole() {
+        return downloadRole;
+    }
+
+    public void setDownloadRole(String downloadRole) {
+        this.downloadRole = downloadRole;
+    }
+
+    @Override
+    public String getUploadRole() {
+        return uploadRole;
+    }
+
+    public void setUploadRole(String uploadRole) {
+        this.uploadRole = uploadRole;
+    }
+
     @Override
     public long getIncrement() {
         return repository.getIncrement();
diff --git a/server/storage/src/main/java/org/apache/karaf/cave/server/storage/CaveRepositoryServiceImpl.java b/server/storage/src/main/java/org/apache/karaf/cave/server/storage/CaveRepositoryServiceImpl.java
index 60dba4b..45e6138 100644
--- a/server/storage/src/main/java/org/apache/karaf/cave/server/storage/CaveRepositoryServiceImpl.java
+++ b/server/storage/src/main/java/org/apache/karaf/cave/server/storage/CaveRepositoryServiceImpl.java
@@ -16,10 +16,12 @@
  */
 package org.apache.karaf.cave.server.storage;
 
+import org.apache.karaf.cave.server.api.CaveMavenRepositoryListener;
 import org.apache.karaf.cave.server.api.CaveRepository;
 import org.apache.karaf.cave.server.api.CaveRepositoryService;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.repository.Repository;
 import org.slf4j.Logger;
@@ -74,7 +76,7 @@ public void setBundleContext(BundleContext bundleContext) {
      */
     public synchronized CaveRepository create(String name, boolean scan) throws Exception {
         File location = new File(storageLocation, name);
-        return create(name, location.getAbsolutePath(), scan);
+        return create(name, location.getAbsolutePath(), "karaf", null, null, scan);
     }
 
     /**
@@ -86,13 +88,22 @@ public synchronized CaveRepository create(String name, boolean scan) throws Exce
      * @return the Cave repository.
      * @throws Exception in case of creation failure.
      */
-    public synchronized CaveRepository create(String name, String location, boolean scan) throws Exception {
+    public synchronized CaveRepository create(String name, String location, String realm, String downloadRole, String uploadRole, boolean scan) throws Exception {
         if (repositories.get(name) != null) {
             throw new IllegalArgumentException("Cave repository " + name + " already exists");
         }
-        CaveRepositoryImpl repository = new CaveRepositoryImpl(name, location, scan);
+        CaveRepositoryImpl repository = new CaveRepositoryImpl(name, location, realm, downloadRole, uploadRole, scan);
         repositories.put(name, repository);
         save();
+        // register the Maven repository if available
+        ServiceReference<CaveMavenRepositoryListener> listenerServiceRef =  bundleContext.getServiceReference(CaveMavenRepositoryListener.class);
+        if (listenerServiceRef != null) {
+            CaveMavenRepositoryListener listener = bundleContext.getService(listenerServiceRef);
+            if (listener != null) {
+                listener.addRepository(name, location);
+            }
+            bundleContext.ungetService(listenerServiceRef);
+        }
         return repository;
     }
 
@@ -125,6 +136,15 @@ public synchronized void remove(String name) throws Exception {
             throw new IllegalArgumentException("Cave repository " + name + " doesn't exist");
         }
         repositories.remove(name);
+        // remove the corresponding Maven repository if present
+        ServiceReference<CaveMavenRepositoryListener> listenerServiceRef =  bundleContext.getServiceReference(CaveMavenRepositoryListener.class);
+        if (listenerServiceRef != null) {
+            CaveMavenRepositoryListener listener = bundleContext.getService(listenerServiceRef);
+            if (listener != null) {
+                listener.removeRepository(name);
+            }
+            bundleContext.ungetService(listenerServiceRef);
+        }
         save();
     }
 
@@ -142,6 +162,15 @@ public synchronized void destroy(String name) throws Exception {
         }
         repositories.remove(name);
         repository.cleanup();
+        // remove the corresponding Maven repository if present
+        ServiceReference<CaveMavenRepositoryListener> listenerServiceRef =  bundleContext.getServiceReference(CaveMavenRepositoryListener.class);
+        if (listenerServiceRef != null) {
+            CaveMavenRepositoryListener listener = bundleContext.getService(listenerServiceRef);
+            if (listener != null) {
+                listener.removeRepository(name);
+            }
+            bundleContext.ungetService(listenerServiceRef);
+        }
         save();
     }
 
@@ -197,6 +226,15 @@ synchronized void save() throws Exception {
         for (int i = 0; i < repositories.length; i++) {
             storage.setProperty("item." + i + ".name", repositories[i].getName());
             storage.setProperty("item." + i + ".location", repositories[i].getLocation());
+            if (repositories[i].getRealm() != null) {
+                storage.setProperty("item." + i + ".realm", repositories[i].getRealm());
+            }
+            if (repositories[i].getDownloadRole() != null) {
+                storage.setProperty("item." + i + ".downloadRole", repositories[i].getDownloadRole());
+            }
+            if (repositories[i].getUploadRole() != null) {
+                storage.setProperty("item." + i + ".uploadRole", repositories[i].getUploadRole());
+            }
             storage.setProperty("item." + i + ".installed", Boolean.toString(services.containsKey(repositories[i].getName())));
         }
         saveStorage(storage, new File(storageLocation, STORAGE_FILE), "Cave Service storage");
@@ -261,10 +299,22 @@ public synchronized void init() throws Exception {
             for (int i = 0; i < count; i++) {
                 String name = storage.getProperty("item." + i + ".name");
                 String location = storage.getProperty("item." + i + ".location");
+                String realm = storage.getProperty("item." + i + ".realm");
+                String downloadRole = storage.getProperty("item." + i + ".downloadRole");
+                String uploadRole = storage.getProperty("item." + i + ".uploadRole");
                 boolean installed = Boolean.parseBoolean(storage.getProperty("item." + i + ".installed"));
                 if (name != null) {
-                    CaveRepositoryImpl repository = new CaveRepositoryImpl(name, location, false);
+                    CaveRepositoryImpl repository = new CaveRepositoryImpl(name, location, realm, downloadRole, uploadRole, false);
                     repositories.put(name, repository);
+                    // register the Maven repository if available
+                    ServiceReference<CaveMavenRepositoryListener> listenerServiceRef =  bundleContext.getServiceReference(CaveMavenRepositoryListener.class);
+                    if (listenerServiceRef != null) {
+                        CaveMavenRepositoryListener listener = bundleContext.getService(listenerServiceRef);
+                        if (listener != null) {
+                            listener.addRepository(name, location);
+                        }
+                        bundleContext.ungetService(listenerServiceRef);
+                    }
                     if (installed) {
                         install(name);
                     }
diff --git a/server/storage/src/test/java/org/apache/karaf/cave/server/storage/CaveRepositoryImplTest.java b/server/storage/src/test/java/org/apache/karaf/cave/server/storage/CaveRepositoryImplTest.java
index 67f7478..b57de23 100644
--- a/server/storage/src/test/java/org/apache/karaf/cave/server/storage/CaveRepositoryImplTest.java
+++ b/server/storage/src/test/java/org/apache/karaf/cave/server/storage/CaveRepositoryImplTest.java
@@ -41,7 +41,7 @@
     @Before
     public void setUp() throws Exception {
         deleteRecursive(Paths.get("target/test-repository"));
-        repository = new CaveRepositoryImpl("test", "target/test-repository", false);
+        repository = new CaveRepositoryImpl("test", "target/test-repository", null, null, null, false);
     }
 
     @Test


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Be able to use proxy or storage in Cave Maven
> ---------------------------------------------
>
>                 Key: KARAF-5661
>                 URL: https://issues.apache.org/jira/browse/KARAF-5661
>             Project: Karaf
>          Issue Type: New Feature
>          Components: cave-maven
>            Reporter: Jean-Baptiste Onofré
>            Assignee: Jean-Baptiste Onofré
>            Priority: Major
>             Fix For: cave-4.1.1
>
>
> The Caven Maven feature is currently a proxy for the repositories defined in {{etc/org.ops4j.pax.url.mvn.cfg}}.
> A good new feature would be to "leverage" the Cave Repositories with Maven. A Cave Repository could act as a proxy (as we do today) or a pure storage.
> I'm refactoring that way. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)