From dfaf97aa1cf68dbd88f35fee89ee207590bdf4d6 Mon Sep 17 00:00:00 2001 From: Pete Meyer Date: Thu, 4 May 2017 11:28:09 -0400 Subject: [PATCH 1/6] utilities for querying setting list --- .../harvard/iq/dataverse/SettingsWrapper.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java b/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java index 4d4e3bb95f8..727eefde326 100644 --- a/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java +++ b/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java @@ -37,6 +37,11 @@ public class SettingsWrapper implements java.io.Serializable { private static final Set TRUE_VALUES = Collections.unmodifiableSet( new TreeSet<>( Arrays.asList("1","yes", "true","allow"))); + /** + * + * @return setting value as string, or null if no setting is specified (JSF test `empty` + * works for null values`) + */ public String get(String settingKey) { if (settingsMap == null) { initSettingsMap(); @@ -62,6 +67,57 @@ private void initSettingsMap() { } } + /** + * default separator "," for settings list + */ + public static String defaultListSeparator = ","; + + /** + * check if a given value is present in a setting list using the default separator. + * @param settingKey setting list to search + * @param queryValue value to search for + * @return true if a given value is present in a setting list, false if the value or key is + * absent + */ + public boolean valueInSettingList(String settingKey, String queryValue ) + { + return valueInSettingList( settingKey, queryValue, defaultListSeparator); + } + + /** + * check if a given value is present in a setting list. + * @param settingKey setting list to search + * @param queryValue value to search for + * @param sep list separator + * @return true if a given value is present in a setting list, false if the value or key is + * absent + */ + public boolean valueInSettingList(String settingKey, String queryValue, String sep) + { + if ( null == settingsMap ) + { + initSettingsMap(); + } + String xs = settingsMap.get( settingKey ); + if ( null == xs ) + { + return false; + } + String[] ys = xs.split( sep ); + if ( 0 == ys.length ) + { + return false; + } + for( String y : ys ) + { + if ( queryValue == y ) + { + return true; + } + } + return false; + } + private String guidesBaseUrl = null; public String getGuidesBaseUrl() { From 2579e3738a7889e788031912fef68ad8f4e825dd Mon Sep 17 00:00:00 2001 From: Pete Meyer Date: Thu, 4 May 2017 14:19:51 -0400 Subject: [PATCH 2/6] specifics for upload/download methods --- .../harvard/iq/dataverse/SettingsWrapper.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java b/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java index 727eefde326..d24d1817b56 100644 --- a/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java +++ b/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java @@ -118,6 +118,58 @@ public boolean valueInSettingList(String settingKey, String queryValue, String s return false; } + /** + * if this key is present in the downloadMethods or uploadMethods list, allow native + * (http) uploads / downloads (if either list has been set). + */ + public static String nativeProtocol = "native/http"; + + /** + * default string for uploadMethods; may belong elsewhere. + */ + private static String uploadMethodsList = "uploadMethods"; + /** + * default string for downloadMethods; may belong elsewhere. + */ + private static String downloadMethodsList = "downloadMethods"; + + /** + * wrapper to see if the native file upload options should be shown. + * @return true if `nativeProtocol` is in the `uploadMethods` list, or if `uploadMethods` + * has not been set; false otherwise. + */ + public boolean allowNativeUploads() + { + return nativeTransferCheck( uploadMethodsList ); + } + + /** + * wrapper to see if the native file download options should be shown. + * @return true if `nativeProtocol` is in the `downloadMethods` list, or if `downloadMethods` + * has not been set; false otherwise. + */ + public boolean allowNativeDownloads() + { + return nativeTransferCheck( downloadMethodsList ); + } + + /** + * centralize logic for check if setting absent, or value present in setting list + */ + private boolean nativeTransferCheck( String transferDirection ) + { + if ( null == settingsMap ) + { + initSettingsMap(); + } + Set keys = settingsMap.keySet(); + if ( ! keys.contains( (Object) transferDirection ) ) + { + return true; + } + return valueInSettingList( transferDirection, nativeProtocol ); + } + private String guidesBaseUrl = null; public String getGuidesBaseUrl() { From b2086cef33f5d3493f3e85ec693f2ff6e440a1e2 Mon Sep 17 00:00:00 2001 From: Pete Meyer Date: Thu, 4 May 2017 17:04:33 -0400 Subject: [PATCH 3/6] ugly first pass at hiding native uploads (POC) --- src/main/webapp/editFilesFragment.xhtml | 30 ++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/main/webapp/editFilesFragment.xhtml b/src/main/webapp/editFilesFragment.xhtml index 67953211afe..3bbc2092dbb 100644 --- a/src/main/webapp/editFilesFragment.xhtml +++ b/src/main/webapp/editFilesFragment.xhtml @@ -19,7 +19,9 @@
-
+
+ + - \ No newline at end of file + From 0be968754847a2b698f052ee2242325d382b896a Mon Sep 17 00:00:00 2001 From: Pete Meyer Date: Thu, 4 May 2017 18:29:31 -0400 Subject: [PATCH 4/6] ugly first pass at hiding native downloads (from dataset page) --- src/main/webapp/dataset.xhtml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/webapp/dataset.xhtml b/src/main/webapp/dataset.xhtml index a44b260ca57..5bf989a37ba 100755 --- a/src/main/webapp/dataset.xhtml +++ b/src/main/webapp/dataset.xhtml @@ -596,7 +596,9 @@ -
+
+ +

#{bundle['dataset.downloadUnrestricted']}

@@ -606,7 +608,9 @@ action="#{DatasetPage.modifyGuestbookMultipleResponse()}" update="@form" /> -
+ + +

#{bundle['file.deleteDialog.tip']}

@@ -1073,6 +1077,8 @@
+ + @@ -1086,7 +1092,9 @@ - + + + From 5a100c60e370f07c143dee34665e68a1be2f9274 Mon Sep 17 00:00:00 2001 From: Pete Meyer Date: Fri, 5 May 2017 12:49:27 -0400 Subject: [PATCH 5/6] bugfix for values in setting list --- src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java b/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java index d24d1817b56..fd6c0ce6135 100644 --- a/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java +++ b/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java @@ -110,7 +110,7 @@ public boolean valueInSettingList(String settingKey, String queryValue, String s } for( String y : ys ) { - if ( queryValue == y ) + if ( queryValue.equals(y) ) { return true; } From 60776bf42aa6895dd2fc3918bed1dce48cb867d9 Mon Sep 17 00:00:00 2001 From: Pete Meyer Date: Mon, 8 May 2017 11:29:15 -0400 Subject: [PATCH 6/6] ungly POC for hiding native downloads --- src/main/webapp/file-download-button-fragment.xhtml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/webapp/file-download-button-fragment.xhtml b/src/main/webapp/file-download-button-fragment.xhtml index bd5937a3551..26af20ed9e7 100644 --- a/src/main/webapp/file-download-button-fragment.xhtml +++ b/src/main/webapp/file-download-button-fragment.xhtml @@ -10,6 +10,8 @@ xmlns:cc="http://java.sun.com/jsf/composite" xmlns:o="http://omnifaces.org/ui" xmlns:iqbs="http://xmlns.jcp.org/jsf/composite/iqbs"> + + @@ -284,5 +286,6 @@ #{bundle.close}
- + +