public Response(HTTPResponse httpResponse) throws ServiceException, IOException { if (httpResponse.getResponseStream() == null) { throw new NullPointerException( "An inputStream is required for " + getClass().getName()); } if (httpResponse.getContentType() == null) { // should missing content type be fatal? Or could we make an assumption? // in case of exception, we have to dispose the response, as it might // be using a deflate input stream, which holds onto native resources httpResponse.getResponseStream().close(); httpResponse.dispose(); throw new NullPointerException("Content type is required for " + getClass().getName()); } this.httpResponse = httpResponse; /* * Intercept XML ServiceExceptions and throw them */ if (httpResponse.getContentType().toLowerCase().equals("application/vnd.ogc.se_xml")) { try { throw parseException(httpResponse.getResponseStream()); } finally { dispose(); } } }
public Response(String contentType, InputStream inputStream) throws ServiceException, IOException { this.inputStream = inputStream; this.contentType = contentType; /* * Intercept XML ServiceExceptions and throw them */ if (contentType.toLowerCase().equals("application/vnd.ogc.se_xml")) { throw parseException(inputStream); } }
public Response(HTTPResponse httpResponse) throws ServiceException, IOException { if( httpResponse.getResponseStream() == null ){ throw new NullPointerException("An inputStream is required for "+getClass().getName()); } if( httpResponse.getContentType() == null ){ // should missing content type be fatal? Or could we make an assumption? throw new NullPointerException("Content type is required for "+getClass().getName()); } this.httpResponse = httpResponse; /* * Intercept XML ServiceExceptions and throw them */ if (httpResponse.getContentType().toLowerCase().equals("application/vnd.ogc.se_xml")) { try { throw parseException(httpResponse.getResponseStream()); } finally { dispose(); } } }