Ignore:
Timestamp:
2009-09-07T00:01:31+02:00 (15 years ago)
Author:
Gubaer
Message:

fixed #3422: Upload dialog allows modification of the created_by=* tag when adding to an existing changeset

File:
1 edited

Legend:

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

    r2070 r2074  
    278278    }
    279279
    280     /**
    281      * Creates the changeset to be used for subsequent uploads.
     280
     281    /**
     282     * Creates a new changeset based on the keys in <code>changeset</code>
    282283     *
    283      * If changesetProcessingType is {@see ChangesetProcessingType#USE_NEW} creates a new changeset based
    284      * on <code>changeset</code>. Otherwise uses the changeset given by {@see OsmApi#getCurrentChangeset()}.
    285      * If this changeset is null or has an id of value 0, a new changeset is created too.
    286      *
    287      * @param changeset the changeset to be used for uploading if <code>changesetProcessingType</code> is
    288      *   {@see ChangesetProcessingType#USE_NEW}
    289      * @param changesetProcessingType  how to handel changesets; set to {@see ChangesetProcessingType#USE_NEW} if null
     284     * @param changeset the changeset to be used for uploading
    290285     * @param progressMonitor the progress monitor
    291286     * @throws OsmTransferException signifying a non-200 return code, or connection errors
    292287     */
    293     public void createChangeset(Changeset changeset, ChangesetProcessingType changesetProcessingType, ProgressMonitor progressMonitor) throws OsmTransferException {
    294         if (changesetProcessingType == null) {
    295             changesetProcessingType = ChangesetProcessingType.USE_NEW_AND_CLOSE;
    296         }
     288    public void createChangeset(Changeset changeset, ProgressMonitor progressMonitor) throws OsmTransferException {
    297289        try {
    298290            progressMonitor.beginTask((tr("Creating changeset...")));
    299             if (changesetProcessingType.isUseNew()) {
    300                 Properties sysProp = System.getProperties();
    301                 Object ua = sysProp.get("http.agent");
    302                 changeset.put("created_by", (ua == null) ? "JOSM" : ua.toString());
    303                 createPrimitive(changeset, progressMonitor);
    304                 this.changeset = changeset;
    305                 progressMonitor.setCustomText((tr("Successfully opened changeset {0}",changeset.getId())));
    306             } else {
    307                 if (this.changeset == null || this.changeset.getId() == 0) {
    308                     progressMonitor.setCustomText((tr("No currently open changeset. Opening a new changeset...")));
    309                     System.out.println(tr("Warning: could not reuse an existing changeset as requested. Opening a new one."));
    310                     Properties sysProp = System.getProperties();
    311                     Object ua = sysProp.get("http.agent");
    312                     changeset.put("created_by", (ua == null) ? "JOSM" : ua.toString());
    313                     createPrimitive(changeset, progressMonitor);
    314                     this.changeset = changeset;
    315                     progressMonitor.setCustomText((tr("Successfully opened changeset {0}",this.changeset.getId())));
    316                 } else {
    317                     progressMonitor.setCustomText((tr("Reusing existing changeset {0}", this.changeset.getId())));
    318                 }
    319             }
     291            createPrimitive(changeset, progressMonitor);
     292            this.changeset = changeset;
     293            progressMonitor.setCustomText((tr("Successfully opened changeset {0}",this.changeset.getId())));
    320294        } finally {
    321295            progressMonitor.finishTask();
     
    324298
    325299    /**
    326      * Update a changeset on the server.
    327      *
    328      * @param changeset the changeset to update
     300     * Updates the current changeset with the keys in  <code>changesetUpdate</code>.
     301     *
     302     * @param changesetUpdate the changeset to update
    329303     * @param progressMonitor the progress monitor
    330304     *
    331305     * @throws OsmTransferException if something goes wrong.
    332306     */
    333     public void updateChangeset(Changeset changeset, ProgressMonitor progressMonitor) throws OsmTransferException {
     307    public void updateChangeset(Changeset changesetUpdate, ProgressMonitor progressMonitor) throws OsmTransferException {
    334308        try {
    335309            progressMonitor.beginTask(tr("Updating changeset..."));
    336310            initialize(progressMonitor);
    337311            if (this.changeset != null && this.changeset.getId() > 0) {
    338                 if (this.changeset.hasEqualSemanticAttributes(changeset)) {
    339                     progressMonitor.setCustomText(tr("Changeset {0} is unchanged. Skipping update.", changeset.getId()));
     312                if (this.changeset.hasEqualSemanticAttributes(changesetUpdate)) {
     313                    progressMonitor.setCustomText(tr("Changeset {0} is unchanged. Skipping update.", changesetUpdate.getId()));
    340314                    return;
    341315                }
    342                 this.changeset.setKeys(changeset.getKeys());
    343                 progressMonitor.setCustomText(tr("Updating changeset {0}...", changeset.getId()));
     316                this.changeset.setKeys(changesetUpdate.getKeys());
     317                progressMonitor.setCustomText(tr("Updating changeset {0}...", this.changeset.getId()));
    344318                sendRequest(
    345319                        "PUT",
    346                         OsmPrimitiveType.from(changeset).getAPIName() + "/" + changeset.getId(),
    347                         toXml(changeset, true),
     320                        OsmPrimitiveType.from(changesetUpdate).getAPIName() + "/" + this.changeset.getId(),
     321                        toXml(this.changeset, true),
    348322                        progressMonitor
    349323                );
    350                 this.changeset = changeset;
    351324            } else
    352325                throw new OsmTransferException(tr("Failed to update changeset. Either there is no current changeset or the id of the current changeset is 0"));
Note: See TracChangeset for help on using the changeset viewer.