- Timestamp:
- 2016-09-08T00:02:03+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/RequestHandler.java
r10587 r10973 146 146 */ 147 147 PermissionPrefWithDefault permissionPref = getPermissionPref(); 148 if (permissionPref != null && permissionPref.pref != null) { 149 if (!Main.pref.getBoolean(permissionPref.pref, permissionPref.defaultVal)) { 150 String err = MessageFormat.format("RemoteControl: ''{0}'' forbidden by preferences", myCommand); 151 Main.info(err); 152 throw new RequestHandlerForbiddenException(err); 153 } 148 if (permissionPref != null && permissionPref.pref != null && !Main.pref.getBoolean(permissionPref.pref, permissionPref.defaultVal)) { 149 String err = MessageFormat.format("RemoteControl: ''{0}'' forbidden by preferences", myCommand); 150 Main.info(err); 151 throw new RequestHandlerForbiddenException(err); 154 152 } 155 153 … … 179 177 * 180 178 * @param url The request URL. 181 */ 182 public void setUrl(String url) { 179 * @throws RequestHandlerBadRequestException if request URL is invalid 180 */ 181 public void setUrl(String url) throws RequestHandlerBadRequestException { 183 182 this.request = url; 184 parseArgs(); 183 try { 184 parseArgs(); 185 } catch (URISyntaxException e) { 186 throw new RequestHandlerBadRequestException(e); 187 } 185 188 } 186 189 … … 190 193 * 191 194 * Can be overridden by subclass. 192 */ 193 protected void parseArgs() { 194 try { 195 this.args = getRequestParameter(new URI(this.request)); 196 } catch (URISyntaxException ex) { 197 throw new RuntimeException(ex); 198 } 195 * @throws URISyntaxException if request URL is invalid 196 */ 197 protected void parseArgs() throws URISyntaxException { 198 this.args = getRequestParameter(new URI(this.request)); 199 199 } 200 200 … … 311 311 312 312 public static class RequestHandlerErrorException extends RequestHandlerException { 313 314 /** 315 * Constructs a new {@code RequestHandlerErrorException}. 316 * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). 317 */ 313 318 public RequestHandlerErrorException(Throwable cause) { 314 319 super(cause); … … 318 323 public static class RequestHandlerBadRequestException extends RequestHandlerException { 319 324 325 /** 326 * Constructs a new {@code RequestHandlerBadRequestException}. 327 * @param message the detail message. The detail message is saved for later retrieval by the {@link #getMessage()} method. 328 */ 320 329 public RequestHandlerBadRequestException(String message) { 321 330 super(message); 322 331 } 323 332 333 /** 334 * Constructs a new {@code RequestHandlerBadRequestException}. 335 * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). 336 */ 337 public RequestHandlerBadRequestException(Throwable cause) { 338 super(cause); 339 } 340 341 /** 342 * Constructs a new {@code RequestHandlerBadRequestException}. 343 * @param message the detail message. The detail message is saved for later retrieval by the {@link #getMessage()} method. 344 * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). 345 */ 324 346 public RequestHandlerBadRequestException(String message, Throwable cause) { 325 347 super(message, cause); … … 328 350 329 351 public static class RequestHandlerForbiddenException extends RequestHandlerException { 330 private static final long serialVersionUID = 2263904699747115423L; 331 352 353 /** 354 * Constructs a new {@code RequestHandlerForbiddenException}. 355 * @param message the detail message. The detail message is saved for later retrieval by the {@link #getMessage()} method. 356 */ 332 357 public RequestHandlerForbiddenException(String message) { 333 358 super(message); … … 337 362 public abstract static class RawURLParseRequestHandler extends RequestHandler { 338 363 @Override 339 protected void parseArgs() {364 protected void parseArgs() throws URISyntaxException { 340 365 Map<String, String> args = new HashMap<>(); 341 366 if (request.indexOf('?') != -1) {
Note:
See TracChangeset
for help on using the changeset viewer.