updateHistory removed from RestResource and other resources and implemented only...
[pithos] / src / gr / ebs / gss / client / rest / resource / FolderResource.java
index 9b3fdd3..84e4861 100644 (file)
@@ -93,6 +93,7 @@ public class FolderResource extends RestResource {
         *
         * @return the name
         */
+       @Override
        public String getName() {
                return name;
        }
@@ -507,49 +508,6 @@ public class FolderResource extends RestResource {
        public void setFilesExpanded(boolean newFilesExpanded) {
                filesExpanded = newFilesExpanded;
        }
-
-       /**
-        * history support for folder navigation
-        */
-       @Override
-       public void updateHistory(TreeItem item, String path){
-               try{
-                       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
         *
@@ -582,5 +540,45 @@ 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;
+               }
+
+       }
 
 }