Move rest component into a different module

Project: http://git-wip-us.apache.org/repos/asf/karaf-cave/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cave/commit/1fc37159
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cave/tree/1fc37159
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cave/diff/1fc37159

Branch: refs/heads/master
Commit: 1fc37159fdb72342f291d96e1bdda2b92cbd57cd
Parents: e63f19b
Author: Guillaume Nodet <[email protected]>
Authored: Tue May 5 16:31:50 2015 +0200
Committer: Guillaume Nodet <[email protected]>
Committed: Tue May 5 16:31:57 2015 +0200

----------------------------------------------------------------------
 assembly/pom.xml                                |  48 ++++++
 assembly/src/main/resources/features.xml        |   6 +-
 pom.xml                                         |   5 +
 server/api/pom.xml                              |   4 -
 .../karaf/cave/server/api/CaveRepository.java   |  55 ++-----
 .../cave/server/api/CaveRepositoryService.java  |  19 +--
 .../karaf/cave/server/http/WrapperServlet.java  |   5 +-
 server/rest/pom.xml                             |   4 +
 .../karaf/cave/server/rest/Activator.java       |  54 +++++++
 .../karaf/cave/server/rest/Repository.java      |  36 +++++
 .../apache/karaf/cave/server/rest/Service.java  | 149 +++++++++++++++++++
 .../OSGI-INF/blueprint/cave-server-rest.xml     |  32 ----
 .../cave/server/storage/CaveRepositoryImpl.java |  26 +++-
 13 files changed, 340 insertions(+), 103 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/1fc37159/assembly/pom.xml
----------------------------------------------------------------------
diff --git a/assembly/pom.xml b/assembly/pom.xml
index 567887b..a4f9674 100644
--- a/assembly/pom.xml
+++ b/assembly/pom.xml
@@ -33,6 +33,24 @@
     <name>Apache Karaf :: Cave :: Assembly</name>
     <packaging>pom</packaging>
 
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.karaf.features</groupId>
+            <artifactId>framework</artifactId>
+            <version>${karaf.version}</version>
+            <type>kar</type>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.karaf.features</groupId>
+            <artifactId>standard</artifactId>
+            <version>${karaf.version}</version>
+            <classifier>features</classifier>
+            <type>xml</type>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
     <build>
         <resources>
             <resource>
@@ -45,6 +63,36 @@
         </resources>
         <plugins>
             <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-maven-plugin</artifactId>
+                <version>${karaf.version}</version>
+                <executions>
+                    <execution>
+                        <id>verify</id>
+                        <phase>process-resources</phase>
+                        <goals>
+                            <goal>verify</goal>
+                        </goals>
+                        <configuration>
+                            <descriptors>
+                                
<descriptor>mvn:org.apache.karaf.features/framework/${karaf.version}/xml/features</descriptor>
+                                
<descriptor>mvn:org.apache.karaf.features/standard/${karaf.version}/xml/features</descriptor>
+                                
<descriptor>file:${project.build.directory}/classes/features.xml</descriptor>
+                            </descriptors>
+                            
<distribution>org.apache.karaf.features:framework</distribution>
+                            <javase>1.7</javase>
+                            <framework>
+                                <feature>framework</feature>
+                            </framework>
+                            <features>
+                                <feature>cave-*</feature>
+                            </features>
+                            <verifyTransitive>false</verifyTransitive>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-resources-plugin</artifactId>
                 <version>2.5</version>

http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/1fc37159/assembly/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/assembly/src/main/resources/features.xml 
b/assembly/src/main/resources/features.xml
index fa53995..a40c3a4 100644
--- a/assembly/src/main/resources/features.xml
+++ b/assembly/src/main/resources/features.xml
@@ -30,8 +30,6 @@
         <configfile finalname="/etc/org.apache.karaf.cave.server.storage.cfg">
             
mvn:org.apache.karaf.cave/apache-karaf-cave/${project.version}/cfg/filesystem
         </configfile>
-        <bundle 
dependency="true">mvn:javax.annotation/javax.annotation-api/1.2</bundle>
-        <bundle 
dependency="true">mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jsr339-api-2.0/2.4.0</bundle>
         <bundle>mvn:org.jsoup/jsoup/${jsoup.version}</bundle>
         
<bundle>mvn:org.apache.karaf.cave.server/org.apache.karaf.cave.server.api/${project.version}</bundle>
         
<bundle>mvn:org.apache.karaf.cave.server/org.apache.karaf.cave.server.storage/${project.version}</bundle>
@@ -55,8 +53,8 @@
         <configfile finalname="/etc/org.apache.cxf.osgi.cfg">
             
