Revision 33738 branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wcs/WCSProtocolHandler.java

View differences:

WCSProtocolHandler.java
42 42

  
43 43
import java.io.ByteArrayInputStream;
44 44
import java.io.File;
45
import java.io.FileInputStream;
46 45
import java.io.IOException;
47 46
import java.net.MalformedURLException;
48 47
import java.net.URL;
49
import java.nio.ByteBuffer;
50
import java.nio.channels.FileChannel;
51 48
import java.util.ArrayList;
52
import java.util.HashMap;
53 49
import java.util.Hashtable;
54 50
import java.util.StringTokenizer;
55
import java.util.Vector;
56 51

  
52
import org.kxml2.io.KXmlParser;
53
import org.xmlpull.v1.XmlPullParserException;
54

  
55
import org.gvsig.compat.CompatLocator;
56
import org.gvsig.compat.lang.StringUtils;
57
import org.gvsig.compat.net.ICancellable;
57 58
import org.gvsig.remoteclient.exceptions.ServerErrorException;
58 59
import org.gvsig.remoteclient.exceptions.WCSException;
59 60
import org.gvsig.remoteclient.ogc.OGCProtocolHandler;
......
62 63
import org.gvsig.remoteclient.utils.Utilities;
63 64
import org.gvsig.remoteclient.wcs.request.WCSDescribeCoverageRequest;
64 65
import org.gvsig.remoteclient.wcs.request.WCSGetCoverageRequest;
65
import org.gvsig.remoteclient.wms.ICancellable;
66
import org.kxml2.io.KXmlParser;
67
import org.xmlpull.v1.XmlPullParserException;
68 66
/**
69 67
 *
70 68
 * @author jaume
......
81 79
     * WCS metadata
82 80
     */
83 81
    protected WCSServiceInformation serviceInfo = new WCSServiceInformation();
82
    
83
    private static final StringUtils stringUtils = CompatLocator.getStringUtils();
84 84

  
85 85
	/*
86 86
	 * (non-Javadoc)
......
122 122
            }
123 123
            try {
124 124
            	if (override)
125
    				Utilities.removeURL(request);
126
            	File f =  Utilities.downloadFile(request,"wcs_capabilities.xml", cancel);
125
            	    downloader.removeURL(request);
126
            	File f =  downloader.downloadFile(request,"wcs_capabilities.xml", cancel);
127 127
            	if (f!=null)
128 128
            		parseCapabilities(f);
129 129
            } catch(Exception e) {
......
188 188
            File f = request.sendRequest();
189 189

  
190 190
            if (f!=null && Utilities.isTextFile(f)) {
191
	    		FileInputStream fis = new FileInputStream(f);
192
	    		FileChannel fc = fis.getChannel();
193
	    		byte[] data = new byte[(int)fc.size()];   // fc.size returns the size of the file which backs the channel
194
	    		ByteBuffer bb = ByteBuffer.wrap(data);
195
	    		fc.read(bb);
191
                byte[] data = fileToBytes(f);
196 192

  
197 193
	    		WCSException wcsEx = null;
198 194

  
......
214 210
            	wcsEx.setWCSMessage(new String(data));
215 211

  
216 212
            	// Since it is an error file, It must be deleted from the cache
217
            	Utilities.removeURL(request);
213
            	downloader.removeURL(request);
218 214
                throw wcsEx;
219 215
            }
220 216
			return f;
......
325 321
    	else
326 322
    		_host += "REQUEST=GetCapabilities&SERVICE=WCS&EXCEPTIONS=XML";
327 323

  
328
    	return _host.replaceAll(" ", "%20");
324
    	return stringUtils.replaceAll(_host, " ", "%20");
329 325
    }
330 326

  
331 327
	public ArrayList getFormats() {
......
342 338

  
343 339
	/* (non-Javadoc)
344 340
	 * @see org.gvsig.remoteclient.ogc.OGCProtocolHandler#getServiceInformation()
345
	 */
346
	@Override
341
	 */	
347 342
	public OGCServiceInformation getServiceInformation() {
348 343
		return serviceInfo;
349 344
	}	

Also available in: Unified diff