1 /********************************************** 2 * Copyright (C) 2012 Lukas Laag 3 * This file is part of svgreal. 4 * 5 * svgreal is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * svgreal is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with svgreal. If not, see http://www.gnu.org/licenses/ 17 **********************************************/ 18 package org.vectomatic.svg.edit.client.load; 19 20 import com.google.gwt.core.client.GWT; 21 22 /** 23 * Class to abstract communications with the server 24 * @author laaglu 25 */ 26 public class FetchUtils { 27 /** 28 * Relative URI of the servlet used to fetch cross origin resources 29 */ 30 public static final String FETCH_URI = "fetch"; 31 public static final String FETCH_URL_PARAM = "url"; 32 public static final String FETCH_TYPE_PARAM = "type"; 33 34 public static String getFetchUrl(String url, String type) { 35 StringBuilder builder = new StringBuilder(); 36 builder.append(GWT.getHostPageBaseURL()); 37 //builder.append(FETCH_URI); 38 return getFetchUrl(builder.toString(), url, type); 39 } 40 public static String getFetchUrl(String base, String url, String type) { 41 /*StringBuilder builder = new StringBuilder(); 42 builder.append(base); 43 builder.append("?"); 44 builder.append(FETCH_URL_PARAM); 45 builder.append("="); 46 builder.append(url); 47 builder.append("&"); 48 builder.append(FETCH_TYPE_PARAM); 49 builder.append("="); 50 builder.append(type); 51 return builder.toString();*/ 52 return url.replace("http://www.openclipart.org", base + "openclipart") 53 .replace("http://openclipart.org", base + "openclipart"); 54 } 55 }