Revision 33738

View differences:

branches/v2_0_0_prep/libraries/libCompat/src/org/gvsig/compat/net/Downloader.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.compat.net;
23

  
24
import java.io.File;
25
import java.io.IOException;
26
import java.net.ConnectException;
27
import java.net.URL;
28
import java.net.UnknownHostException;
29

  
30

  
31

  
32
/**
33
 * @author gvSIG Team
34
 * @version $Id$
35
 *
36
 */
37
public interface Downloader {
38
    /**
39
     * Downloads an URL into a temporary file that is removed the next time the
40
     * tempFileManager class is called, which means the next time gvSIG is launched.
41
     *
42
     * @param url
43
     * @param name
44
     * @return
45
     * @throws IOException
46
     * @throws ServerErrorResponseException
47
     * @throws ConnectException
48
     * @throws UnknownHostException
49
     */
50
    public File downloadFile(URL url, String name, ICancellable cancel) throws IOException,ConnectException, UnknownHostException;
51
    
52

  
53
    /**
54
     * Downloads a URL using the HTTP Post protocol
55
     * @param url
56
     * The server URL
57
     * @param data
58
     * The data to send in the request
59
     * @param name
60
     * A common name for all the retrieved files
61
     * @param cancel
62
     * Used to cancel the downloads
63
     * @return
64
     * The retrieved file
65
     * @throws IOException
66
     * @throws ConnectException
67
     * @throws UnknownHostException
68
     */
69
    public File downloadFile(URL url, String data, String name, ICancellable cancel) throws IOException,ConnectException, UnknownHostException;
70
 
71
    public void removeURL(URL url);
72
    
73
    public void removeURL(Object url);
74
    
75
    /**
76
     * Cleans every temporal file previously downloaded.
77
     */
78
    public void cleanUpTempFiles();
79
       
80

  
81
}
0 82

  
branches/v2_0_0_prep/libraries/libCompat/src/org/gvsig/compat/net/ICancellable.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program 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 this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41

  
42
/* CVS MESSAGES:
43
 *
44
 * $Id: ICancellable.java 29658 2009-06-29 17:10:19Z jpiera $
45
 * $Log$
46
 * Revision 1.1  2006-05-24 16:37:34  jaume
47
 * *** empty log message ***
48
 *
49
 *
50
 */
51
package org.gvsig.compat.net;
52

  
53
/**
54
 * <p>When a task is accessing to remote data, takes an indeterminate time, and occasionally gets locked. That's
55
 * the reason a task should support to be cancelable.</p>
56
 * <p><code>ICancellable</code> interface is designed for getting information about the cancellation of a
57
 * task of downloading remote information.</p>
58
 */
59
public interface ICancellable {
60
	/**
61
	 * <p>Returns <code>true</code> if a download or a group of downloads tasks has been canceled.</p>
62
	 * 
63
	 * @return <code>true</code> if a download or a group of downloads tasks has been canceled, otherwise <code>false</code>
64
	 */
65
	public boolean isCanceled();
66
	
67
	/**
68
	 * <p>Used to cancel only a group of downloads tasks with the same identifier.</p>
69
	 * 
70
	 * @return the identifier
71
	 */
72
	public Object getID();
73
}
0 74

  
branches/v2_0_0_prep/libraries/libCompat/src/org/gvsig/compat/CompatLocator.java
29 29
import org.gvsig.compat.lang.GraphicsUtils;
30 30
import org.gvsig.compat.lang.MathUtils;
31 31
import org.gvsig.compat.lang.StringUtils;
32
import org.gvsig.compat.net.Downloader;
32 33
import org.gvsig.tools.locator.BaseLocator;
33 34
import org.gvsig.tools.locator.Locator;
34 35
import org.gvsig.tools.locator.LocatorException;
......
62 63
     */
63 64
    private static final String MATHUTILS_DESCRIPTION = "Compatible implementation for Math Utilities";
64 65
    private static final String GRAPHICSUTILS_DESCRIPTION = "Compatible implementation for Graphics Utilities";
66
    
67
    /**
68
     * The name and the description for the {@link Downloader} reference.
69
     */
70
    public static final String DOWNLOADER_NAME = "Downloader";
71
    public static final String DOWNLOADER_DESCRIPTION = "Downloader descripction";
65 72

  
66 73
    /**
67 74
     * Unique instance.
......
154 161
        getInstance()
155 162
                .register(GRAPHICSUTILS_NAME, GRAPHICSUTILS_DESCRIPTION, clazz);
156 163
    }
164
    
165
    /**
166
     * Return a reference to GraphicsUtils.
167
     * 
168
     * @return a reference to GraphicsUtils
169
     * @throws LocatorException
170
     *             if there is no access to the class or the class cannot be
171
     *             instantiated
172
     * @see Locator#get(String)
173
     */
174
    public static Downloader getDownloader() throws LocatorException {
175
        return (Downloader) getInstance().get(DOWNLOADER_NAME);
176
    }
177

  
178
    
179
    /**
180
     * Registers the Class implementing the GraphicsUtils interface.
181
     * 
182
     * @param clazz
183
     *            implementing the GraphicsUtils interface
184
     */
185
    public static void registerDownloader(Class clazz) {
186
        getInstance()
187
                .register(DOWNLOADER_NAME, DOWNLOADER_DESCRIPTION, clazz);
188
    }
189
    
190
    
157 191
}
branches/v2_0_0_prep/libraries/libCompat/src/org/gvsig/compat/se/SECompatLibrary.java
31 31
import org.gvsig.compat.se.lang.SEGraphUtils;
32 32
import org.gvsig.compat.se.lang.SEMathUtils;
33 33
import org.gvsig.compat.se.lang.StandardStringUtils;
34
import org.gvsig.compat.se.net.SEDownloader;
34 35
import org.gvsig.tools.library.AbstractLibrary;
35 36
import org.gvsig.tools.library.Library;
36 37
import org.gvsig.tools.library.LibraryException;
......
51 52
		CompatLocator.registerStringUtils(StandardStringUtils.class);
52 53
		CompatLocator.registerMathUtils(SEMathUtils.class);
53 54
		CompatLocator.registerGraphicsUtils(SEGraphUtils.class);
