Author: deepal
Date: Thu Jan 17 00:57:02 2008
New Revision: 12392

Log:

fixing 108 and 110

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/test/java/org/wso2/registry/app/JettyBasedServerTest.java
   trunk/registry/modules/core/src/test/java/org/wso2/registry/app/UserTest.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
   Thu Jan 17 00:57:02 2008
@@ -131,13 +131,16 @@
                         for (Object attribute : attributes) {
                             QName attName = (QName)attribute;
                             String key = attName.getLocalPart();
-                            if (!"mediaType".equals(key)) {
-                                resource.setProperty(key, 
entry.getAttributeValue(key));
-                            }
+                            resource.setProperty(key, 
entry.getAttributeValue(key));
+                        }
+
+                        String mediaTyep = entry.getSimpleExtension(new 
QName("mediaType"));
+                        if (mediaTyep !=null) {
+                            resource.setMediaType(mediaTyep);
                         }
-                        String mediaType = 
entry.getAttributeValue("mediaType");
-                        if (mediaType != null) {
-                            resource.setMediaType(mediaType);
+                        String parentPath = entry.getSimpleExtension(new 
QName("parentPath"));
+                        if (parentPath !=null ){
+                            resource.setParentPath(parentPath);
                         }
                         
resource.setAuthorUserName(entry.getAuthor().getName());
                         resource.setDescription(entry.getSummary());
@@ -430,11 +433,12 @@
             feed.addSimpleExtension(new QName("createdTime"),
                                     "" + resource.getCreatedTime().getTime());
         }
+        feed.addSimpleExtension(new QName("mediaType") 
,resource.getMediaType());
+        feed.addSimpleExtension(new QName("parentPath") , 
resource.getParentPath());
         String href = baseURI + "atom" + path;
         feed.addLink(href);
         feed.addLink(href, "path");
         feed.addSimpleExtension(new QName("lastUpdatedUser") , 
resource.getLastUpdaterUserName());
-
         //if the content type is comment then the resource will contains ,
         // String array of comments
         if (resource.isDirectory()) {

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 Jan 17 00:57:02 2008
@@ -123,6 +123,14 @@
         if (lastUpdatedUSer != null){
             resource.setLastUpdaterUserName(lastUpdatedUSer);
         }
+        String mediaTyep = feed.getSimpleExtension(new QName("mediaType"));
+        if (mediaTyep !=null) {
+            resource.setMediaType(mediaTyep);
+        }
+        String parentPath = feed.getSimpleExtension(new QName("parentPath"));
+        if (parentPath !=null ){
+            resource.setParentPath(parentPath);
+        }
         resource.setPath(feed.getTitle());
         resource.setDescription(feed.getSubtitle());
         String state = feed.getSimpleExtension(new QName("state"));
@@ -192,9 +200,6 @@
         Abdera abdera = new Abdera();
         AbderaClient abderaClient = new AbderaClient(abdera);
         Entry entry = abdera.getFactory().newEntry();
-        if (SQL_QUERY_MEDIA_TYPE.equals(resource.getMediaType())) {
-            entry.setAttributeValue("mediaType", SQL_QUERY_MEDIA_TYPE);
-        }
         entry.setSummary(resource.getDescription());
         entry.addAuthor(resource.getAuthorUserName());
         Properties properties = resource.getProperties();
@@ -205,6 +210,8 @@
                 entry.setAttributeValue(key, (String) properties.get(key));
             }
         }
+        entry.addSimpleExtension(new QName("mediaType") 
,resource.getMediaType());
+        entry.addSimpleExtension(new QName("parentPath") , 
resource.getParentPath());
         if (resource.isDirectory()) {
             entry.addSimpleExtension(new QName("directory"), "true");
         } else {

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
   Thu Jan 17 00:57:02 2008
@@ -40,4 +40,16 @@
         }
     }
 
+    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()));
+    }
+
 }

Modified: 
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/UserTest.java
==============================================================================
--- 
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/UserTest.java   
    (original)
+++ 
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/UserTest.java   
    Thu Jan 17 00:57:02 2008
@@ -264,7 +264,7 @@
         r1.setDescription("C3 collection description");
         r1.setMediaType("text");
         r1.setDirectory(true);
-        r1.setParentPath("/c1/c2/c3");
+        r1.setParentPath("/c1/c2");
 
 
         Properties r2Pro = new Properties();
@@ -296,11 +296,11 @@
          System.out.println("File Desciption:" + r1_actual.getDescription());
          System.out.println("Author Name:" + r1_actual.getAuthorUserName());
          System.out.println("Resource Properties:" + 
r1_actual.getProperties());
-         System.out.println("Resource MediaType:" + r1_actual.getMediaType());
-         System.out.println("Resource MediaType:" + r1.getMediaType());
+
+         assertEquals(r1_actual.getMediaType() ,r1.getMediaType());
+         assertEquals(r1_actual.getParentPath() , r1.getParentPath());
          System.out.println("Resource Properties by key:" + 
r1_actual.getProperty("key2"));
-         System.out.println("Resource Parent path:" + 
r1_actual.getParentPath());
-         System.out.println("Resource is Directory:" + 
r1_actual.isDirectory());
+         assertTrue(r1_actual.isDirectory());
          System.out.println("Resource get ID:" + r1_actual.getId());
          System.out.println("Resource get CreatedTime:" + 
r1_actual.getCreatedTime());
          System.out.println("Resource get LastModified Time:" + 
r1_actual.getLastModified());

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

Reply via email to