Revision 3785

View differences:

trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/wms/WMSProtocolHandlerFactory.java
2 2
package org.gvsig.remoteClient.wms;
3 3

  
4 4
import java.io.DataInputStream;
5
import java.io.IOException;
5 6
import java.io.StringReader;
7
import java.net.ConnectException;
6 8
import java.net.URL;
7 9
import java.util.ArrayList;
8 10
import java.util.Iterator;
9 11

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

  
13 16
/**
14 17
 * <p></p>
......
69 72
     * @return instancia de un cliente capaz de negociar con el host que se
70 73
     *         pasa como par?metro
71 74
     */
72
     public static WMSProtocolHandler negotiate(String host){
75
     public static WMSProtocolHandler negotiate(String host) throws ConnectException {
73 76

  
74 77
        if (supportedVersions.size() == 0) 
75 78
        {
......
122 125
		                }
123 126
        		}
124 127
        	}//case we had to start the negotiation process.
125
	        return null; // if it did not find any suitable version.
126
        }catch(Exception e)
128
	        return null; // if it did not find any suitable version.        
129
        }
130
        catch(ConnectException conEx)
127 131
        {
132
        	throw conEx;
133
        }
134
        catch(Exception e)
135
        {
128 136
        	e.printStackTrace();
129 137
        	return null;
130 138
        }
......
138 146
      * @param version
139 147
      * @return suitable version supported by the server 
140 148
      */
141
     private static String getSuitableWMSVersion(String host, String _version)
149
     private static String getSuitableWMSVersion(String host, String _version) throws ConnectException, IOException 
142 150
     {    	 
143 151
    	String request = WMSProtocolHandler.buildCapabilitiesSuitableVersionRequest(host, _version);
144 152
    	String version = new String(); 
......
156 164
            //String readed = new String(buffer);
157 165
            dis = new DataInputStream(url.openStream()); 
158 166
            dis.readFully(buffer);
159
            
160
//            //NOTE: look for the version string in the stream we read from the WMS.
161
//            //double quote are included in the string to discriminate from the xml version. version='1.0'
162
//            int pos = readed.toLowerCase().indexOf("version=\"");
163
//            if (pos!= -1)
164
//            {
165
//            	version = readed.substring( pos + 9, pos + 14);
166
//            }
167
//            else
168
//            {
169
//            	System.out.println("ERROR getting version from WMService");
170
//            }
171
            
167
       
172 168
            reader = new StringReader(new String(buffer));
173 169
	    	KXmlParser kxmlParser = null;
174 170
	    	kxmlParser = new KXmlParser();
175

  
176 171
    		kxmlParser.setInput(reader);		
177 172
			kxmlParser.nextTag();
178 173
    		if ( kxmlParser.getEventType() != KXmlParser.END_DOCUMENT ) 
......
188 183
    		reader.close();    		
189 184
    		dis.close();
190 185
			return version;		
191
		} catch(Exception e){		
186
		}
187
		catch(ConnectException conEx)
188
		{
189
			throw new ConnectException(conEx.getMessage()); 			
190
		}
191
		catch(IOException ioEx)
192
		{
193
			throw new IOException(ioEx.getMessage()); 	
194
		}
195
		catch(XmlPullParserException xmlEx)
196
		{
197
			xmlEx.printStackTrace();
198
			return "";
199
		}
200
		finally{		
192 201
			if (reader != null)
193 202
			{
194 203
				try{
......
205 214
					ex.printStackTrace(); 
206 215
				}
207 216
			}
208
			e.printStackTrace();
209
			return null;
210 217
		}    	 
211 218
     }
212 219
     
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/wms/wms_1_1_0/WMSStyle1_1_0.java
16 16
/**
17 17
 * <p>URL pointing to the legend for a layer with this style</p>
18 18
 */
19
    private org.gvsig.remoteClient.wms.WMSStyle.LegendURL legendURL;
20 19

  
21 20
/**
22 21
 * <p>Parses the STYLE TAG according with the OGC Specifications for the WMS 1.1.1</p>
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/wms/WMSProtocolHandler.java
17 17
import org.gvsig.remoteClient.utils.Utilities;
18 18
import org.kxml2.io.KXmlParser;
19 19

  
20
import com.iver.andami.PluginServices;
21

  
22

  
23 20
/**
24 21
 * <p> Abstract class that represents handlers to comunicate via WMS protocol.
25 22
 * </p>

Also available in: Unified diff