From 7a0e1c89f2954af087a66cf5f5e5a9ebfda52e3b Mon Sep 17 00:00:00 2001 From: Aldo Mihasi Date: Thu, 24 Nov 2022 16:29:11 +0200 Subject: [PATCH] when finalizing a dmp and its access rights are open, make it publicly available in Argos --- .../config/DataverseConfig.java | 18 ++++ .../interfaces/DataverseDeposit.java | 18 ++-- .../src/main/resources/dataverse.json | 6 +- .../managers/DataManagementPlanManager.java | 4 + .../app/ui/dmp/editor/dmp-editor.component.ts | 3 +- .../dmp-finalize-dialog.component.html | 7 +- .../dmp-finalize-dialog.component.ts | 1 + .../dmp/overview/dmp-overview.component.html | 4 +- .../ui/dmp/overview/dmp-overview.component.ts | 93 ++++++++++++------- .../quick-wizard-editor.component.ts | 3 +- dmp-frontend/src/assets/i18n/en.json | 3 +- 11 files changed, 106 insertions(+), 54 deletions(-) diff --git a/dmp-backend/dataverseRepository/src/main/java/eu/eudat/depositinterface/dataverserepository/config/DataverseConfig.java b/dmp-backend/dataverseRepository/src/main/java/eu/eudat/depositinterface/dataverserepository/config/DataverseConfig.java index 90b21c58d..b664dd9c9 100644 --- a/dmp-backend/dataverseRepository/src/main/java/eu/eudat/depositinterface/dataverserepository/config/DataverseConfig.java +++ b/dmp-backend/dataverseRepository/src/main/java/eu/eudat/depositinterface/dataverserepository/config/DataverseConfig.java @@ -41,6 +41,10 @@ public class DataverseConfig { private String repositoryUrl; @JsonProperty("repositoryRecordUrl") private String repositoryRecordUrl; + @JsonProperty("server") + private String server; + @JsonProperty("parentDataverseAlias") + private String parentDataverseAlias; public int getDepositType() { return depositType; @@ -77,6 +81,20 @@ public class DataverseConfig { this.repositoryRecordUrl = repositoryRecordUrl; } + public String getServer() { + return server; + } + public void setServer(String server) { + this.server = server; + } + + public String getParentDataverseAlias() { + return parentDataverseAlias; + } + public void setParentDataverseAlias(String parentDataverseAlias) { + this.parentDataverseAlias = parentDataverseAlias; + } + public RepositoryDepositConfiguration toRepoConfig() { RepositoryDepositConfiguration config = new RepositoryDepositConfiguration(); config.setDepositType(this.depositType); diff --git a/dmp-backend/dataverseRepository/src/main/java/eu/eudat/depositinterface/dataverserepository/interfaces/DataverseDeposit.java b/dmp-backend/dataverseRepository/src/main/java/eu/eudat/depositinterface/dataverserepository/interfaces/DataverseDeposit.java index 0b8022b52..377847e58 100644 --- a/dmp-backend/dataverseRepository/src/main/java/eu/eudat/depositinterface/dataverserepository/interfaces/DataverseDeposit.java +++ b/dmp-backend/dataverseRepository/src/main/java/eu/eudat/depositinterface/dataverserepository/interfaces/DataverseDeposit.java @@ -41,11 +41,6 @@ public class DataverseDeposit implements RepositoryDeposit { private static final Logger logger = LoggerFactory.getLogger(DataverseDeposit.class); private static final ObjectMapper objectMapper = new ObjectMapper(); - private static final String API_TOKEN = ""; - private static final String SYSTEM_PARENT_DATAVERSE_ALIAS = ""; - private static final String SERVER = ""; - private static final String SYSTEM_EMAIL = ""; - private DataverseAPI api; private boolean isApiSet; @@ -62,7 +57,8 @@ public class DataverseDeposit implements RepositoryDeposit { private void setDataverseApi() throws MalformedURLException { if(!this.isApiSet) { this.api = new DataverseAPIImpl(); - DataverseConfig config = new DataverseConfig(new URL(SERVER), API_TOKEN, SYSTEM_PARENT_DATAVERSE_ALIAS); + eu.eudat.depositinterface.dataverserepository.config.DataverseConfig jsonConfig = this.configLoader.getDataverseConfig(); + DataverseConfig config = new DataverseConfig(new URL(jsonConfig.getServer()), jsonConfig.getApiToken(), jsonConfig.getParentDataverseAlias()); api.configure(config); this.isApiSet = true; } @@ -86,7 +82,7 @@ public class DataverseDeposit implements RepositoryDeposit { .build(); if(dmpDepositModel.getPreviousDOI() == null || dmpDepositModel.getPreviousDOI().isEmpty()){ - Identifier id = this.api.getDataverseOperations().createDataset(dataset, SYSTEM_PARENT_DATAVERSE_ALIAS); + Identifier id = this.api.getDataverseOperations().createDataset(dataset, this.configLoader.getDataverseConfig().getParentDataverseAlias()); doi = this.api.getDatasetOperations().getDataset(id).getDoiId().orElse(null); @@ -131,8 +127,8 @@ public class DataverseDeposit implements RepositoryDeposit { private Map getDatasetIdentifier(String previousDOI) { HttpHeaders headers = new HttpHeaders(); - headers.set("X-Dataverse-key", API_TOKEN); - String serverUrl = SERVER + "/api/datasets/:persistentId?persistentId=doi:" + previousDOI; + headers.set("X-Dataverse-key", this.configLoader.getDataverseConfig().getApiToken()); + String serverUrl = this.configLoader.getDataverseConfig().getServer() + "/api/datasets/:persistentId?persistentId=doi:" + previousDOI; RestTemplate restTemplate = new RestTemplate(); return (Map) restTemplate.exchange(serverUrl, HttpMethod.GET, new HttpEntity<>(headers), Map.class).getBody().get("data"); } @@ -140,7 +136,7 @@ public class DataverseDeposit implements RepositoryDeposit { private void uploadFile(String filename, File file, String doi) throws IOException { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.MULTIPART_FORM_DATA); - headers.set("X-Dataverse-key", API_TOKEN); + headers.set("X-Dataverse-key", this.configLoader.getDataverseConfig().getApiToken()); MultiValueMap fileMap = new LinkedMultiValueMap<>(); ContentDisposition contentDisposition = ContentDisposition .builder("form-data") @@ -155,7 +151,7 @@ public class DataverseDeposit implements RepositoryDeposit { HttpEntity> requestEntity = new HttpEntity<>(body, headers); - String serverUrl = SERVER + "/api/datasets/:persistentId/add?persistentId=doi:" + doi; + String serverUrl = this.configLoader.getDataverseConfig().getServer() + "/api/datasets/:persistentId/add?persistentId=doi:" + doi; RestTemplate restTemplate = new RestTemplate(); ResponseEntity resp = restTemplate.postForEntity(serverUrl, requestEntity, Object.class); diff --git a/dmp-backend/dataverseRepository/src/main/resources/dataverse.json b/dmp-backend/dataverseRepository/src/main/resources/dataverse.json index 6ef4f472f..9bdb6e91d 100644 --- a/dmp-backend/dataverseRepository/src/main/resources/dataverse.json +++ b/dmp-backend/dataverseRepository/src/main/resources/dataverse.json @@ -2,6 +2,8 @@ "depositType": 0, "repositoryId": "Dataverse", "apiToken": "", - "repositoryUrl": "", - "repositoryRecordUrl": "" + "repositoryUrl": "https://demo.dataverse.org/api/", + "repositoryRecordUrl": "https://demo.dataverse.org/dataset.xhtml?persistentId=doi:", + "server": "https://demo.dataverse.org", + "parentDataverseAlias": "" } \ No newline at end of file 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 aba36f4c0..1d13b72a9 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 @@ -1156,6 +1156,10 @@ public class DataManagementPlanManager { throw new Exception("User does not have the privilege to do this action."); if (dmp.getStatus().equals(DMP.DMPStatus.ACTIVE.getValue())) throw new Exception("DMP is already Active"); + if (dmp.isPublic()) + throw new Exception("DMP is publicly available"); + if (!dmp.getDois().isEmpty()) + throw new Exception("DMP is deposited"); dmp.setStatus(DMP.DMPStatus.ACTIVE.getValue()); apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp); UUID dmpId = dmp.getId(); diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts index 007dfa991..4c6a8bc76 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts @@ -980,7 +980,8 @@ export class DmpEditorComponent extends CheckDeactivateBaseComponent implements dmpDescription: this.formGroup.get('description').value, datasets: this.formGroup.get('datasets').value.map(x => { return { label: x.label, id: x.id, status: x.status }; - }) + }), + accessRights: false } const dialogRef = this.dialog.open(DmpFinalizeDialogComponent, { diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-finalize-dialog/dmp-finalize-dialog.component.html b/dmp-frontend/src/app/ui/dmp/editor/dmp-finalize-dialog/dmp-finalize-dialog.component.html index 634ea89e8..a19f9cc0d 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-finalize-dialog/dmp-finalize-dialog.component.html +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-finalize-dialog/dmp-finalize-dialog.component.html @@ -64,8 +64,11 @@
{{ 'DMP-FINALISE-DIALOG.IMPACT' | translate }}
-
- {{ 'DMP-FINALISE-DIALOG.AFTER-FINALIZATION' | translate }} +
+ {{ 'DMP-FINALISE-DIALOG.AFTER-FINALIZATION-PUBLISH' | translate }} +
+
+ {{ 'DMP-FINALISE-DIALOG.AFTER-FINALIZATION-RESTRICT-ACCESS' | translate }}
diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-finalize-dialog/dmp-finalize-dialog.component.ts b/dmp-frontend/src/app/ui/dmp/editor/dmp-finalize-dialog/dmp-finalize-dialog.component.ts index f16ff8747..dd8b27e34 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-finalize-dialog/dmp-finalize-dialog.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-finalize-dialog/dmp-finalize-dialog.component.ts @@ -95,6 +95,7 @@ export interface DmpFinalizeDialogInput { dmpLabel: string; dmpDescription: string; datasets: DmpFinalizeDialogDataset[]; + accessRights: boolean; } export interface DmpFinalizeDialogDataset { diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html index bec9d1720..ef03de5fe 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html @@ -187,12 +187,12 @@

{{ 'DMP-LISTING.ACTIONS.START-NEW-VERSION' | translate }}

-
+