Added connection timeout to loadStyles
git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/spatial-data/geo-utility@124091 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
a87db32ae8
commit
733d2dc1e0
|
@ -150,7 +150,7 @@ public class GeoNcWMSMetadataUtility {
|
|||
layerName,
|
||||
crs,
|
||||
validator.getValueOfParsedWMSParameter(WmsParameters.WIDTH),
|
||||
validator.getValueOfParsedWMSParameter(WmsParameters.HEIGHT));
|
||||
validator.getValueOfParsedWMSParameter(WmsParameters.HEIGHT),connectionTimeout);
|
||||
|
||||
if(minmax!=null && minmax.length==2 && minmax[0]!=null && minmax[1]!=null){
|
||||
String valueMinMax = minmax[0]+","+minmax[1];
|
||||
|
@ -169,7 +169,7 @@ public class GeoNcWMSMetadataUtility {
|
|||
layerName,
|
||||
crs,
|
||||
validator.getValueOfParsedWMSParameter(WmsParameters.WIDTH),
|
||||
validator.getValueOfParsedWMSParameter(WmsParameters.HEIGHT));
|
||||
validator.getValueOfParsedWMSParameter(WmsParameters.HEIGHT),connectionTimeout);
|
||||
|
||||
if(minmax!=null && minmax.length==2 && minmax[0]!=null && minmax[1]!=null){
|
||||
isNcWms = true;
|
||||
|
|
|
@ -51,10 +51,11 @@ public class NcWmsGetMetadataRequest {
|
|||
* @param crs the crs
|
||||
* @param width the width
|
||||
* @param height the height
|
||||
* @param connectionTimeout the connection timeout
|
||||
* @return the color scale range - an array of 2 elements that contains min and max value for the COLORSCALERANGE
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static String[] getColorScaleRange(String wmsServerUri, String wmsVersion, String bbox, String layerName, String crs, String width, String height) throws Exception {
|
||||
public static String[] getColorScaleRange(String wmsServerUri, String wmsVersion, String bbox, String layerName, String crs, String width, String height, int connectionTimeout) throws Exception {
|
||||
logger.trace(NcWmsGetMetadataRequest.class.getName()+".getColorScaleRange working...");
|
||||
String[] colorScaleMinMax = null;
|
||||
// http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc?item=minmax&layers=analyzed_field&bbox=-180.0,-85.0,180.0,85.0&crs=EPSG%3A4326&request=GetMetadata&width=640&height=480
|
||||
|
@ -83,7 +84,7 @@ public class NcWmsGetMetadataRequest {
|
|||
try {
|
||||
|
||||
String query = UrlEncoderUtil.encodeQuery(parameters);
|
||||
colorScaleMinMax = openConnectionGetColorScaleRange(wmsServerUri, query);
|
||||
colorScaleMinMax = openConnectionGetColorScaleRange(wmsServerUri, query, connectionTimeout);
|
||||
return colorScaleMinMax;
|
||||
|
||||
}catch (Exception e) {
|
||||
|
@ -97,9 +98,10 @@ public class NcWmsGetMetadataRequest {
|
|||
*
|
||||
* @param urlConn the url conn
|
||||
* @param query the query
|
||||
* @param connectionTimeout the connection timeout
|
||||
* @return the string[] an array with 2 elements witch contains min, max value for the COLORSCALERANGE
|
||||
*/
|
||||
private static String[] openConnectionGetColorScaleRange(String urlConn, String query) {
|
||||
private static String[] openConnectionGetColorScaleRange(String urlConn, String query, int connectionTimeout) {
|
||||
|
||||
URL url;
|
||||
String[] colorScaleRange = null;
|
||||
|
@ -108,8 +110,11 @@ public class NcWmsGetMetadataRequest {
|
|||
url = new URL(urlConn + "?" + query);
|
||||
URLConnection connection = url.openConnection();
|
||||
|
||||
connection.setConnectTimeout(CONNECTION_TIMEOUT);
|
||||
connection.setReadTimeout(CONNECTION_TIMEOUT + CONNECTION_TIMEOUT);
|
||||
if(connectionTimeout<0)
|
||||
connectionTimeout = CONNECTION_TIMEOUT;
|
||||
|
||||
connection.setConnectTimeout(connectionTimeout);
|
||||
connection.setReadTimeout(connectionTimeout*2);
|
||||
|
||||
logger.trace("openConnectionGetColorScaleRange on: " + url);
|
||||
|
||||
|
@ -207,7 +212,7 @@ public class NcWmsGetMetadataRequest {
|
|||
// http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc?item=minmax&layers=analyzed_field&bbox=-180.0,-85.0,180.0,85.0&crs=EPSG%3A4326&request=GetMetadata&width=640&height=480
|
||||
|
||||
try {
|
||||
NcWmsGetMetadataRequest.getColorScaleRange("http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc", "1.1.1", "-85.0,-180.0,85.0,180.0", "analyzed_field", "EPSG:4326", "640", "480");
|
||||
NcWmsGetMetadataRequest.getColorScaleRange("http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc", "1.1.1", "-85.0,-180.0,85.0,180.0", "analyzed_field", "EPSG:4326", "640", "480", 2000);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
|
Loading…
Reference in New Issue