55
		CompatLocator.registerDownloader(SEDownloader.class);
54 56
	}
55 57

  
56 58
	protected void doPostInitialize() throws LibraryException {
branches/v2_0_0_prep/libraries/libCompat/src/org/gvsig/compat/se/net/SEDownloader.java
1
package org.gvsig.compat.se.net;
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42

  
43
import java.io.BufferedOutputStream;
44
import java.io.DataInputStream;
45
import java.io.DataOutputStream;
46
import java.io.File;
47
import java.io.FileNotFoundException;
48
import java.io.FileOutputStream;
49
import java.io.IOException;
50
import java.io.OutputStreamWriter;
51
import java.net.ConnectException;
52
import java.net.HttpURLConnection;
53
import java.net.URL;
54
import java.net.UnknownHostException;
55
import java.security.KeyManagementException;
56
import java.security.NoSuchAlgorithmException;
57
import java.util.Hashtable;
58

  
59
import javax.net.ssl.HttpsURLConnection;
60
import javax.net.ssl.SSLContext;
61
import javax.net.ssl.TrustManager;
62
import javax.net.ssl.X509TrustManager;
63

  
64
import org.gvsig.compat.net.ICancellable;
65

  
66

  
67
/**
68
 * Clase con m?todos de utilidad en el protocolo WMS
69
 *
70
 * @authors Laura D?az, jaume dominguez faus
71
 */
72
public class SEDownloader implements org.gvsig.compat.net.Downloader{
73
    String characters;
74
	boolean canceled;
75
	final long latency = 500;
76
		
77
	/**
78
	 * Used to cancel a group of files
79
	 * <b>key</b>: Group id, <b>value</b>: Boolean (true if
80
	 * the group has to be canceled. Otherwise it is
81
	 * false)
82
	 */
83
	Hashtable canceledGroup = new Hashtable();
84
	/**
85
	 * <b>key</b>: URL, <b>value</b>: path to the downloaded file.
86
	 */
87
	Hashtable downloadedFiles;
88
	Exception downloadException;
89
	final String tempDirectoryPath = System.getProperty("java.io.tmpdir")+"/tmp-andami";
90
    
91
	public SEDownloader() {
92
        super();  
93
		characters = "";
94
		for (int j = 32; j<=127; j++){
95
			characters += (char) j;
96
		}
97
		characters += "?????????????????????????????????????????????????\n\r\f\t??";
98
	}
99
	
100
	/**
101
	 * Return the content of a file that has been created 
102
	 * from a URL using the HTTP GET protocol
103
	 * @param url
104
	 * The URL
105
	 * @return
106
	 * File containing this URL's content or null if no file was found.
107
	 */
108
	private File getPreviousDownloadedURL(URL url){
109
		return getPreviousDownloaded(url);
110
	}
111

  
112
	/**
113
	 * Return the content of a file that has been created 
114
	 * from a URL using the HTTP POST protocol
115
	 * @param url
116
	 * The URL
117
	 * @param data
118
	 * The data to send on the query
119
	 * @return
120
	 * File containing this URL's content or null if no file was found.
121
	 */
122
	private File getPreviousDownloadedURL(URL url, String data){
123
		return getPreviousDownloaded(url+data);
124
	}
125

  
126
	/**
127
	 * Returns the content of a URL as a file from the file system.<br>
128
	 * <p>
129
	 * If the URL has been already downloaded in this session and notified
130
	 * to the system using the static <b>Utilities.addDownloadedURL(URL)</b>
131
	 * method, it can be restored faster from the file system avoiding to
132
	 * download it again.
133
	 * </p>
134
	 * @param url
135
	 * @return File containing this URL's content or null if no file was found.
136
	 */
137
	private File getPreviousDownloaded(Object object){
138
		File f = null;
139
		if (downloadedFiles!=null && downloadedFiles.containsKey(object)){
140
			String filePath = (String) downloadedFiles.get(object);
141
			f = new File(filePath);
142
			if (!f.exists())
143
				return null;
144
		}
145
		return f;
146
	}
147

  
148
	/**
149
	 * Adds an URL to the table of downloaded files for further uses. If the URL
150
	 * already exists in the table its filePath value is updated to the new one and
151
	 * the old file itself is removed from the file system.
152
	 *
153
	 * @param url
154
	 * @param filePath
155
	 */
156
	void addDownloadedURL(URL url, String filePath){
157
		if (downloadedFiles==null)
158
			downloadedFiles = new Hashtable();
159
		String fileName = (String) downloadedFiles.put(url, filePath);
160
		//JMV: No se puede eliminar el anterior porque puede que alguien lo
161
		// este usando
162
		/*
163
        if (fileName!=null){
164
            File f = new File(fileName);
165
            if (f.exists())
166
                f.delete();
167
        }
168
		 */
169
	}
170

  
171
	/**
172
	 * Downloads an URL into a temporary file that is removed the next time the
173
	 * tempFileManager class is called, which means the next time gvSIG is launched.
174
	 *
175
	 * @param url
176
	 * @param name
177
	 * @return
178
	 * @throws IOException
179
	 * @throws ServerErrorResponseException
180
	 * @throws ConnectException
181
	 * @throws UnknownHostException
182
	 */
183
	public synchronized File downloadFile(URL url, String name, ICancellable cancel) throws IOException,ConnectException, UnknownHostException{
184
		File f = null;
185

  
186
		if ((f=getPreviousDownloadedURL(url))==null){
187
			File tempDirectory = new File(tempDirectoryPath);
188
			if (!tempDirectory.exists())
189
				tempDirectory.mkdir();
190

  
191
			f = new File(calculateFileName(name));
192

  
193
			if (cancel == null) {
194
				cancel = new ICancellable() {
195
					public boolean isCanceled() {
196
						return false;
197
					}
198
					public Object getID(){
199
						return SEDownloader.class.getName();
200
					}
201
				};
202
			}
203
			Thread downloader = new Thread(new Downloader(this, url, f, cancel.getID()));
204
			Thread monitor = new Thread(new Monitor(this, cancel));
205
			monitor.start();
206
			downloader.start();
207
			while(!getCanceled(cancel.getID()) && downloader.isAlive()) {
208
				try {
209
					Thread.sleep(latency);
210
				} catch (InterruptedException e) {
211
					// TODO Auto-generated catch block
212
					e.printStackTrace();
213
				}
214
			}
215

  
216
			if (getCanceled(cancel.getID()))
217
				return null;
218
			downloader = null;
219
			monitor = null;
220
			if (this.downloadException!=null) {
221
				Exception e = this.downloadException;
222
				if (e instanceof FileNotFoundException)
223
					throw (IOException) e;
224
				else if (e instanceof IOException)
225
					throw (IOException) e;
226
				else if (e instanceof ConnectException)
227
					throw (ConnectException) e;
228
				else if (e instanceof UnknownHostException)
229
					throw (UnknownHostException) e;
230
			}
231
		} else {
232
			System.out.println(url.toString()+" cached at '"+f.getAbsolutePath()+"'");
233
		}
234

  
235
		return f;
236
	}
237
	
238
	private String calculateFileName(String name){
239
		int index = name.lastIndexOf(".");
240
		if (index > 0){
241
			return tempDirectoryPath + "/" + name.substring(0,index) + System.currentTimeMillis() + 
242
				name.substring(index, name.length());
243
		}
244
		return tempDirectoryPath+"/"+name+System.currentTimeMillis();
245
	}
246

  
247
	/**
248
	 * Downloads a URL using the HTTP Post protocol
249
	 * @param url
250
	 * The server URL
251
	 * @param data
252
	 * The data to send in the request
253
	 * @param name
254
	 * A common name for all the retrieved files
255
	 * @param cancel
256
	 * Used to cancel the downloads
257
	 * @return
258
	 * The retrieved file
259
	 * @throws IOException
260
	 * @throws ConnectException
261
	 * @throws UnknownHostException
262
	 */
263
	public synchronized File downloadFile(URL url, String data, String name, ICancellable cancel) throws IOException,ConnectException, UnknownHostException{
264
		File f = null;
265

  
266
		if ((f=getPreviousDownloadedURL(url,data))==null){
267
			File tempDirectory = new File(tempDirectoryPath);
268
			if (!tempDirectory.exists())
269
				tempDirectory.mkdir();
270

  
271
			f = new File(calculateFileName(name));
272

  
273
			if (cancel == null) {
274
				cancel = new ICancellable() {
275
					public boolean isCanceled() {
276
						return false;
277
					}
278
					public Object getID(){
279
						return SEDownloader.class.getName();
280
					}
281
				};
282
			}
283
			Thread downloader = new Thread(new Downloader(url, data, f, cancel.getID()));
284
			Thread monitor = new Thread(new Monitor(this, cancel));
285
			monitor.start();
286
			downloader.start();
287
			while(!getCanceled(cancel.getID()) && downloader.isAlive()) {
288
				try {
289
					Thread.sleep(latency);
290
				} catch (InterruptedException e) {
291
					// TODO Auto-generated catch block
292
					e.printStackTrace();
293
				}
294
			}
295

  
296
			if (getCanceled(cancel.getID()))
297
				return null;
298
			downloader = null;
299
			monitor = null;
300
			if (this.downloadException!=null) {
301
				Exception e = this.downloadException;
302
				if (e instanceof FileNotFoundException)
303
					throw (IOException) e;
304
				else if (e instanceof IOException)
305
					throw (IOException) e;
306
				else if (e instanceof ConnectException)
307
					throw (ConnectException) e;
308
				else if (e instanceof UnknownHostException)
309
					throw (UnknownHostException) e;
310
			}
311
		} else {
312
			System.out.println(url.toString()+" cached at '"+f.getAbsolutePath()+"'");
313
		}
314

  
315
		return f;
316
	}
317

  
318
	/**
319
	 * Try if a group of downloads has been canceled
320
	 * @param groupId
321
	 * Group id
322
	 * @return
323
	 * If the group has been canceled
324
	 */
325
	protected boolean getCanceled(Object groupId){
326
		Object obj = canceledGroup.get(groupId);
327
		if (obj != null){
328
			return ((Boolean)obj).booleanValue();
329
		}
330
		return false;
331
	}
332

  
333
	/**
334
	 * Cancel a group of downloads
335
	 * @param groupId
336
	 * Group id
337
	 * @param isCanceled
338
	 * if the group has to be canceled
339
	 */
340
	protected void setCanceled(Object groupId, boolean isCanceled){
341
		if (groupId == null){
342
			groupId = SEDownloader.class.getName();
343
		}
344
		canceledGroup.put(groupId,new Boolean(isCanceled));
345
	}
346

  
347
	/**
348
	 * Cleans every temporal file previously downloaded.
349
	 */
350
	public void cleanUpTempFiles() {
351
		try{
352
			File tempDirectory = new File(tempDirectoryPath);
353

  
354
			File[] files = tempDirectory.listFiles();
355
			if (files!=null) {
356
				for (int i = 0; i < files.length; i++) {
357
					// s?lo por si en un futuro se necesitan crear directorios temporales
358
					if (files[i].isDirectory())	deleteDirectory(files[i]);
359
					files[i].delete();
360
				}
361
			}
362
			tempDirectory.delete();
363
		} catch (Exception e) {	}
364

  
365
	}
366
	/**
367
	 * Recursive directory delete.
368
	 * @param f
369
	 */
370
	private void deleteDirectory(File f) {
371
		File[] files = f.listFiles();
372
		for (int i = 0; i < files.length; i++) {
373
			if (files[i].isDirectory()) deleteDirectory(files[i]);
374
			files[i].delete();
375
		}
376

  
377
	}
378

  
379

  
380
	/**
381
	 * Remove an URL from the system cache. The file will remain in the file
382
	 * system for further eventual uses.
383
	 * @param request
384
	 */
385
	public void removeURL(URL url) {
386
		if (downloadedFiles != null && downloadedFiles.containsKey(url))
387
			downloadedFiles.remove(url);
388
	}
389

  
390
	/**
391
	 * Remove an URL from the system cache. The file will remain in the file
392
	 * system for further eventual uses.
393
	 * @param request
394
	 */
395
	public void removeURL(Object url) {
396
		if (downloadedFiles != null && downloadedFiles.containsKey(url))
397
			downloadedFiles.remove(url);
398
	}
399
}
400

  
401
final class Monitor implements Runnable {
402
	ICancellable c;
403
	SEDownloader downloader;
404
	
405
	public Monitor(SEDownloader downloader, ICancellable cancel) {
406
	    downloader.setCanceled(cancel.getID(),false);
407
		this.c = cancel;
408
		this.downloader = downloader;
409
	}
410
	
411
	public void run() {
412
		while (!c.isCanceled()) {
413
			try {
414
				Thread.sleep(downloader.latency);
415
			} catch (InterruptedException e) {
416
				e.printStackTrace();
417
			}
418
		}
419

  
420
		/*  WARNING!! This works because only one download is being processed at once.
421
		 *  You could prefer to start several transfers simultaneously. If so, you
422
		 *  should consideer using a non-static variable such is Utilities.canceled to
423
		 *  control when and which transfer in particular has been canceled.
424
		 *
425
		 *  The feature of transfer several files is at the moment under study. We are
426
		 *  planning to add an intelligent system that will give you a lot of services
427
		 *  and ease-of-use. So, we encourage you to wait for it instead of write your
428
		 *  own code.
429
		 */
430

  
431
		downloader.setCanceled(c.getID(),true);
432
	}
433
}
434

  
435
final class Downloader implements Runnable {
436
	private URL url;
437
	private File dstFile;
438
	private Object groupID = null;
439
	private String data = null;
440
	private SEDownloader downloader;
441
	
442
	public Downloader(SEDownloader downloader, URL url, File dstFile, Object groupID) {
443
		this.url = url;
444
		this.dstFile = dstFile;
445
		this.groupID = groupID;
446
		this.downloader = downloader;
447
		downloader.downloadException = null;
448
	}
449

  
450
	public Downloader(URL url, String data, File dstFile, Object groupID) {
451
		this.url = url;
452
		this.data = data;
453
		this.dstFile = dstFile;
454
		this.groupID = groupID;
455
		downloader.downloadException = null;
456
	}
457

  
458
	public void run() {
459
		System.out.println("downloading '"+url.toString()+"' to: "+dstFile.getAbsolutePath());
460

  
461
		DataOutputStream dos;
462
		try {
463
			DataInputStream is;
464
			OutputStreamWriter os = null;
465
			HttpURLConnection connection = null;
466
			//If the used protocol is HTTPS
467
			if (url.getProtocol().equals("https")){
468
				disableHttsValidation();
469
			}
470
			connection = (HttpURLConnection)url.openConnection();
471
			//If it uses a HTTP POST
472
			if (data != null){
473
				connection.setRequestProperty("SOAPAction","post");
474
				connection.setRequestMethod("POST");
475
				connection.setDoOutput(true);
476
				connection.setRequestProperty("Content-Type", "text/xml; charset=UTF-8");
477
				os = new OutputStreamWriter(connection.getOutputStream());
478
				os.write(data);
479
				os.flush();	
480
				is = new DataInputStream(connection.getInputStream());
481
			}else{
482
				is = new DataInputStream(url.openStream());
483
			}
484
			
485
			dos = new DataOutputStream( new BufferedOutputStream(new FileOutputStream(dstFile)));
486
			byte[] buffer = new byte[1024*4];
487

  
488

  
489
			long readed = 0;
490
			for (int i = is.read(buffer); !downloader.getCanceled(groupID) && i>0; i = is.read(buffer)){
491
				dos.write(buffer, 0, i);
492
				readed += i;
493

  
494
			}
495
			if(os != null){
496
				os.close();
497
			}
498
			dos.close();
499
			is.close();
500
			is = null;
501
			dos = null;
502
			if (downloader.getCanceled(groupID)) {
503
				System.err.println("[RemoteServices] '"+url+"' CANCELED.");
504
				dstFile.delete();
505
				dstFile= null;
506
			} else {
507
			    downloader.addDownloadedURL(url, dstFile.getAbsolutePath());
508
			}
509
		} catch (Exception e) {
510
			e.printStackTrace();
511
			downloader.downloadException = e;
512
		}		
513
	}
514

  
515
	/**
516
	 * This method disables the Https certificate validation.
517
	 * @throws KeyManagementException
518
	 * @throws NoSuchAlgorithmException
519
	 */
520
	private void disableHttsValidation() throws KeyManagementException, NoSuchAlgorithmException{
521
		// Create a trust manager that does not validate certificate chains
522
		TrustManager[] trustAllCerts = new TrustManager[]{
523
				new X509TrustManager() {
524
					public java.security.cert.X509Certificate[] getAcceptedIssuers() {
525
						return null;
526
					}
527
					public void checkClientTrusted(
528
							java.security.cert.X509Certificate[] certs, String authType) {
529
					}
530
					public void checkServerTrusted(
531
							java.security.cert.X509Certificate[] certs, String authType) {
532
					}
533
				}
534
		};
535

  
536
		// Install the all-trusting trust manager
537
		SSLContext sc = SSLContext.getInstance("SSL");
538
		sc.init(null, trustAllCerts, new java.security.SecureRandom());
539
		HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
540
	}
541
}
0 542

  
branches/v2_0_0_prep/libraries/libCompat/src/org/gvsig/compat/CompatLibrary.java
29 29
import org.gvsig.compat.lang.GraphicsUtils;
30 30
import org.gvsig.compat.lang.MathUtils;
31 31
import org.gvsig.compat.lang.StringUtils;
32
import org.gvsig.compat.net.Downloader;
32 33
import org.gvsig.tools.library.AbstractLibrary;
33 34
import org.gvsig.tools.library.Library;
34 35
import org.gvsig.tools.library.LibraryException;
......
73 74
			throw new ReferenceNotRegisteredException(
74 75
					CompatLocator.GRAPHICSUTILS_NAME, CompatLocator.getInstance());
75 76
		}
