#8740 - multiple configuration for a deposit repository

This commit is contained in:
Bernaldo Mihasi 2023-06-21 12:46:37 +03:00
parent 3630727fed
commit 741179a53f
5 changed files with 58 additions and 43 deletions

View File

@ -34,7 +34,7 @@
<dependency>
<groupId>gr.cite.opendmp</groupId>
<artifactId>repositorydepositbase</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
</dependency>

View File

@ -2134,15 +2134,17 @@ public class DataManagementPlanManager {
DMPDepositModel dmpDepositModel = DMPToDepositMapper.fromDMP(dmp, pdfEnvelope, rdaJsonFile, supportingFilesZip, previousDOI);
Optional<RepositoryDeposit> repo = this.repositoriesDeposit.stream().filter(x -> x.getConfiguration().getRepositoryId().equals(depositRequest.getRepositoryId())).findFirst();
String finalDoi = repo.map(r -> {
try {
return r.deposit(dmpDepositModel, depositRequest.getAccessToken());
} catch (Exception e) {
logger.error(e.getMessage(), e);
return null;
String finalDoi = null;
for(RepositoryDeposit repo: this.repositoriesDeposit){
if(repo.getConfiguration().stream().anyMatch(x-> x.getRepositoryId().equals(depositRequest.getRepositoryId()))){
try {
finalDoi = repo.deposit(depositRequest.getRepositoryId(), dmpDepositModel, depositRequest.getAccessToken());
} catch (Exception e) {
logger.error(e.getMessage(), e);
return null;
}
}
}).orElse(null);
}
Doi doiModel = null;
if (finalDoi != null) {

View File

@ -31,18 +31,24 @@ public class DepositManager {
public List<RepositoryConfig> getAvailableRepos() {
List<RepositoryConfig> reposConfigModel = new ArrayList<>();
for (RepositoryDeposit r: this.repositories) {
RepositoryConfig repoModel = new RepositoryConfig();
RepositoryDepositConfiguration repoConf = r.getConfiguration();
List<RepositoryDepositConfiguration> repoConf = r.getConfiguration();
if(repoConf != null) {
reposConfigModel.add(repoModel.toModel(repoConf));
for(RepositoryDepositConfiguration cf: repoConf){
RepositoryConfig repoModel = new RepositoryConfig();
reposConfigModel.add(repoModel.toModel(cf));
}
}
}
return reposConfigModel;
}
public String authenticate(String id, String code) {
Optional<RepositoryDeposit> repo = repositories.stream().filter(x -> x.getConfiguration().getRepositoryId().equals(id)).findFirst();
return repo.map(repositoryDeposit -> repositoryDeposit.authenticate(code)).orElse(null);
for(RepositoryDeposit r: this.repositories){
if(r.getConfiguration().stream().anyMatch(x -> x.getRepositoryId().equals(id))){
return r.authenticate(id, code);
}
}
return null;
}
public Doi deposit(DepositRequest depositRequest, Principal principal) throws Exception {
@ -50,9 +56,12 @@ public class DepositManager {
}
public String getRepositoryLogo(String repositoryId){
Optional<RepositoryDeposit> repo = repositories.stream().filter(x -> x.getConfiguration().getRepositoryId().equals(repositoryId)).findFirst();
return repo.map(repositoryDeposit ->
(repositoryDeposit.getConfiguration().isHasLogo()) ? repositoryDeposit.getLogo() : null
).orElse(null);
for(RepositoryDeposit r: this.repositories){
Optional<RepositoryDepositConfiguration> cf = r.getConfiguration().stream().filter(x -> x.getRepositoryId().equals(repositoryId)).findFirst();
if(cf.isPresent()){
return cf.get().isHasLogo() ? r.getLogo(repositoryId) : null;
}
}
return null;
}
}

View File

@ -1,11 +1,13 @@
{
"depositType": 0,
"repositoryId": "Dataverse",
"apiToken": "",
"repositoryUrl": "https://demo.dataverse.org/api/",
"repositoryRecordUrl": "https://demo.dataverse.org/dataset.xhtml?persistentId=doi:",
"server": "https://demo.dataverse.org",
"parentDataverseAlias": "test1000"
"parentDataverseAlias": "test1000",
"hasLogo": false
}
[
{
"depositType": 0,
"repositoryId": "Dataverse",
"apiToken": "",
"repositoryUrl": "https://demo.dataverse.org/api/",
"repositoryRecordUrl": "https://demo.dataverse.org/dataset.xhtml?persistentId=doi:",
"server": "https://demo.dataverse.org",
"parentDataverseAlias": "test1000",
"hasLogo": true,
"logo": "dataverse.png"
}
]

View File

@ -1,14 +1,16 @@
{
"depositType": 2,
"repositoryId": "Zenodo",
"accessToken": "",
"repositoryUrl": "https://sandbox.zenodo.org/api/",
"repositoryAuthorizationUrl": "https://sandbox.zenodo.org/oauth/authorize",
"repositoryRecordUrl": "https://sandbox.zenodo.org/record/",
"repositoryAccessTokenUrl": "https://sandbox.zenodo.org/oauth/token",
"repositoryClientId": "",
"repositoryClientSecret": "",
"redirectUri": "http://localhost:4200/login/external/zenodo"
"redirectUri": "http://localhost:4200/login/external/zenodo",
"hasLogo": true
}
[
{
"depositType": 2,
"repositoryId": "Zenodo",
"accessToken": "",
"repositoryUrl": "https://sandbox.zenodo.org/api/",
"repositoryAuthorizationUrl": "https://sandbox.zenodo.org/oauth/authorize",
"repositoryRecordUrl": "https://sandbox.zenodo.org/record/",
"repositoryAccessTokenUrl": "https://sandbox.zenodo.org/oauth/token",
"repositoryClientId": "",
"repositoryClientSecret": "",
"redirectUri": "http://localhost:4200/login/external/zenodo",
"hasLogo": true,
"logo": "zenodo.jpg"
}
]