Search in sources :

Example 1 with WmsLayerDefinition

use of com.revolsys.gis.wms.capabilities.WmsLayerDefinition in project com.revolsys.open by revolsys.

the class OgcWmsImageLayer method initializeDo.

@Override
protected boolean initializeDo() {
    final boolean initialized = super.initializeDo();
    if (initialized) {
        try {
            final WmsClient wmsClient;
            if (Property.hasValue(this.connectionName)) {
                final WebService<?> webService = WebServiceConnectionManager.getWebService(this.connectionName);
                if (webService == null) {
                    Logs.error(this, getPath() + ": Web service " + this.connectionName + ": no connection configured");
                    return false;
                } else if (webService instanceof WmsClient) {
                    wmsClient = (WmsClient) webService;
                } else {
                    Logs.error(this, getPath() + ": Web service " + this.connectionName + ": is not a OGS WMS service");
                    return false;
                }
            } else if (Property.hasValue(this.serviceUrl)) {
                wmsClient = new WmsClient(this.serviceUrl);
            } else {
                Logs.error(this, getPath() + ": A record store layer requires a connection entry with a name or url, username, and password ");
                return false;
            }
            final WmsLayerDefinition wmsLayerDefinition = wmsClient.getLayer(this.layerName);
            setWmsLayerDefinition(wmsLayerDefinition);
            return wmsLayerDefinition != null;
        } catch (final WrappedException e) {
            final Throwable cause = Exceptions.unwrap(e);
            if (cause instanceof UnknownHostException) {
                return setNotExists("Unknown host: " + cause.getMessage());
            } else {
                throw e;
            }
        }
    }
    return initialized;
}
Also used : WrappedException(com.revolsys.util.WrappedException) UnknownHostException(java.net.UnknownHostException) WmsLayerDefinition(com.revolsys.gis.wms.capabilities.WmsLayerDefinition) WmsClient(com.revolsys.gis.wms.WmsClient)

Aggregations

WmsClient (com.revolsys.gis.wms.WmsClient)1 WmsLayerDefinition (com.revolsys.gis.wms.capabilities.WmsLayerDefinition)1 WrappedException (com.revolsys.util.WrappedException)1 UnknownHostException (java.net.UnknownHostException)1