diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java index efc212e5e..3e421e8fc 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java @@ -9,12 +9,10 @@ import eu.eudat.data.entities.DMP; import eu.eudat.data.entities.Dataset; import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem; import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest; -import eu.eudat.data.query.items.table.dmp.DataManagmentPlanPublicTableRequest; import eu.eudat.exceptions.datamanagementplan.DMPNewVersionException; import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsDeleteException; import eu.eudat.exceptions.security.UnauthorisedException; import eu.eudat.logic.managers.DataManagementPlanManager; -import eu.eudat.logic.managers.DatasetManager; import eu.eudat.logic.proxy.config.configloaders.ConfigLoader; import eu.eudat.logic.security.claims.ClaimedAuthorities; import eu.eudat.logic.services.ApiContext; @@ -152,7 +150,7 @@ public class DMPs extends BaseController { @RequestMapping(method = RequestMethod.GET, value = {"/publicOverview/{id}"}) public @ResponseBody - ResponseEntity getOverviewSinglePublic(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception { + ResponseEntity> getOverviewSinglePublic(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception { // try { DataManagementPlanOverviewModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSingle(id, principal, true); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan)); @@ -321,21 +319,6 @@ public class DMPs extends BaseController { } } - /* - * DOI Generation - * */ - - @RequestMapping(method = RequestMethod.POST, value = {"/createZenodoDoi/{id}"}) - public ResponseEntity> createZenodoDoi(@PathVariable String id, Principal principal) { - try { - String zenodoDOI = this.dataManagementPlanManager.createZenodoDoi(UUID.fromString(id), principal); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully created DOI for Data Datamanagement Plan in question.").payload(zenodoDOI)); - } catch (Exception e) { - logger.error(e.getMessage(), e); - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to create DOI for the Data Management Plan: " + e.getMessage())); - } - } - /* * Data Index * */ diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/Datasets.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/Datasets.java index 94a17913b..8c5b003fa 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/Datasets.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/Datasets.java @@ -117,7 +117,7 @@ public class Datasets extends BaseController { @RequestMapping(method = RequestMethod.GET, value = {"/publicOverview/{id}"}) public @ResponseBody - ResponseEntity getOverviewSinglePublic(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception { + ResponseEntity> getOverviewSinglePublic(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception { // try { DatasetOverviewModel dataset = this.datasetManager.getOverviewSingle(id, principal, true); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(dataset)); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index 25ab0217a..02c05a5a2 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -1064,9 +1064,6 @@ public class DataManagementPlanManager { }); UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId()); sendNotification(dmp, user, NotificationType.DMP_PUBLISH); -// if (dmp.getDois() != null && !dmp.getDois().isEmpty()) { -// this.createZenodoDoi(dmp.getId(), principal, true); -// } } @Transactional @@ -2067,74 +2064,6 @@ public class DataManagementPlanManager { } } - public String createZenodoDoi(UUID id, Principal principal) throws Exception { - return this.createZenodoDoi(id, principal, false); - } - - public String createZenodoDoi(UUID id, Principal principal, boolean update) throws Exception { - DMP dmp = this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(id); - if (!isUserOwnerOfDmp(dmp, principal)) - 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() != null) - throw new Exception("DMP already has a DOI");*/ - - FileEnvelope file = getWordDocument(id.toString(), principal, configLoader); - String name = file.getFilename().substring(0, file.getFilename().length() - 5); - File pdfFile = PDFUtils.convertToPDF(file, environment); - String fileName = name + ".pdf"; - ResponseEntity jsonFile; - try { - jsonFile = getRDAJsonDocument(id.toString(), principal); - } catch (Exception e) { - throw e; - } - String previousDOI = this.getPreviousDOI(dmp.getGroupId(), dmp.getId(), "Zenodo"); - - File supportingFilesZip = this.createSupportingFilesZip(dmp); - - DMPDepositModel dmpDepositModel = DMPToDepositMapper.fromDMP(dmp, pdfFile, fileName, jsonFile, supportingFilesZip, previousDOI); - - String zenodoToken = ""; - try { - if (this.userManager.isDOITokenValid(principal)) { - zenodoToken = principal.getZenodoToken(); - } - } catch (NonValidTokenException e) { - zenodoToken = this.environment.getProperty("zenodo.access_token"); - } - - String finalDoi = null; - for(RepositoryDeposit repo: this.repositoriesDeposit) { //temp - if(repo.getConfiguration().getRepositoryId().equals("Zenodo")) { - finalDoi = repo.deposit(dmpDepositModel, zenodoToken); - if (finalDoi != null) { - EntityDoi doiEntity = new EntityDoi(); - doiEntity.setId(UUID.randomUUID()); - doiEntity.setEntityType(EntityDoi.EntityType.DMP); - doiEntity.setDoi(finalDoi); - doiEntity.setRepositoryId("Zenodo"); - Date now = new Date(); - doiEntity.setCreatedAt(now); - doiEntity.setUpdatedAt(now); - doiEntity.setEntityId(dmp); - apiContext.getOperationsContext().getDatabaseRepository().getEntityDoiDao().createOrUpdate(doiEntity); - - dmp.getDois().add(doiEntity); - apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp); - } - } - } - if(supportingFilesZip != null) { - Files.deleteIfExists(supportingFilesZip.toPath()); - } - Files.deleteIfExists(pdfFile.toPath()); - Files.deleteIfExists(file.getFile().toPath()); - - return finalDoi; - } - public Doi createDoi(DepositRequest depositRequest, Principal principal) throws Exception { DMP dmp = this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(UUID.fromString(depositRequest.getDmpId())); if (!isUserOwnerOfDmp(dmp, principal)) diff --git a/dmp-frontend/src/app/core/services/dmp/dmp.service.ts b/dmp-frontend/src/app/core/services/dmp/dmp.service.ts index ce1bc9d0d..c85650c00 100644 --- a/dmp-frontend/src/app/core/services/dmp/dmp.service.ts +++ b/dmp-frontend/src/app/core/services/dmp/dmp.service.ts @@ -114,10 +114,6 @@ export class DmpService { return this.http.post(`${this.actionUrl}updateusers/${id}`, users, { headers: this.headers }); } - getDoi(id: string): Observable { - return this.http.post(this.actionUrl + 'createZenodoDoi/' + id, { headers: this.headers }); - } - getDynamicField(requestItem: RequestItem): any { return this.http.post(this.actionUrl + 'dynamic', requestItem, { headers: this.headers }); } diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts index 6e83b0dcf..ea14b095e 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts @@ -838,90 +838,4 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { // return url; // } - // getDoi(dmp: DmpOverviewModel) { - // this.userService.hasDOIToken().subscribe(response => { - // this.hasDOIToken = true; - // this.showConfirmationDOIDialog(dmp); - // }, error => { - // this.hasDOIToken = false; - // this.showErrorConfirmationDOIDialog(error.error.message, dmp); - // }); - // } - - // showConfirmationDOIDialog(dmp: DmpOverviewModel) { - // const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - // maxWidth: '600px', - // restoreFocus: false, - // data: { - // message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ZENODO-DOI', { 'username': this.hasDOIToken ? this.authentication.current().zenodoEmail : 'default' }), - // confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'), - // cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - // } - // }); - // dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - // if (result) { - // this.dmpService.getDoi(dmp.id) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // complete => { - // this.onDOICallbackSuccess(); - // this.dmp.doi = complete; - // }, - // error => this.onDeleteCallbackError(error) - // ); - // } - // }); - // } - - // showErrorConfirmationDOIDialog(message: string, dmp: DmpOverviewModel) { - // const dialogRef = this.dialog.open(MultipleChoiceDialogComponent, { - // maxWidth: '600px', - // restoreFocus: false, - // data: { - // message: message ? this.language.instant(message) : this.language.instant('GENERAL.ERRORS.HTTP-REQUEST-ERROR'), - // titles: [this.language.instant('DMP-OVERVIEW.MULTIPLE-DIALOG.ZENODO-LOGIN'), this.language.instant('DMP-OVERVIEW.MULTIPLE-DIALOG.USE-DEFAULT')] - // } - // }); - // dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - // switch (result) { - // case 0: - // // this.authentication.logout(); - // // this.router.navigate(['/login/external/zenodo']); - // this.showOauth2Dialog(this.getAccessUrl(), dmp); - // break; - // case 1: - // this.showConfirmationDOIDialog(dmp); - // break; - // } - // }); - // } - - // showOauth2Dialog(url: string, dmp: DmpOverviewModel) { - // this.oauth2DialogService.login(url) - // .pipe(takeUntil(this._destroyed)) - // .subscribe(result => { - // if (result !== undefined) { - // if (result.oauthCode !== undefined && result.oauthCode !== null && !this.oauthLock) { - // this.userService.registerDOIToken(result.oauthCode, this.configurationService.app + 'oauth2') - // .pipe(takeUntil(this._destroyed)) - // .subscribe(() => { - // this.hasDOIToken = true; - // this.showConfirmationDOIDialog(dmp); - // }); - // this.oauthLock = true; - // } - // } else { - // this.oauthLock = false; - // } - // }); - // } - - // onDOICallbackSuccess(): void { - // this.uiNotificationService.snackBarNotification(this.language.instant('DMP-EDITOR.SNACK-BAR.SUCCESSFUL-DOI'), SnackBarNotificationLevel.Success); - // } - - // onDOICallbackError(error) { - // this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('DMP-EDITOR.SNACK-BAR.UNSUCCESSFUL-DOI'), SnackBarNotificationLevel.Error); - // } - }