Author: deepal
Date: Wed Jan 23 22:53:46 2008
New Revision: 12806

Log:

there was a big issue with the version handling (Thanks Krishantha for finding 
that) , so when I try to fix that I found some other issues as well, so this 
commit is to fix all those

Modified:
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/AtomRegistry.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/DefaultMediaTypeHandler.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java
   
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/CommentTest.java
   
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/JettyBasedServerTest.java
   
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/RatingTest.java
   
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/VersionTest.java
   
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java
   
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/VersionHandlingTest.java

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/AtomRegistry.java
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/AtomRegistry.java
   (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/AtomRegistry.java
   Wed Jan 23 22:53:46 2008
@@ -108,46 +108,57 @@
             Parser parser = abdera.getParser();
             Document<Entry> entry_doc = 
(Document<Entry>)request.getDocument(parser).clone();
 
+
+            // Need to add a resource
             Entry entry = entry_doc.getRoot();
-            Resource resource;
-            if (jdbcregistry.resourceExists(entry_id)) {
-                try {
-                    resource = jdbcregistry.get(entry_id);
-                } catch (RegistryException e) {
-                    // Seems like the resource has deleted
-                    resource = new Resource();
-                }
-            } else {
-                resource = new Resource();
-            }
+//                        if (jdbcregistry.resourceExists(entry_id)) {
+//                            try {
+//                                resource = jdbcregistry.get(entry_id);
+//                            } catch (RegistryException e) {
+//                                // Seems like the resource has deleted
+//                                resource = new Resource();
+//                            }
+//                        } else {
+            Resource resource = new Resource();
+//                        }
             String attValue = entry.getSimpleExtension(new QName("directory"));
             Properties properties = 
entry.getExtension(PropertyExtensionFactory.PROPERTIES);
             RemoteRegistry.createPropertiesFromExtensionElement(properties, 
resource);
-
             String mediaType = entry.getSimpleExtension(new 
QName("mediaType"));
             if (mediaType != null) {
                 resource.setMediaType(mediaType);
             }
             String parentPath = entry.getSimpleExtension(new 
QName("parentPath"));
-            if (parentPath != null) {
+            if (parentPath != null && !"".equals(parentPath)) {
                 resource.setParentPath(parentPath);
             }
-            resource.setAuthorUserName(entry.getAuthor().getName());
-            resource.setDescription(entry.getSummary());
+            if (entry.getAuthor().getName() != null) {
+                resource.setAuthorUserName(entry.getAuthor().getName());
+            }
+            if (entry.getSummary() != null) {
+                resource.setDescription(entry.getSummary());
+            }
+            String contentModified = entry.getSimpleExtension(
+                    new QName("contentModified"));
             if (attValue != null && "true".equals(attValue)) {
                 // Directory
                 resource.setDirectory(true);
             } else {
                 // Resource
-                String content1 = entry.getContent();
-                if (content1 != null &&
-                    !Content.Type.TEXT.equals(entry.getContentType())) {
-                    byte[] content = Base64.decode(content1);
-                    resource.setContent(content);
-                } else {
-                    resource.setContent(content1);
+                if (contentModified != null) {
+                    String content1 = entry.getContent();
+                    if (content1 != null &&
+                            !Content.Type.TEXT.equals(entry.getContentType())) 
{
+                        byte[] content = Base64.decode(content1);
+                        resource.setContent(content);
+                    } else {
+                        resource.setContent(content1);
+                    }
                 }
             }
+            //entry-id will tell where to put the resource.
+            resource.setPath(entry_id);
+
 
             // entry-id will tell where to put the resource.
             String location = getSecureRegistry(request).put(entry_id, 
resource);
@@ -157,7 +168,6 @@
         } catch (Exception e) {
             rc = new StringResponseContext(abdera, e, 500);
         }
-
         return rc;
     }
 

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
 Wed Jan 23 22:53:46 2008
@@ -48,6 +48,7 @@
     private Log log = LogFactory.getLog(RemoteRegistry.class);
     //This will keep the value of username and the password for authorization
     private String authorizationString = null;
+    private String usreName = null;
 
     /**
      * To create a remote registry need to provide a URL of a remote registry 
and the URL should be
@@ -78,6 +79,7 @@
         if (baseURI.endsWith("/")) {
             baseURI = baseURI.substring(0, baseURI.length() - 1);
         }
+        this.usreName = userName;
         if (userName != null && password != null) {
             authorizationString = userName + ":" + password;
             authorizationString = "Basic " + 
Base64.encode(authorizationString.getBytes());
@@ -88,7 +90,8 @@
         Abdera abdera = new Abdera();
         AbderaClient abderaClient = new AbderaClient(abdera);
         ClientResponse clientResponse = abderaClient.get(baseURI + path, 
getAuthorization());
-        if (clientResponse.getType() == Response.ResponseType.CLIENT_ERROR) {
+        if (clientResponse.getType() == Response.ResponseType.CLIENT_ERROR ||
+                clientResponse.getType() == Response.ResponseType.SERVER_ERROR 
) {
             throw new ResourceNotFoundException(path);
         }
         Document introspection = clientResponse.getDocument();
@@ -216,12 +219,19 @@
         AbderaClient abderaClient = new AbderaClient(abdera);
         Entry entry = abdera.getFactory().newEntry();
         entry.setSummary(resource.getDescription());
-        entry.addAuthor(resource.getAuthorUserName());
+        if (resource.getAuthorUserName() !=null) {
+            entry.addAuthor(resource.getAuthorUserName());
+        } else {
+            entry.addAuthor(usreName);
+        }
         java.util.Properties properties = resource.getProperties();
         addPropertyExtensionElement(properties, abdera, entry, 
PropertyExtensionFactory.PROPERTIES,
                                     PropertyExtensionFactory.PROPERTY);
         entry.addSimpleExtension(new QName("mediaType"), 
resource.getMediaType());
         entry.addSimpleExtension(new QName("parentPath"), 
resource.getParentPath());
+        if(resource.isContentModified()) {
+            entry.addSimpleExtension(new QName("contentModified"), "true");
+        }
         if (resource.isDirectory()) {
             entry.addSimpleExtension(new QName("directory"), "true");
         } else {

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java
      (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java
      Wed Jan 23 22:53:46 2008
@@ -204,7 +204,7 @@
      * @return : Result artifact
      * @throws SQLException : if something went wrong
      */
-    public Resource getLatestVersion(String path, Connection conn) throws 
SQLException {
+    public Resource getLatestVersion(String path, Connection conn) throws 
RegistryException , SQLException {
         /*
         * when someone give path like "root/wso2/wsas/r1" , then need to 
figure out the latest
         * version of the root and from the need to figure out the version of 
wso2 and so so
@@ -295,27 +295,50 @@
      * @param conn : Connection to DB
      * @return : verion number of the resource user requested
      */
-    private long getCurrentVerisonNumber(String path, Connection conn) {
+    private long getCurrentVerisonNumber(String path, Connection conn) throws 
RegistryException {
         if (path != null) {
             try {
-                int index = path.lastIndexOf(RegistryConstants.PATH_SEPARATOR);
-                if (index > 0) {
-                    String parentPath = path.substring(0, index);
-                    long parentId = getResourceID(parentPath, conn);
-                    long latestVersion = getLatestVerisonNumber(parentId, 
conn);
-                    long childID = getResourceID(path, conn);
-                    String SQL = "SELECT DVN FROM DEPENDENCY WHERE AID=? AND 
VN=? AND DAID=?";
-                    PreparedStatement s = conn.prepareStatement(SQL);
-                    s.setLong(1, parentId);
-                    s.setLong(2, latestVersion);
-                    s.setLong(3, childID);
-                    ResultSet result = s.executeQuery();
-                    if (result.next()) {
-                        return result.getLong(1);
+                String[] parts = path.split(RegistryConstants.PATH_SEPARATOR);
+                if(parts.length > 1 ) {
+                    String currentPath = RegistryConstants.ROOT_PATH + 
parts[1];
+                    String parentPath  = RegistryConstants.ROOT_PATH;
+                    long parentVersion = getLatestVerisonNumber(
+                            getResourceID(RegistryConstants.ROOT_PATH, conn), 
conn);
+                    long childId = 0;
+                    for (int i = 2; i < parts.length; i++) {
+                        if (!resourceActive(parentPath, conn)){
+                            throw new RegistryException("Resource is not 
active");
+                        }
+                        long parentId = getResourceID(parentPath, conn);
+                        childId = getResourceID(currentPath, conn);
+                        parentVersion = getChildVersion(conn, parentId, 
parentVersion, childId);
+                        parentPath = currentPath;
+                        currentPath = currentPath + 
RegistryConstants.PATH_SEPARATOR + parts[i];
                     }
+                    long id = getResourceID(currentPath,conn);
+                    return getChildVersion(conn, childId, parentVersion, id);
+
                 } else {
                     return getLatestVerisonNumber(getResourceID(path, conn), 
conn);
                 }
+//                int index = 
path.lastIndexOf(RegistryConstants.PATH_SEPARATOR);
+//                if (index > 0) {
+//                    String parentPath = path.substring(0, index);
+//                    long parentId = getResourceID(parentPath, conn);
+//                    long latestVersion = getLatestVerisonNumber(parentId, 
conn);
+//                    long childID = getResourceID(path, conn);
+//                    String SQL = "SELECT DVN FROM DEPENDENCY WHERE AID=? AND 
VN=? AND DAID=?";
+//                    PreparedStatement s = conn.prepareStatement(SQL);
+//                    s.setLong(1, parentId);
+//                    s.setLong(2, latestVersion);
+//                    s.setLong(3, childID);
+//                    ResultSet result = s.executeQuery();
+//                    if (result.next()) {
+//                        return result.getLong(1);
+//                    }
+//                } else {
+//                    return getLatestVerisonNumber(getResourceID(path, conn), 
conn);
+//                }
             } catch (SQLException e) {
                 log.info("Something went wrong while calculating the current " 
+
                          "version for the path : " + path + " and the error us 
" + e);
@@ -325,6 +348,22 @@
         return -1;
     }
 
+    private long getChildVersion(Connection conn,
+                                long parentId,
+                                long parentVersion,
+                                long childId) throws SQLException {
+        String SQL = "SELECT DVN FROM DEPENDENCY WHERE AID=? AND VN=? AND 
DAID=?";
+        PreparedStatement selectps = conn.prepareStatement(SQL);
+        selectps.setLong(1, parentId);
+        selectps.setLong(2, parentVersion);
+        selectps.setLong(3, childId);
+        ResultSet childResult = selectps.executeQuery();
+        while (childResult.next()) {
+            return childResult.getLong("DVN");
+        }
+        return -1;
+    }
+
     public String[] getChildPaths(long artifcatID, long versionNumber,
                                   Connection connection) throws SQLException {
 
@@ -575,6 +614,25 @@
         return count == 1;
     }
 
+     public boolean resourceActive(String path, Connection conn) throws 
SQLException {
+
+        String sql = "SELECT STATE FROM ARTIFACTS A WHERE A.PATH=?";
+
+        PreparedStatement s = conn.prepareStatement(sql);
+        s.setString(1, path);
+
+        ResultSet result = s.executeQuery();
+        long count = 0;
+        if (result.next()) {
+            count = result.getLong(1);
+        }
+        if (RegistryConstants.ACTIVE_STATE == count) {
+            return  true;
+        } else {
+            return false;
+        }
+    }
+
     public long getResourceID(String path, Connection conn) throws 
SQLException {
 
         String sql = "SELECT A.AID FROM ARTIFACTS A WHERE A.PATH=?";
@@ -656,7 +714,7 @@
         }
     }
 
-    public void addResourceVersion(Resource resource, Connection connection) 
throws SQLException {
+    public long addResourceVersion(Resource resource, Connection connection) 
throws SQLException , RegistryException {
 
         if (resource.getLastModified() == null) {
             resource.setLastModified(new java.util.Date());
@@ -666,6 +724,7 @@
 
         //updating max version table
         updateDependency(resource, versionNumber, false, connection);
+        return versionNumber;
     }
 
     private long insertToVersionTable(Resource resource, Connection connection)
@@ -704,7 +763,7 @@
 
     private void updateDependency(Resource resource,
                                   long versionNumber,
-                                  boolean delete, Connection connection) 
throws SQLException {
+                                  boolean delete, Connection connection) 
throws SQLException , RegistryException {
 
         // updating dependency table , so that we can rollback to a particular 
version
         // updating for the current resource
@@ -751,7 +810,7 @@
      */
     private long updateDependencyTable(Resource resource,
                                        long versionNumber,
-                                       boolean delete, Connection connection) 
throws SQLException {
+                                       boolean delete, Connection connection) 
throws SQLException , RegistryException {
         /**
          *        D0
          *    D1      D2
@@ -870,7 +929,7 @@
     }
 
     public void restore(long resourceId, long toVersion, Connection connection)
-            throws SQLException {
+            throws SQLException , RegistryException {
 
         Resource oldArtifact = getResourceByID(resourceId, toVersion, 
connection);
         if (User.getCurrentUser() != null) {
@@ -885,14 +944,13 @@
         addResourceVersion(oldArtifact, connection);
 
         if (oldArtifact.isDirectory()) {
-
+            activateDirectory(oldArtifact,connection);
             String selectChildSql = "SELECT DAID, DVN FROM DEPENDENCY WHERE 
AID=? AND VN=?";
             PreparedStatement selectps = 
connection.prepareStatement(selectChildSql);
             selectps.setLong(1, resourceId);
             selectps.setLong(2, toVersion);
             ResultSet childResult = selectps.executeQuery();
             ArrayList dependencyList = new ArrayList();
-
             while (childResult.next()) {
 
                 long daid = childResult.getLong("DAID");
@@ -921,7 +979,7 @@
      * @throws java.sql.SQLException : if something went wrong
      */
     public void deleteResource(Resource resource,
-                               Connection connection) throws SQLException {
+                               Connection connection) throws SQLException  , 
RegistryException{
         long versionNumber = getLatestVerisonNumber(resource.getId(), 
connection);
         updateDependency(resource, versionNumber, true, connection);
     }
@@ -1067,7 +1125,7 @@
         }
     }
 
-    private void deleteDirectory(Resource collection, Connection conn) throws 
SQLException {
+    private void deleteDirectory(Resource collection, Connection conn) throws 
SQLException , RegistryException {
         List childList = getChildren(collection.getId(), -1, conn);
         Iterator i = childList.iterator();
         while (i.hasNext()) {
@@ -1082,5 +1140,19 @@
         markDeleted(collection.getPath(), conn);
         deleteResource(collection, conn);
     }
+
+    private void activateDirectory(Resource collection, Connection conn) 
throws SQLException {
+        List childList = getChildren(collection.getId(), -1, conn);
+        Iterator i = childList.iterator();
+        while (i.hasNext()) {
+            Resource child = (Resource)i.next();
+            if (child.isDirectory()) {
+                activateDirectory(child, conn);
+            } else {
+                markActivated(child.getId(), conn);
+            }
+        }
+        markActivated(collection.getId(), conn);
+    }
   
 }

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/DefaultMediaTypeHandler.java
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/DefaultMediaTypeHandler.java
    (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/DefaultMediaTypeHandler.java
    Wed Jan 23 22:53:46 2008
@@ -320,17 +320,17 @@
         return true;
     }
 
-    private void deleteDirectory(Resource collection, Connection conn) throws 
SQLException {
+    private void deleteDirectory(Resource collection, Connection conn) throws 
SQLException  , RegistryException{
         List childList = resourceDAO.getChildren(collection.getId(), -1, conn);
         Iterator i = childList.iterator();
         while (i.hasNext()) {
             Resource child = (Resource)i.next();
-            if (child.isDirectory()) {
-                deleteDirectory(child, conn);
-            } else {
-                resourceDAO.markDeleted(child.getPath(), conn);
-                resourceDAO.deleteResource(child, conn);
-            }
+//            if (child.isDirectory()) {
+//                deleteDirectory(child, conn);
+//            } else {
+            resourceDAO.markDeleted(child.getPath(), conn);
+            resourceDAO.deleteResource(child, conn);
+//            }
         }
         resourceDAO.markDeleted(collection.getPath(), conn);
         resourceDAO.deleteResource(collection, conn);

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java
      (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java
      Wed Jan 23 22:53:46 2008
@@ -264,9 +264,7 @@
     }
 
     public void delete(String path) throws RegistryException {
-
         String authPath = getAuthorizationPath(path);
-
         try {
             if (path.indexOf(";") > 0) {
 

Modified: 
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/CommentTest.java
==============================================================================
--- 
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/CommentTest.java
    (original)
+++ 
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/CommentTest.java
    Wed Jan 23 22:53:46 2008
@@ -320,7 +320,6 @@
                        commentTexts.contains(comment2));
 
         } catch (RegistryException e) {
-            e.printStackTrace();
             fail("Failed to get comments form URL: /;comments");
         }
 
@@ -443,7 +442,8 @@
             assertTrue("deleted comment still exists", 
!containsString(cTexts1, "test comment1"));
             
         } catch (RegistryException e) {
-            e.printStackTrace();
+            //TODO Chathura please fix this
+//            fail(e.getMessage());
         }
 
     }

Modified: 
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/JettyBasedServerTest.java
==============================================================================
--- 
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/JettyBasedServerTest.java
   (original)
+++ 
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/JettyBasedServerTest.java
   Wed Jan 23 22:53:46 2008
@@ -44,17 +44,6 @@
         }
     }
 
-    public void testCollectionDetails() throws Exception {
-        Resource r1 = new Resource();
-        String str = "My Content";
-        r1.setContent(str.getBytes());
-        registry.put("/c1/c2/c3/c4/r1", r1);
-        r1.setDescription("This is test discription");
-        r1.setProperty("p1", "value1");
-        registry.put("/c1/c2/c3", r1);
-        r1 = registry.get("/c1/c2/c3/c4/r1");
-        assertEquals(str, new String((byte[])r1.getContent()));
-    }
 
     public void testAddComment() {
         try {

Modified: 
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/RatingTest.java
==============================================================================
--- 
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/RatingTest.java 
    (original)
+++ 
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/RatingTest.java 
    Wed Jan 23 22:53:46 2008
@@ -93,7 +93,7 @@
             byte[] r1content = "R1 content".getBytes();
             r1.setContent(r1content);
 
-            registry.put("/d16/d17/d18/r1", r1);
+            registry.put("/d61/d17/d18/r1", r1);
 
         } catch (
                 RegistryException e) {
@@ -101,43 +101,43 @@
         }
 
         try {
-            registry.rateResource("/d16/d17/d18/r1", 5);
+            registry.rateResource("/d61/d17/d18/r1", 5);
         } catch (RegistryException e) {
-            fail("Couldn't rate the resource /d16/d17/d18/r1");
+            fail("Couldn't rate the resource /d61/d17/d18/r1");
         }
 
         float rating = 0;
         try {
-            rating = registry.getAverageRating("/d16/d17/d18/r1");
+            rating = registry.getAverageRating("/d61/d17/d18/r1");
 
         } catch (RegistryException e) {
-            fail("Couldn't get the rating of the resource /d16/d17/d18/r1");
+            fail("Couldn't get the rating of the resource /d61/d17/d18/r1");
         }
 
         //System.out.println("Start rating:" + rating);
 
-        assertEquals("Rating of the resource /d16/d17/d18/r1 should be 5.", 
rating, (float)5.0,
+        assertEquals("Rating of the resource /d61/d17/d18/r1 should be 5.", 
rating, (float)5.0,
                      (float)0.01);
 
         /*rate the same resource again*/
 
         try {
-            registry.rateResource("/d16/d17/d18/r1", 3);
+            registry.rateResource("/d61/d17/d18/r1", 3);
         } catch (RegistryException e) {
-            fail("Couldn't rate the resource /d16/d17/d18/r1");
+            fail("Couldn't rate the resource /d61/d17/d18/r1");
         }
 
         float rating_edit = 0;
         try {
-            rating_edit = registry.getAverageRating("/d16/d17/d18/r1");
+            rating_edit = registry.getAverageRating("/d61/d17/d18/r1");
 
         } catch (RegistryException e) {
-            fail("Couldn't get the rating of the resource /d16/d17/d18/r1");
+            fail("Couldn't get the rating of the resource /d61/d17/d18/r1");
         }
 
         //System.out.println("Start rating:" + rating_edit);
 
-        assertEquals("Rating of the resource /d16/d17/d18/r1 should be 5.", 
rating_edit, (float)3.0,
+        assertEquals("Rating of the resource /d61/d17/d18/r1 should be 5.", 
rating_edit, (float)3.0,
                      (float)0.01);
         /* try {
            registry.delete("/d16/d17/r1");

Modified: 
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/VersionTest.java
==============================================================================
--- 
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/VersionTest.java
    (original)
+++ 
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/VersionTest.java
    Wed Jan 23 22:53:46 2008
@@ -48,7 +48,7 @@
         assertEquals("/wso2/wsas/v1/resource2", content1[1]);
 
 
-        registry.restoreVersion("/wso2/wsas?v=3");
+        registry.restoreVersion("/wso2/wsas?v=2");
         resource1 = registry.get("/wso2/wsas/v1");
         content1 = ((String[])resource1.getContent());
         assertEquals(2, content1.length);
@@ -65,7 +65,7 @@
         assertEquals("/wso2/wsas/v1/resource1", content1[1]);
         assertEquals("/wso2/wsas/v1/r3", content1[2]);
 
-        registry.restoreVersion("/wso2/wsas?v=3");
+        registry.restoreVersion("/wso2/wsas?v=2");
         resource1 = registry.get("/wso2/wsas/v1");
         content1 = ((String[])resource1.getContent());
         assertEquals(2, content1.length);
@@ -322,18 +322,18 @@
         assertTrue("Collection not deleted.", deleted);
 
         /*restore delted collection*/
-        /*
+
         try{
             registry.restoreVersion("/c25/c26?v=1");
 
         }catch(RegistryException e){
             fail("Couldn't restore the version");
         }
-        */
+
 
         /*read restored version*/
 
-        /*
+
         Resource r3= new Resource();
 
         try{
@@ -346,7 +346,7 @@
         //System.out.println("File content:" + new String((byte[]) 
r1.getContent()));
         //System.out.println("File content:" + new String((byte[]) 
r3.getContent()));
         assertEquals("Restored file content is not matching",new 
String((byte[]) r1.getContent()),new String((byte[]) r3.getContent()));
-       */
+       
 
     }
 

Modified: 
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java
==============================================================================
--- 
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java
      (original)
+++ 
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java
      Wed Jan 23 22:53:46 2008
@@ -44,6 +44,21 @@
         }
     }
 
+    
+
+     public void testCollectionDetails() throws Exception {
+         Resource  r1 = new Resource();
+         String str = "My Content";
+         r1.setContent(str.getBytes());
+         registry.put("/c1/c2/c3/c4/r1",r1);
+         r1 = new Resource();
+         r1.setDescription("This is test discription");
+         r1.setProperty("p1","value1");
+         registry.put("/c1/c2/c3" , r1);
+         r1= registry.get("/c1/c2/c3/c4/r1");
+         assertEquals(str , new String((byte[])r1.getContent()));
+    }
+
     public void testFlatResourceHandling() {
         Resource r1 = new Resource();
         r1.setAuthorUserName("Chathura");

Modified: 
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/VersionHandlingTest.java
==============================================================================
--- 
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/VersionHandlingTest.java
   (original)
+++ 
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/VersionHandlingTest.java
   Wed Jan 23 22:53:46 2008
@@ -68,7 +68,7 @@
         assertEquals("/wso2/wsas/v1/resource2", content1[1]);
 
 
-        registry.restoreVersion("/wso2/wsas?v=3");
+        registry.restoreVersion("/wso2/wsas?v=2");
         resource1 = registry.get("/wso2/wsas/v1");
         content1 = ((String[])resource1.getContent());
         assertEquals(2, content1.length);
@@ -85,7 +85,7 @@
         assertEquals("/wso2/wsas/v1/resource1", content1[1]);
         assertEquals("/wso2/wsas/v1/r3", content1[2]);
 
-        registry.restoreVersion("/wso2/wsas?v=3");
+        registry.restoreVersion("/wso2/wsas?v=2");
         resource1 = registry.get("/wso2/wsas/v1");
         content1 = ((String[])resource1.getContent());
         assertEquals(2, content1.length);

_______________________________________________
Registry-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/registry-dev

Reply via email to