Revision 41316 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wms/WMSProtocolHandlerFactory.java

View differences:

WMSProtocolHandlerFactory.java
174 174
      */
175 175
     private static String getSuitableWMSVersion(String host, String _version) throws ConnectException, IOException
176 176
     {
177
         int sizes[] = new int[] { 1024, 1024*10, 1024*50, 1024*100 };
178
         XmlPullParserException  xmlEx = null;
179
         for( int i=0; i<sizes.length; i++ ) {
180
             String version;
181
             try {
182
                 version = getSuitableWMSVersion(host, _version, sizes[i]);
183
                 return version;
184
             } catch (XmlPullParserException ex) {
185
                 xmlEx = ex;
186
                 // Try with other size
187
             }
188
         }
189
         logger.warn("Can't determine server version",xmlEx);
190
         return "";
191
     }
192
     
193
     private static String getSuitableWMSVersion(String host, String _version, int size) throws ConnectException, IOException, XmlPullParserException
194
     {
177 195
    	String request = WMSProtocolHandler.buildCapabilitiesSuitableVersionRequest(host, _version);
178 196
    	String version = new String();
179 197
    	StringReader reader = null;
......
183 201
		try
184 202
		{
185 203
			URL url = new URL(request);
186
            byte[] buffer = new byte[1024];//new byte[1024*256];
187
//            is = url.openStream();
188
//            reader = new InputStreamReader(is);
189
            //int numberOfBytes = is.read(buffer);
190
            //String readed = new String(buffer);
204
            byte[] buffer = new byte[size];
191 205
            dis = new DataInputStream(url.openStream());
192 206
            dis.readFully(buffer);
193 207
            String string = new String(buffer);
......
228 242
		}
229 243
		catch(XmlPullParserException xmlEx)
230 244
		{
231
                        logger.warn("Can't determine server version",xmlEx);
232
			return "";
245
                    throw  xmlEx;
246
//                    logger.warn("Can't determine server version",xmlEx);
247
//                    return "";
233 248
		}
234 249
		finally{
235 250
			if (reader != null)

Also available in: Unified diff