From e663b3a74fb5c88b9479bfcd3db170115725b877 Mon Sep 17 00:00:00 2001 From: Christos KK Loverdos Date: Mon, 10 Jun 2013 16:26:52 +0300 Subject: [PATCH] Change image view URL according to new semantics for "view" URLs Refs #3965 --- src/gr/grnet/pithos/web/client/FileList.java | 4 ++-- src/gr/grnet/pithos/web/client/Pithos.java | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/gr/grnet/pithos/web/client/FileList.java b/src/gr/grnet/pithos/web/client/FileList.java index 2785186..2a9068d 100644 --- a/src/gr/grnet/pithos/web/client/FileList.java +++ b/src/gr/grnet/pithos/web/client/FileList.java @@ -282,7 +282,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(Pithos.getStorageAPIURL() + object.getOwnerID() + object.getUri(), object.getName())); + .append(Templates.INSTANCE.viewLink(Pithos.getFileViewURL(object), object.getName())); } return sb.toSafeHtml(); @@ -409,7 +409,7 @@ public class FileList extends Composite { if (DOM.eventGetType(event) == Event.ONDBLCLICK) if (getSelectedFiles().size() == 1) { File file = getSelectedFiles().get(0); - Window.open(Pithos.getStorageViewURL() + file.getOwnerID() + file.getUri(), "_blank", ""); + Window.open(Pithos.getFileViewURL(file), "_blank", ""); event.preventDefault(); return; } diff --git a/src/gr/grnet/pithos/web/client/Pithos.java b/src/gr/grnet/pithos/web/client/Pithos.java index 57e6841..fbb5f98 100644 --- a/src/gr/grnet/pithos/web/client/Pithos.java +++ b/src/gr/grnet/pithos/web/client/Pithos.java @@ -99,16 +99,20 @@ public class Pithos implements EntryPoint, ResizeHandler { } public static final Dictionary otherProperties = Dictionary.getDictionary(Const.OTHER_PROPERTIES); - public static String getFromOtherPropertiesOrNull(String key) { + public static String getFromOtherPropertiesOrDefault(String key, String def) { try { - return otherProperties.get(key); + final String value = otherProperties.get(key); + return value == null ? def : value; } catch(Exception e) { - LOGError(e); - return null; + return def; } } + public static String getFromOtherPropertiesOrNull(String key) { + return getFromOtherPropertiesOrDefault(key, null); + } + public static final String OTHERPROPS_STORAGE_API_URL = getFromOtherPropertiesOrNull("STORAGE_API_URL"); public static final String OTHERPROPS_USER_CATALOGS_API_URL = getFromOtherPropertiesOrNull("USER_CATALOGS_API_URL"); static { @@ -144,6 +148,8 @@ public class Pithos implements EntryPoint, ResizeHandler { LOG("Computed STORAGE_VIEW_URL = ", STORAGE_VIEW_URL); } + public static final String PUBLIC_LINK_VIEW_PREFIX = getFromOtherPropertiesOrDefault("PUBLIC_LINK_VIEW_PREFIX", ""); + public static final String USER_CATALOGS_API_URL; static { if(OTHERPROPS_USER_CATALOGS_API_URL != null) { @@ -1105,6 +1111,10 @@ public class Pithos implements EntryPoint, ResizeHandler { return USER_CATALOGS_API_URL; } + public static String getFileViewURL(File file) { + return Pithos.getStorageViewURL() + file.getOwnerID() + file.getUri(); + } + /** * History support for folder navigation * adds a new browser history entry -- 1.7.10.4