Changeset 36319 in osm for applications/editors/josm/plugins/reverter/src
- Timestamp:
- 2024-08-21T22:49:24+02:00 (8 months ago)
- Location:
- applications/editors/josm/plugins/reverter/src/reverter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/reverter/src/reverter/RevertChangesetHandler.java
r33572 r36319 7 7 import org.openstreetmap.josm.io.remotecontrol.PermissionPrefWithDefault; 8 8 import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler; 9 import org.openstreetmap.josm.tools.Logging; 9 10 11 import java.util.List; 12 import java.util.ArrayList; 13 14 /** 15 * The handler for {@link org.openstreetmap.josm.io.remotecontrol.RemoteControl} revert commands 16 */ 10 17 public class RevertChangesetHandler extends RequestHandler { 11 public static final String command= "revert_changeset";12 p ublicstatic final StringpermissionKey= "remotecontrol.permission.revert_changeset";13 p ublicstatic final booleanpermissionDefault= true;18 public static final String COMMAND = "revert_changeset"; 19 private static final String PERMISSION_KEY = "remotecontrol.permission.revert_changeset"; 20 private static final boolean PERMISSION_DEFAULT = true; 14 21 15 private intchangesetId;22 private final List<Integer> changesetIds = new ArrayList<>(); 16 23 17 24 @Override 18 protected void handleRequest() throws RequestHandlerErrorException, 19 RequestHandlerBadRequestException { 25 protected void handleRequest() throws RequestHandlerErrorException { 20 26 try { 21 MainApplication.worker.submit(new RevertChangesetTask(changesetId, ChangesetReverter.RevertType.FULL, true)); 27 MainApplication.worker.submit(new RevertChangesetTask(changesetIds, ChangesetReverter.RevertType.FULL, true, false)); 22 28 } catch (Exception ex) { 23 System.out.println("RemoteControl: Error parsing revert_changeset remote control request:");24 ex.printStackTrace();29 Logging.debug("RemoteControl: Error parsing revert_changeset remote control request:"); 30 Logging.debug(ex); 25 31 throw new RequestHandlerErrorException(ex); 26 32 } … … 34 40 @Override 35 41 public PermissionPrefWithDefault getPermissionPref() { 36 return n ull;42 return new PermissionPrefWithDefault(PERMISSION_KEY, PERMISSION_DEFAULT, tr("Revert changeset(s)")); 37 43 } 38 44 … … 44 50 @Override 45 51 protected void validateRequest() throws RequestHandlerBadRequestException { 46 try { 47 changesetId = Integer.parseInt(args.get("id")); 48 } catch (NumberFormatException e) { 49 throw new RequestHandlerBadRequestException("NumberFormatException: "+e.getMessage()); 52 if (args.get("id") != null) { 53 try { 54 for (String id : args.get("id").split(",", -1)) { 55 changesetIds.add(Integer.parseInt(id)); 56 } 57 } catch (NumberFormatException e) { 58 throw new RequestHandlerBadRequestException("NumberFormatException: " + e.getMessage()); 59 } 60 } else { 61 throw new RequestHandlerBadRequestException("The required id argument must be specified"); 50 62 } 51 63 } -
applications/editors/josm/plugins/reverter/src/reverter/ReverterPlugin.java
r35868 r36319 28 28 MainMenu.add(historyMenu, new RevertChangesetAction()); 29 29 UploadAction.registerUploadHook(new ReverterUploadHook(info)); 30 new RemoteControl().addRequestHandler(RevertChangesetHandler. command, RevertChangesetHandler.class);30 new RemoteControl().addRequestHandler(RevertChangesetHandler.COMMAND, RevertChangesetHandler.class); 31 31 } 32 32 }
Note:
See TracChangeset
for help on using the changeset viewer.