1. return bad request when deposition failed and returned null

2. close modal with repositories after a successful deposition
This commit is contained in:
Bernaldo Mihasi 2022-12-19 16:07:03 +02:00
parent 976d0221ce
commit 749dbefc38
3 changed files with 13 additions and 14 deletions

View File

@ -53,7 +53,12 @@ public class DepositController extends BaseController {
ResponseEntity<ResponseItem<Doi>> createDoi(@RequestBody DepositRequest depositRequest, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) {
try {
Doi doi = this.depositManager.deposit(depositRequest, principal);
if(doi != null){
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Doi>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully created DOI for Data Datamanagement Plan in question.").payload(doi));
}
else{
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Doi>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to create DOI for the Data Management Plan"));
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Doi>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to create DOI for the Data Management Plan: " + e.getMessage()));

View File

@ -41,7 +41,10 @@ public class DepositManager {
List<RepositoryConfig> reposConfigModel = new ArrayList<>();
for (RepositoryDeposit r: this.repositories) {
RepositoryConfig repoModel = new RepositoryConfig();
reposConfigModel.add(repoModel.toModel(r.getConfiguration()));
RepositoryDepositConfiguration repoConf = r.getConfiguration();
if(repoConf != null) {
reposConfigModel.add(repoModel.toModel(repoConf));
}
}
return reposConfigModel;
}

View File

@ -83,10 +83,7 @@ export class DmpDepositDialogComponent extends BaseComponent implements OnInit {
.subscribe(doi =>{
this.onDOICallbackSuccess();
this.outputRepos.push(doi);
this.inputRepos = this.inputRepos.filter(function(x) { return x.repositoryId !== repo.repositoryId; });
if(this.inputRepos.length == 0){
this.close();
}
}, error => this.onDOICallbackError(error));
break;
}
@ -99,10 +96,7 @@ export class DmpDepositDialogComponent extends BaseComponent implements OnInit {
.subscribe(doi =>{
this.onDOICallbackSuccess();
this.outputRepos.push(doi);
this.inputRepos = this.inputRepos.filter(function(x) { return x.repositoryId !== repo.repositoryId; });
if(this.inputRepos.length == 0){
this.close();
}
}, error => this.onDOICallbackError(error));
}
}
@ -129,10 +123,7 @@ export class DmpDepositDialogComponent extends BaseComponent implements OnInit {
.subscribe(doi =>{
this.onDOICallbackSuccess();
this.outputRepos.push(doi);
this.inputRepos = this.inputRepos.filter(function(x) { return x.repositoryId !== repo.repositoryId; });
if(this.inputRepos.length == 0){
this.close();
}
}, error => this.onDOICallbackError(error));
});
this.oauthLock = true;