Automated merge with https://gss.googlecode.com/hg/
[pithos] / src / gr / ebs / gss / client / rest / resource / FolderResource.java
index 395e23d..59e25c3 100644 (file)
@@ -79,6 +79,30 @@ public class FolderResource extends RestResource {
 
        private boolean filesExpanded=false;
 
+       boolean readForAll;
+       
+       Boolean shared;
+       
+       
+       /**
+        * Retrieve the shared.
+        *
+        * @return the shared
+        */
+       public Boolean getShared() {
+               return shared;
+       }
+       
+       
+       /**
+        * Modify the shared.
+        *
+        * @param shared the shared to set
+        */
+       public void setShared(Boolean shared) {
+               this.shared = shared;
+       }
+
        /**
         * Modify the parentName.
         *
@@ -337,7 +361,11 @@ public class FolderResource extends RestResource {
                JSONObject json = (JSONObject) JSONParser.parse(text);
                name = unmarshallString(json, "name");
                owner = unmarshallString(json, "owner");
+               createdBy = unmarshallString(json, "createdBy");
+               modifiedBy = unmarshallString(json, "modifiedBy");
                deleted = unmarshallBoolean(json, "deleted");
+               shared = unmarshallBoolean(json, "shared");
+               readForAll = unmarshallBoolean(json, "readForAll");
                if (deleted)
                        GWT.log("FOUND A DELETED FOLDER:" + name, null);
 
@@ -378,6 +406,8 @@ public class FolderResource extends RestResource {
                                                                subUri = subUri + "/";
                                                        FolderResource sub = new FolderResource(subUri);
                                                        sub.setName(subName);
+                                                       sub.setParentURI(uri);
+                                                       sub.setParentName(name);
                                                        sub.setNeedsExpanding(true);
                                                        folders.add(sub);
                                                        subfolderPaths.add(subUri);
@@ -395,6 +425,7 @@ public class FolderResource extends RestResource {
                                                String fowner = unmarshallString(fo, "owner");
                                                String fcontent = unmarshallString(fo, "content");
                                                String fpath = unmarshallString(fo, "path");
+                                               Boolean fshared = unmarshallBoolean(fo, "shared");
                                                fpath = URL.decodeComponent(fpath);
                                                Integer fversion = null;
                                                if (fo.get("version") != null)
@@ -418,6 +449,7 @@ public class FolderResource extends RestResource {
                                                fs.setVersion(fversion);
                                                fs.setContentLength(fsize);
                                                fs.setDeleted(fdeleted);
+                                               fs.setShared(fshared);
                                                fs.setCreationDate(fcreationDate);
                                                fs.setModificationDate(fmodificationDate);
                                                fs.setContentType(fcontent);
@@ -508,55 +540,8 @@ public class FolderResource extends RestResource {
        public void setFilesExpanded(boolean newFilesExpanded) {
                filesExpanded = newFilesExpanded;
        }
-
-       /**
-        * History support for folder navigation
-        * This method constructs the uri when a folder is selected. This folder is either below user's
-        * home directory or below "My Shared" or "Trash" or "Other's Shared" directory/
-        * (each if/else describes the case)
-        */
-       @Override
-       public void updateHistory(TreeItem item, String path){
-               try{
-                       GWT.log("getParentURI() ='"+getParentURI()+"'");
-                       if(getParentURI() == null){
-                               if(containsFolder(item, "Trash")){
-//                                     case: selected folders below Trash folder
-                                       String partialUri = constructPartialPath(item);
-                                       GSS.get().updateHistory("Files/trash/" + partialUri, item);
-                               } else
-//                                     case: home folders are selected
-                                       GSS.get().updateHistory("Files/files/" + getName(), item);
-                       }
-                       else if(item.getParentItem() == null){
-//                             this is the case when the user uses the browser's forward arrow to navigate through other's
-//                             shared folders and      item.getParentItem is null only inside other's shared folder
-                               String apiPath = GSS.get().getApiPath();
-                               String newPath = getParentURI().substring(apiPath.lastIndexOf("/"));
-                               GSS.get().updateHistory("Files"+ newPath + getName(), item);
-                       }
-                       else if(containsFolder(item, "My Shared")){
-//                             case: selected folders below My Shared folder
-                               String partialUri = constructPartialPath(item);
-                               GSS.get().updateHistory("Files/shared/" + partialUri, item);
-                       }else if(containsFolder(item, "Other's Shared")){
-//                             case: selected folders below Other's Shared folder
-                               String partialPath = constructPartialPath(item);
-                               GSS.get().updateHistory("Files/others/"+ partialPath, item);
-                       }
-                       else{
-//                             case:all folders in user's folders tree
-                               String finalUri = getParentURI().substring(path.lastIndexOf("/")) + getName();
-                               GSS.get().updateHistory("Files"+ finalUri, item);
-                       }
-
-               }catch (Exception e){
-                       throw new UnsupportedOperationException(e);
-               }
-
-       }
        /**
-        * construct the partial path of the selected TreeItem
+        * this method constructs the partial path of a given TreeItem using it's text
         *
         * @param selectedItem the selectedItem to check
         */
@@ -587,5 +572,62 @@ public class FolderResource extends RestResource {
                        }
                return false;
        }
+       @Override
+       public String constructUri(TreeItem treeItem, String path){
+               String constructedUri = "";
+               if(containsFolder(treeItem, "My Shared")){
+                       //case: selected folders below My Shared folder
+                       String partialUri = constructPartialPath(treeItem);
+                       constructedUri = constructedUri + "Files/shared/" + partialUri;
+                       return constructedUri;
+               }else if(containsFolder(treeItem, "Other's Shared")){
+                       //case: selected folders below Other's Shared folder
+                       String partialPath = constructPartialPath(treeItem);
+                       constructedUri = constructedUri + "Files/others/"+ partialPath;
+                       return constructedUri;
+               }
+               else if(getParentURI()==null){
+                       if(containsFolder(treeItem, "Trash")){
+                               //case: selected folders below Trash folder
+                               String partialUri = constructPartialPath(treeItem);
+                               constructedUri = constructedUri + "Files/trash/" + partialUri;
+                               return constructedUri;
+                       }
+                       //case: home folder is selected
+                       constructedUri = constructedUri + "Files/files/" + getName();
+                       return constructedUri;
+               }
+               else if(treeItem.getParentItem() == null){
+                       //this is the case when the user uses the browser's forward arrow to navigate through other's
+                       //shared folders and item.getParentItem is null only inside other's shared folder
+                       String apiPath = GSS.get().getApiPath();
+                       String newPath = getParentURI().substring(apiPath.lastIndexOf("/"));
+                       constructedUri = constructedUri + "Files"+ newPath + getName();
+                       return constructedUri;
+               }
+               else{
+                       String finalUri = getParentURI().substring(path.lastIndexOf("/")) + getName();
+                       constructedUri = constructedUri + "Files"+ finalUri;
+                       return constructedUri;
+               }
+
+       }
+
+       /**
+        * Retrieve the readForAll.
+        *
+        * @return the readForAll
+        */
+       public boolean isReadForAll() {
+               return readForAll;
+       }
+       /**
+        * Modify the readForAll.
+        *
+        * @param newReadForAll the readForAll to set
+        */
+       public void setReadForAll(boolean newReadForAll) {
+               readForAll = newReadForAll;
+       }
 
 }