/* * This is part of Geomajas, a GIS framework, http://www.geomajas.org/. * * Copyright 2008-2015 Geosparc nv, http://www.geosparc.com/, Belgium. * * The program is available in open source according to the GNU Affero * General Public License. All contributions in this program are covered * by the Geomajas Contributors License Agreement. For full licensing * details, see LICENSE.txt in the project root. */ package org.geomajas.gwt2.plugin.print.client.event; import java.util.HashMap; import java.util.Map; import org.geomajas.gwt2.plugin.print.client.util.PrintConfiguration; import org.geomajas.gwt2.plugin.print.client.util.UrlBuilder; /** * Info object, containing info of the successful end of a print request. This info consists of the HTTP url and request * parameters that should be called to actually download the print. In the case of a synchronous print service, the HTTP * method is POST (and the parameters contain the jsonized template), in the case of an asynchronous print service the * HTTP method is GET. * * @author Jan Venstermans * @author Jan De Moerloose * */ public class PrintFinishedInfo { /** * HTTP method for the url. * * @author Jan De Moerloose * */ public enum HttpMethod { GET, POST } private String url; private HttpMethod method = HttpMethod.GET; private PrintConfiguration.PostPrintAction postPrintAction; /** * A map of POST/GET parameters (NOT encoded yet !!!) */ private Map<String, String> params = new HashMap<String, String>(); /** * Get the encoded url. This returns a complete URL in the case of a HTTP GET method (async print). * * @return the url */ public String getEncodedUrl() { if (method.equals(HttpMethod.GET)) { UrlBuilder builder = new UrlBuilder(url); for (String name : getParams().keySet()) { builder.addParameter(name, getParams().get(name)); } return builder.toString(); } else { return url; } } /** * Set the encoded url. * * @param the url * * @deprecated use {@link #setUrl(String)} and {@link #addParam(String, String)} instead. */ @Deprecated public void setEncodedUrl(String url) { this.url = url; } public HttpMethod getMethod() { return method; } public void setMethod(HttpMethod method) { this.method = method; } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public Map<String, String> getParams() { return params; } public void addParam(String name, String value) { params.put(name, value); } public PrintConfiguration.PostPrintAction getPostPrintAction() { return postPrintAction; } public void setPostPrintAction(PrintConfiguration.PostPrintAction postPrintAction) { this.postPrintAction = postPrintAction; } }