Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion citation/src/main/webapp/js/citation_request.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@

// 'Blob' type is requred to have the 'filename="blob" parameter added
// to the multipart section, and have the Content-type header added
multiPartData.append('doiMeta', new Blob([JSON.stringify(doiDoc.getDoc())], {
multiPartData.append('doiMetaData', new Blob([JSON.stringify(doiDoc.getDoc())], {
type: 'application/json'
}))

Expand Down
8 changes: 8 additions & 0 deletions doi/src/intTest/java/ca/nrc/cadc/doi/AltStatusTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ public void testUpdateStatus() {

Subject.doAs(publisherSubject, (PrivilegedExceptionAction<Object>) () -> {

// reviewer tries to publish when 'in review', should fail
log.debug("publisher - update status to 'minted'");
publishFailure(doiSuffix, DOISettingsType.ALT_DOI);

// reviewer updates status to 'in review'
log.debug("publisher - update status to 'in review'");
updateStatus(doiSuffix, Status.IN_REVIEW, true);
Expand Down Expand Up @@ -226,6 +230,10 @@ public void testUpdateStatus() {
checkPermissions(doiNode, false, false, 2,0);
log.debug("publisher - checked permissions");

// reviewer tries to publish when 'rejected', should fail
log.debug("publisher - update status to 'minted'");
publishFailure(doiSuffix, DOISettingsType.ALT_DOI);

return null;
});

Expand Down
17 changes: 16 additions & 1 deletion doi/src/intTest/java/ca/nrc/cadc/doi/LifecycleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,21 @@ void update(Resource expected, String doiSuffix, URL doiServiceURL) throws Excep
compareResource(expected, actual, true);
}

void publishFailure(String doiSuffix,DOISettingsType doiSettingsType) throws Exception {
URL mintURL = new URL(String.format("%s/%s/%s", getDoiServiceURL(doiSettingsType), doiSuffix, DoiAction.MINT_ACTION));
Map<String, Object> params = new HashMap<>();

boolean failure = false;
try {
HttpPost post = new HttpPost(mintURL, params, false);
post.prepare();
} catch (Exception e) {
// expected
failure = true;
}
Assert.assertTrue("Expected exception for publish from invalid state", failure);
}

void publish(Resource expected, String doiSuffix, DOISettingsType doiSettingsType) throws Exception {
// For DOI tests below
URL doiURL = new URL(String.format("%s/%s", getDoiServiceURL(doiSettingsType), doiSuffix));
Expand Down Expand Up @@ -336,7 +351,7 @@ void publish(Resource expected, String doiSuffix, DOISettingsType doiSettingsTyp
DataNode testFile2Node = createDataNode(testFile2Path, testFile2, doiSettingsType);
}

// mint the document, DRAFT or IN REVIEW ==> LOCKING_DATA
// mint the document, DRAFT, IN REVIEW, APPROVED ==> LOCKING_DATA
doMintTest(doiURL);
doiNode = getContainerNode(doiSuffix , doiParentPathURI, vosClient);
dataNode = getContainerNode(doiSuffix + "/data" , doiParentPathURI, vosClient);
Expand Down
15 changes: 8 additions & 7 deletions doi/src/main/java/ca/nrc/cadc/doi/PostAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -717,16 +717,13 @@ private void performDOIAction() throws Exception {
// process DOI based on current minting status
ContainerNode doiContainerNode = vospaceDoiClient.getContainerNode(doiSuffix);
Status mintingStatus = Status.toValue(doiContainerNode.getPropertyValue(DOI.VOSPACE_DOI_STATUS_PROPERTY));

switch (mintingStatus) {
case DRAFT:
if (isAlternativeConfiguration()) {
throw new IllegalArgumentException("Cannot publish an 'in progress' DOI for an alternative configuration");
if (!isAlternativeConfiguration()) {
lockData(doiContainerNode);
}
lockData(doiContainerNode);
break;
case REVIEW_READY:
case REJECTED:
throw new IllegalArgumentException("Cannot publish a DOI with status '" + mintingStatus + "'");
case IN_REVIEW:
case APPROVED:
case ERROR_LOCKING_DATA:
Expand All @@ -753,7 +750,7 @@ private void performDOIAction() throws Exception {
log.debug("doi " + doiSuffix + " status: " + Status.COMPLETED);
break;
default:
// do nothing
throw new IllegalArgumentException("Cannot publish a DOI with status '" + mintingStatus + "'");
}

// Done, send redirect to GET for the XML file just minted
Expand Down Expand Up @@ -807,6 +804,8 @@ private void lockData(ContainerNode doiContainerNode) throws Exception {
doiContainerNode.getProperties().add(jobURLProp);
vospaceDoiClient.getVOSpaceClient().setNode(containerVOSURI, doiContainerNode);
} catch (Exception ex) {
log.error("error locking data folder for " + doiSuffix, ex);

// update status
doiContainerNode.getProperty(DOI.VOSPACE_DOI_STATUS_PROPERTY).setValue(Status.ERROR_LOCKING_DATA.getValue());
String jobURLString = doiContainerNode.getPropertyValue(DOI.VOSPACE_DOI_JOB_URL_PROPERTY);
Expand Down Expand Up @@ -868,6 +867,8 @@ private void register(ContainerNode doiContainerNode) throws Exception {
vospaceDoiClient.getVOSpaceClient().setNode(doiURI, doiContainerNode);

} catch (Exception ex) {
log.error("error registering DOI " + doiSuffix, ex);

// update status to flag error state, and original properties of
// container node and xml file

Expand Down