Skip to content

Commit

Permalink
avoid OptimisticLockException on publishing dataset #3562 #2290
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Jan 26, 2017
1 parent 7a11e9c commit 5fc191b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ public Dataset execute(CommandContext ctxt) throws CommandException {
if (!theDataset.getOwner().isReleased()) {
throw new IllegalCommandException("This dataset may not be published because its host dataverse (" + theDataset.getOwner().getAlias() + ") has not been published.", this);
}


if (theDataset.isLocked()) {
throw new IllegalCommandException("This dataset is locked due to files being ingested. Please try publishing later.", this);
}

if (theDataset.getLatestVersion().isReleased()) {
throw new IllegalCommandException("Latest version of dataset " + theDataset.getIdentifier() + " is already released. Only draft versions can be released.", this);
}
Expand Down
6 changes: 5 additions & 1 deletion src/test/java/edu/harvard/iq/dataverse/api/FilesIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.junit.Test;
import com.jayway.restassured.path.json.JsonPath;
import edu.harvard.iq.dataverse.util.BundleUtil;
import static java.lang.Thread.sleep;
import java.util.Arrays;
import java.util.Collections;
import java.util.ResourceBundle;
Expand Down Expand Up @@ -423,7 +424,7 @@ public void test_006_ReplaceFileGood() {
}

@Test
public void test_006_ReplaceFileGoodTabular() {
public void test_006_ReplaceFileGoodTabular() throws InterruptedException {
msgt("test_006_ReplaceFileGoodTabular");

// Create user
Expand Down Expand Up @@ -467,6 +468,9 @@ public void test_006_ReplaceFileGoodTabular() {
publishDataversetResp.then().assertThat()
.statusCode(OK.getStatusCode());

// give file time to ingest
sleep(1000);

Response publishDatasetResp = UtilIT.publishDatasetViaNativeApi(datasetId, "major", apiToken);
publishDatasetResp.prettyPrint();
publishDatasetResp.then().assertThat()
Expand Down

0 comments on commit 5fc191b

Please sign in to comment.