Changeset 13414 in josm for trunk


Ignore:
Timestamp:
2018-02-12T02:31:14+01:00 (6 years ago)
Author:
Don-vip
Message:

fix #15452 - More details are needed for "Tag value longer than allowed" (patch by Klumbumbus, modified)

Location:
trunk/src/org/openstreetmap/josm
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/upload/ApiPreconditionCheckerHook.java

    r12636 r13414  
    1212import org.openstreetmap.josm.data.APIDataSet;
    1313import org.openstreetmap.josm.data.osm.OsmPrimitive;
     14import org.openstreetmap.josm.data.osm.Tagged;
    1415import org.openstreetmap.josm.data.osm.Way;
    1516import org.openstreetmap.josm.gui.ExceptionDialogUtil;
     
    6162            for (String key: osmPrimitive.keySet()) {
    6263                String value = osmPrimitive.get(key);
    63                 if (key.length() > 255) {
     64                if (key.length() > Tagged.MAX_TAG_LENGTH) {
    6465                    if (osmPrimitive.isDeleted()) {
    6566                        // if OsmPrimitive is going to be deleted we automatically shorten the value
     
    7071                                )
    7172                        );
    72                         osmPrimitive.put(key, value.substring(0, 255));
     73                        osmPrimitive.put(key, value.substring(0, Tagged.MAX_TAG_LENGTH));
    7374                        continue;
    7475                    }
    7576                    JOptionPane.showMessageDialog(Main.parent,
    7677                            tr("Length of value for tag ''{0}'' on object {1} exceeds the max. allowed length {2}. Values length is {3}.",
    77                                     key, Long.toString(osmPrimitive.getId()), 255, value.length()
     78                                    key, Long.toString(osmPrimitive.getId()), Tagged.MAX_TAG_LENGTH, value.length()
    7879                            ),
    7980                            tr("Precondition Violation"),
  • trunk/src/org/openstreetmap/josm/data/osm/Changeset.java

    r13173 r13414  
    2525
    2626    /** The maximum changeset tag length allowed by API 0.6 **/
    27     public static final int MAX_CHANGESET_TAG_LENGTH = 255;
     27    public static final int MAX_CHANGESET_TAG_LENGTH = MAX_TAG_LENGTH;
    2828
    2929    /** the changeset id */
  • trunk/src/org/openstreetmap/josm/data/osm/Tagged.java

    r11608 r13414  
    1313//
    1414public interface Tagged {
     15
     16    /**
     17     * The maximum tag length allowed by OSM API
     18     * @since 13414
     19     */
     20    int MAX_TAG_LENGTH = 255;
     21
    1522    /**
    1623     * Sets the map of key/value pairs
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r13246 r13414  
    3434import org.openstreetmap.josm.data.osm.OsmUtils;
    3535import org.openstreetmap.josm.data.osm.Tag;
     36import org.openstreetmap.josm.data.osm.Tagged;
    3637import org.openstreetmap.josm.data.preferences.sources.ValidatorPrefHelper;
    3738import org.openstreetmap.josm.data.validation.Severity;
     
    447448                withErrors.put(p, "ICK");
    448449            }
    449             if (checkValues && (value != null && value.length() > 255) && !withErrors.contains(p, "LV")) {
     450            if (checkValues && (value != null && value.length() > Tagged.MAX_TAG_LENGTH) && !withErrors.contains(p, "LV")) {
    450451                errors.add(TestError.builder(this, Severity.ERROR, LONG_VALUE)
    451                         .message(tr("Tag value longer than allowed"), s, key)
     452                        .message(tr("Tag value longer than {0} characters ({1} characters)", Tagged.MAX_TAG_LENGTH, value.length()), s, key)
    452453                        .primitives(p)
    453454                        .build());
    454455                withErrors.put(p, "LV");
    455456            }
    456             if (checkKeys && (key != null && key.length() > 255) && !withErrors.contains(p, "LK")) {
     457            if (checkKeys && (key != null && key.length() > Tagged.MAX_TAG_LENGTH) && !withErrors.contains(p, "LK")) {
    457458                errors.add(TestError.builder(this, Severity.ERROR, LONG_KEY)
    458                         .message(tr("Tag key longer than allowed"), s, key)
     459                        .message(tr("Tag key longer than {0} characters ({1} characters)", Tagged.MAX_TAG_LENGTH, key.length()), s, key)
    459460                        .primitives(p)
    460461                        .build());
Note: See TracChangeset for help on using the changeset viewer.