Ignore:
Timestamp:
2009-12-09T21:25:40+01:00 (14 years ago)
Author:
Gubaer
Message:

fixed #4130: Chunked upload mode counter is wrong
fixed #4118: Upload dialog too complicated
fixed #4129: Hide the new "Upload data in one request/chunks/individually" behind an expanding "Upload method" box
fixed #2075: API 0.6: don't upload more than 50K edits at once
fixed #4044: Huge uploads never end [should be solved with chunked upload mode]
fixed #4110: Upload dialog spacing wrong
fixed #3386: Upload dialog has empty areas when the changeset doesn't include all of add/modify/delete operations
see #3369: bulk import helper [JOSM now supports multi changesets uploads]

See online help for more details.

Completes r2598

Location:
trunk/src/org/openstreetmap/josm/io
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/Capabilities.java

    r2512 r2599  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.io;
     3
     4import static org.openstreetmap.josm.tools.I18n.tr;
    35
    46import java.util.HashMap;
     
    7173    }
    7274
     75    /**
     76     * Replies the max number of objects in a changeset. -1 if either the capabilities
     77     * don't include this parameter or if the parameter value is illegal (not a number,
     78     * a negative number)
     79     *
     80     * @return the max number of objects in a changeset
     81     */
     82    public int getMaxChangsetSize() {
     83        String v = get("changesets", "maximum_elements");
     84        if (v == null) return -1;
     85        try {
     86            int n = Integer.parseInt(v);
     87            if (n <= 0) {
     88                System.err.println(tr("Warning: illegal value of attribute '{0}'' of element ''{1}'' in server capabilities. Got ''{2}", "changesets", "maximum_elements", n ));
     89                return -1;
     90            }
     91            return n;
     92        } catch(NumberFormatException e) {
     93            System.err.println(tr("Warning: illegal value of attribute '{0}'' of element ''{1}'' in server capabilities. Got ''{2}", "changesets", "maximum_elements", v ));
     94            return -1;
     95        }
     96    }
    7397}
  • trunk/src/org/openstreetmap/josm/io/ChangesetClosedException.java

    r2569 r2599  
    3131    final static public String ERROR_HEADER_PATTERN = "The changeset (\\d+) was closed at (.*)";
    3232
    33     static enum Source {
     33    public static enum Source {
    3434        /**
    3535         * The exception was thrown when a changeset was updated. This most likely means
     
    114114
    115115    /**
     116     * Creates the exception
     117     *
     118     * @param changesetId the id if the closed changeset
     119     * @param closedOn the date the changeset was closed on
     120     * @param source the source for the exception
     121     */
     122    public ChangesetClosedException(long changesetId, Date closedOn, Source source) {
     123        super("");
     124        this.source = source == null ? Source.UNSPECIFIED : source;
     125        this.changesetId = changesetId;
     126        this.closedOn = closedOn;
     127    }
     128
     129    /**
    116130     * Replies the id of the changeset which was closed
    117131     *
     
    139153        return source;
    140154    }
     155
     156    public void setSource(Source source) {
     157        this.source = source == null ? Source.UNSPECIFIED : source;
     158    }
    141159}
  • trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java

    r2578 r2599  
    1919import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2020import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
     21import org.openstreetmap.josm.data.osm.PrimitiveId;
    2122import org.openstreetmap.josm.data.osm.Relation;
    2223import org.openstreetmap.josm.data.osm.RelationMember;
     
    7677
    7778    /**
    78      * remembers an {@see OsmPrimitive}'s id and its type. The id will
     79     * Remembers an {@see OsmPrimitive}'s id. The id will
    7980     * later be fetched as part of a Multi Get request.
    8081     *
    81      * Ignore the id if it id <= 0.
     82     * Ignore the id if it represents a new primitives.
    8283     *
    8384     * @param id  the id
    84      * @param type  the type
    85      */
    86     protected void remember(long id, OsmPrimitiveType type) {
    87         if (id <= 0) return;
    88         if (type.equals(OsmPrimitiveType.NODE)) {
    89             nodes.add(id);
    90         } else if (type.equals(OsmPrimitiveType.WAY)) {
    91             ways.add(id);
    92         } if (type.equals(OsmPrimitiveType.RELATION)) {
    93             relations.add(id);
     85     */
     86    protected void remember(PrimitiveId id) {
     87        if (id.isNew()) return;
     88        switch(id.getType()) {
     89        case NODE: nodes.add(id.getUniqueId()); break;
     90        case WAY: ways.add(id.getUniqueId()); break;
     91        case RELATION: relations.add(id.getUniqueId()); break;
    9492        }
    9593    }
     
    115113        if (primitive == null)
    116114            throw new NoSuchElementException(tr("No primitive with id {0} in local dataset. Can't infer primitive type.", id));
    117         remember(id, OsmPrimitiveType.from(primitive));
     115        remember(primitive.getPrimitiveId());
    118116        return;
    119117    }
     
    153151    public MultiFetchServerObjectReader append(Node node) {
    154152        if (node == null) return this;
    155         if (node.isNew()) return this;
    156         remember(node.getId(), OsmPrimitiveType.NODE);
     153        remember(node.getPrimitiveId());
    157154        return this;
    158155    }
     
    170167        for (Node node: way.getNodes()) {
    171168            if (!node.isNew()) {
    172                 remember(node.getId(), OsmPrimitiveType.NODE);
    173             }
    174         }
    175         remember(way.getId(), OsmPrimitiveType.WAY);
     169                remember(node.getPrimitiveId());
     170            }
     171        }
     172        remember(way.getPrimitiveId());
    176173        return this;
    177174    }
     
    187184        if (relation == null) return this;
    188185        if (relation.isNew()) return this;
    189         remember(relation.getId(), OsmPrimitiveType.RELATION);
     186        remember(relation.getPrimitiveId());
    190187        for (RelationMember member : relation.getMembers()) {
    191188            if (OsmPrimitiveType.from(member.getMember()).equals(OsmPrimitiveType.RELATION)) {
  • trunk/src/org/openstreetmap/josm/io/OsmApi.java

    r2569 r2599  
    8080        String serverUrl = Main.pref.get("osm-server.url", "http://api.openstreetmap.org/api");
    8181        if (serverUrl == null)
    82             throw new IllegalStateException(tr("Preference ''{0}'' missing. Can't initialize OsmApi.", "osm-server.url"));
     82            throw new IllegalStateException(tr("Preference ''{0}'' missing. Can''t initialize OsmApi.", "osm-server.url"));
    8383        return getOsmApi(serverUrl);
    8484    }
     
    342342                    monitor
    343343            );
     344        } catch(ChangesetClosedException e) {
     345            e.setSource(ChangesetClosedException.Source.UPDATE_CHANGESET);
     346            throw e;
    344347        } catch(OsmApiException e) {
    345348            if (e.getResponseCode() == HttpURLConnection.HTTP_CONFLICT && ChangesetClosedException.errorHeaderMatchesPattern(e.getErrorHeader()))
  • trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java

    r2569 r2599  
    149149            while(it.hasNext()) {
    150150                i++;
    151                 progressMonitor.setCustomText(tr("({0}/{1}) Uploading {2} objects...", i,numChunks,chunkSize));
    152151                if (canceled) return;
    153152                int j = 0;
     
    158157                    chunk.add(it.next());
    159158                }
     159                progressMonitor.setCustomText(tr("({0}/{1}) Uploading {2} objects...", i,numChunks,chunk.size()));
    160160                processed.addAll(api.uploadDiff(chunk, progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false)));
    161161            }
Note: See TracChangeset for help on using the changeset viewer.