Automated merge with https://gss.googlecode.com/hg/
[pithos] / src / gr / ebs / gss / client / GSS.java
index af95cac..c786dbc 100644 (file)
@@ -19,6 +19,7 @@
 package gr.ebs.gss.client;
 
 import gr.ebs.gss.client.clipboard.Clipboard;
+import gr.ebs.gss.client.commands.GetUserCommand;
 import gr.ebs.gss.client.dnd.DnDFocusPanel;
 import gr.ebs.gss.client.dnd.DnDSimpleFocusPanel;
 import gr.ebs.gss.client.rest.GetCommand;
@@ -29,6 +30,7 @@ import gr.ebs.gss.client.rest.resource.TrashResource;
 import gr.ebs.gss.client.rest.resource.UserResource;
 
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 
@@ -203,6 +205,8 @@ public class GSS implements EntryPoint, ResizeHandler {
 
        private PickupDragController dragController;
 
+       public HashMap<String, String> userFullNameMap = new HashMap<String, String>();
+
        @Override
        public void onModuleLoad() {
                // Initialize the singleton before calling the constructors of the
@@ -339,12 +343,12 @@ public class GSS implements EntryPoint, ResizeHandler {
                                                PopupTree popupTree = GSS.get().getFolders().getPopupTree();
                                                TreeItem treeObj = GSS.get().getFolders().getPopupTree().getTreeItem(historyToken);
                                                SelectionEvent.fire(popupTree, treeObj);
-                                               }
-                                       } catch (IndexOutOfBoundsException e) {
-                                               inner.selectTab(0);
-                                               }
                                        }
-                       });
+                               } catch (IndexOutOfBoundsException e) {
+                                       inner.selectTab(0);
+                               }
+                       }
+               });
 
                // Add the left and right panels to the split panel.
                splitPanel.setLeftWidget(folders);
@@ -812,13 +816,32 @@ public class GSS implements EntryPoint, ResizeHandler {
        }
 
        /**
-        * Reject illegal resource names, like '.' or '..'.
+        * Reject illegal resource names, like '.' or '..' or slashes '/'.
         */
        static boolean isValidResourceName(String name) {
-               if (".".equals(name) || "..".equals(name))
+               if (".".equals(name) || "..".equals(name) || name.contains("/"))
                        return false;
                return true;
        }
 
+       public void putUserToMap(String _userName, String _userFullName){
+               userFullNameMap.put(_userName, _userFullName);
+       }
+
+       public String findUserFullName(String _userName){
+               return userFullNameMap.get(_userName);
+       }
 
+       public String getUserFullName(String _userName) {
+               if (GSS.get().findUserFullName(_userName) == null)
+                       //if there is no userFullName found then the map fills with the given _userName,
+                       //so userFullName = _userName
+                       GSS.get().putUserToMap(_userName, _userName);
+               else if(GSS.get().findUserFullName(_userName).indexOf('@') != -1){
+                       //if the userFullName = _userName the GetUserCommand updates the userFullName in the map
+                       GetUserCommand guc = new GetUserCommand(_userName);
+                       guc.execute();
+               }
+               return GSS.get().findUserFullName(_userName);
+       }
 }