Changeset 5085 in josm for trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/RequestHandler.java
- Timestamp:
- 2012-03-14T23:33:27+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/RequestHandler.java
r5008 r5085 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.text.MessageFormat; 6 7 import java.util.HashMap; 7 8 import java.util.LinkedList; 8 9 import java.util.List; 9 import java.util.StringTokenizer;10 10 11 11 import javax.swing.JOptionPane; … … 50 50 public final void handle() throws RequestHandlerForbiddenException, RequestHandlerBadRequestException, RequestHandlerErrorException 51 51 { 52 checkMandatoryParams(); 52 53 checkPermission(); 53 checkMandatoryParams();54 54 handleRequest(); 55 55 } … … 86 86 * @return the preference name and error message or null 87 87 */ 88 public PermissionPrefWithDefault getPermissionPref() 89 { 90 /* Example: 91 return new PermissionPrefWithDefault("fooobar.remotecontrol", 92 true 93 "RemoteControl: foobar forbidden by preferences"); 94 */ 95 return null; 96 } 97 98 public String[] getMandatoryParams() { 99 return null; 100 } 88 abstract public PermissionPrefWithDefault getPermissionPref(); 89 90 abstract public String[] getMandatoryParams(); 101 91 102 92 /** … … 119 109 { 120 110 if (!Main.pref.getBoolean(permissionPref.pref, permissionPref.defaultVal)) { 121 System.out.println(permissionPref.message); 122 throw new RequestHandlerForbiddenException(); 111 String err = MessageFormat.format("RemoteControl: ''{0}'' forbidden by preferences", myCommand); 112 System.out.println(err); 113 throw new RequestHandlerForbiddenException(err); 123 114 } 124 115 } … … 133 124 tr("Confirm Remote Control action"), 134 125 JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) { 135 throw new RequestHandlerForbiddenException(); 126 String err = MessageFormat.format("RemoteControl: ''{0}'' forbidden by user''s choice", myCommand); 127 throw new RequestHandlerForbiddenException(err); 136 128 } 137 129 } … … 178 170 List<String> missingKeys = new LinkedList<String>(); 179 171 boolean error = false; 180 for (int i = 0; i < mandatory.length; ++i) { 181 String key = mandatory[i]; 172 for (String key : mandatory) { 182 173 String value = args.get(key); 183 174 if ((value == null) || (value.length() == 0)) { … … 243 234 public static class RequestHandlerForbiddenException extends RequestHandlerException { 244 235 private static final long serialVersionUID = 2263904699747115423L; 236 237 public RequestHandlerForbiddenException(String message) { 238 super(message); 239 } 245 240 } 246 241 }
Note:
See TracChangeset
for help on using the changeset viewer.