Fixes bug on Zenodo DOI's property "creator name".

This commit is contained in:
gkolokythas 2019-08-21 17:31:33 +03:00
parent f38a8fd36b
commit 05c4039dbe
2 changed files with 4 additions and 2 deletions

View File

@ -258,12 +258,14 @@ public class DMPs extends BaseController {
}
}
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/createZenodoDoi/{id}"})
public ResponseEntity<ResponseItem<String>> createZenodoDoi(@PathVariable String id, Principal principal) {
try {
String zenodoDOI = this.dataManagementPlanManager.createZenodoDoi(UUID.fromString(id), principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully created DOI for Data Datamanagement Plan in question.").payload(zenodoDOI));
} catch (Exception e) {
e.printStackTrace();
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<String>().status(ApiMessageCode.ERROR_MESSAGE).message(e.getMessage()));
}
}

View File

@ -1000,7 +1000,7 @@ public class DataManagementPlanManager {
throw new Exception("User is not authorized to invoke this action");
if (!dmp.getStatus().equals(DMP.DMPStatus.FINALISED.getValue()))
throw new Exception("DMP is not finalized");
if (!dmp.getDoi().trim().isEmpty())
if (dmp.getDoi() != null)
throw new Exception("DMP already has a DOI");
// First step, post call to Zenodo, to create the entry.
@ -1015,7 +1015,7 @@ public class DataManagementPlanManager {
" \"publication_type\": \"datamanagementplan\",\n" +
" \"description\": \"" + dmp.getDescription() + "\",\n" +
" \"creators\": [{\n" +
" \t\t\"name\": \"Kolokythas, Georgios\",\n" +
" \t\t\"name\": \"" + dmp.getUsers().stream().filter(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser().getName() + "\",\n" +
" \t\t\"affiliation\": \"OpenDMP\"}]\n" +
" }\n" +
"}";