77
		
78
		  // Validate there is any implementation registered for the Downloader.
79
        Downloader downloader = CompatLocator.getDownloader();
80
        
81
        if (downloader == null) {
82
            throw new ReferenceNotRegisteredException(
83
                    CompatLocator.DOWNLOADER_NAME, CompatLocator.getInstance());
84
        }
76 85
	}
77 86

  
78 87
}
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/WMSDimension.java
3 3

  
4 4
import java.io.IOException;
5 5

  
6
import org.gvsig.remoteclient.utils.CapabilitiesTags;
7 6
import org.kxml2.io.KXmlParser;
8 7
import org.xmlpull.v1.XmlPullParserException;
9 8

  
9
import org.gvsig.remoteclient.utils.CapabilitiesTags;
10

  
10 11
/**
11 12
 * <p></p>
12 13
 * 
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/WMSProtocolHandlerFactory.java
9 9
import java.util.ArrayList;
10 10
import java.util.Iterator;
11 11

  
12
import org.gvsig.remoteclient.utils.CapabilitiesTags;
13 12
import org.kxml2.io.KXmlParser;
14 13
import org.xmlpull.v1.XmlPullParserException;
15 14

  
15
import org.gvsig.remoteclient.utils.CapabilitiesTags;
16

  
16 17
/**
17 18
 * <p></p>
18 19
 *
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/WMSProtocolHandler.java
2 2

  
3 3
import java.io.ByteArrayInputStream;
4 4
import java.io.File;
5
import java.io.FileInputStream;
6 5
import java.io.FileReader;
7 6
import java.io.IOException;
8 7
import java.io.InputStream;
9 8
import java.net.URL;
10 9
import java.net.URLConnection;
11
import java.nio.ByteBuffer;
12
import java.nio.channels.FileChannel;
13 10
import java.util.ArrayList;
14 11
import java.util.StringTokenizer;
15 12
import java.util.TreeMap;
16 13

  
14
import org.kxml2.io.KXmlParser;
15
import org.xmlpull.v1.XmlPullParserException;
16

  
17
import org.gvsig.compat.net.ICancellable;
17 18
import org.gvsig.remoteclient.exceptions.ServerErrorException;
18 19
import org.gvsig.remoteclient.exceptions.WMSException;
19 20
import org.gvsig.remoteclient.ogc.OGCProtocolHandler;
......
25 26
import org.gvsig.remoteclient.wms.request.WMSGetFeatureInfoRequest;
26 27
import org.gvsig.remoteclient.wms.request.WMSGetLegendGraphicRequest;
27 28
import org.gvsig.remoteclient.wms.request.WMSGetMapRequest;
28
import org.kxml2.io.KXmlParser;
29
import org.xmlpull.v1.XmlPullParserException;
30 29

  
31 30
/**
32 31
 * <p> Abstract class that represents handlers to comunicate via WMS protocol.
......
257 256
	    	if (f== null)
258 257
	    		return null;
259 258
            if (Utilities.isTextFile(f)) {
260
	    		FileInputStream fis = new FileInputStream(f);
261
	    		FileChannel fc = fis.getChannel();
262
	    		byte[] data = new byte[(int)fc.size()];
263
	    		ByteBuffer bb = ByteBuffer.wrap(data);
264
	    		fc.read(bb);
259
	    		
260
                byte[] data = fileToBytes(f);
265 261

  
266 262
	    		WMSException wmsEx = null;
267 263

  
......
281 277
                }
282 278
             	wmsEx = new WMSException(exceptionMessage);
283 279
            	wmsEx.setWMSMessage(new String(data));
284
            	Utilities.removeURL(request);
280
            	downloader.removeURL(request);
285 281
                throw wmsEx;
286 282
            }
287 283
			return f;
......
303 299
			if (f== null)
304 300
	    		return null;
305 301
            if (Utilities.isTextFile(f)) {
306
	    		FileInputStream fis = new FileInputStream(f);
307
	    		FileChannel fc = fis.getChannel();
308
	    		byte[] data = new byte[(int)fc.size()];   // fc.size returns the size of the file which backs the channel
309
	    		ByteBuffer bb = ByteBuffer.wrap(data);
310
	    		fc.read(bb);
302
                byte[] data = fileToBytes(f);
311 303

  
312 304
	    		WMSException wmsEx = null;
313 305

  
......
331 323
            	wmsEx.setWMSMessage(new String(data));
332 324

  
333 325
            	// Since it is an error file, It must be deleted from the cache
334
            	Utilities.removeURL(request);
326
            	downloader.removeURL(request);
335 327
                throw wmsEx;
336 328
            }
337 329
			return f;
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/WMSStyle.java
3 3

  
4 4
import java.io.IOException;
5 5

  
6
import org.gvsig.remoteclient.utils.CapabilitiesTags;
7 6
import org.kxml2.io.KXmlParser;
8 7
import org.xmlpull.v1.XmlPullParserException;
9 8

  
9
import org.gvsig.remoteclient.utils.CapabilitiesTags;
10

  
10 11
/**
11 12
 * <p>Defines a OGC style. Theme that describes the appeareance of certain layer.</p>
12 13
 *
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/WMSExtent.java
2 2

  
3 3
import java.io.IOException;
4 4

  
5
import org.gvsig.remoteclient.utils.CapabilitiesTags;
6 5
import org.kxml2.io.KXmlParser;
7 6
import org.xmlpull.v1.XmlPullParserException;
8 7

  
8
import org.gvsig.remoteclient.utils.CapabilitiesTags;
9

  
9 10
public class WMSExtent {
10 11
	    
11 12
    private String name; 
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/WMSLayer.java
6 6
import java.util.TreeMap;
7 7
import java.util.Vector;
8 8

  
9
import org.gvsig.remoteclient.utils.BoundaryBox;
10
import org.gvsig.remoteclient.utils.CapabilitiesTags;
11 9
import org.kxml2.io.KXmlParser;
12 10
import org.xmlpull.v1.XmlPullParserException;
13 11

  
12
import org.gvsig.remoteclient.utils.BoundaryBox;
13
import org.gvsig.remoteclient.utils.CapabilitiesTags;
14

  
14 15
/**
15 16
 * <p>Abstract class that defines an WMSLayer.</p>
16 17
 *
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/WMSClient.java
8 8
import java.util.TreeMap;
9 9
import java.util.Vector;
10 10

  
11
import org.gvsig.compat.net.ICancellable;
11 12
import org.gvsig.remoteclient.exceptions.ServerErrorException;
12 13
import org.gvsig.remoteclient.exceptions.WMSException;
13 14
import org.gvsig.remoteclient.utils.BoundaryBox;
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/wms_1_1_0/WMSLayer1_1_0.java
5 5
import java.util.ArrayList;
6 6
import java.util.TreeMap;
7 7

  
8
import org.kxml2.io.KXmlParser;
9
import org.xmlpull.v1.XmlPullParserException;
10

  
11
import org.gvsig.compat.CompatLocator;
12
import org.gvsig.compat.lang.StringUtils;
8 13
import org.gvsig.remoteclient.utils.BoundaryBox;
9 14
import org.gvsig.remoteclient.utils.CapabilitiesTags;
10 15
import org.gvsig.remoteclient.utils.Utilities;
11 16
import org.gvsig.remoteclient.wms.WMSDimension;
12 17
import org.gvsig.remoteclient.wms.WMSExtent;
13
import org.kxml2.io.KXmlParser;
14
import org.xmlpull.v1.XmlPullParserException;
15 18

  
16 19

  
17 20
/**
......
19 22
 * 
20 23
 */