mvn:org.apache.karaf.cave/apache-karaf-cave/${project.version}/cfg/cxf
         </configfile>
-        <feature version="[3,4)">cxf</feature>
-        <feature>aries-blueprint</feature>
+        <feature>http</feature>
+        <feature version="[3,4)">cxf-jaxrs</feature>
         <feature>cave-storage</feature>
         
<bundle>mvn:org.apache.karaf.cave.server/org.apache.karaf.cave.server.rest/${project.version}</bundle>
     </feature>

http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/1fc37159/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 854c952..a742400 100644
--- a/pom.xml
+++ b/pom.xml
@@ -216,6 +216,11 @@
                     </executions>
                 </plugin>
                 <plugin>
+                    <groupId>org.apache.karaf.tooling</groupId>
+                    <artifactId>karaf-maven-plugin</artifactId>
+                    <version>${karaf.version}</version>
+                </plugin>
+                <plugin>
                     <groupId>org.apache.felix</groupId>
                     <artifactId>maven-bundle-plugin</artifactId>
                     <version>2.5.4</version>

http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/1fc37159/server/api/pom.xml
----------------------------------------------------------------------
diff --git a/server/api/pom.xml b/server/api/pom.xml
index 0634b2a..58e211f 100644
--- a/server/api/pom.xml
+++ b/server/api/pom.xml
@@ -34,10 +34,6 @@
     <packaging>bundle</packaging>
 
     <dependencies>
-        <dependency>
-            <groupId>org.apache.cxf</groupId>
-            <artifactId>cxf-rt-frontend-jaxrs</artifactId>
-        </dependency>
     </dependencies>
 
     <build>

http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/1fc37159/server/api/src/main/java/org/apache/karaf/cave/server/api/CaveRepository.java
----------------------------------------------------------------------
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 3713367..2c4e12d 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
@@ -16,61 +16,34 @@
  */
 package org.apache.karaf.cave.server.api;
 
-import javax.xml.bind.annotation.XmlRootElement;
 import java.net.URL;
 
 /**
  * Cave repository is a storage area where to upload artifacts.
  * It's already the basement of the OBR repository.xml metadata.
  */
