From 0801d56fd07db8967f479d04d7ddeef5a2a18c4e Mon Sep 17 00:00:00 2001 From: Leonid Andreev Date: Fri, 17 Nov 2017 15:36:04 -0500 Subject: [PATCH] ldjson should will only be embedded into the page if this is the LATEST PUBLISHED version (#2243) --- .../edu/harvard/iq/dataverse/DatasetPage.java | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java index 64d0012d4b9..45ecf178c52 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java @@ -79,6 +79,7 @@ import java.util.logging.Level; import edu.harvard.iq.dataverse.datasetutility.TwoRavensHelper; import edu.harvard.iq.dataverse.datasetutility.WorldMapPermissionHelper; +import edu.harvard.iq.dataverse.engine.command.impl.GetLatestPublishedDatasetVersionCommand; import edu.harvard.iq.dataverse.engine.command.impl.RequestRsyncScriptCommand; import edu.harvard.iq.dataverse.engine.command.impl.PublishDatasetResult; import edu.harvard.iq.dataverse.engine.command.impl.RestrictFileCommand; @@ -3957,8 +3958,37 @@ public List getDatasetSummaryFields() { return DatasetUtil.getDatasetSummaryFields(workingVersion, customFields); } - + + Boolean thisLatestReleasedVersion = null; + + public boolean isThisLatestReleasedVersion() { + if (thisLatestReleasedVersion != null) { + return thisLatestReleasedVersion; + } + + if (!workingVersion.isPublished()) { + thisLatestReleasedVersion = false; + return false; + } + + DatasetVersion latestPublishedVersion = null; + Command cmd = new GetLatestPublishedDatasetVersionCommand(dvRequestService.getDataverseRequest(), dataset); + try { + latestPublishedVersion = commandEngine.submit(cmd); + } catch (Exception ex) { + // whatever... + } + + thisLatestReleasedVersion = workingVersion.equals(latestPublishedVersion); + + return thisLatestReleasedVersion; + + } + public String getJsonLd() { - return workingVersion.getJsonLd(); + if (isThisLatestReleasedVersion()) { + return workingVersion.getJsonLd(); + } + return ""; } }