Changeset 15015 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2019-04-22T16:43:22+02:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
r15010 r15015 23 23 import java.util.Iterator; 24 24 import java.util.List; 25 import java.util.Locale; 25 26 import java.util.Map; 26 27 import java.util.Map.Entry; … … 581 582 582 583 static boolean isUploadCommentTooShort(String comment) { 583 String s = comment .trim();584 String s = Utils.strip(comment); 584 585 boolean result = true; 585 586 if (!s.isEmpty()) { … … 594 595 } 595 596 596 static String validateUploadTag(String uploadValue, String preferencePrefix) { 597 private static String lc(String s) { 598 return s.toLowerCase(Locale.ENGLISH); 599 } 600 601 static String validateUploadTag(String uploadValue, String preferencePrefix, List<String> defMandatory, List<String> defForbidden) { 602 String uploadValueLc = lc(uploadValue); 597 603 // Check mandatory terms 598 List<String> missingTerms = Config.getPref().getList(preferencePrefix+".mandatory-terms") 599 .stream().filter(x -> !uploadValue.contains(x)).collect(Collectors.toList()); 604 List<String> missingTerms = Config.getPref().getList(preferencePrefix+".mandatory-terms", defMandatory) 605 .stream().map(UploadAction::lc).filter(x -> !uploadValueLc.contains(x)).collect(Collectors.toList()); 600 606 if (!missingTerms.isEmpty()) { 601 607 return tr("The following required terms are missing: {0}", missingTerms); 602 608 } 603 609 // Check forbidden terms 604 List<String> forbiddenTerms = Config.getPref().getList(preferencePrefix+".forbidden-terms") 605 .stream().filter(uploadValue::contains).collect(Collectors.toList()); 610 List<String> forbiddenTerms = Config.getPref().getList(preferencePrefix+".forbidden-terms", defForbidden) 611 .stream().map(UploadAction::lc).filter(uploadValueLc::contains).collect(Collectors.toList()); 606 612 if (!forbiddenTerms.isEmpty()) { 607 613 return tr("The following forbidden terms have been found: {0}", forbiddenTerms); … … 615 621 dialog.forceUpdateActiveField(); 616 622 623 final List<String> def = Collections.emptyList(); 617 624 final String uploadComment = dialog.getUploadComment(); 618 final String uploadCommentRejection = validateUploadTag(uploadComment, "upload.comment"); 625 final String uploadCommentRejection = validateUploadTag( 626 uploadComment, "upload.comment", def, def); 619 627 if ((isUploadCommentTooShort(uploadComment) && warnUploadComment()) || 620 628 (uploadCommentRejection != null && warnRejectedUploadComment(uploadCommentRejection))) { … … 624 632 } 625 633 final String uploadSource = dialog.getUploadSource(); 626 final String uploadSourceRejection = validateUploadTag(uploadSource, "upload.source"); 634 final String uploadSourceRejection = validateUploadTag( 635 uploadSource, "upload.source", def, Collections.singletonList("google")); 627 636 if ((Utils.isStripEmpty(uploadSource) && warnUploadSource()) || 628 637 (uploadSourceRejection != null && warnRejectedUploadSource(uploadSourceRejection))) {
Note:
See TracChangeset
for help on using the changeset viewer.