21 24
public class WMSLayer1_1_0 extends org.gvsig.remoteclient.wms.WMSLayer {
25
    private static final StringUtils stringUtils = CompatLocator.getStringUtils();
22 26
    
23 27
    /**
24 28
     * <p>Extents defined for the layer in the capabilities doc</p>
......
154 158
                    {
155 159
                        value = parser.nextText();
156 160
                        if (value != null){
157
                            String[] mySRSs = value.split(" ");
161
                            String[] mySRSs = stringUtils.split(value, " ");
158 162
                            for (int i = 0; i < mySRSs.length; i++) {
159 163
                                addSrs(mySRSs[i]);    
160 164
                            }
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/wms_1_1_0/WMSProtocolHandler1_1_0.java
7 7
import java.util.ArrayList;
8 8
import java.util.TreeMap;
9 9

  
10
import org.kxml2.io.KXmlParser;
11
import org.xmlpull.v1.XmlPullParserException;
12

  
10 13
import org.gvsig.remoteclient.utils.CapabilitiesTags;
11 14
import org.gvsig.remoteclient.utils.EncodingXMLParser;
12 15
import org.gvsig.remoteclient.utils.ExceptionTags;
......
20 23
import org.gvsig.remoteclient.wms.wms_1_1_0.request.WMSGetFeatureInfoRequest1_1_0;
21 24
import org.gvsig.remoteclient.wms.wms_1_1_0.request.WMSGetLegendGraphicRequest1_1_0;
22 25
import org.gvsig.remoteclient.wms.wms_1_1_0.request.WMSGetMapRequest1_1_0;
23
import org.kxml2.io.KXmlParser;
24
import org.xmlpull.v1.XmlPullParserException;
25 26

  
26 27
/**
27 28
 * <p>
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/wms_1_1_0/WMSStyle1_1_0.java
3 3

  
4 4
import java.io.IOException;
5 5

  
6
import org.gvsig.remoteclient.utils.CapabilitiesTags;
7 6
import org.kxml2.io.KXmlParser;
8 7
import org.xmlpull.v1.XmlPullParserException;
9 8

  
9
import org.gvsig.remoteclient.utils.CapabilitiesTags;
10

  
10 11
/**
11 12
 * <p>Represents the layer style defined by the OGC Specifications for WMS 1.1.0</p>
12 13
 * 
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/wms_1_1_0/request/WMSGetFeatureInfoRequest1_1_0.java
27 27
 
28 28
package org.gvsig.remoteclient.wms.wms_1_1_0.request;
29 29

  
30
import org.gvsig.compat.CompatLocator;
31
import org.gvsig.compat.lang.StringUtils;
30 32
import org.gvsig.remoteclient.utils.CapabilitiesTags;
31 33
import org.gvsig.remoteclient.utils.Utilities;
32 34
import org.gvsig.remoteclient.wms.WMSProtocolHandler;
......
37 39
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
38 40
 */
39 41
public class WMSGetFeatureInfoRequest1_1_0 extends WMSGetFeatureInfoRequest{
40

  
41
	public WMSGetFeatureInfoRequest1_1_0(WMSStatus status,
42
    
43
    private static final StringUtils stringUtils = CompatLocator.getStringUtils();
44
	
45
    public WMSGetFeatureInfoRequest1_1_0(WMSStatus status,
42 46
			WMSProtocolHandler protocolHandler, int x, int y) {
43 47
		super(status, protocolHandler, x, y);		
44 48
	}
......
58 62
		//we set it to avoid the bug in mapserver that takes this number like max number of total features.
59 63
		req.append("&FEATURE_COUNT=10000");
60 64
		req.append("&EXCEPTIONS=" + getExceptionsFormat());  
61
		return req.toString().replaceAll(" ", "%20");
65
		return stringUtils.replaceAll(req.toString(), " ", "%20");
62 66
	}
63 67
	
64 68
	/**
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/wms_1_1_0/request/WMSGetCapabilitiesRequest1_1_0.java
31 31
import org.gvsig.remoteclient.wms.WMSProtocolHandler;
32 32
import org.gvsig.remoteclient.wms.WMSStatus;
33 33
import org.gvsig.remoteclient.wms.request.WMSGetCapabilitiesRequest;
34
import org.omg.CORBA.Request;
35 34

  
36 35
/**
37 36
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/wms_1_1_0/request/WMSGetLegendGraphicRequest1_1_0.java
27 27
 
28 28
package org.gvsig.remoteclient.wms.wms_1_1_0.request;
29 29

  
30
import org.gvsig.compat.CompatLocator;
31
import org.gvsig.compat.lang.StringUtils;
30 32
import org.gvsig.remoteclient.wms.WMSProtocolHandler;
31 33
import org.gvsig.remoteclient.wms.WMSStatus;
32 34
import org.gvsig.remoteclient.wms.request.WMSGetLegendGraphicRequest;
......
36 38
 */
37 39
public class WMSGetLegendGraphicRequest1_1_0 extends WMSGetLegendGraphicRequest{
38 40

  
41
    private static final StringUtils stringUtils = CompatLocator.getStringUtils();
42
    
39 43
	public WMSGetLegendGraphicRequest1_1_0(WMSStatus status,
40 44
			WMSProtocolHandler protocolHandler, String layerName) {
41 45
		super(status, protocolHandler, layerName);		
......
50 54
		req.append(onlineResource);
51 55
		req.append("REQUEST=GetLegendGraphic&SERVICE=WMS&VERSION=").append(protocolHandler.getVersion());
52 56
        req.append("&LAYER=" + layerName).append("&TRANSPARENT=TRUE").append("&FORMAT=image/png");
53
		return req.toString().replaceAll(" ", "%20");
57
		return stringUtils.replaceAll(req.toString(), " ", "%20");
54 58
	}
55 59

  
56 60
}
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/wms_1_1_0/request/WMSGetMapRequest1_1_0.java
27 27
 
28 28
package org.gvsig.remoteclient.wms.wms_1_1_0.request;
29 29

  
30
import org.gvsig.compat.CompatLocator;
31
import org.gvsig.compat.lang.StringUtils;
30 32
import org.gvsig.remoteclient.utils.CapabilitiesTags;
31 33
import org.gvsig.remoteclient.wms.WMSProtocolHandler;
32 34
import org.gvsig.remoteclient.wms.WMSStatus;
......
36 38
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
37 39
 */
38 40
public class WMSGetMapRequest1_1_0 extends WMSGetMapRequest{
39

  
41
    
42
    private static final StringUtils stringUtils = CompatLocator.getStringUtils();
43
    
40 44
	public WMSGetMapRequest1_1_0(WMSStatus status,
41 45
			WMSProtocolHandler protocolHandler) {
42 46
		super(status, protocolHandler);		
......
52 56
		req.append("REQUEST=GetMap&SERVICE=WMS&VERSION=").append(protocolHandler.getVersion()).append("&");
53 57
		req.append(getPartialQuery(status));
54 58
        req.append("&EXCEPTIONS=" + getExceptionsFormat());      
55
		return req.toString().replaceAll(" ", "%20");
59
		return stringUtils.replaceAll(req.toString(), " ", "%20");
56 60
	}
57 61
	
58 62
	/**
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/wms_1_1_1/WMSLayer1_1_1.java
5 5
import java.util.ArrayList;
6 6
import java.util.TreeMap;
7 7

  
8
import org.kxml2.io.KXmlParser;
9
import org.xmlpull.v1.XmlPullParserException;
10

  
11
import org.gvsig.compat.CompatLocator;
12
import org.gvsig.compat.lang.StringUtils;
8 13
import org.gvsig.remoteclient.utils.BoundaryBox;
9 14
import org.gvsig.remoteclient.utils.CapabilitiesTags;
10 15
import org.gvsig.remoteclient.utils.Utilities;
11 16
import org.gvsig.remoteclient.wms.WMSDimension;
12 17
import org.gvsig.remoteclient.wms.WMSExtent;
13
import org.kxml2.io.KXmlParser;
14
import org.xmlpull.v1.XmlPullParserException;
15 18

  
16 19

  
17 20
/**
......
20 23
 */
21 24
public class WMSLayer1_1_1 extends org.gvsig.remoteclient.wms.WMSLayer {
22 25
    
26
    private static final StringUtils stringUtils = CompatLocator.getStringUtils();
27
    
23 28
	 /**
24 29
     * <p>Extents defined for the layer in the capabilities doc</p>
25 30
     */
......
145 150
                    {
146 151
                        value = parser.nextText();
147 152
                        if (value != null){
148
                            String[] mySRSs = value.split(" ");
153
                            String[] mySRSs = stringUtils.split(value, " ");
149 154
                            for (int i = 0; i < mySRSs.length; i++) {
150 155
                                addSrs(mySRSs[i]);    
151 156
                            }                            
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/wms_1_1_1/WMSProtocolHandler1_1_1.java
7 7
import java.util.ArrayList;
8 8
import java.util.TreeMap;
9 9

  
10
import org.kxml2.io.KXmlParser;
11
import org.xmlpull.v1.XmlPullParserException;
12

  
10 13
import org.gvsig.remoteclient.utils.CapabilitiesTags;
11 14
import org.gvsig.remoteclient.utils.EncodingXMLParser;
12 15
import org.gvsig.remoteclient.utils.ExceptionTags;
......
21 24
import org.gvsig.remoteclient.wms.wms_1_1_1.request.WMSGetFeatureInfoRequest1_1_1;
22 25
import org.gvsig.remoteclient.wms.wms_1_1_1.request.WMSGetLegendGraphicRequest1_1_1;
23 26
import org.gvsig.remoteclient.wms.wms_1_1_1.request.WMSGetMapRequest1_1_1;
24
import org.kxml2.io.KXmlParser;
25
import org.xmlpull.v1.XmlPullParserException;
26 27

  
27 28
/**
28 29
 * <p>
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/wms_1_1_1/WMSStyle1_1_1.java
3 3

  
4 4
import java.io.IOException;
5 5

  
6
import org.gvsig.remoteclient.utils.CapabilitiesTags;
7 6
import org.kxml2.io.KXmlParser;
8 7
import org.xmlpull.v1.XmlPullParserException;
9 8

  
9
import org.gvsig.remoteclient.utils.CapabilitiesTags;
10

  
10 11
/**
11 12
 * <p>Represents the layer style defined by the OGC Specifications for WMS 1.1.1</p>
12 13
 * 
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/wms_1_3_0/WMSProtocolHandler1_3_0.java
7 7
import java.util.ArrayList;
8 8
import java.util.TreeMap;
9 9

  
10
import org.kxml2.io.KXmlParser;
11
import org.xmlpull.v1.XmlPullParserException;
12

  
10 13
import org.gvsig.remoteclient.utils.CapabilitiesTags;
11 14
import org.gvsig.remoteclient.utils.EncodingXMLParser;
12 15
import org.gvsig.remoteclient.utils.ExceptionTags;
......
20 23
import org.gvsig.remoteclient.wms.wms_1_3_0.request.WMSGetFeatureInfoRequest1_1_3;
21 24
import org.gvsig.remoteclient.wms.wms_1_3_0.request.WMSGetLegendGraphicRequest1_1_3;
22 25
import org.gvsig.remoteclient.wms.wms_1_3_0.request.WMSGetMapRequest1_1_3;
23
import org.kxml2.io.KXmlParser;
24
import org.xmlpull.v1.XmlPullParserException;
25 26

  
26 27
/**
27 28
 * <p>
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/wms_1_3_0/request/WMSGetFeatureInfoRequest1_1_3.java
27 27
 
28 28
package org.gvsig.remoteclient.wms.wms_1_3_0.request;
29 29

  
30
import org.gvsig.compat.CompatLocator;
31
import org.gvsig.compat.lang.StringUtils;
30 32
import org.gvsig.remoteclient.utils.CapabilitiesTags;
31 33
import org.gvsig.remoteclient.utils.Utilities;
32 34
import org.gvsig.remoteclient.wms.WMSProtocolHandler;
......
38 40
 */
39 41
public class WMSGetFeatureInfoRequest1_1_3 extends WMSGetFeatureInfoRequest{
40 42

  
43
    private static final StringUtils stringUtils = CompatLocator.getStringUtils();
44
    
41 45
	public WMSGetFeatureInfoRequest1_1_3(WMSStatus status,
42 46
			WMSProtocolHandler protocolHandler, int x, int y) {
43 47
		super(status, protocolHandler, x, y);	
......
56 60
		req.append(getPartialQuery(status)).append("&I="+ x + "&J=" + y);
57 61
		req.append("&FEATURE_COUNT=10000");
58 62
		req.append("&EXCEPTIONS=" + getExceptionsFormat());
59
		return req.toString().replaceAll(" ", "%20");
63
		return stringUtils.replaceAll(req.toString(), " ", "%20");
60 64
	}
61 65
	
62 66
	/**
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/wms_1_3_0/WMSStyle1_3_0.java
3 3

  
4 4
import java.io.IOException;
5 5

  
6
import org.gvsig.remoteclient.utils.CapabilitiesTags;
7 6
import org.kxml2.io.KXmlParser;
8 7
import org.xmlpull.v1.XmlPullParserException;
9 8

  
9
import org.gvsig.remoteclient.utils.CapabilitiesTags;
10

  
10 11
/**
11 12
 * <p>Represents the layer style defined by the OGC Specifications for WMS 1.3.0</p>
12 13
 * 
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/wms_1_3_0/WMSLayer1_3_0.java
5 5
import java.util.ArrayList;
6 6
import java.util.TreeMap;
7 7

  
8
import org.kxml2.io.KXmlParser;
9
import org.xmlpull.v1.XmlPullParserException;
10

  
11
import org.gvsig.compat.CompatLocator;
12
import org.gvsig.compat.lang.StringUtils;
8 13
import org.gvsig.remoteclient.utils.BoundaryBox;
9 14
import org.gvsig.remoteclient.utils.CapabilitiesTags;
10 15
import org.gvsig.remoteclient.utils.Utilities;
11 16
import org.gvsig.remoteclient.wms.WMSDimension;
12
import org.kxml2.io.KXmlParser;
13
import org.xmlpull.v1.XmlPullParserException;
14 17

  
15 18

  
16 19
/**
......
19 22
 */
20 23
public class WMSLayer1_3_0 extends org.gvsig.remoteclient.wms.WMSLayer {
21 24
    
25
    private static final StringUtils stringUtils = CompatLocator.getStringUtils();
22 26
    
23 27
    public ArrayList getDimensions()
24 28
    {   
......
105 109
                    	//comentar esto y a?adir solo los SRS o CRS que incluyan un extent...
106 110
                        value = parser.nextText();
107 111
                        if (value != null){
108
                            String[] mySRSs = value.split(" ");
112
                            String[] mySRSs = stringUtils.split(value, " ");
109 113
                            for (int i = 0; i < mySRSs.length; i++) {
110 114
                                addSrs(mySRSs[i]);    
111 115
                            }                        
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/ogc/OGCProtocolHandler.java
41 41
package org.gvsig.remoteclient.ogc;
42 42

  
43 43
import java.io.File;
44
import java.io.FileInputStream;
45
import java.io.FileNotFoundException;
44 46
import java.io.IOException;
45 47

  
46
import org.gvsig.remoteclient.utils.CapabilitiesTags;
47 48
import org.kxml2.io.KXmlParser;
48 49
import org.xmlpull.v1.XmlPullParserException;
49 50

  
51
import org.gvsig.compat.CompatLocator;
52
import org.gvsig.compat.net.Downloader;
53
import org.gvsig.remoteclient.utils.CapabilitiesTags;
54

  
50 55
public abstract class OGCProtocolHandler {
51
	/**
52
	 * procotol handler name
53
	 */
56
    protected static final Downloader downloader = CompatLocator.getDownloader();
57
    
58
    /**
59
     * procotol handler name
60
     */
54 61
    protected String name;
55 62
    /**
56 63
     * protocol handler version
......
64 71
     *  port number of the comunication channel of the WMS to connect
65 72
     */
66 73
    protected String port;    
67
    
74

  
68 75
    /**
69
	 * @return Returns the host.
70
	 */
71
	public String getHost() {
72
		return host;
73
	}
74
	/**
75
	 * @param host The host to set.
76
	 */
77
	public void setHost(String host) {
78
		this.host = host;
79
	}
80
	/**
81
	 * @return Returns the name.
82
	 */
83
	public String getName() {
84
		return name;
85
	}
86
	/**
87
	 * @param name The name to set.
88
	 */
89
	public void setName(String name) {
90
		this.name = name;
91
	}
92
	/**
93
	 * @return Returns the port.
94
	 */
95
	public String getPort() {
96
		return port;
97
	}
98
	/**
99
	 * @param port The port to set.
100
	 */
101
	public void setPort(String port) {
102
		this.port = port;
103
	}
104
	/**
105
	 * @return Returns the version.
106
	 */
107
	public String getVersion() {
108
		return version;
109
	}
110
	/**
111
	 * @param version The version to set.
112
	 */
113
	public void setVersion(String version) {
114
		this.version = version;
115
	}
116
    
76
     * @return Returns the host.
77
     */
78
    public String getHost() {
79
        return host;
80
    }
117 81
    /**
82
     * @param host The host to set.
83
     */
84
    public void setHost(String host) {
85
        this.host = host;
86
    }
87
    /**
88
     * @return Returns the name.
89
     */
90
    public String getName() {
91
        return name;
92
    }
93
    /**
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff