Fixed display of folders that end with /
authorChristos Stathis <chstath@ebs.gr>
Mon, 6 Feb 2012 14:19:37 +0000 (16:19 +0200)
committerChristos Stathis <chstath@ebs.gr>
Mon, 6 Feb 2012 14:19:37 +0000 (16:19 +0200)
src/gr/grnet/pithos/web/client/foldertree/File.java
src/gr/grnet/pithos/web/client/foldertree/Folder.java

index fadd01f..4956981 100644 (file)
@@ -144,8 +144,8 @@ public class File extends Resource {
     public void populate(Folder _parent, JSONObject o, String _owner, String _container) {
         this.parent = _parent;
         path = unmarshallString(o, "name");
-        if (path.contains("/"))
-            name = path.substring(path.lastIndexOf("/") + 1, path.length()); //strip the prefix
+        if (parent != null && parent.getPrefix().length() > 0)
+               name = path.substring(parent.getPrefix().length() + 1);
         else
             name = path;
         this.owner = _owner;
index 1bbd399..fb03f1b 100644 (file)
@@ -180,12 +180,14 @@ public class Folder extends Resource {
                     if (o.containsKey("subdir") || (contentType != null && (contentType.startsWith("application/directory") || contentType.startsWith("application/folder")))) {
                         Folder f = new Folder();
                         f.populate(this, o, _owner, container);
-                        subfolders.add(f);
+                        if (f.getName().length() > 0)
+                               subfolders.add(f);
                     }
                     else {
                         File file = new File();
                         file.populate(this, o, _owner, container);
-                        files.add(file);
+                        if (file.getName().length() > 0)
+                               files.add(file);
                     }
                 }
             }
@@ -197,18 +199,24 @@ public class Folder extends Resource {
         String path = null;
         if (o.containsKey("subdir")) {
             path = unmarshallString(o, "subdir");
+            if (path.endsWith("/")) { //Always true for "subdir"
+                path = path.substring(0, path.length() - 1);
+            }
+            if (parent != null && parent.getPrefix().length() > 0)
+               name = path.substring(parent.getPrefix().length() + 1);
+            else
+               name = path;
+            if (name.equals("/"))
+               name = "";
         }
         else {
             path = unmarshallString(o, "name");
             lastModified = unmarshallDate(o, "last_modified");
+            if (parent != null && parent.getPrefix().length() > 0)
+               name = path.substring(parent.getPrefix().length() + 1);
+            else
+               name = path;
         }
-        if (path.endsWith("/")) {
-            path = path.substring(0, path.length() - 1);
-        }
-        if (path.contains("/"))
-            name = path.substring(path.lastIndexOf("/") + 1, path.length()); //strip the prefix
-        else
-            name = path;
         if (aContainer != null) {
             container = aContainer;
             prefix = path;