From cde22209110742d0e82858971a983ae0f2211442 Mon Sep 17 00:00:00 2001 From: Christos KK Loverdos Date: Fri, 1 Feb 2013 14:52:02 +0200 Subject: [PATCH] Show display name in FilePropertiesDialog --- .../grnet/pithos/web/client/DeleteFileDialog.java | 2 +- .../grnet/pithos/web/client/FileContextMenu.java | 4 ++-- src/gr/grnet/pithos/web/client/FileList.java | 12 +++++------ .../pithos/web/client/FilePermissionsDialog.java | 6 +++--- .../pithos/web/client/FilePropertiesDialog.java | 21 ++++++++++++++++---- .../grnet/pithos/web/client/FilePublishDialog.java | 6 +++--- .../pithos/web/client/FileVersionsDialog.java | 2 +- .../pithos/web/client/FolderPropertiesDialog.java | 2 +- src/gr/grnet/pithos/web/client/Pithos.java | 16 +++++++++++---- src/gr/grnet/pithos/web/client/ToolsMenu.java | 4 ++-- src/gr/grnet/pithos/web/client/VersionsList.java | 4 ++-- .../grnet/pithos/web/client/foldertree/File.java | 10 +++++----- 12 files changed, 54 insertions(+), 35 deletions(-) diff --git a/src/gr/grnet/pithos/web/client/DeleteFileDialog.java b/src/gr/grnet/pithos/web/client/DeleteFileDialog.java index 7cfc97e..ffbacdd 100644 --- a/src/gr/grnet/pithos/web/client/DeleteFileDialog.java +++ b/src/gr/grnet/pithos/web/client/DeleteFileDialog.java @@ -135,7 +135,7 @@ public class DeleteFileDialog extends DialogBox { if (iter.hasNext()) { File f = iter.next(); String path = f.getUri(); - DeleteRequest deleteFile = new DeleteRequest(app.getApiPath(), f.getOwner(), URL.encode(path)) { + DeleteRequest deleteFile = new DeleteRequest(app.getApiPath(), f.getOwnerID(), URL.encode(path)) { @Override public void onSuccess(Resource result) { deleteFile(iter); diff --git a/src/gr/grnet/pithos/web/client/FileContextMenu.java b/src/gr/grnet/pithos/web/client/FileContextMenu.java index eb9baec..ba56139 100644 --- a/src/gr/grnet/pithos/web/client/FileContextMenu.java +++ b/src/gr/grnet/pithos/web/client/FileContextMenu.java @@ -198,7 +198,7 @@ public class FileContextMenu extends PopupPanel { else { for (File f : selectedFiles) { permissions = f.getPermissions().get(app.getUserID()); - canWrite &= (f.getOwner().equals(app.getUserID()) || (permissions!= null && permissions[1] != null && permissions[1])); + canWrite &= (f.getOwnerID().equals(app.getUserID()) || (permissions!= null && permissions[1] != null && permissions[1])); } } boolean isFolderTreeSelected = selectedTree.equals(app.getFolderTreeView()); @@ -252,7 +252,7 @@ public class FileContextMenu extends PopupPanel { @Override public void execute() { for (File f : selectedFiles) - Window.open(app.getApiPath() + f.getOwner() + f.getUri(), "_blank", ""); + Window.open(app.getApiPath() + f.getOwnerID() + f.getUri(), "_blank", ""); } })); diff --git a/src/gr/grnet/pithos/web/client/FileList.java b/src/gr/grnet/pithos/web/client/FileList.java index 556e5a1..5384d11 100644 --- a/src/gr/grnet/pithos/web/client/FileList.java +++ b/src/gr/grnet/pithos/web/client/FileList.java @@ -54,10 +54,8 @@ import com.google.gwt.cell.client.ValueUpdater; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ContextMenuEvent; import com.google.gwt.event.dom.client.ContextMenuHandler; -import com.google.gwt.http.client.URL; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.resources.client.ImageResource; -import com.google.gwt.resources.client.ClientBundle.Source; import com.google.gwt.resources.client.ImageResource.ImageOptions; import com.google.gwt.resources.client.ImageResource.RepeatStyle; import com.google.gwt.safehtml.client.SafeHtmlTemplates; @@ -290,7 +288,7 @@ public class FileList extends Composite { sb.append(Templates.INSTANCE.filenameSpan(object.getName())); if (object.getContentType() != null && (object.getContentType().endsWith("png") || object.getContentType().endsWith("gif") || object.getContentType().endsWith("jpeg"))) { sb.appendHtmlConstant(" ") - .append(Templates.INSTANCE.viewLink(app.getApiPath() + object.getOwner() + object.getUri(), object.getName())); + .append(Templates.INSTANCE.viewLink(app.getApiPath() + object.getOwnerID() + object.getUri(), object.getName())); } return sb.toSafeHtml(); @@ -417,7 +415,7 @@ public class FileList extends Composite { if (DOM.eventGetType(event) == Event.ONDBLCLICK) if (getSelectedFiles().size() == 1) { File file = getSelectedFiles().get(0); - Window.open(app.getApiPath() + file.getOwner() + file.getUri(), "_blank", ""); + Window.open(app.getApiPath() + file.getOwnerID() + file.getUri(), "_blank", ""); event.preventDefault(); return; } @@ -547,7 +545,7 @@ public class FileList extends Composite { if (sortingProperty.equals("version")) { return arg0.getVersion() - arg1.getVersion(); } else if (sortingProperty.equals("owner")) { - return arg0.getOwner().compareTo(arg1.getOwner()); + return arg0.getOwnerID().compareTo(arg1.getOwnerID()); } else if (sortingProperty.equals("date")) { if (arg0.getLastModified() != null && arg1.getLastModified() != null) return arg0.getLastModified().compareTo(arg1.getLastModified()); @@ -567,7 +565,7 @@ public class FileList extends Composite { return arg1.getVersion() - arg0.getVersion(); } else if (sortingProperty.equals("owner")) { - return arg1.getOwner().compareTo(arg0.getOwner()); + return arg1.getOwnerID().compareTo(arg0.getOwnerID()); } else if (sortingProperty.equals("date")) { return arg1.getLastModified().compareTo(arg0.getLastModified()); @@ -649,7 +647,7 @@ public class FileList extends Composite { int i = 0; boolean scrolled = false; for (File f : files) { - if (selectedUrls.contains(app.getApiPath() + f.getOwner() + f.getUri())) { + if (selectedUrls.contains(app.getApiPath() + f.getOwnerID() + f.getUri())) { selectionModel.setSelected(f, true); if (!scrolled) { celltable.getRowElement(i).getCells().getItem(0).scrollIntoView(); diff --git a/src/gr/grnet/pithos/web/client/FilePermissionsDialog.java b/src/gr/grnet/pithos/web/client/FilePermissionsDialog.java index 5192a52..3cf468e 100644 --- a/src/gr/grnet/pithos/web/client/FilePermissionsDialog.java +++ b/src/gr/grnet/pithos/web/client/FilePermissionsDialog.java @@ -144,7 +144,7 @@ public class FilePermissionsDialog extends AbstractPropertiesDialog { private VerticalPanel createSharingPanel() { VerticalPanel permPanel = new VerticalPanel(); - permList = new PermissionsList(images, file.getPermissions(), file.getOwner(), false, new Command() { + permList = new PermissionsList(images, file.getPermissions(), file.getOwnerID(), false, new Command() { @Override public void execute() { @@ -240,7 +240,7 @@ public class FilePermissionsDialog extends AbstractPropertiesDialog { void showLinkIfShared() { if (file.isShared()) { UrlBuilder b = Window.Location.createUrlBuilder(); - b.setPath(app.getApiPath() + file.getOwner() + file.getUri()); + b.setPath(app.getApiPath() + file.getOwnerID() + file.getUri()); String href = Window.Location.getHref(); boolean hasParameters = href.contains("?"); path.setText(href + (hasParameters ? "&" : "?") + "goto=" + b.buildString()); @@ -265,7 +265,7 @@ public class FilePermissionsDialog extends AbstractPropertiesDialog { PostRequest updateFile = new PostRequest(api, owner, path) { @Override public void onSuccess(Resource result) { - HeadRequest headFile = new HeadRequest(File.class, app.getApiPath(), file.getOwner(), path, file) { + HeadRequest headFile = new HeadRequest(File.class, app.getApiPath(), file.getOwnerID(), path, file) { @Override public void onSuccess(File _result) { diff --git a/src/gr/grnet/pithos/web/client/FilePropertiesDialog.java b/src/gr/grnet/pithos/web/client/FilePropertiesDialog.java index 013f631..2aa3788 100644 --- a/src/gr/grnet/pithos/web/client/FilePropertiesDialog.java +++ b/src/gr/grnet/pithos/web/client/FilePropertiesDialog.java @@ -133,11 +133,24 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog { name.setWidth("100%"); name.setText(file.getName()); generalTable.setWidget(0, 1, name); - if(file.getParent() != null) + if(file.getParent() != null) { generalTable.setText(1, 1, file.getParent().getName()); - else + } + else { generalTable.setText(1, 1, "-"); - generalTable.setText(2, 1, file.getOwner()); + } + + final String ownerID = file.getOwnerID(); + final String displayName = app.getUserDisplayNameByID(ownerID); + final String ownerDisplayName; + if(displayName == null) { + // FIXME: Get the actual display name and do not use the id + ownerDisplayName = ownerID; + } + else { + ownerDisplayName = displayName; + } + generalTable.setText(2, 1, ownerDisplayName); final DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a"); generalTable.setText(3, 1, file.getLastModified() != null ? formatter.format(file.getLastModified()) : ""); @@ -251,7 +264,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog { PutRequest updateFile = new PutRequest(app.getApiPath(), app.getUserID(), path) { @Override public void onSuccess(Resource result) { - updateMetaData(app.getApiPath(), file.getOwner(), path, newMeta); + updateMetaData(app.getApiPath(), file.getOwnerID(), path, newMeta); } @Override diff --git a/src/gr/grnet/pithos/web/client/FilePublishDialog.java b/src/gr/grnet/pithos/web/client/FilePublishDialog.java index 83df31e..b074f01 100644 --- a/src/gr/grnet/pithos/web/client/FilePublishDialog.java +++ b/src/gr/grnet/pithos/web/client/FilePublishDialog.java @@ -157,7 +157,7 @@ public class FilePublishDialog extends AbstractPropertiesDialog { }); // Only show the read for all permission if the user is the owner. - if (file.getOwner().equals(app.getUserID())) { + if (file.getOwnerID().equals(app.getUserID())) { final HorizontalPanel permForAll = new HorizontalPanel(); permForAll.add(new Label("Public")); permForAll.add(readForAll); @@ -222,7 +222,7 @@ public class FilePublishDialog extends AbstractPropertiesDialog { protected boolean accept() { Boolean published = null; if (readForAll.getValue() != file.isPublished()) - if (file.getOwner().equals(app.getUserID())) + if (file.getOwnerID().equals(app.getUserID())) published = readForAll.getValue(); updateMetaData(app.getApiPath(), app.getUserID(), file.getUri() + "?update=", published); return true; @@ -233,7 +233,7 @@ public class FilePublishDialog extends AbstractPropertiesDialog { PostRequest updateFile = new PostRequest(api, owner, path) { @Override public void onSuccess(Resource result) { - HeadRequest headFile = new HeadRequest(File.class, app.getApiPath(), file.getOwner(), path, file) { + HeadRequest headFile = new HeadRequest(File.class, app.getApiPath(), file.getOwnerID(), path, file) { @Override public void onSuccess(File _result) { diff --git a/src/gr/grnet/pithos/web/client/FileVersionsDialog.java b/src/gr/grnet/pithos/web/client/FileVersionsDialog.java index 2ee4de2..2a2fa79 100644 --- a/src/gr/grnet/pithos/web/client/FileVersionsDialog.java +++ b/src/gr/grnet/pithos/web/client/FileVersionsDialog.java @@ -146,7 +146,7 @@ public class FileVersionsDialog extends AbstractPropertiesDialog { protected void fetchVersions() { String path = file.getUri() + "?format=json&version=list"; - GetRequest getVersions = new GetRequest(FileVersions.class, app.getApiPath(), file.getOwner(), path) { + GetRequest getVersions = new GetRequest(FileVersions.class, app.getApiPath(), file.getOwnerID(), path) { @Override public void onSuccess(FileVersions _result) { diff --git a/src/gr/grnet/pithos/web/client/FolderPropertiesDialog.java b/src/gr/grnet/pithos/web/client/FolderPropertiesDialog.java index 994e210..db3393a 100644 --- a/src/gr/grnet/pithos/web/client/FolderPropertiesDialog.java +++ b/src/gr/grnet/pithos/web/client/FolderPropertiesDialog.java @@ -141,7 +141,7 @@ public class FolderPropertiesDialog extends DialogBox { else generalTable.setText(1, 1, folder.getParent().getName()); if (create) - generalTable.setText(2, 1, app.getUserDisplayName()); + generalTable.setText(2, 1, app.getCurrentUserDisplayNameOrID()); else generalTable.setText(2, 1, folder.getOwner()); DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a"); diff --git a/src/gr/grnet/pithos/web/client/Pithos.java b/src/gr/grnet/pithos/web/client/Pithos.java index 80c1e32..9effc6d 100644 --- a/src/gr/grnet/pithos/web/client/Pithos.java +++ b/src/gr/grnet/pithos/web/client/Pithos.java @@ -126,11 +126,19 @@ public class Pithos implements EntryPoint, ResizeHandler { return userID; } - public String getUserDisplayName() { + 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 String getUserDisplayNameByID(String id) { + return userCatalogs.getDisplayName(id); + } + public void setAccount(AccountResource acct) { account = acct; } @@ -1025,8 +1033,8 @@ public class Pithos implements EntryPoint, ResizeHandler { }; copyFile.setHeader("X-Auth-Token", getUserToken()); copyFile.setHeader("X-Copy-From", URL.encodePathSegment(file.getUri())); - if(!file.getOwner().equals(targetUsername)) { - copyFile.setHeader("X-Source-Account", URL.encodePathSegment(file.getOwner())); + if(!file.getOwnerID().equals(targetUsername)) { + copyFile.setHeader("X-Source-Account", URL.encodePathSegment(file.getOwnerID())); } copyFile.setHeader("Content-Type", file.getContentType()); Scheduler.get().scheduleDeferred(copyFile); @@ -1321,7 +1329,7 @@ public class Pithos implements EntryPoint, ResizeHandler { } public void scheduleFileHeadCommand(File f, final Command callback) { - HeadRequest headFile = new HeadRequest(File.class, getApiPath(), f.getOwner(), f.getUri(), f) { + HeadRequest headFile = new HeadRequest(File.class, getApiPath(), f.getOwnerID(), f.getUri(), f) { @Override public void onSuccess(File _result) { diff --git a/src/gr/grnet/pithos/web/client/ToolsMenu.java b/src/gr/grnet/pithos/web/client/ToolsMenu.java index 9d9452f..d72729e 100644 --- a/src/gr/grnet/pithos/web/client/ToolsMenu.java +++ b/src/gr/grnet/pithos/web/client/ToolsMenu.java @@ -135,7 +135,7 @@ public class ToolsMenu extends PopupPanel { if (item instanceof List) { @SuppressWarnings("unchecked") List _files = (List) item; - if (_files.get(0).getOwner().equals(folder.getOwner())) + if (_files.get(0).getOwnerID().equals(folder.getOwner())) showPaste = true; } else { @@ -194,7 +194,7 @@ public class ToolsMenu extends PopupPanel { @Override public void execute() { for (File f: files) - Window.open(app.getApiPath() + f.getOwner() + f.getUri(), "_blank", ""); + Window.open(app.getApiPath() + f.getOwnerID() + f.getUri(), "_blank", ""); } })); empty = false; diff --git a/src/gr/grnet/pithos/web/client/VersionsList.java b/src/gr/grnet/pithos/web/client/VersionsList.java index 4d479dd..88f8aa2 100644 --- a/src/gr/grnet/pithos/web/client/VersionsList.java +++ b/src/gr/grnet/pithos/web/client/VersionsList.java @@ -116,7 +116,7 @@ public class VersionsList extends Composite { downloadHtml.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { - String fileUrl = app.getApiPath() + file.getOwner() + file.getUri() + "?version=" + v.getVersion(); + String fileUrl = app.getApiPath() + file.getOwnerID() + file.getUri() + "?version=" + v.getVersion(); Window.open(fileUrl, "_BLANK", ""); } }); @@ -132,7 +132,7 @@ public class VersionsList extends Composite { void restoreVersion(int version) { String path = file.getUri() + "?update="; - PostRequest restoreVersion = new PostRequest(app.getApiPath(), file.getOwner(), path) { + PostRequest restoreVersion = new PostRequest(app.getApiPath(), file.getOwnerID(), path) { @Override public void onSuccess(Resource result) { diff --git a/src/gr/grnet/pithos/web/client/foldertree/File.java b/src/gr/grnet/pithos/web/client/foldertree/File.java index 52cdca2..a8a02da 100644 --- a/src/gr/grnet/pithos/web/client/foldertree/File.java +++ b/src/gr/grnet/pithos/web/client/foldertree/File.java @@ -66,7 +66,7 @@ public class File extends Resource { private String path; - private String owner; + private String ownerID; private String container; @@ -111,8 +111,8 @@ public class File extends Resource { return "/" + container + "/" + path; } - public String getOwner() { - return owner; + public String getOwnerID() { + return ownerID; } public String getPath() { @@ -149,7 +149,7 @@ public class File extends Resource { name = path.substring(parent.getPrefix().length() + 1); else name = path; - this.owner = _owner; + this.ownerID = _owner; hash = unmarshallString(o, "hash"); bytes = unmarshallLong(o, "bytes"); version = unmarshallInt(o, "x_object_version"); @@ -223,7 +223,7 @@ public class File extends Resource { } private void populate(String _owner, Response response) { - this.owner = _owner; + this.ownerID = _owner; published = false; publicUri = null; permissions.clear(); -- 1.7.10.4