don't deposit empty supportingFiles.zip when no files are uploaded in datasets
This commit is contained in:
parent
e1a3e9b7bc
commit
572be373e5
|
@ -150,7 +150,9 @@ public class DataverseDeposit implements RepositoryDeposit {
|
||||||
this.uploadFile(jsonFileName, rdaJson, doi);
|
this.uploadFile(jsonFileName, rdaJson, doi);
|
||||||
Files.deleteIfExists(rdaJson.toPath());
|
Files.deleteIfExists(rdaJson.toPath());
|
||||||
|
|
||||||
this.uploadFile(dmpDepositModel.getSupportingFilesZip().getName(), dmpDepositModel.getSupportingFilesZip(), doi);
|
if(dmpDepositModel.getSupportingFilesZip() != null) {
|
||||||
|
this.uploadFile(dmpDepositModel.getSupportingFilesZip().getName(), dmpDepositModel.getSupportingFilesZip(), doi);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Object> getDatasetIdentifier(String previousDOI) {
|
private Map<String, Object> getDatasetIdentifier(String previousDOI) {
|
||||||
|
|
|
@ -2196,7 +2196,7 @@ public class DataManagementPlanManager {
|
||||||
FileOutputStream fout = new FileOutputStream(this.environment.getProperty("temp.temp") + "supportingFiles.zip");
|
FileOutputStream fout = new FileOutputStream(this.environment.getProperty("temp.temp") + "supportingFiles.zip");
|
||||||
ZipOutputStream zout = new ZipOutputStream(fout);
|
ZipOutputStream zout = new ZipOutputStream(fout);
|
||||||
|
|
||||||
//List<File> supportingFiles = new ArrayList<>();
|
boolean hasFileUploaded = false;
|
||||||
Set<Dataset> datasets = dmp.getDataset();
|
Set<Dataset> datasets = dmp.getDataset();
|
||||||
for (Dataset dataset : datasets) {
|
for (Dataset dataset : datasets) {
|
||||||
List<FileUpload> files = this.apiContext.getOperationsContext().getDatabaseRepository().getFileUploadDao().getFileUploads(dataset.getId());
|
List<FileUpload> files = this.apiContext.getOperationsContext().getDatabaseRepository().getFileUploadDao().getFileUploads(dataset.getId());
|
||||||
|
@ -2209,12 +2209,12 @@ public class DataManagementPlanManager {
|
||||||
zout.putNextEntry(ze);
|
zout.putNextEntry(ze);
|
||||||
zout.write(content, 0, content.length);
|
zout.write(content, 0, content.length);
|
||||||
zout.closeEntry();
|
zout.closeEntry();
|
||||||
|
hasFileUploaded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
zout.close();
|
zout.close();
|
||||||
return new File(this.environment.getProperty("temp.temp") + "supportingFiles.zip");
|
return hasFileUploaded ? new File(this.environment.getProperty("temp.temp") + "supportingFiles.zip") : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue