From b9a1049a2c0fbae37f7fec67801b7ac2f37d862c Mon Sep 17 00:00:00 2001 From: Christos KK Loverdos Date: Fri, 1 Feb 2013 18:41:11 +0200 Subject: [PATCH] Show display name in "Shared with me" --- .../pithos/web/client/FilePropertiesDialog.java | 2 +- .../pithos/web/client/FolderPropertiesDialog.java | 2 +- src/gr/grnet/pithos/web/client/Pithos.java | 42 +- src/gr/grnet/pithos/web/client/SharingUsers.java | 11 +- .../pithos/web/client/catalog/GetUserCatalogs.java | 4 + .../pithos/web/client/catalog/UserCatalogs.java | 8 +- .../othersharedtree/OtherSharedTreeViewModel.java | 401 ++++++++++++-------- 7 files changed, 296 insertions(+), 174 deletions(-) diff --git a/src/gr/grnet/pithos/web/client/FilePropertiesDialog.java b/src/gr/grnet/pithos/web/client/FilePropertiesDialog.java index 2aa3788..4161b90 100644 --- a/src/gr/grnet/pithos/web/client/FilePropertiesDialog.java +++ b/src/gr/grnet/pithos/web/client/FilePropertiesDialog.java @@ -141,7 +141,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog { } final String ownerID = file.getOwnerID(); - final String displayName = app.getUserDisplayNameByID(ownerID); + final String displayName = app.getUserDisplayNameForID(ownerID); final String ownerDisplayName; if(displayName == null) { // FIXME: Get the actual display name and do not use the id diff --git a/src/gr/grnet/pithos/web/client/FolderPropertiesDialog.java b/src/gr/grnet/pithos/web/client/FolderPropertiesDialog.java index 0528c1e..e2f1def 100644 --- a/src/gr/grnet/pithos/web/client/FolderPropertiesDialog.java +++ b/src/gr/grnet/pithos/web/client/FolderPropertiesDialog.java @@ -136,7 +136,7 @@ public class FolderPropertiesDialog extends DialogBox { } else { final String ownerID = folder.getOwnerID(); - final String displayName = app.getUserDisplayNameByID(ownerID); + final String displayName = app.getUserDisplayNameForID(ownerID); final String ownerDisplayName; if(displayName == null) { // FIXME: Get the actual display name and do not use the id diff --git a/src/gr/grnet/pithos/web/client/Pithos.java b/src/gr/grnet/pithos/web/client/Pithos.java index 8caac03..bc267f9 100644 --- a/src/gr/grnet/pithos/web/client/Pithos.java +++ b/src/gr/grnet/pithos/web/client/Pithos.java @@ -126,17 +126,51 @@ public class Pithos implements EntryPoint, ResizeHandler { return userID; } + public UserCatalogs getUserCatalogs() { + return userCatalogs; + } + public String getCurrentUserDisplayNameOrID() { final String displayName = userCatalogs.getDisplayName(getUserID()); return displayName == null ? getUserID() : displayName; } - public boolean hasUserDisplayNameForID(String id) { - return userCatalogs.getDisplayName(id) != null; + public boolean hasUserDisplayNameForID(String userID) { + return userCatalogs.getDisplayName(userID) != null; + } + + public String getUserDisplayNameForID(String userID) { + return userCatalogs.getDisplayName(userID); + } + + public String getUserIDForDisplayName(String displayName) { + return userCatalogs.getUserID(displayName); + } + + public List getUserDisplayNamesForIDs(List userIDs) { + if(userIDs == null) { + userIDs = new ArrayList(); + } + final List userDisplayNames = new ArrayList(); + for(String userID : userIDs) { + final String displayName = getUserDisplayNameForID(userID); + userDisplayNames.add(displayName); + } + + return userDisplayNames; } - public String getUserDisplayNameByID(String id) { - return userCatalogs.getDisplayName(id); + public List filterUserIDsWithUnknownDisplayName(Collection userIDs) { + if(userIDs == null) { + userIDs = new ArrayList(); + } + final List filtered = new ArrayList(); + for(String userID : userIDs) { + if(!this.userCatalogs.hasID(userID)) { + filtered.add(userID); + } + } + return filtered; } public void setAccount(AccountResource acct) { diff --git a/src/gr/grnet/pithos/web/client/SharingUsers.java b/src/gr/grnet/pithos/web/client/SharingUsers.java index 00dbd18..575928b 100644 --- a/src/gr/grnet/pithos/web/client/SharingUsers.java +++ b/src/gr/grnet/pithos/web/client/SharingUsers.java @@ -35,6 +35,7 @@ package gr.grnet.pithos.web.client; import java.util.ArrayList; +import java.util.Collections; import java.util.Date; import java.util.List; @@ -45,7 +46,7 @@ import com.google.gwt.json.client.JSONParser; import com.google.gwt.json.client.JSONValue; public class SharingUsers extends Resource { - private List users; + private List userIDs; public static SharingUsers createFromResponse(Response response, SharingUsers result) { SharingUsers u; @@ -58,21 +59,21 @@ public class SharingUsers extends Resource { } private void populate(Response response) { - users = new ArrayList(); + userIDs = new ArrayList(); JSONValue json = JSONParser.parseStrict(response.getText()); JSONArray array = json.isArray(); if (array != null) { for (int i=0; i getUsers() { - return users; + public List getUserIDs() { + return Collections.unmodifiableList(userIDs); } @Override diff --git a/src/gr/grnet/pithos/web/client/catalog/GetUserCatalogs.java b/src/gr/grnet/pithos/web/client/catalog/GetUserCatalogs.java index 78c963e..3cb6669 100644 --- a/src/gr/grnet/pithos/web/client/catalog/GetUserCatalogs.java +++ b/src/gr/grnet/pithos/web/client/catalog/GetUserCatalogs.java @@ -36,6 +36,10 @@ public class GetUserCatalogs implements Scheduler.ScheduledCommand { this(app, Helpers.toList(userID), null); } + public GetUserCatalogs(Pithos app, List ids) { + this(app, ids, null); + } + public GetUserCatalogs(Pithos app, List ids, List names) { assert app != null; diff --git a/src/gr/grnet/pithos/web/client/catalog/UserCatalogs.java b/src/gr/grnet/pithos/web/client/catalog/UserCatalogs.java index 948f1ad..7a58247 100644 --- a/src/gr/grnet/pithos/web/client/catalog/UserCatalogs.java +++ b/src/gr/grnet/pithos/web/client/catalog/UserCatalogs.java @@ -49,14 +49,18 @@ public class UserCatalogs implements Iterable>{ return id2name.containsKey(id); } - public boolean hasName(String email) { - return name2id.containsKey(email); + public boolean hasName(String name) { + return name2id.containsKey(name); } public String getDisplayName(String id) { return id2name.get(id); } + public String getUserID(String name) { + return name2id.get(name); + } + @Override public Iterator> iterator() { return id2name.entrySet().iterator(); diff --git a/src/gr/grnet/pithos/web/client/othersharedtree/OtherSharedTreeViewModel.java b/src/gr/grnet/pithos/web/client/othersharedtree/OtherSharedTreeViewModel.java index 0da9572..0758c7d 100644 --- a/src/gr/grnet/pithos/web/client/othersharedtree/OtherSharedTreeViewModel.java +++ b/src/gr/grnet/pithos/web/client/othersharedtree/OtherSharedTreeViewModel.java @@ -35,19 +35,6 @@ package gr.grnet.pithos.web.client.othersharedtree; -import gr.grnet.pithos.web.client.FolderContextMenu; -import gr.grnet.pithos.web.client.Pithos; -import gr.grnet.pithos.web.client.SharingUsers; -import gr.grnet.pithos.web.client.foldertree.AccountResource; -import gr.grnet.pithos.web.client.foldertree.Folder; -import gr.grnet.pithos.web.client.othersharedtree.OtherSharedTreeView.Templates; -import gr.grnet.pithos.web.client.rest.GetRequest; -import gr.grnet.pithos.web.client.rest.RestException; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - import com.google.gwt.cell.client.AbstractCell; import com.google.gwt.cell.client.Cell; import com.google.gwt.cell.client.TextCell; @@ -55,8 +42,10 @@ import com.google.gwt.cell.client.ValueUpdater; import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; import com.google.gwt.event.dom.client.ContextMenuEvent; +import com.google.gwt.http.client.Request; import com.google.gwt.http.client.Response; import com.google.gwt.http.client.URL; +import com.google.gwt.json.client.JSONObject; import com.google.gwt.safehtml.shared.SafeHtml; import com.google.gwt.safehtml.shared.SafeHtmlBuilder; import com.google.gwt.text.shared.SafeHtmlRenderer; @@ -65,46 +54,62 @@ import com.google.gwt.user.client.ui.AbstractImagePrototype; import com.google.gwt.view.client.ListDataProvider; import com.google.gwt.view.client.SingleSelectionModel; import com.google.gwt.view.client.TreeViewModel; +import gr.grnet.pithos.web.client.FolderContextMenu; +import gr.grnet.pithos.web.client.Pithos; +import gr.grnet.pithos.web.client.SharingUsers; +import gr.grnet.pithos.web.client.catalog.GetUserCatalogs; +import gr.grnet.pithos.web.client.catalog.UserCatalogs; +import gr.grnet.pithos.web.client.foldertree.AccountResource; +import gr.grnet.pithos.web.client.foldertree.Folder; +import gr.grnet.pithos.web.client.othersharedtree.OtherSharedTreeView.Templates; +import gr.grnet.pithos.web.client.rest.GetRequest; +import gr.grnet.pithos.web.client.rest.RestException; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; public class OtherSharedTreeViewModel implements TreeViewModel { protected Pithos app; - String dummy = "No shares by others yet"; + final String dummy = "No shares by others yet"; private Cell folderCell = new AbstractCell(ContextMenuEvent.getType().getName()) { - @Override + @Override public void render(Context context, Folder folder, SafeHtmlBuilder safeHtmlBuilder) { String html = AbstractImagePrototype.create(OtherSharedTreeView.images.folderYellow()).getHTML(); - safeHtmlBuilder.appendHtmlConstant(html).appendHtmlConstant(" "); + safeHtmlBuilder.appendHtmlConstant(html).appendHtmlConstant(" "); safeHtmlBuilder.append(Templates.INSTANCE.nameSpan(folder.getName())); } @Override public void onBrowserEvent(Context context, com.google.gwt.dom.client.Element parent, final Folder folder, com.google.gwt.dom.client.NativeEvent event, ValueUpdater valueUpdater) { - if (event.getType().equals(ContextMenuEvent.getType().getName())) { - final int x = event.getClientX(); - final int y = event.getClientY(); + if(event.getType().equals(ContextMenuEvent.getType().getName())) { + final int x = event.getClientX(); + final int y = event.getClientY(); OtherSharedTreeViewModel.this.selectionModel.setSelected(folder, true); app.scheduleFolderHeadCommand(folder, new Command() { - - @Override - public void execute() { - FolderContextMenu menu = new FolderContextMenu(app, OtherSharedTreeView.images, app.getSelectedTree(), folder); - menu.setPopupPosition(x, y); - menu.show(); - } - }); + + @Override + public void execute() { + FolderContextMenu menu = new FolderContextMenu(app, OtherSharedTreeView.images, app.getSelectedTree(), folder); + menu.setPopupPosition(x, y); + menu.show(); + } + }); } } }; - protected ListDataProvider userLevelDataProvider = new ListDataProvider(); + protected ListDataProvider userLevelDataProviderForIDs = new ListDataProvider(); +// protected ListDataProvider userLevelDataProviderForDisplayNames = new ListDataProvider(); protected Map> userDataProviderMap = new HashMap>(); private Map> dataProviderMap = new HashMap>(); - + protected SingleSelectionModel selectionModel; public OtherSharedTreeViewModel(Pithos _app, SingleSelectionModel selectionModel) { @@ -114,39 +119,48 @@ public class OtherSharedTreeViewModel implements TreeViewModel { @Override public NodeInfo getNodeInfo(T value) { - if (value == null) { - fetchSharingUsers(null); - return new DefaultNodeInfo(userLevelDataProvider, new TextCell(new SafeHtmlRenderer() { - - @Override - public SafeHtml render(String object) { + if(value == null) { +// LOG("getNodeInfo(null), calling fetchSharingUsers(null)"); + fetchSharingUsers(null); +// LOG("getNodeInfo(null), called fetchSharingUsers(null)"); + return new DefaultNodeInfo(userLevelDataProviderForIDs, new TextCell(new SafeHtmlRenderer() { + @Override + public SafeHtml render(String object) { + final String displayName = app.getUserDisplayNameForID(object); +// LOG("render(userID = "+object+"), displayName = " + displayName); SafeHtmlBuilder builder = new SafeHtmlBuilder(); - render(object, builder); + render(displayName, builder); return builder.toSafeHtml(); - } + } - @Override - public void render(String object, SafeHtmlBuilder builder) { - if (!object.equals(dummy)) { - String html = AbstractImagePrototype.create(OtherSharedTreeView.images.myShared()).getHTML(); - builder.appendHtmlConstant(html).appendHtmlConstant(" "); + @Override + public void render(String object, SafeHtmlBuilder builder) { + if(!object.equals(dummy)) { +// LOG("render(userID [not dummy] = "+object+")"); + String html = AbstractImagePrototype.create(OtherSharedTreeView.images.myShared()).getHTML(); + builder.appendHtmlConstant(html).appendHtmlConstant(" "); } + final String displayName = app.getUserDisplayNameForID(object); builder.append(OtherSharedTreeView.Templates.INSTANCE.nameSpan(object)); - } - }), null, null); + } + }), null, null); } - else if (value instanceof String) { - String username = (String) value; - if (userDataProviderMap.get(username) == null) { - userDataProviderMap.put(username, new ListDataProvider()); - } - final ListDataProvider dataProvider = userDataProviderMap.get(username); - fetchSharedContainers(username, dataProvider, null); - return new DefaultNodeInfo(dataProvider, folderCell, selectionModel, null); + else if(value instanceof String) { +// LOG("getNodeInfo(String "+value+"), called with userID"); + final String userID = (String) value; + + if(userDataProviderMap.get(userID) == null) { + userDataProviderMap.put(userID, new ListDataProvider()); + } + final ListDataProvider userIDDataProvider = userDataProviderMap.get(userID); + fetchSharedContainers(userID, userIDDataProvider, null); + + return new DefaultNodeInfo(userIDDataProvider, folderCell, selectionModel, null); } else { +// LOG("getNodeInfo(Folder "+value+"), called with a folder"); final Folder f = (Folder) value; - if (dataProviderMap.get(f) == null) { + if(dataProviderMap.get(f) == null) { dataProviderMap.put(f, new ListDataProvider()); } final ListDataProvider dataProvider = dataProviderMap.get(f); @@ -155,144 +169,205 @@ public class OtherSharedTreeViewModel implements TreeViewModel { } } +// native void LOG(String message) /*-{ +// console.log(message ); +// }-*/; + private void fetchSharingUsers(final Command callback) { GetRequest getSharingUsers = new GetRequest(SharingUsers.class, app.getApiPath(), "", "?format=json") { @Override public void onSuccess(final SharingUsers _result) { - userLevelDataProvider.getList().clear(); - userLevelDataProvider.getList().addAll(_result.getUsers()); - if (userLevelDataProvider.getList().isEmpty()) - userLevelDataProvider.getList().add(dummy); - Iterator iter = _result.getUsers().iterator(); - fetchSharedContainers(iter, callback); + userLevelDataProviderForIDs.getList().clear(); + + final List userIDs = _result.getUserIDs(); +// for(String userID : userIDs) { +// LOG("fetchSharingUsers(): userID =" + userID); +// } + final List userIDsWithUnknownDisplayNames = app.filterUserIDsWithUnknownDisplayName(userIDs); +// for(String userID : userIDsWithUnknownDisplayNames) { +// LOG("fetchSharingUsers(): userID (with unknown name) =" + userID); +// } + + userLevelDataProviderForIDs.getList().addAll(userIDs); + if(userLevelDataProviderForIDs.getList().isEmpty()) { + userLevelDataProviderForIDs.getList().add(dummy); +// userLevelDataProviderForDisplayNames.getList().add(dummy); + } else { +// userLevelDataProviderForDisplayNames.getList().addAll(app.getUserDisplayNamesForIDs(userIDs)); + } + + if(userIDsWithUnknownDisplayNames.size() == 0) { + // All display names are known, so we proceed directly + fetchSharedContainers(userLevelDataProviderForIDs.getList().iterator(), callback); + } else { + // First fetch unknown display names and then proceed + new GetUserCatalogs(app, userIDsWithUnknownDisplayNames) { + @Override + public void onSuccess(Request request, Response response, JSONObject result, UserCatalogs userCatalogs) { +// for(Map.Entry entry : userCatalogs) { +// final String id = entry.getKey(); +// final String name = entry.getValue(); +// LOG("mapping: userID("+id+") -> name("+name+")"); +// } + + // Update the cached user catalogs + app.getUserCatalogs().updateFrom(userCatalogs); + + fetchSharedContainers(userLevelDataProviderForIDs.getList().iterator(), callback); + } + + @Override + public void onError(Request request, Throwable t) { + super.onError(request, t); + app.setError(t); + } + }.scheduleDeferred(); + } } @Override public void onError(Throwable t) { GWT.log("Error getting folder", t); - app.setError(t); - if (t instanceof RestException) + app.setError(t); + if(t instanceof RestException) { app.displayError("Error getting folder: " + ((RestException) t).getHttpStatusText()); - else + } + else { app.displayError("System error fetching folder: " + t.getMessage()); + } } - @Override - protected void onUnauthorized(Response response) { - app.sessionExpired(); - } + @Override + protected void onUnauthorized(Response response) { + app.sessionExpired(); + } }; getSharingUsers.setHeader("X-Auth-Token", app.getUserToken()); Scheduler.get().scheduleDeferred(getSharingUsers); - } - - protected void fetchSharedContainers(final Iterator iter, final Command callback) { - if (iter.hasNext()) { - String username = iter.next(); - if (userDataProviderMap.get(username) == null) { - userDataProviderMap.put(username, new ListDataProvider()); - } - final ListDataProvider dataProvider = userDataProviderMap.get(username); - fetchSharedContainers(username, dataProvider, new Command() { - - @Override - public void execute() { - fetchSharedContainers(iter, callback); - - } - }); - } - else - if (callback != null) - callback.execute(); - } - - @Override + } + + protected void fetchSharedContainers(final Iterator userIDsIterator, final Command callback) { + if(userIDsIterator.hasNext()) { + String userID = userIDsIterator.next(); + if(userDataProviderMap.get(userID) == null) { + userDataProviderMap.put(userID, new ListDataProvider()); + } + final ListDataProvider dataProvider = userDataProviderMap.get(userID); + fetchSharedContainers(userID, dataProvider, new Command() { + + @Override + public void execute() { + fetchSharedContainers(userIDsIterator, callback); + + } + }); + } + else if(callback != null) { + callback.execute(); + } + } + + @Override public boolean isLeaf(Object o) { - if (o == null) - return userLevelDataProvider.getList().isEmpty(); - else if (o instanceof Folder) { - Folder f = (Folder) o; - return f.getSubfolders().isEmpty(); + if(o == null) { + boolean result = userLevelDataProviderForIDs.getList().isEmpty(); +// LOG("isLeaf(null) ==> " + result); + return result; + } + else if(o instanceof Folder) { + Folder folder = (Folder) o; + boolean result = folder.getSubfolders().isEmpty(); +// LOG("isLeaf(Folder "+folder+") ==> " + result); + return result; + } + else { + ListDataProvider dp = userDataProviderMap.get(o); + if(dp != null) { + boolean result = dp.getList().isEmpty(); +// LOG("isLeaf("+o.getClass().getName()+" "+o+") ==> " + result); + return result; + } +// LOG("isLeaf("+o.getClass().getName()+" "+o+") ==> (true)"); + return true; } - else { - ListDataProvider dp = userDataProviderMap.get(o); - if (dp != null) - return dp.getList().isEmpty(); - return true; - } } - private void fetchSharedContainers(final String username, final ListDataProvider dataProvider, final Command callback) { - GetRequest getUserSharedContainers = new GetRequest(AccountResource.class, app.getApiPath(), username, "?format=json") { - - @Override - public void onSuccess(AccountResource _result) { - final ListDataProvider tempProvider = new ListDataProvider(); - Iterator iter = _result.getContainers().iterator(); - fetchFolder(username, iter, tempProvider, new Command() { - - @Override - public void execute() { - dataProvider.getList().clear(); - dataProvider.getList().addAll(tempProvider.getList()); - if (callback != null) - callback.execute(); - } - }); - } - - @Override - public void onError(Throwable t) { + private void fetchSharedContainers(final String userID, final ListDataProvider dataProvider, final Command callback) { + GetRequest getUserSharedContainers = new GetRequest(AccountResource.class, app.getApiPath(), userID, "?format=json") { + + @Override + public void onSuccess(AccountResource _result) { + final ListDataProvider tempProvider = new ListDataProvider(); + Iterator folderIterator = _result.getContainers().iterator(); + fetchFolder(userID, folderIterator, tempProvider, new Command() { + + @Override + public void execute() { + dataProvider.getList().clear(); + dataProvider.getList().addAll(tempProvider.getList()); + if(callback != null) { + callback.execute(); + } + } + }); + } + + @Override + public void onError(Throwable t) { GWT.log("Error getting account", t); - app.setError(t); - if (t instanceof RestException) + app.setError(t); + if(t instanceof RestException) { app.displayError("Error getting account: " + ((RestException) t).getHttpStatusText()); - else + } + else { app.displayError("System error fetching user data: " + t.getMessage()); - } + } + } - @Override - protected void onUnauthorized(Response response) { - app.sessionExpired(); - } - }; - getUserSharedContainers.setHeader("X-Auth-Token", app.getUserToken()); - Scheduler.get().scheduleDeferred(getUserSharedContainers); - } + @Override + protected void onUnauthorized(Response response) { + app.sessionExpired(); + } + }; + getUserSharedContainers.setHeader("X-Auth-Token", app.getUserToken()); + Scheduler.get().scheduleDeferred(getUserSharedContainers); + } - protected void fetchFolder(final String username, final Iterator iter, final ListDataProvider dataProvider, final Command callback) { - if (iter.hasNext()) { - final Folder f = iter.next(); + protected void fetchFolder(final String userID, final Iterator folderIterator, final ListDataProvider dataProvider, final Command callback) { + if(folderIterator.hasNext()) { + final Folder f = folderIterator.next(); String path = "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(f.getPrefix()); - GetRequest getFolder = new GetRequest(Folder.class, app.getApiPath(), username, path, f) { + GetRequest getFolder = new GetRequest(Folder.class, app.getApiPath(), userID, path, f) { @Override public void onSuccess(Folder _result) { - dataProvider.getList().add(_result); - fetchFolder(username, iter, dataProvider, callback); + dataProvider.getList().add(_result); + fetchFolder(userID, folderIterator, dataProvider, callback); } @Override public void onError(Throwable t) { GWT.log("Error getting folder", t); - app.setError(t); - if (t instanceof RestException) + app.setError(t); + if(t instanceof RestException) { app.displayError("Error getting folder: " + ((RestException) t).getHttpStatusText()); - else + } + else { app.displayError("System error fetching folder: " + t.getMessage()); + } } - @Override - protected void onUnauthorized(Response response) { - app.sessionExpired(); - } + @Override + protected void onUnauthorized(Response response) { + app.sessionExpired(); + } }; getFolder.setHeader("X-Auth-Token", app.getUserToken()); Scheduler.get().scheduleDeferred(getFolder); } - else if (callback != null) + else if(callback != null) { callback.execute(); + } } public Folder getSelection() { @@ -300,7 +375,7 @@ public class OtherSharedTreeViewModel implements TreeViewModel { } public void updateFolder(Folder folder, boolean showfiles, Command callback) { - if (dataProviderMap.get(folder) == null) { + if(dataProviderMap.get(folder) == null) { dataProviderMap.put(folder, new ListDataProvider()); } final ListDataProvider dataProvider = dataProviderMap.get(folder); @@ -312,8 +387,9 @@ public class OtherSharedTreeViewModel implements TreeViewModel { GetRequest getFolder = new GetRequest(Folder.class, app.getApiPath(), f.getOwnerID(), path, f) { @Override public void onSuccess(final Folder _result) { - if (showfiles) + if(showfiles) { app.showFiles(_result); + } Iterator iter = _result.getSubfolders().iterator(); fetchFolder(_result.getOwnerID(), iter, dataProvider, new Command() { @Override @@ -321,8 +397,9 @@ public class OtherSharedTreeViewModel implements TreeViewModel { dataProvider.getList().clear(); dataProvider.getList().addAll(_result.getSubfolders()); app.getOtherSharedTreeView().updateChildren(f); - if (callback != null) - callback.execute(); + if(callback != null) { + callback.execute(); + } } }); } @@ -330,23 +407,25 @@ public class OtherSharedTreeViewModel implements TreeViewModel { @Override public void onError(Throwable t) { GWT.log("Error getting folder", t); - app.setError(t); - if (t instanceof RestException) + app.setError(t); + if(t instanceof RestException) { app.displayError("Error getting folder: " + ((RestException) t).getHttpStatusText()); - else + } + else { app.displayError("System error fetching folder: " + t.getMessage()); + } } - @Override - protected void onUnauthorized(Response response) { - app.sessionExpired(); - } + @Override + protected void onUnauthorized(Response response) { + app.sessionExpired(); + } }; getFolder.setHeader("X-Auth-Token", app.getUserToken()); Scheduler.get().scheduleDeferred(getFolder); } - + public void initialize(Command callback) { - fetchSharingUsers(callback); + fetchSharingUsers(callback); } } -- 1.7.10.4