[Registry-dev] svn commit r16706 - in trunk/registry/modules/core/src: main/java/org/wso2/registry main/java/org/wso2/registry/app main/java/org/wso2/registry/config main/java/org/wso2/registry/jdbc main/java/org/wso2/registry/session test/java/org/wso2/registry/jdbc

svn at wso2.org svn at wso2.org
Thu May 8 09:04:33 PDT 2008


Author: glen
Date: Thu May  8 09:04:30 2008
New Revision: 16706

Log:

* Add getAvailableAspects() to Registry interface - still need to go over aspect config and storage (there are collections both in RegistryContext and Registry...?) but this should give Chanaka something to hang the UI hat on

* Fix up PaginationTest - code style (spaces and commas), incorrect argument order for assertEquals().  Also make sure resource names use 2-digit numbers so lexical ordering works nicely.


Modified:
   trunk/registry/modules/core/src/main/java/org/wso2/registry/Registry.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryContext.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/NonTransactionalJDBCRegistry.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/TransactionalJDBCRegistry.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/session/UserRegistry.java
   trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/PaginationTest.java

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/Registry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/Registry.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/Registry.java	Thu May  8 09:04:30 2008
@@ -324,6 +324,12 @@
     void addAspect(String name, Aspect aspect) throws RegistryException;
 
     /**
+     * Get a list of the available Aspects for this Registry
+     * @return a String array containing available Aspect names
+     */
+    String [] getAvailableAspects();
+
+    /**
      * Associate an Aspect with a resource.
      *
      * @param resourcePath Path of the resource

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java	Thu May  8 09:04:30 2008
@@ -998,6 +998,10 @@
                           getAuthorization());
     }
 
+    public String[] getAvailableAspects() {
+        throw new UnsupportedOperationException();
+    }
+
     public void addAspect(String name, Aspect aspect) throws RegistryException {
         throw new UnsupportedOperationException();
     }

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryContext.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryContext.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryContext.java	Thu May  8 09:04:30 2008
@@ -183,6 +183,9 @@
         return (Aspect)aspects.get(name);
     }
 
+    public String [] getAspectNames() {
+        return (String [])aspects.keySet().toArray();
+    }
 
     public List getQueryProcessors() {
         return queryProcessors;

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java	Thu May  8 09:04:30 2008
@@ -625,6 +625,10 @@
 
     }
 
+    public String[] getAvailableAspects() {
+        return (String[])aspects.keySet().toArray();
+    }
+
     public void addAspect(String name, Aspect aspect) throws RegistryException {
         aspects.put(name, aspect);
     }

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/NonTransactionalJDBCRegistry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/NonTransactionalJDBCRegistry.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/NonTransactionalJDBCRegistry.java	Thu May  8 09:04:30 2008
@@ -1251,6 +1251,10 @@
         }
     }
 
+    public String[] getAvailableAspects() {
+        return transactionalJDBCRegistry.getAvailableAspects();
+    }
+
     public void addAspect(String name, Aspect aspect) throws RegistryException {
         String msg = "Atomic registry does not support adding aspects.";
         log.error(msg);

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/TransactionalJDBCRegistry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/TransactionalJDBCRegistry.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/TransactionalJDBCRegistry.java	Thu May  8 09:04:30 2008
@@ -836,6 +836,10 @@
         return logEntryCollection;
     }
 
+    public String[] getAvailableAspects() {
+        return (String[])aspects.keySet().toArray(); // TODO - which aspects, here or context?
+    }
+
     public void addAspect(String name, Aspect aspect) throws RegistryException {
         String msg = "Transactional registry does not support adding aspects.";
         log.error(msg);

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/session/UserRegistry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/session/UserRegistry.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/session/UserRegistry.java	Thu May  8 09:04:30 2008
@@ -461,8 +461,14 @@
         return coreRegistry.getLogCollection(resourcePath, action, userName, from, to, recentFirst);
     }
 
-    public void addAspect(String name, Aspect aspect) throws RegistryException {
+    public String[] getAvailableAspects() {
+        CurrentSession.setUser(userName);
+        CurrentSession.setRealm(userRealm);
 
+        return coreRegistry.getAvailableAspects();
+    }
+
+    public void addAspect(String name, Aspect aspect) throws RegistryException {
         CurrentSession.setUser(userName);
         CurrentSession.setRealm(userRealm);
 

Modified: trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/PaginationTest.java
==============================================================================
--- trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/PaginationTest.java	(original)
+++ trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/PaginationTest.java	Thu May  8 09:04:30 2008
@@ -39,16 +39,21 @@
         registry.put("/test/c1", c1);
         for (int j = 0; j < 50; j++) {
             Collection ci = registry.newCollection();
-            registry.put("/test/c1/c_" + j, ci);
+            registry.put(String.format("/test/c1/c_%2d", j), ci);
         }
         Resource collection = registry.get("/test/c1");
-        String childNodes [] = (String[])collection.getContent();
-        assertEquals(childNodes.length ,50);
+        String childNodes[] = (String[])collection.getContent();
+        assertEquals(50, childNodes.length);
         Collection coll = registry.get("/test/c1", 0, 20);
-        assertEquals(coll.getChildCount() ,20);
+        assertEquals(20, coll.getChildCount());
         childNodes = coll.getChildren();
-        assertEquals(childNodes.length ,20);
-        coll = (Collection) registry.get("/test/c1");
-        assertEquals(coll.getChildCount() ,50);
+        assertEquals(20, childNodes.length);
+        coll = (Collection)registry.get("/test/c1");
+        assertEquals(50, coll.getChildCount());
+
+        coll = registry.get("/test/c1", 20, 5);
+        childNodes = coll.getChildren();
+        assertEquals(5, childNodes.length);
+        assertTrue(childNodes[0].indexOf("20") > -1);
     }
 }



More information about the Registry-dev mailing list