public InputStream getStream ( String url , RasterLayer layer ) throws IOException { if ( layer instanceof ProxyLayerSupport ) { ProxyLayerSupport proxyLayer = ( ProxyLayerSupport ) layer ; if ( proxyLayer . isUseCache ( ) && null != cacheManagerService ) { Object cachedObject = cacheManagerService . get ( proxyLayer , CacheCategory . RASTER , url ) ; if ( null != cachedObject ) { testRecorder . record ( TEST_RECORDER_GROUP , TEST_RECORDER_GET_FROM_CACHE ) ; return new ByteArrayInputStream ( ( byte [ ] ) cachedObject ) ; } else { testRecorder . record ( TEST_RECORDER_GROUP , TEST_RECORDER_PUT_IN_CACHE ) ; InputStream stream = super . getStream ( url , proxyLayer ) ; ByteArrayOutputStream os = new ByteArrayOutputStream ( ) ; int b ; while ( ( b = stream . read ( ) ) >= 0 ) { os . write ( b ) ; } cacheManagerService . put ( proxyLayer , CacheCategory . RASTER , url , os . toByteArray ( ) , getLayerEnvelope ( proxyLayer ) ) ; return new ByteArrayInputStream ( ( byte [ ] ) os . toByteArray ( ) ) ; } } } return super . getStream ( url , layer ) ; }
Get the contents from the request URL .