}
@Override
public Map<String, Serializable> createConnectionParameters(Object context) {
if( context instanceof PostgisService2 ){
PostgisService2 postgis = (PostgisService2) context;
return postgis.getConnectionParams();
}
URL url = toCapabilitiesURL( context );
if( url == null ){
// so we are not sure it is a postgis url
// lets guess
ID sample = ID.cast( context );
url = sample != null ? sample.toURL() : null;
}
if( url != null && PostgisServiceExtension2.isPostGIS(url)) {
// well we have a url - lets try it!
List<IResolve> list = CatalogPlugin.getDefault().getLocalCatalog().find( url, null );
for( IResolve resolve : list ){
if( resolve instanceof PostgisService2) {
// got a hit!
PostgisService2 postgisService = (PostgisService2) context;
return postgisService.getConnectionParams();
}
else if (resolve instanceof PostgisSchemaFolder) {
PostgisSchemaFolder postgisFolder = (PostgisSchemaFolder) resolve;
return postgisFolder.getService(new NullProgressMonitor()).getConnectionParams();
}
else if (resolve instanceof PostgisGeoResource2 ){
PostgisGeoResource2 layer = (PostgisGeoResource2) resolve;
PostgisService2 postgis;
try {
postgis = (PostgisService2) layer.parent( null );
return postgis.getConnectionParams();
} catch (IOException e) {
toCapabilitiesURL( layer.getIdentifier() );
}
}
}