Package org.openstreetmap.josm.io.remotecontrol.handler

Examples of org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler


                String help = "No command specified! The following commands are available:<ul>" + usage
                        + "</ul>" + "See <a href=\""+websiteDoc+"\">"+websiteDoc+"</a> for complete documentation.";
                sendBadRequest(out, help);
            } else {
                // create handler object
                RequestHandler handler = handlerClass.newInstance();
                try {
                    handler.setCommand(command);
                    handler.setUrl(url);
                    handler.setSender(sender);
                    handler.handle();
                    sendHeader(out, "200 OK", handler.getContentType(), false);
                    out.write("Content-length: " + handler.getContent().length()
                            + "\r\n");
                    out.write("\r\n");
                    out.write(handler.getContent());
                    out.flush();
                } catch (RequestHandlerErrorException ex) {
                    sendError(out);
                } catch (RequestHandlerBadRequestException ex) {
                    sendBadRequest(out, ex.getMessage());
View Full Code Here


    }

    public static String getHandlerInfoAsJSON(String cmd) {
        try (StringWriter w = new StringWriter()) {
            PrintWriter r = new PrintWriter(w);
            RequestHandler handler = null;
            try {
                Class<?> c = handlers.get(cmd);
                if (c==null) return null;
                handler = handlers.get(cmd).newInstance();
            } catch (InstantiationException | IllegalAccessException ex) {
View Full Code Here

     * @throws InstantiationException
     */
    public static String getUsageAsHtml() throws IllegalAccessException, InstantiationException {
        StringBuilder usage = new StringBuilder(1024);
        for (Entry<String, Class<? extends RequestHandler>> handler : handlers.entrySet()) {
            RequestHandler sample = handler.getValue().newInstance();
            String[] mandatory = sample.getMandatoryParams();
            String[] optional = sample.getOptionalParams();
            String[] examples = sample.getUsageExamples(handler.getKey().substring(1));
            usage.append("<li>");
            usage.append(handler.getKey());
            if (sample.getUsage() != null && !sample.getUsage().isEmpty()) {
                usage.append(" &mdash; <i>").append(sample.getUsage()).append("</i>");
            }
            if (mandatory != null) {
                usage.append("<br/>mandatory parameters: ").append(Utils.join(", ", Arrays.asList(mandatory)));
            }
            if (optional != null) {
View Full Code Here

TOP

Related Classes of org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.