use of com.revolsys.util.WrappedException 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;
}
use of com.revolsys.util.WrappedException in project com.revolsys.open by revolsys.
the class ArcGisRestServerTileCacheLayer method initializeDo.
@Override
protected boolean initializeDo() {
synchronized (this.initSync) {
if (this.mapService == null) {
try {
if (Property.hasValue(this.connectionName)) {
final WebService<?> webService = WebServiceConnectionManager.getWebService(this.connectionName);
if (webService instanceof ArcGisRestCatalog) {
final ArcGisRestCatalog catalog = (ArcGisRestCatalog) webService;
final WebServiceResource service = catalog.getWebServiceResource(this.servicePath);
if (service instanceof MapService) {
this.mapService = (MapService) service;
} else {
Logs.error(this, getPath() + ": Web service " + this.connectionName + " is not a ArcGIS service");
return false;
}
} else {
Logs.error(this, getPath() + ": Web service " + this.connectionName + " " + this.servicePath + " is not a ArcGIS Map service");
return false;
}
} else {
// TODO username/password
this.mapService = MapService.getMapService(this.url);
}
if (this.mapService == null) {
Logs.error(this, "Unable to connect to ArcGIS rest server");
return false;
} else {
final TileInfo tileInfo = this.mapService.getTileInfo();
if (tileInfo == null) {
Logs.info(this, this.url + " does not contain a tileInfo definition.");
return false;
} else {
this.geometryFactory = tileInfo.getGeometryFactory();
final BoundingBox boundingBox = this.mapService.getFullExtent();
setBoundingBox(boundingBox);
return true;
}
}
} catch (final WrappedException e) {
final Throwable cause = Exceptions.unwrap(e);
if (cause instanceof UnknownHostException) {
// cause.getMessage());
return setNotExists("Unknown host: " + cause.getMessage());
} else {
throw e;
}
}
} else {
return true;
}
}
}
use of com.revolsys.util.WrappedException in project com.revolsys.open by revolsys.
the class Logs method getMessageAndException.
public static Throwable getMessageAndException(final StringBuilder messageText, final String message, final Throwable e) {
Throwable logException = e;
final Set<String> messages = Sets.newLinkedHash(message);
if (Property.hasValue(message)) {
messageText.append(message);
}
while (logException instanceof WrappedException || logException instanceof NestedRuntimeException) {
if (messageText.length() > 0) {
messageText.append('\n');
}
messageText.append(logException.getClass().getName());
messageText.append(": ");
final String wrappedMessage = logException.getMessage();
if (messages.add(wrappedMessage)) {
messageText.append(wrappedMessage);
}
final Throwable cause = logException.getCause();
if (cause == null) {
break;
} else {
logException = cause;
}
}
if (logException instanceof SQLException) {
final SQLException sqlException = (SQLException) logException;
final List<Throwable> exceptions = Lists.toArray(sqlException);
final int exceptionCount = exceptions.size();
if (exceptionCount > 0) {
logException = exceptions.remove(exceptionCount - 1);
for (final Throwable throwable : exceptions) {
if (messageText.length() > 0) {
messageText.append('\n');
}
if (throwable == sqlException) {
messageText.append(sqlException.getClass().getName());
messageText.append(": ");
final String wrappedMessage = sqlException.getMessage();
if (messages.add(wrappedMessage)) {
messageText.append(wrappedMessage);
}
} else {
messageText.append(Exceptions.toString(throwable));
}
}
}
}
return logException;
}
Aggregations