@Override public void assertHttpStatus200() throws OWSExceptionReport { StatusLine statusLine = httpResponse.getStatusLine(); int statusCode = statusLine.getStatusCode(); if ( statusCode != 200 ) { try { XMLStreamReader xmlStream = xmlFac.createXMLStreamReader( url, is ); assertNoExceptionReport( xmlStream ); } catch ( OWSExceptionReport e ) { throw e; } catch ( Exception e ) { throwHttpStatusException( statusLine ); } throwHttpStatusException( statusLine ); } }
@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; }
LOG.debug( "Performing GET request: " + query ); HttpResponse httpResponse = httpClient.execute( httpGet ); response = new OwsHttpResponseImpl( httpResponse, httpClient.getConnectionManager(), sb.toString() ); } catch ( Throwable e ) { e.printStackTrace();
private void assertNoExceptionReport( XMLStreamReader xmlStream ) throws OWSExceptionReport, XMLStreamException { skipStartDocument( xmlStream ); if ( isExceptionReport( xmlStream.getName() ) ) { try { throw parseExceptionReport( xmlStream ); } finally { close(); } } }
@Override public void assertNoXmlContentTypeAndExceptionReport() throws OWSExceptionReport, XMLStreamException { Header contentType = httpResponse.getFirstHeader( "Content-Type" ); if ( contentType != null && contentType.getValue().startsWith( "text/xml" ) ) { XMLStreamReader xmlStream = xmlFac.createXMLStreamReader( url, is ); try { assertNoExceptionReport( xmlStream ); } finally { xmlStream.close(); } } }
@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; }