Skip to content

Commit 12726e4

Browse files
committed
merge fixes
1 parent 057916a commit 12726e4

File tree

3 files changed

+34
-9
lines changed

3 files changed

+34
-9
lines changed

modules/dataverse-parent/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133

134134
<properties>
135135
<!-- This is a special Maven property name, do not change! -->
136-
<revision>6.6</revision>
136+
<revision>6.7</revision>
137137

138138
<target.java.version>17</target.java.version>
139139
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>edu.harvard.iq</groupId>
88
<artifactId>dataverse-parent</artifactId>
9-
<version>6.6-qdr-dev</version>
9+
<version>6.7-qdr-dev</version>
1010
<relativePath>modules/dataverse-parent</relativePath>
1111
</parent>
1212

src/main/java/edu/harvard/iq/dataverse/EditDatafilesPage.java

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,10 @@ public enum Referrer {
204204
private Long maxIngestSizeInBytes = null;
205205
// CSV: 4.8 MB, DTA: 976.6 KB, XLSX: 5.7 MB, etc.
206206
private String humanPerFormatTabularLimits = null;
207-
private Integer multipleUploadFilesLimit = null;
207+
private Integer multipleUploadFilesLimit = null;
208+
// Maximum number of files per dataset allowed ot be uploaded
209+
private Integer maxFileUploadCount = null;
210+
private Integer fileUploadsAvailable = null;
208211

209212
//MutableBoolean so it can be passed from DatasetPage, supporting DatasetPage.cancelCreate()
210213
private MutableBoolean uploadInProgress = null;
@@ -396,6 +399,10 @@ public String populateHumanPerFormatTabularLimits() {
396399
return String.join(", ", formatLimits);
397400
}
398401

402+
public Integer getFileUploadsAvailable() {
403+
return fileUploadsAvailable != null ? fileUploadsAvailable : -1;
404+
}
405+
399406
/*
400407
The number of files the GUI user is allowed to upload in one batch,
401408
via drag-and-drop, or through the file select dialog. Now configurable
@@ -559,17 +566,28 @@ public String initCreateMode(String modeToken, DatasetVersion version, MutableBo
559566
this.maxIngestSizeInBytes = systemConfig.getTabularIngestSizeLimit();
560567
this.humanPerFormatTabularLimits = populateHumanPerFormatTabularLimits();
561568
this.multipleUploadFilesLimit = systemConfig.getMultipleUploadFilesLimit();
562-
569+
setFileUploadCountLimits(0);
563570
logger.fine("done");
564571

565572
saveEnabled = true;
566573

567574
return null;
568575
}
576+
private void setFileUploadCountLimits(int preLoaded) {
577+
this.maxFileUploadCount = this.maxFileUploadCount == null ? dataset.getEffectiveDatasetFileCountLimit() : this.maxFileUploadCount;
578+
Long id = dataset.getId() != null ? dataset.getId() : dataset.getOwner() != null ? dataset.getOwner().getId() : null;
579+
this.fileUploadsAvailable = this.maxFileUploadCount != null && id != null ?
580+
Math.max(0, this.maxFileUploadCount - datasetService.getDataFileCountByOwner(id) - preLoaded) :
581+
-1;
582+
}
569583

570584
public boolean isQuotaExceeded() {
571585
return systemConfig.isStorageQuotasEnforced() && uploadSessionQuota != null && uploadSessionQuota.getRemainingQuotaInBytes() == 0;
572586
}
587+
public boolean isFileUploadCountExceeded() {
588+
boolean ignoreLimit = this.session.getUser().isSuperuser();
589+
return !ignoreLimit && !isFileReplaceOperation() && fileUploadsAvailable != null && fileUploadsAvailable == 0;
590+
}
573591

574592
public String init() {
575593
// default mode should be EDIT
@@ -620,9 +638,8 @@ public String init() {
620638
}
621639
this.maxIngestSizeInBytes = systemConfig.getTabularIngestSizeLimit();
622640
this.humanPerFormatTabularLimits = populateHumanPerFormatTabularLimits();
623-
this.multipleUploadFilesLimit = systemConfig.getMultipleUploadFilesLimit();
624-
this.maxFileUploadSizeInBytes = systemConfig.getMaxFileUploadSizeForStore(dataset.getEffectiveStorageDriverId());
625-
641+
this.multipleUploadFilesLimit = systemConfig.getMultipleUploadFilesLimit();
642+
setFileUploadCountLimits(0);
626643
hasValidTermsOfAccess = isHasValidTermsOfAccess();
627644
if (!hasValidTermsOfAccess) {
628645
PrimeFaces.current().executeScript("PF('blockDatasetForm').show()");
@@ -1119,9 +1136,17 @@ public String save() {
11191136
}
11201137
}
11211138
}
1122-
1139+
boolean ignoreUploadFileLimits = this.session.getUser() != null ? this.session.getUser().isSuperuser() : false;
11231140
// Try to save the NEW files permanently:
1124-
List<DataFile> filesAdded = ingestService.saveAndAddFilesToDataset(workingVersion, newFiles, null, true);
1141+
List<DataFile> filesAdded = ingestService.saveAndAddFilesToDataset(workingVersion, newFiles, null, true, ignoreUploadFileLimits);
1142+
if (filesAdded.size() < nNewFiles) {
1143+
// Not all files were saved
1144+
Integer limit = dataset.getEffectiveDatasetFileCountLimit();
1145+
if (limit != null) {
1146+
String msg = BundleUtil.getStringFromBundle("file.add.count_exceeds_limit", List.of(limit.toString()));
1147+
JsfHelper.addInfoMessage(msg);
1148+
}
1149+
}
11251150

11261151
// reset the working list of fileMetadatas, as to only include the ones
11271152
// that have been added to the version successfully:

0 commit comments

Comments
 (0)