karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject [4/7] git commit: [KARAF-2408] Add new operations in the CaveRepositoryMBean
Date Sat, 11 Jan 2014 16:14:45 GMT
[KARAF-2408] Add new operations in the CaveRepositoryMBean


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

Branch: refs/heads/cave-2.x
Commit: 1ba080c9403cfcbabcb6278859af97f5defc1904
Parents: 11f8946
Author: Jean-Baptiste Onofré <jbonofre@apache.org>
Authored: Sat Jan 11 15:32:19 2014 +0100
Committer: Jean-Baptiste Onofré <jbonofre@apache.org>
Committed: Sat Jan 11 15:32:19 2014 +0100

----------------------------------------------------------------------
 .../server/management/CaveRepositoryMBean.java  | 10 ++-
 .../internal/CaveRepositoryMBeanImpl.java       | 79 +++++++++++++++++++-
 2 files changed, 84 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/1ba080c9/server/management/src/main/java/org/apache/karaf/cave/server/management/CaveRepositoryMBean.java
----------------------------------------------------------------------
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 cc50dd3..326147d 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,13 @@ public interface CaveRepositoryMBean {
 
     TabularData getCaveRepositories() throws Exception;
 
-    void createRepository(String name) throws Exception;
-    void removeRepository(String name) throws Exception;
+    void createRepository(String name, String location, boolean generateObr, boolean install)
throws Exception;
+    void destroyRepository(String name) throws Exception;
+    void installRepository(String name) throws Exception;
+    void uninstallRepository(String name) throws Exception;
+    void populateRepository(String name, String url, boolean generateObr, String filter)
throws Exception;
+    void proxyRepository(String name, String url, boolean generateObr, String filter) throws
Exception;
+    void updateRepository(String name) throws Exception;
+    void uploadArtifact(String repository, String artifactUrl, boolean generateObr) throws
Exception;
 
 }

http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/1ba080c9/server/management/src/main/java/org/apache/karaf/cave/server/management/internal/CaveRepositoryMBeanImpl.java
----------------------------------------------------------------------
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 40979b1..cb09a0e 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
@@ -21,6 +21,7 @@ import org.apache.karaf.cave.server.management.CaveRepositoryMBean;
 import javax.management.NotCompliantMBeanException;
 import javax.management.StandardMBean;
 import javax.management.openmbean.*;
+import java.net.URL;
 
 /**
  * Implementation of the Cave repository MBean.
@@ -64,12 +65,84 @@ public class CaveRepositoryMBeanImpl extends StandardMBean implements
CaveReposi
         return table;
     }
 
-    public void createRepository(String name) throws Exception {
-        caveRepositoryService.create(name, true);
+    public void createRepository(String name, String location, boolean generateObr, 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);
+        } else {
+            getCaveRepositoryService().create(name, false);
+        }
+        CaveRepository caveRepository = getCaveRepositoryService().getRepository(name);
+        if (generateObr) {
+            caveRepository.scan();
+        }
+        if (install) {
+            getCaveRepositoryService().install(name);
+        }
+    }
+
+    public void destroyRepository(String name) throws Exception {
+        if (getCaveRepositoryService().getRepository(name) != null) {
+            throw new IllegalArgumentException("Cave repository " + name + " doesn't exist");
+        }
+        caveRepositoryService.destroy(name);
     }
 
-    public void removeRepository(String name) throws Exception {
+    public void installRepository(String name) throws Exception {
+        if (getCaveRepositoryService().getRepository(name) != null) {
+            throw new IllegalArgumentException("Cave repository " + name + " doesn't exist");
+        }
+        caveRepositoryService.install(name);
+    }
+
+    public void uninstallRepository(String name) throws Exception {
+        if (getCaveRepositoryService().getRepository(name) != null) {
+            throw new IllegalArgumentException("Cave repository " + name + " doesn't exist");
+        }
         caveRepositoryService.uninstall(name);
     }
 
+    public void populateRepository(String name, String url, boolean generateObr, String filter)
throws Exception {
+        if (getCaveRepositoryService().getRepository(name) != null) {
+            throw new IllegalArgumentException("Cave repository " + name + " doesn't exist");
+        }
+        CaveRepository repository = getCaveRepositoryService().getRepository(name);
+        repository.populate(new URL(url), filter, generateObr);
+        if (generateObr) {
+            getCaveRepositoryService().install(name);
+        }
+    }
+
+    public void proxyRepository(String name, String url, boolean generateObr, String filter)
throws Exception {
+        if (getCaveRepositoryService().getRepository(name) != null) {
+            throw new IllegalArgumentException("Cave repository " + name + " doesn't exist");
+        }
+        CaveRepository repository = getCaveRepositoryService().getRepository(name);
+        repository.proxy(new URL(url), filter);
+        if (generateObr) {
+            getCaveRepositoryService().install(name);
+        }
+    }
+
+    public void updateRepository(String name) throws Exception {
+        if (getCaveRepositoryService().getRepository(name) != null) {
+            throw new IllegalArgumentException("Cave repository " + name + " doesn't exist");
+        }
+        CaveRepository caveRepository = getCaveRepositoryService().getRepository(name);
+        caveRepository.scan();
+    }
+
+    public void uploadArtifact(String repository, String artifactUrl, boolean generateObr)
throws Exception {
+        if (getCaveRepositoryService().getRepository(repository) != null) {
+            throw new IllegalArgumentException("Cave repository " + repository + " doesn't
exist");
+        }
+        CaveRepository caveRepository = getCaveRepositoryService().getRepository(repository);
+        caveRepository.upload(new URL(artifactUrl));
+        if (generateObr) {
+            getCaveRepositoryService().install(repository);
+        }
+    }
+
 }


Mime
View raw message