Skip to content

Commit

Permalink
#4813 clean up some message code
Browse files Browse the repository at this point in the history
  • Loading branch information
sekmiller committed Jul 17, 2020
1 parent d0f5adc commit 36a0d76
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
18 changes: 10 additions & 8 deletions src/main/java/edu/harvard/iq/dataverse/EditDatafilesPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -2241,11 +2241,12 @@ private String processUploadedFileList(List<DataFile> dFileList) {
if (isFileAlreadyInDataset(dataFile)) {
DataFile existingFile = fileAlreadyExists.get(dataFile);

// String alreadyExists = dataFile.getFileMetadata().getLabel() + " at " + existingFile.getDirectoryLabel() != null ? existingFile.getDirectoryLabel() + "/" + existingFile.getDisplayName() : existingFile.getDisplayName();
String uploadedDuplicateFileName = dataFile.getFileMetadata().getLabel();
String existingFileName = existingFile.getDisplayName();
String inLineMessage = getBundleString("dataset.file.inline.message.prefix") + " " + existingFile.getDisplayName();

// String alreadyExists = dataFile.getFileMetadata().getLabel() + " at " + existingFile.getDirectoryLabel() != null ? existingFile.getDirectoryLabel() + "/" + existingFile.getDisplayName() : existingFile.getDisplayName();
String uploadedDuplicateFileName = dataFile.getFileMetadata().getLabel();
String existingFileName = existingFile.getDisplayName();
List<String> args = Arrays.asList(existingFileName);
String inLineMessage = BundleUtil.getStringFromBundle("dataset.file.inline.message", args);

if (existingFilesWithDupeContent == null) {
existingFilesWithDupeContent = existingFileName;
uploadedFilesWithDupeContentToExisting = uploadedDuplicateFileName;
Expand Down Expand Up @@ -2278,7 +2279,8 @@ private String processUploadedFileList(List<DataFile> dFileList) {
// deleteTempFile(dataFile);
dataFile.setMarkedAsDuplicate(true);
dataFile.getFileMetadata().setMarkedAsDuplicate(true);
String inLineMessage = getBundleString("dataset.file.inline.message.prefix") + " " + existingFile.getDisplayName();
List<String> args = Arrays.asList(existingFile.getDisplayName());
String inLineMessage = BundleUtil.getStringFromBundle("dataset.file.inline.message", args);
dataFile.setDuplicateFilename(inLineMessage);
} else {
// OK, this one is not a duplicate, we want it.
Expand Down Expand Up @@ -2357,7 +2359,7 @@ private String processUploadedFileList(List<DataFile> dFileList) {
if (warningMessage == null) {
warningMessage = duplicateFilesErrorMessage;
} else {
warningMessage = warningMessage.concat("; " + duplicateFilesErrorMessage);
warningMessage = warningMessage.concat(" " + duplicateFilesErrorMessage);
}
}

Expand All @@ -2373,7 +2375,7 @@ private String processUploadedFileList(List<DataFile> dFileList) {
if (warningMessage == null) {
warningMessage = duplicateFilesErrorMessage;
} else {
warningMessage = warningMessage.concat("; " + duplicateFilesErrorMessage);
warningMessage = warningMessage.concat(" " + duplicateFilesErrorMessage);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import edu.harvard.iq.dataverse.FileMetadata;
import edu.harvard.iq.dataverse.util.BundleUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -157,7 +158,8 @@ public static boolean isDuplicateOriginalWay(DatasetVersion workingVersion, File
if (currentCheckSum != null) {
if (currentCheckSum.equals(selectedCheckSum)) {
DataFile existingFile = fm.getDataFile();
String inLineMessage = BundleUtil.getStringFromBundle("dataset.file.inline.message.prefix") + " " + existingFile.getDisplayName();
List<String> args = Arrays.asList(existingFile.getDisplayName());
String inLineMessage = BundleUtil.getStringFromBundle("dataset.file.inline.message", args);
fileMetadata.getDataFile().setDuplicateFilename(inLineMessage);
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/propertyFiles/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2111,10 +2111,10 @@ dataset.save.fail=Dataset Save Failed

dataset.files.exist=Files {0} have the same content as {1} that already exists in the dataset.
dataset.file.exist=File {0} has the same content as {1} that already exists in the dataset.
dataset.file.exist.test={0, choice, 1#File |2#Files |} {1} {0, choice, 1#has |2#have |} the same content as {2} that already {0, choice, 1#exist |2#exist |}in the dataset.
dataset.files.duplicate=Files {0} have the same content as {1} that have already been uploaded.
dataset.file.duplicate=File {0} has the same content as {1} that has already been uploaded.
dataset.file.inline.message.prefix= This file has the same content as
dataset.file.skip=(skipping)
dataset.file.inline.message= This file has the same content as {0}.
dataset.file.upload=Succesful {0} is uploaded.
dataset.file.uploadFailure=upload failure
dataset.file.uploadFailure.detailmsg=the file {0} failed to upload!
Expand Down

0 comments on commit 36a0d76

Please sign in to comment.