Skip to content

Commit

Permalink
rearranged the order of operations inside FinalizeDatasetPublicationC…
Browse files Browse the repository at this point in the history
…ommand. #6558
  • Loading branch information
landreev committed Apr 13, 2020
1 parent 840f389 commit 093ed6d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ public FinalizeDatasetPublicationCommand(Dataset aDataset, DataverseRequest aReq
public Dataset execute(CommandContext ctxt) throws CommandException {
Dataset theDataset = getDataset();

// validate the physical files before we do anything else:
// (unless specifically disabled)
if (theDataset.getLatestVersion().getVersionState() != RELEASED
&& ctxt.systemConfig().isDatafileValidationOnPublishEnabled()) {
// some imported datasets may already be released.

// validate the physical files (verify checksums):
validateDataFiles(theDataset, ctxt);
// (this will throw a CommandException if it fails)
}

if ( theDataset.getGlobalIdCreateTime() == null ) {
registerExternalIdentifier(theDataset, ctxt);
}
Expand Down Expand Up @@ -134,19 +145,15 @@ public Dataset execute(CommandContext ctxt) throws CommandException {
ctxt.engine().submit(new DeletePrivateUrlCommand(getRequest(), theDataset));
}

if ( theDataset.getLatestVersion().getVersionState() != RELEASED ) {
// some imported datasets may already be released.

// validate the physical files (verify checksums):
validateDataFiles(theDataset, ctxt);
// (this will throw a CommandException if it fails)

if (!datasetExternallyReleased){
publicizeExternalIdentifier(theDataset, ctxt);
// (will also throw a CommandException, unless successful)
}
theDataset.getLatestVersion().setVersionState(RELEASED);
}
if (theDataset.getLatestVersion().getVersionState() != RELEASED) {
// some imported datasets may already be released.

if (!datasetExternallyReleased) {
publicizeExternalIdentifier(theDataset, ctxt);
// (will throw a CommandException, unless successful)
}
theDataset.getLatestVersion().setVersionState(RELEASED);
}


// Remove locks
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/util/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -1688,10 +1688,11 @@ public static void validateDataFileChecksum(DataFile dataFile) throws IOExceptio
}

StorageIO<DataFile> storage = dataFile.getStorageIO();
storage.open(DataAccessOption.READ_ACCESS);
InputStream in = null;

try {
storage.open(DataAccessOption.READ_ACCESS);

if (!dataFile.isTabularData()) {
in = storage.getInputStream();
} else {
Expand Down

0 comments on commit 093ed6d

Please sign in to comment.