From 481c3b4bb03209bca88de6a6b70673e86145f791 Mon Sep 17 00:00:00 2001 From: Leonid Andreev Date: Wed, 3 Feb 2021 19:23:03 -0500 Subject: [PATCH] implements changes to the API path as discussed (#7084) --- .../java/edu/harvard/iq/dataverse/api/Datasets.java | 8 ++++---- .../java/edu/harvard/iq/dataverse/util/FileUtil.java | 12 ++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/api/Datasets.java b/src/main/java/edu/harvard/iq/dataverse/api/Datasets.java index e0ed28a9f3b..52790256bea 100644 --- a/src/main/java/edu/harvard/iq/dataverse/api/Datasets.java +++ b/src/main/java/edu/harvard/iq/dataverse/api/Datasets.java @@ -468,12 +468,12 @@ public Response getVersionFiles( @PathParam("id") String datasetId, @PathParam(" } @GET - @Path("{id}/versions/{versionId}/fileaccess") + @Path("{id}/dirindex") @Produces("text/html") - //public Response getFileAccessFolderView(@PathParam("id") String datasetId, @PathParam("versionId") String versionId, @PathParam("name") String name, @QueryParam("folder") String folderName, @Context UriInfo uriInfo, @Context HttpHeaders headers, @Context HttpServletResponse response) { - public Response getFileAccessFolderView(@PathParam("id") String datasetId, @PathParam("versionId") String versionId, @QueryParam("folder") String folderName, @QueryParam("original") Boolean originals, @Context UriInfo uriInfo, @Context HttpHeaders headers, @Context HttpServletResponse response) { + public Response getFileAccessFolderView(@PathParam("id") String datasetId, @QueryParam("version") String versionId, @QueryParam("folder") String folderName, @QueryParam("original") Boolean originals, @Context UriInfo uriInfo, @Context HttpHeaders headers, @Context HttpServletResponse response) { - folderName = folderName == null ? "" : folderName; + folderName = folderName == null ? "" : folderName; + versionId = versionId == null ? ":latest-published" : versionId; DatasetVersion version; try { diff --git a/src/main/java/edu/harvard/iq/dataverse/util/FileUtil.java b/src/main/java/edu/harvard/iq/dataverse/util/FileUtil.java index 58a1e7e4c14..04d539ffb98 100644 --- a/src/main/java/edu/harvard/iq/dataverse/util/FileUtil.java +++ b/src/main/java/edu/harvard/iq/dataverse/util/FileUtil.java @@ -1935,12 +1935,16 @@ public static String formatFolderListingHtml(String folderName, DatasetVersion v StringBuilder sb = new StringBuilder(); - sb.append(HtmlFormatUtil.formatTag("Index of folder /" + folderName + " in dataset " + persistentId, HTML_H1)); + String versionTag = version.getFriendlyVersionNumber(); + versionTag = "DRAFT".equals(versionTag) ? "Draft Version" : "v. " + versionTag; + sb.append(HtmlFormatUtil.formatTag("Index of folder /" + folderName + + " in dataset " + persistentId + + " (" + versionTag + ")", HTML_H1)); sb.append("\n"); sb.append(formatFolderListingTableHtml(folderName, fileMetadatas, apiLocation, originals)); String body = sb.toString(); - + return formatDoc(title, body); } @@ -2034,8 +2038,8 @@ private static String getFolderAccessUrl(DatasetVersion version, String currentF } return apiLocation + "/api/datasets/" + datasetId + - "/versions/" + versionTag + - "/fileaccess?folder=" + subFolder + + "/dirindex/?version=" + versionTag + "&" + + "folder=" + subFolder + (originals ? "&original=true" : ""); }