Ignore:
Timestamp:
2013-10-27T15:19:50+01:00 (11 years ago)
Author:
donvip
Message:

[josm_reverter] fix #josm9197 - Forbid revert of redaction changesets

Location:
applications/editors/josm/plugins/reverter/src/reverter
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/reverter/src/reverter/ChangesetReverter.java

    r30000 r30031  
    5555        SELECTION_WITH_UNDELETE
    5656    }
     57   
     58    public static final Collection<Long> MODERATOR_REDACTION_ACCOUNTS = Collections.unmodifiableCollection(Arrays.asList(
     59            722137L, // OSMF Redaction Account
     60            760215L  // pnorman redaction revert
     61            ));
    5762
    5863    public final int changesetId;
     
    122127     * @param monitor
    123128     * @throws OsmTransferException
     129     * @throws RevertRedactedChangesetException
    124130     */
    125131    public ChangesetReverter(int changesetId, RevertType revertType, boolean newLayer, ProgressMonitor monitor)
    126             throws OsmTransferException {
     132            throws OsmTransferException, RevertRedactedChangesetException {
    127133        this.changesetId = changesetId;
    128134        if (newLayer) {
     
    137143        OsmServerChangesetReader csr = new OsmServerChangesetReader();
    138144        monitor.beginTask("", 2);
     145        changeset = csr.readChangeset(changesetId, monitor.createSubTaskMonitor(1, false));
     146        if (MODERATOR_REDACTION_ACCOUNTS.contains(changeset.getUser().getId())) {
     147            throw new RevertRedactedChangesetException(tr("It is not allowed to revert changeset from {0}", changeset.getUser().getName()));
     148        }
    139149        try {
    140             changeset = csr.readChangeset(changesetId, monitor.createSubTaskMonitor(1, false));
    141150            cds = csr.downloadChangeset(changesetId, monitor.createSubTaskMonitor(1, false));
    142151        } finally {
  • applications/editors/josm/plugins/reverter/src/reverter/RevertChangesetTask.java

    r29553 r30031  
    1010import org.openstreetmap.josm.command.Command;
    1111import org.openstreetmap.josm.command.ConflictAddCommand;
     12import org.openstreetmap.josm.gui.Notification;
    1213import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    1314import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor;
     
    6465    protected void realRun() throws OsmTransferException {
    6566        progressMonitor.indeterminateSubTask(tr("Downloading changeset"));
    66         rev = new ChangesetReverter(changesetId, revertType, newLayer,
    67                 progressMonitor.createSubTaskMonitor(0, true));
     67        try {
     68            rev = new ChangesetReverter(changesetId, revertType, newLayer,
     69                    progressMonitor.createSubTaskMonitor(0, true));
     70        } catch (final RevertRedactedChangesetException e) {
     71            GuiHelper.runInEDT(new Runnable() {
     72                @Override
     73                public void run() {
     74                    new Notification(
     75                            e.getMessage()+"<br>"+
     76                            tr("See {0}", "<a href=\"http://www.openstreetmap.org/redactions\">http://www.openstreetmap.org/redactions</a>"))
     77                    .setIcon(JOptionPane.ERROR_MESSAGE)
     78                    .setDuration(Notification.TIME_LONG)
     79                    .show();
     80                }
     81            });
     82            progressMonitor.cancel();
     83        }
    6884        if (progressMonitor.isCanceled()) return;
    6985
Note: See TracChangeset for help on using the changeset viewer.