/** * * @throws IOException */ public void close() throws IOException { rawResponse.close(); }
@Override public CloseRequiredInputStream getAsBinaryStream() { return new CloseRequiredInputStream( this, is ); }
/** * Sets the {@link OwsHttpResponse} that will be returned by the next call to {@link #doGet(URL, Map, Map)} or * {@link #doPost(URL, String, StreamBufferStore, Map)}. * * @param responseBody * source of the response body, must not be <code>null</code> * @param contentType * content-type header, may be <code>null</code> * @param httpStatus * HTTP response status, usually 200 (OK) */ public void setResponse( URL responseBody, String contentType, int httpStatus ) { this.response = new OwsHttpResponseMock( responseBody, contentType, httpStatus ); } }
private void initCapabilities( URL capaUrl ) throws IOException, OWSExceptionReport, XMLStreamException { if ( shouldUseGet( capaUrl ) ) { OwsHttpResponse response = httpClient.doGet( capaUrl, null, null ); response.assertHttpStatus200(); XMLStreamReader responseAsXMLStream = response.getAsXMLStream(); try { XMLAdapter xmlAdapter = new XMLAdapter( responseAsXMLStream ); initCapabilities( xmlAdapter ); } finally { responseAsXMLStream.close(); response.close(); } } else { XMLAdapter xmlAdapter = new XMLAdapter( capaUrl ); initCapabilities( xmlAdapter ); } }
public MetadataRecord getRecordById( String fileIdentifier, String schema ) throws IOException, OWSExceptionReport, XMLStreamException { URL endPoint = getGetUrl( "GetRecordById" ); Map<String, String> params = getGetRecordByIdKvpParams( fileIdentifier, schema ); OwsHttpResponse response = httpClient.doGet( endPoint, params, null ); XMLStreamReader xmlStream = response.getAsXMLStream(); XMLStreamUtils.skipStartDocument( xmlStream ); moveToNextStartElement( xmlStream ); return MetadataRecordFactory.create( xmlStream ); }
/** * Returns the tile as an image. * * @return image, never <code>null</code> * @throws IOException * @throws XMLStreamException * @throws OWSExceptionReport */ public BufferedImage getAsImage() throws IOException, OWSExceptionReport, XMLStreamException { rawResponse.assertNoXmlContentTypeAndExceptionReport(); BufferedImage image = null; try { InputStream is = rawResponse.getAsBinaryStream(); image = HttpUtils.IMAGE.work( is ); } finally { rawResponse.close(); } return image; }
public TransactionResponse( OwsHttpResponse response ) throws XMLProcessingException, OWSExceptionReport, XMLStreamException { this.response = response; this.load( response.getAsXMLStream() ); }
/** * 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; }
@Override public XMLStreamReader getAsXMLStream() throws OWSExceptionReport, XMLStreamException { return XMLInputFactory.newInstance().createXMLStreamReader( getAsBinaryStream(), "UTF-8" ); }
@Override public XMLStreamReader getAsXMLStream() throws OWSExceptionReport, XMLStreamException { XMLStreamReader xmlStream = xmlFac.createXMLStreamReader( url, is ); assertNoExceptionReport( xmlStream ); LOG.debug( "Response root element: " + xmlStream.getName() ); String version = xmlStream.getAttributeValue( null, "version" ); LOG.trace( "Response version attribute: " + version ); return xmlStream; }
@Override public void assertNoXmlContentTypeAndExceptionReport() throws OWSExceptionReport, XMLStreamException { if ( "text/xml".equals( contentType ) ) { XMLStreamReader xmlStream = getAsXMLStream(); OWSExceptionReader.assertNoExceptionReport( xmlStream ); } }
private void assertNoExceptionReport( XMLStreamReader xmlStream ) throws OWSExceptionReport, XMLStreamException { skipStartDocument( xmlStream ); if ( isExceptionReport( xmlStream.getName() ) ) { try { throw parseExceptionReport( xmlStream ); } finally { close(); } } }
/** * * @throws IOException */ public void close() throws IOException { response.close(); } }
/** * Provides access to the feature objects and WFS provided information in the response. * * @return WFS feature collection, never <code>null</code> * * @throws OWSExceptionReport * @throws UnknownCRSException * @throws XMLStreamException * @throws XMLParsingException */ public WFSFeatureCollection<T> getAsWFSFeatureCollection() throws XMLParsingException, XMLStreamException, UnknownCRSException, OWSExceptionReport { return new WFSFeatureCollection<T>( response.getAsXMLStream(), gmlVersion, appSchema ); }
@Override public CloseRequiredInputStream getAsBinaryStream() { try { return new CloseRequiredInputStream( this, responseBody.openStream() ); } catch ( IOException e ) { throw new RuntimeException( e.getMessage(), e ); } }
/** * * @throws IOException */ public void close() throws IOException { rawResponse.close(); }
protected void closeQuietly( OwsHttpResponse response ) { if (response != null) { response.close(); } } }
public void close() throws IOException { response.close(); }
public void close() throws IOException { response.close(); }