Revision 41316 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wcs/WCSProtocolHandlerFactory.java

View differences:

WCSProtocolHandlerFactory.java
35 35
import org.xmlpull.v1.XmlPullParserException;
36 36

  
37 37
import org.gvsig.remoteclient.utils.CapabilitiesTags;
38
import org.slf4j.Logger;
39
import org.slf4j.LoggerFactory;
38 40

  
39 41
/**
40 42
 *
......
42 44
 *
43 45
 */
44 46
public class WCSProtocolHandlerFactory {
47
        private static final Logger logger = LoggerFactory.getLogger(WCSProtocolHandlerFactory.class);
45 48

  
46 49
	public org.gvsig.remoteclient.wcs.WCSProtocolHandler wCSProtocolHandler;
47 50

  
......
163 166
	 * @param version
164 167
	 * @return suitable version supported by the server
165 168
	 */
166
	private static String getSuitableWCSVersion(String host, String _version) throws ConnectException, IOException {
169
     private static String getSuitableWCSVersion(String host, String _version) throws ConnectException, IOException
170
     {
171
         int sizes[] = new int[] { 1024, 1024*10, 1024*50, 1024*100 };
172
         XmlPullParserException  xmlEx = null;
173
         for( int i=0; i<sizes.length; i++ ) {
174
             String version;
175
             try {
176
                 version = getSuitableWCSVersion(host, _version, sizes[i]);
177
                 return version;
178
             } catch (XmlPullParserException ex) {
179
                 xmlEx = ex;
180
                 // Try with other size
181
             }
182
         }
183
         logger.warn("Can't determine server version",xmlEx);
184
         return "";
185
     }
186
             
187
	private static String getSuitableWCSVersion(String host, String _version, int size) throws ConnectException, IOException, XmlPullParserException {
167 188
		String request = WCSProtocolHandler.buildCapabilitiesSuitableVersionRequest(host, _version);
168 189
		String version = new String();
169 190
		StringReader reader = null;
......
172 193
		DataInputStream dis = null;
173 194
		try {
174 195
			URL url = new URL(request);
175
			byte[] buffer = new byte[1024];//new byte[1024*256];
196
			byte[] buffer = new byte[size];//new byte[1024*256];
176 197
//			is = url.openStream();
177 198
//			reader = new InputStreamReader(is);
178 199
			//int numberOfBytes = is.read(buffer);
......
199 220
		} catch(IOException ioEx) {
200 221
			throw new IOException(ioEx.getMessage());
201 222
		} catch(XmlPullParserException xmlEx) {
202
			xmlEx.printStackTrace();
203
			return "";
223
                        throw  xmlEx;
224
//			xmlEx.printStackTrace();
225
//			return "";
204 226
		} finally {
205 227
			if (reader != null) {
206 228
				try {

Also available in: Unified diff