/** * Creates a new {@link CSWClient} instance. * * @param capaUrl * url of a CSW capabilities document, usually this is a <code>GetCapabilities</code> request to the * service, must not be <code>null</code> * @param connectionTimeout * the timeout for get/post requests in milliseconds, 0 is interpreted as an infinite timeout (default) * @throws OWSExceptionReport * if the server replied with a service exception report * @throws XMLStreamException * @throws IOException * if a communication/network problem occured */ public CSWClient( URL capaUrl, int connectionTimeout, int readTimeout ) throws OWSExceptionReport, XMLStreamException, IOException { super( capaUrl, new OwsHttpClientImpl( connectionTimeout, readTimeout, null, null ) ); }
private DefaultHttpClient getInitializedHttpClient( URL url ) { DefaultHttpClient client = new DefaultHttpClient(); setTimeouts( client ); setProxies( url, client ); setCredentials( url, client ); return client; }
URI query = null; try { URL normalizedEndpointUrl = normalizeGetUrl( endPoint ); StringBuilder sb = new StringBuilder( normalizedEndpointUrl.toString() ); boolean first = true; DefaultHttpClient httpClient = getInitializedHttpClient( endPoint ); LOG.debug( "Performing GET request: " + query ); HttpResponse httpResponse = httpClient.execute( httpGet );
@Override public OwsHttpResponse doPost( URL endPoint, String contentType, StreamBufferStore body, Map<String, String> headers ) throws IOException { OwsHttpResponse response = null; try { HttpPost httpPost = new HttpPost( endPoint.toURI() ); DefaultHttpClient httpClient = getInitializedHttpClient( endPoint ); LOG.debug( "Performing POST request on " + endPoint ); LOG.debug( "post size: " + body.size() ); InputStreamEntity entity = new InputStreamEntity( body.getInputStream(), (long) body.size() ); entity.setContentType( contentType ); httpPost.setEntity( entity ); HttpResponse httpResponse = httpClient.execute( httpPost ); response = new OwsHttpResponseImpl( httpResponse, httpClient.getConnectionManager(), endPoint.toString() ); } catch ( Throwable e ) { String msg = "Error performing POST request on '" + endPoint + "': " + e.getMessage(); throw new IOException( msg ); } return response; }
this.httpClient = httpClient; } else { this.httpClient = new OwsHttpClientImpl();
/** * Creates a new {@link AbstractOWSClient} instance from the given capabilities document. * * @param capabilities * OWS capabilities document, must not be <code>null</code> * @param httpClient * client for customizing HTTP communication, can be <code>null</code> * @throws OWSExceptionReport * if the server replied with a service exception report * @throws XMLStreamException * @throws IOException * if a communication/network problem occured */ protected AbstractOWSClient( XMLAdapter capabilities, OwsHttpClient httpClient ) throws OWSExceptionReport, XMLStreamException, IOException { if ( capabilities == null ) { throw new NullPointerException( "Capabilities must not be null." ); } try { capaBaseUrl = getGetUrl( "GetCapabilities" ); } catch ( Exception e ) { LOG.warn( "No GetCapabilities URL available." ); } if ( httpClient != null ) { this.httpClient = httpClient; } else { this.httpClient = new OwsHttpClientImpl(); } initCapabilities( capabilities ); }
/** * @param url * @param connectionTimeout * default is 5 seconds * @param requestTimeout * default is 60 seconds * @param user * http basic username * @param pass * http basic password * @throws XMLStreamException * @throws OWSExceptionReport * @throws IOException */ public WMSClient( URL url, int connectionTimeout, int requestTimeout, String user, String pass ) throws IOException, OWSExceptionReport, XMLStreamException { super( url, new OwsHttpClientImpl( connectionTimeout * 1000, requestTimeout * 1000, user, pass ) ); this.connectionTimeout = connectionTimeout; this.requestTimeout = requestTimeout; capaDoc.parseWMSSpecificCapabilities( getOperations() ); checkCapabilities(); this.httpBasicUser = user; this.httpBasicPass = pass; }
private OwsHttpClient createOwsHttpClient( RemoteWMTSConfig config ) { int connTimeout = DEFAULT_CONNECTION_TIMEOUT_SECS; if ( config.getConnectionTimeout() != null ) { connTimeout = config.getConnectionTimeout(); } int reqTimeout = DEFAULT_REQUEST_TIMEOUT_SECS; if ( config.getRequestTimeout() != null ) { reqTimeout = config.getRequestTimeout(); } AuthenticationType type = config.getAuthentication() == null ? null : config.getAuthentication().getValue(); String user = null; String pass = null; if ( type instanceof HTTPBasicAuthenticationType ) { HTTPBasicAuthenticationType basic = (HTTPBasicAuthenticationType) type; user = basic.getUsername(); pass = basic.getPassword(); } return new OwsHttpClientImpl( connTimeout * 1000, reqTimeout * 1000, user, pass ); }