source: josm/trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/VersionHandler.java@ 7937

Last change on this file since 7937 was 7937, checked in by bastiK, 9 years ago

add subversion property svn:eol=native

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.io.remotecontrol.handler;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import org.openstreetmap.josm.io.remotecontrol.PermissionPrefWithDefault;
7import org.openstreetmap.josm.io.remotecontrol.RequestProcessor;
8
9/**
10 * Handler for version request.
11 */
12public class VersionHandler extends RequestHandler {
13
14 /**
15 * The remote control command name used to reply version.
16 */
17 public static final String command = "version";
18
19 @Override
20 protected void handleRequest() throws RequestHandlerErrorException,
21 RequestHandlerBadRequestException {
22 content = RequestProcessor.PROTOCOLVERSION;
23 contentType = "application/json";
24 if (args.containsKey("jsonp")) {
25 content = args.get("jsonp") + " && " + args.get("jsonp") + "(" + content + ")";
26 }
27 }
28
29 @Override
30 public String getPermissionMessage() {
31 return tr("Remote Control has been asked to report its protocol version. This enables web sites to detect a running JOSM.");
32 }
33
34 @Override
35 public PermissionPrefWithDefault getPermissionPref() {
36 return PermissionPrefWithDefault.READ_PROTOCOL_VERSION;
37 }
38
39 @Override
40 public String[] getMandatoryParams() {
41 return null;
42 }
43
44 @Override
45 public String[] getOptionalParams() {
46 return new String[]{"jsonp"};
47 }
48
49 @Override
50 protected void validateRequest() throws RequestHandlerBadRequestException {
51 // Nothing to do
52 }
53
54 @Override
55 public String getUsage() {
56 return "returns the current protocol version of the installed JOSM RemoteControl";
57 }
58
59 @Override
60 public String[] getUsageExamples() {
61 return new String[] { "/version", "/version?jsonp=test"};
62 }
63}
Note: See TracBrowser for help on using the repository browser.