From 7e7a502ec1c87d5b99cbbf6487154ea466d9f53d Mon Sep 17 00:00:00 2001 From: Philip Durbin Date: Tue, 9 Mar 2021 12:13:31 -0500 Subject: [PATCH 01/44] download differentially private statistics #7400 This is just a stub for now with many FIXMEs. --- .../iq/dataverse/AuxiliaryFileServiceBean.java | 8 ++++++++ .../iq/dataverse/FileDownloadServiceBean.java | 8 ++++++++ .../webapp/file-download-button-fragment.xhtml | 18 ++++++++++++++++++ .../edu/harvard/iq/dataverse/api/AccessIT.java | 10 ++++++++-- 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/AuxiliaryFileServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/AuxiliaryFileServiceBean.java index 4f97c146e7b..0275ac4db5f 100644 --- a/src/main/java/edu/harvard/iq/dataverse/AuxiliaryFileServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/AuxiliaryFileServiceBean.java @@ -8,6 +8,7 @@ import java.io.InputStream; import java.security.DigestInputStream; import java.security.MessageDigest; +import java.util.List; import java.util.logging.Logger; import javax.ejb.EJB; import javax.ejb.Stateless; @@ -15,6 +16,7 @@ import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.persistence.Query; +import javax.persistence.TypedQuery; import org.apache.tika.Tika; /** @@ -114,4 +116,10 @@ public AuxiliaryFile lookupAuxiliaryFile(DataFile dataFile, String formatTag, St } } + public List findAuxiliaryFiles(DataFile dataFile) { + TypedQuery query = em.createQuery("select object(o) from AuxiliaryFile as o where o.dataFile.id = :dataFileId", AuxiliaryFile.class); + query.setParameter("dataFileId", dataFile.getId()); + return query.getResultList(); + } + } diff --git a/src/main/java/edu/harvard/iq/dataverse/FileDownloadServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/FileDownloadServiceBean.java index 4b0272d4a36..6f7d62924ac 100644 --- a/src/main/java/edu/harvard/iq/dataverse/FileDownloadServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/FileDownloadServiceBean.java @@ -280,6 +280,14 @@ private void redirectToBatchDownloadAPI(String multiFileString, Boolean download redirectToBatchDownloadAPI(multiFileString, true, downloadOriginal); } + public void redirectToAuxFileDownloadAPI(Long fileId, String formatTag, String formatVersion) { + String fileDownloadUrl = "/api/access/datafile/" + fileId + "/metadata/" + formatTag + "/" + formatVersion; + try { + FacesContext.getCurrentInstance().getExternalContext().redirect(fileDownloadUrl); + } catch (IOException ex) { + logger.info("Failed to issue a redirect to aux file download url (" + fileDownloadUrl + "): " + ex); + } + } /** * Launch an "explore" tool which is a type of ExternalTool such as diff --git a/src/main/webapp/file-download-button-fragment.xhtml b/src/main/webapp/file-download-button-fragment.xhtml index 85fe60863b4..82ca8b608a4 100644 --- a/src/main/webapp/file-download-button-fragment.xhtml +++ b/src/main/webapp/file-download-button-fragment.xhtml @@ -219,6 +219,24 @@ + + + + diff --git a/src/test/java/edu/harvard/iq/dataverse/api/AccessIT.java b/src/test/java/edu/harvard/iq/dataverse/api/AccessIT.java index 4fb1271c8c9..80db1502c07 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/AccessIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/AccessIT.java @@ -103,6 +103,11 @@ public static void setUp() throws InterruptedException { Response createDatasetResponse = UtilIT.createDatasetViaNativeApi(dataverseAlias, pathToJsonFile, apiToken); createDatasetResponse.prettyPrint(); datasetId = JsonPath.from(createDatasetResponse.body().asString()).getInt("data.id"); + + // TODO: Get this working. + Response allowAccessRequests = UtilIT.allowAccessRequests(datasetId.toString(), true, apiToken); + allowAccessRequests.prettyPrint(); + allowAccessRequests.then().assertThat().statusCode(200); basicFileName = "004.txt"; String basicPathToFile = "scripts/search/data/replace_test/" + basicFileName; @@ -179,13 +184,14 @@ public void testSaveAuxiliaryFileWithVersion() throws IOException { Response response = given() .header(API_TOKEN_HTTP_HEADER, apiToken) .multiPart("file", new File(pathToFile), mimeType) - .post("/api/access/datafile/" + tabFile1Id + "/metadata/dpJSON/v1"); + // In the DP use case, the file is restricted. + .post("/api/access/datafile/" + tabFile3IdRestricted + "/metadata/dpJSON/v1"); response.prettyPrint(); assertEquals(200, response.getStatusCode()); System.out.println("Downloading Aux file that was just added"); response = given() .header(API_TOKEN_HTTP_HEADER, apiToken) - .get("/api/access/datafile/" + tabFile1Id + "/metadata/dpJSON/v1"); + .get("/api/access/datafile/" + tabFile3IdRestricted + "/metadata/dpJSON/v1"); String dataStr = response.prettyPrint(); assertEquals(dataStr,"a\n"); From 2e89bde5ece06f402f2ba25a9e22ff1b48cfa180 Mon Sep 17 00:00:00 2001 From: Danny Brooke Date: Thu, 4 Mar 2021 19:44:11 -0500 Subject: [PATCH 02/44] initial docs for DP metadata access --- .../source/user/dataset-management.rst | 21 +++++++++++++++++++ .../source/user/find-use-data.rst | 13 ++++++++++++ 2 files changed, 34 insertions(+) diff --git a/doc/sphinx-guides/source/user/dataset-management.rst b/doc/sphinx-guides/source/user/dataset-management.rst index 1d5f1344c6c..8b9ef3d691c 100755 --- a/doc/sphinx-guides/source/user/dataset-management.rst +++ b/doc/sphinx-guides/source/user/dataset-management.rst @@ -179,6 +179,8 @@ Additional download options available for tabular data (found in the same drop-d - Data File Citation (currently in either RIS, EndNote XML, or BibTeX format); - All of the above, as a zipped bundle. +Differentially Private (DP) Metadata can also be accessed for restricted tabular files if the data depositor has created a DP Metadata Release. See :ref:`dp-release-create` for more information. + Astronomy (FITS) ---------------- @@ -210,6 +212,8 @@ Restricted Files When you restrict a file it cannot be downloaded unless permission has been granted. +Differentially Private (DP) Metadata can be accessed for restricted tabular files if the data depositor has created a DP Metadata Release. See :ref:`dp-release-create` for more information. + See also :ref:`terms-of-access` and :ref:`permissions`. Edit Files @@ -302,6 +306,23 @@ If you restrict any files in your dataset, you will be prompted by a pop-up to e See also :ref:`restricted-files`. +.. _dp-release-create: + +Creating and Depositing Differentially Private Metadata (Experimental) +---------------------------------------------------------------------- + +Through an integration with tools from the OpenDP Project (opendp.io), the Dataverse Software offers an experimental workflow that allows a data depositor to create and deposit Differentially Private (DP) Metadata files, which can then be used for exploratory data analysis. This workflow allows researchers to view the DP metadata for a tabular file, determine whether or not the file contains useful information, and then make an informed decision about whether or not to request access to the original file. + +If this integration has been enabled in your Dataverse installation, you can follow these steps to create a DP Metadata Release and make it available to researchers, while still keeping the files themselves restricted and able to be accessed after a successful access request. + +- Deposit a tabular file and let the ingest process complete +- Restrict the File +- In the kebab next to the file on the dataset page, or from the "Edit Files" dropdown on the file page, click "OpenDP Tool" +- Go through the process to create a DP Metadata Release in the OpenDP tool, and at the end of the process deposit the DP Metadata Release back to the Dataverse installation +- Publish the Dataset + +Once the dataset is published, users will be able to request access using the normal process, but will also have the option to download DP Statistics in order to get more information about the file. + Guestbook --------- diff --git a/doc/sphinx-guides/source/user/find-use-data.rst b/doc/sphinx-guides/source/user/find-use-data.rst index 97b7694b9f2..95939bc65ee 100755 --- a/doc/sphinx-guides/source/user/find-use-data.rst +++ b/doc/sphinx-guides/source/user/find-use-data.rst @@ -153,6 +153,19 @@ Explore Data Some file types and datasets offer data exploration options if external tools have been installed. The tools are described in the :doc:`/admin/external-tools` section of the Admin Guide. +Exploratory Data Analysis Using Differentially Private Metadata (Experimental) +------------------------------------------------------------------------------ + +Through an integration with tools from the OpenDP Project (opendp.io), the Dataverse Software offers an experimental workflow that allows a data depositor to create and deposit Differentially Private (DP) Metadata files, which can then be used for exploratory data analysis. This workflow allows researchers to view the DP metadata for a tabular file in a Dataverse installation, and then determine whether or not access to file contains useful information and make an informed decision about whether or not to request access to the original files themselves. + +If the data depositor has made available DP metadata for one or more files in their dataset, these access options will appear on the access dropdown on both the Dataset Page and the File Page. These access options will be available even if a file is restricted. Three types of DP metadata will be available: + +- .PDF +- .XML +- .JSON + +For more information about how data depositors can enable access using the OpenDP tool, visit the :doc:`/user/dataset-management` section of the User Guide. + .. |image-file-tree-view| image:: ./img/file-tree-view.png :class: img-responsive .. |image-file-search-facets| image:: ./img/file-search-facets.png From d8e4b0a26fb0aab8456141dc2a4c6375ed1544c4 Mon Sep 17 00:00:00 2001 From: Danny Brooke Date: Fri, 5 Mar 2021 14:54:00 -0500 Subject: [PATCH 03/44] update to match text from depositing data --- doc/sphinx-guides/source/user/find-use-data.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/sphinx-guides/source/user/find-use-data.rst b/doc/sphinx-guides/source/user/find-use-data.rst index 95939bc65ee..95485b3c66a 100755 --- a/doc/sphinx-guides/source/user/find-use-data.rst +++ b/doc/sphinx-guides/source/user/find-use-data.rst @@ -156,7 +156,7 @@ Some file types and datasets offer data exploration options if external tools ha Exploratory Data Analysis Using Differentially Private Metadata (Experimental) ------------------------------------------------------------------------------ -Through an integration with tools from the OpenDP Project (opendp.io), the Dataverse Software offers an experimental workflow that allows a data depositor to create and deposit Differentially Private (DP) Metadata files, which can then be used for exploratory data analysis. This workflow allows researchers to view the DP metadata for a tabular file in a Dataverse installation, and then determine whether or not access to file contains useful information and make an informed decision about whether or not to request access to the original files themselves. +Through an integration with tools from the OpenDP Project (opendp.io), the Dataverse Software offers an experimental workflow that allows a data depositor to create and deposit Differentially Private (DP) Metadata files, which can then be used for exploratory data analysis. This workflow allows researchers to view the DP metadata for a tabular file, determine whether or not the file contains useful information, and then make an informed decision about whether or not to request access to the original file. If the data depositor has made available DP metadata for one or more files in their dataset, these access options will appear on the access dropdown on both the Dataset Page and the File Page. These access options will be available even if a file is restricted. Three types of DP metadata will be available: From 53b4201f8e24d2c3d83659fd4c36dae74da39144 Mon Sep 17 00:00:00 2001 From: Michael Heppler Date: Tue, 9 Mar 2021 15:56:08 -0500 Subject: [PATCH 04/44] Moved aux file download link to clean up float issue [ref #7400] --- .../file-download-button-fragment.xhtml | 136 +++++++++--------- 1 file changed, 70 insertions(+), 66 deletions(-) diff --git a/src/main/webapp/file-download-button-fragment.xhtml b/src/main/webapp/file-download-button-fragment.xhtml index 82ca8b608a4..4df213a436b 100644 --- a/src/main/webapp/file-download-button-fragment.xhtml +++ b/src/main/webapp/file-download-button-fragment.xhtml @@ -11,9 +11,55 @@ xmlns:o="http://omnifaces.org/ui" xmlns:iqbs="http://xmlns.jcp.org/jsf/composite/iqbs"> + + + + + + + + + #{fileMetadata.dataFile.fileAccessRequesters.contains(dataverseSession.user) ? bundle['file.accessRequested'] : bundle['file.requestAccess']} + + + +
  • + + #{bundle['file.requestAccess']} + +
  • +
    + + +
  • - +
  • @@ -168,75 +214,33 @@
  • - + + + + + + + +
    - - - - - - - + - - - #{fileMetadata.dataFile.fileAccessRequesters.contains(dataverseSession.user) ? bundle['file.accessRequested'] : bundle['file.requestAccess']} - - - -
  • - - #{bundle['file.requestAccess']} - -
  • -
    - - - - - - From 5c8085d9cacd32205b93f8216968a204e5a75102 Mon Sep 17 00:00:00 2001 From: Michael Heppler Date: Wed, 10 Mar 2021 10:06:35 -0500 Subject: [PATCH 05/44] Moved aux file download link out of canDownload render logic [ref #7400] --- .../file-download-button-fragment.xhtml | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/main/webapp/file-download-button-fragment.xhtml b/src/main/webapp/file-download-button-fragment.xhtml index 4df213a436b..ab8a8613293 100644 --- a/src/main/webapp/file-download-button-fragment.xhtml +++ b/src/main/webapp/file-download-button-fragment.xhtml @@ -216,31 +216,34 @@ - - - - - -
    + + + + + + + + + From 767f2ebca92c3c3b11d7996ad06a1bbabf4ce956 Mon Sep 17 00:00:00 2001 From: Michael Heppler Date: Wed, 10 Mar 2021 10:32:17 -0500 Subject: [PATCH 06/44] Removed aux file download link debug code and typo [ref #7400] --- src/main/webapp/file-download-button-fragment.xhtml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/webapp/file-download-button-fragment.xhtml b/src/main/webapp/file-download-button-fragment.xhtml index ab8a8613293..14073ce35c7 100644 --- a/src/main/webapp/file-download-button-fragment.xhtml +++ b/src/main/webapp/file-download-button-fragment.xhtml @@ -222,12 +222,12 @@ - +