Revision 5aaf7821

b/src/gr/grnet/pithos/web/client/foldertree/File.java
144 144
    public void populate(Folder _parent, JSONObject o, String _owner, String _container) {
145 145
        this.parent = _parent;
146 146
        path = unmarshallString(o, "name");
147
        if (path.contains("/"))
148
            name = path.substring(path.lastIndexOf("/") + 1, path.length()); //strip the prefix
147
        if (parent != null && parent.getPrefix().length() > 0)
148
        	name = path.substring(parent.getPrefix().length() + 1);
149 149
        else
150 150
            name = path;
151 151
        this.owner = _owner;
b/src/gr/grnet/pithos/web/client/foldertree/Folder.java
180 180
                    if (o.containsKey("subdir") || (contentType != null && (contentType.startsWith("application/directory") || contentType.startsWith("application/folder")))) {
181 181
                        Folder f = new Folder();
182 182
                        f.populate(this, o, _owner, container);
183
                        subfolders.add(f);
183
                        if (f.getName().length() > 0)
184
                        	subfolders.add(f);
184 185
                    }
185 186
                    else {
186 187
                        File file = new File();
187 188
                        file.populate(this, o, _owner, container);
188
                        files.add(file);
189
                        if (file.getName().length() > 0)
190
                        	files.add(file);
189 191
                    }
190 192
                }
191 193
            }
......
197 199
        String path = null;
198 200
        if (o.containsKey("subdir")) {
199 201
            path = unmarshallString(o, "subdir");
202
            if (path.endsWith("/")) { //Always true for "subdir"
203
                path = path.substring(0, path.length() - 1);
204
            }
205
            if (parent != null && parent.getPrefix().length() > 0)
206
            	name = path.substring(parent.getPrefix().length() + 1);
207
            else
208
            	name = path;
209
            if (name.equals("/"))
210
            	name = "";
200 211
        }
201 212
        else {
202 213
            path = unmarshallString(o, "name");
203 214
            lastModified = unmarshallDate(o, "last_modified");
215
            if (parent != null && parent.getPrefix().length() > 0)
216
            	name = path.substring(parent.getPrefix().length() + 1);
217
            else
218
            	name = path;
204 219
        }
205
        if (path.endsWith("/")) {
206
            path = path.substring(0, path.length() - 1);
207
        }
208
        if (path.contains("/"))
209
            name = path.substring(path.lastIndexOf("/") + 1, path.length()); //strip the prefix
210
        else
211
            name = path;
212 220
        if (aContainer != null) {
213 221
            container = aContainer;
214 222
            prefix = path;

Also available in: Unified diff