-@XmlRootElement(name = "cave-repository")
-public abstract class CaveRepository {
-
-    private String name;
-    private String location;
+public interface CaveRepository {
 
     /**
      * Get the name of the repository.
      *
      * @return the name of the repository
      */
-    public String getName() {
-        return this.name;
-    }
-
-    /**
-     * Set the name of the repository.
-     *
-     * @param name the name of the repository
-     */
-    public void setName(String name) {
-        this.name = name;
-    }
+    public String getName();
 
     /**
      * Get the location (filesystem) of this repository.
      *
      * @return the location of this repository.
      */
-    public String getLocation() {
-        return this.location;
-    }
-
-    /**
-     * Set the location (filesystem) of this repository.
-     *
-     * @param location the location of this repository
-     */
-    public void setLocation(String location) {
-        this.location = location;
-    }
+    public String getLocation();
 
     /**
      * Get the last modification date of this repository.
      *
      * @return the last modification date.
      */
-    public abstract long getIncrement();
+    public long getIncrement();
 
     /**
      * Upload an artifact from the given URL into the repository.
@@ -78,7 +51,7 @@ public abstract class CaveRepository {
      * @param url the URL of the artifact.
      * @throws Exception in case of upload failure.
      */
-    public abstract void upload(URL url) throws Exception;
+    public void upload(URL url) throws Exception;
 
     /**
      * Scan the whole repository, reading bundle MANIFEST, etc to update
@@ -86,7 +59,7 @@ public abstract class CaveRepository {
      *
      * @throws Exception in case of scan failure.
      */
-    public abstract void scan() throws Exception;
+    public void scan() throws Exception;
 
     /**
      * Proxy an URL (for instance a Maven repository) and add OBR information.
@@ -94,7 +67,7 @@ public abstract class CaveRepository {
      * @param url the URL to proxy.
      * @throws Exception
      */
-    public abstract void proxy(URL url) throws Exception;
+    public void proxy(URL url) throws Exception;
 
     /**
      * Proxy an URL (for instance a Maven repository), eventually filtering 
some artifacts, and add OBR information.
@@ -103,7 +76,7 @@ public abstract class CaveRepository {
      * @param filter regex filter on the artifacts URL.
      * @throws Exception
      */
-    public abstract void proxy(URL url, String filter) throws Exception;
+    public void proxy(URL url, String filter) throws Exception;
 
     /**
      * Populate from a remote URL (for instance a Maven repository), and 
eventually update the OBR information.
@@ -112,7 +85,7 @@ public abstract class CaveRepository {
      * @param update if true the OBR information is updated, false else.
      * @throws Exception in case of copy failure.
      */
-    public abstract void populate(URL url, boolean update) throws Exception;
+    public void populate(URL url, boolean update) throws Exception;
 
     /**
      * Populate from a remote URL (for instance a Maven repository), 
eventually filtering artifacts, and eventually update the OBR information.
@@ -122,7 +95,7 @@ public abstract class CaveRepository {
      * @param update if true the OBR information is updated, false else.
      * @throws Exception
      */
-    public abstract void populate(URL url, String filter, boolean update) 
throws Exception;
+    public void populate(URL url, String filter, boolean update) throws 
Exception;
 
     /**
      * Return an URL for the resource at the given URI.
@@ -131,7 +104,7 @@ public abstract class CaveRepository {
      * @return the URL for the resource.
      * @throws Exception in case of read failure.
      */
-    public abstract URL getResourceByUri(String uri) throws Exception;
+    public URL getResourceByUri(String uri) throws Exception;
 
     /**
      * Return the output stream of the resource identified by the given ID.
@@ -140,7 +113,7 @@ public abstract class CaveRepository {
      * @return the output stream of the resource.
      * @throws Exception in case of read failure.
      */
-    //public abstract OutputStream getResourceById(String id) throws Exception;
+    //public OutputStream getResourceById(String id) throws Exception;
 
     /**
      * Return the repository URL of the OBR repository.xml.
@@ -148,13 +121,13 @@ public abstract class CaveRepository {
      * @return the URL of the OBR repository.xml.
      * @throws Exception in case of failure to get repository.xml URL.
      */
-    public abstract URL getRepositoryXml() throws Exception;
+    public URL getRepositoryXml() throws Exception;
 
     /**
      * Cleanup the repository storage.
      *
      * @throws Exception in case of cleanup failure.
      */
-    public abstract void cleanup() throws Exception;
+    public void cleanup() throws Exception;
 
 }

http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/1fc37159/server/api/src/main/java/org/apache/karaf/cave/server/api/CaveRepositoryService.java
----------------------------------------------------------------------
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 733f631..c0f7803 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
@@ -16,12 +16,9 @@
  */
 package org.apache.karaf.cave.server.api;
 
-import javax.ws.rs.*;
-
 /**
  * Service to manipulate a Cave repository.
  */
-@Path("/")
 public interface CaveRepositoryService {
 
     /**
@@ -32,9 +29,6 @@ public interface CaveRepositoryService {
      * @return the Cave repository.
      * @throws Exception in case of creation failure.
      */
-    @POST
-    @Consumes("application/xml")
-    @Produces("application/xml")
     CaveRepository create(String name, boolean scan) throws Exception;
 
     /**
@@ -46,9 +40,6 @@ public interface CaveRepositoryService {
      * @return the Cave repository.
      * @throws Exception in case of creation failure.
      */
-    @POST
-    @Consumes("application/xml")
-    @Produces("application/xml")
     CaveRepository create(String name, String location, boolean scan) throws 
Exception;
 
     /**
@@ -81,8 +72,6 @@ public interface CaveRepositoryService {
      * @param name the name of the Cave repository.
      * @throws Exception in case of registration failure.
      */
-    @POST
-    @Consumes("text/plain")
     void install(String name) throws Exception;
 
     /**
@@ -90,9 +79,6 @@ public interface CaveRepositoryService {
      *
      * @return the Cave repositories.
      */
-    @GET
-    @Path("/repositories")
-    @Produces("application/xml")
     CaveRepository[] getRepositories();
 
     /**
@@ -101,9 +87,6 @@ public interface CaveRepositoryService {
      * @param name the name of the Cave repository.
      * @return the Cave repository
      */
-    @GET
-    @Path("/repositories/{name}")
-    @Produces("application/xml")
-    CaveRepository getRepository(@PathParam("name") String name);
+    CaveRepository getRepository(String name);
 
 }

http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/1fc37159/server/http/src/main/java/org/apache/karaf/cave/server/http/WrapperServlet.java
----------------------------------------------------------------------
diff --git 
a/server/http/src/main/java/org/apache/karaf/cave/server/http/WrapperServlet.java
 
b/server/http/src/main/java/org/apache/karaf/cave/server/http/WrapperServlet.java
index e2f360e..a7b37de 100644
--- 
a/server/http/src/main/java/org/apache/karaf/cave/server/http/WrapperServlet.java
+++ 
b/server/http/src/main/java/org/apache/karaf/cave/server/http/WrapperServlet.java
@@ -66,7 +66,10 @@ public class WrapperServlet extends HttpServlet {
 
     @Override
     public void destroy() {
-        tracker.close();
+        if (tracker != null) {
+            tracker.close();
+            tracker = null;
+        }
         super.destroy();
     }
 

http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/1fc37159/server/rest/pom.xml
----------------------------------------------------------------------
diff --git a/server/rest/pom.xml b/server/rest/pom.xml
index 54c05c0..0b6afb1 100644
--- a/server/rest/pom.xml
+++ b/server/rest/pom.xml
@@ -47,6 +47,10 @@
     <build>
         <plugins>
             <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-services-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>

http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/1fc37159/server/rest/src/main/java/org/apache/karaf/cave/server/rest/Activator.java
----------------------------------------------------------------------
diff --git 
a/server/rest/src/main/java/org/apache/karaf/cave/server/rest/Activator.java 
b/server/rest/src/main/java/org/apache/karaf/cave/server/rest/Activator.java
new file mode 100644
index 0000000..c44fb34
--- /dev/null
+++ b/server/rest/src/main/java/org/apache/karaf/cave/server/rest/Activator.java
@@ -0,0 +1,54 @@
+/*
+ * 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.rest;
+
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
+import org.apache.karaf.cave.server.api.CaveRepositoryService;
+import org.apache.karaf.util.tracker.BaseActivator;
+import org.apache.karaf.util.tracker.annotation.RequireService;
+import org.apache.karaf.util.tracker.annotation.Services;
+
+
+@Services(
+        requires = { @RequireService(CaveRepositoryService.class) }
+)
+public class Activator extends BaseActivator {
+
+    private Server server;
+
+    @Override
+    protected void doStart() throws Exception {
+        Service service = new 
Service(getTrackedService(CaveRepositoryService.class));
+        JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
+        sf.setResourceClasses(Service.class, Repository.class);
+        sf.setResourceProvider(Service.class, new 
SingletonResourceProvider(service));
+        sf.setAddress("/cave/rest");
+        server = sf.create();
+    }
+
+    @Override
+    protected void doStop() {
+        if (server != null) {
+            server.destroy();
+            server = null;
+        }
+        super.doStop();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/1fc37159/server/rest/src/main/java/org/apache/karaf/cave/server/rest/Repository.java
----------------------------------------------------------------------
diff --git 
a/server/rest/src/main/java/org/apache/karaf/cave/server/rest/Repository.java 
b/server/rest/src/main/java/org/apache/karaf/cave/server/rest/Repository.java
new file mode 100644
index 0000000..8e1a38a
--- /dev/null
+++ 
b/server/rest/src/main/java/org/apache/karaf/cave/server/rest/Repository.java
@@ -0,0 +1,36 @@
+/*
+ * 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.rest;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.karaf.cave.server.api.CaveRepository;
+
+@XmlRootElement(name = "cave-repository")
+public class Repository {
+
+    private final CaveRepository repository;
+
+    public Repository() {
+        repository = null;
+    }
+
+    public Repository(CaveRepository repository) {
+        this.repository = repository;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/1fc37159/server/rest/src/main/java/org/apache/karaf/cave/server/rest/Service.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..14f133e
--- /dev/null
+++ b/server/rest/src/main/java/org/apache/karaf/cave/server/rest/Service.java
@@ -0,0 +1,149 @@
+/*
+ * 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.rest;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+
+import org.apache.karaf.cave.server.api.CaveRepository;
+import org.apache.karaf.cave.server.api.CaveRepositoryService;
+
+/**
+ * Service to manipulate a Cave repository.
+ */
+@Path("/")
+public class Service {
+
+    private final CaveRepositoryService service;
+
+    public Service(CaveRepositoryService service) {
+        this.service = service;
+    }
+
+    /**
+     * Create a Cave repository.
+     *
+     * @param name the name of the repository
+     * @param scan if true, the repository is scanned at creation time, and 
the OBR metadata are created.
+     * @return the Cave repository.
+     * @throws Exception in case of creation failure.
+     */
+    @POST
+    @Consumes("application/xml")
+    @Produces("application/xml")
+    public Repository create(String name, boolean scan) throws Exception {
+        return new Repository(service.create(name, scan));
+    }
+
+    /**
+     * Create a Cave repository.
+     *
+     * @param name the name of the repository.
+     * @param location the storage location of the repository.
+     * @param scan if true, the repository is scanned at creation time, and 
the OBR metadata are created.
+     * @return the Cave repository.
+     * @throws Exception in case of creation failure.
+     */
+    @POST
+    @Consumes("application/xml")
+    @Produces("application/xml")
+    public Repository create(String name, String location, boolean scan) 
throws Exception {
+        return new Repository(service.create(name, location, scan));
+    }
+
+    /**
+     * Uninstall a Cave repository from the OBR service.
+     *
+     * @param name the name of the repository.
+     * @throws Exception in case of uninstall failure.
+     */
+    public void uninstall(String name) throws Exception {
+        service.uninstall(name);
+    }
+
+    /**
+     * Remove a Cave repository from the repositories registry.
+     *
+     * @param name the name of the repository.
+     * @throws Exception in case of remove failure.
+     */
+    public void remove(String name) throws Exception {
+        service.remove(name);
+    }
+
+    /**
+     * Destroy a Cave repository, including the storage.
+     *
+     * @param name the name of the repository.
+     * @throws Exception incase of remove failure.
+     */
+    public void destroy(String name) throws Exception {
+        service.destroy(name);
+    }
+
+    /**
+     * Install a Cave repository into the OBR service.
+     *
+     * @param name the name of the Cave repository.
+     * @throws Exception in case of registration failure.
+     */
+    @POST
+    @Consumes("text/plain")
+    public void install(String name) throws Exception {
+        service.install(name);
+    }
+
+    /**
+     * Get the list of all Cave repositories.
+     *
+     * @return the Cave repositories.
+     */
+    @GET
+    @Path("/repositories")
+    @Produces("application/xml")
+    public Repository[] getRepositories() {
+        CaveRepository[] repositories = service.getRepositories();
+        Repository[] repos = new Repository[repositories.length];
+        for (int i = 0; i < repositories.length; i++) {
+            repos[i] = new Repository(repositories[i]);
+        }
+        return repos;
+    }
+
+    /**
+     * Get a Cave repository identified by the given name.
+     *
+     * @param name the name of the Cave repository.
+     * @return the Cave repository
+     */
+    @GET
+    @Path("/repositories/{name}")
+    @Produces("application/xml")
+    public Repository getRepository(@PathParam("name") String name) {
+        CaveRepository repository = service.getRepository(name);
+        if (repository != null) {
+            return new Repository(repository);
+        } else {
+            return null;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/1fc37159/server/rest/src/main/resources/OSGI-INF/blueprint/cave-server-rest.xml
----------------------------------------------------------------------
diff --git 
a/server/rest/src/main/resources/OSGI-INF/blueprint/cave-server-rest.xml 
b/server/rest/src/main/resources/OSGI-INF/blueprint/cave-server-rest.xml
deleted file mode 100644
index be6e9d1..0000000
--- a/server/rest/src/main/resources/OSGI-INF/blueprint/cave-server-rest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
-           xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs";>
-
-    <reference id="caveRepositoryService" 
interface="org.apache.karaf.cave.server.api.CaveRepositoryService"/>
-
-    <!-- start the JAX-RS server -->
-    <jaxrs:server id="caveRepositoryJaxRsServer" address="/cave">
-        <jaxrs:serviceBeans>
-            <ref component-id="caveRepositoryService"/>
-        </jaxrs:serviceBeans>
-    </jaxrs:server>
-
-</blueprint>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/1fc37159/server/storage/src/main/java/org/apache/karaf/cave/server/storage/CaveRepositoryImpl.java
----------------------------------------------------------------------
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 2ccef4e..4b55360 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
@@ -56,17 +56,19 @@ import static 
org.osgi.service.repository.ContentNamespace.CONTENT_NAMESPACE;
 /**
  * Default implementation of a Cave repository.
  */
-public class CaveRepositoryImpl extends CaveRepository {
+public class CaveRepositoryImpl implements CaveRepository {
 
     private final static Logger LOGGER = 
LoggerFactory.getLogger(CaveRepositoryImpl.class);
 
+    private String name;
+    private String location;
     private OsgiRepository repository;
 
     public CaveRepositoryImpl(String name, String location, boolean scan) 
throws Exception {
         super();
 
-        setName(name);
-        setLocation(location);
+        this.name = name;
+        this.location = location;
 
         createRepositoryDirectory();
         if (scan) {
@@ -77,6 +79,24 @@ public class CaveRepositoryImpl extends CaveRepository {
     }
 
     @Override
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    @Override
+    public String getLocation() {
+        return location;
+    }
+
+    public void setLocation(String location) {
+        this.location = location;
+    }
+
+    @Override
     public long getIncrement() {
         return repository.getIncrement();
     }

Reply via email to