Hi all!
I'm working at the moment on a project where we want to use Geoserver as a cascading WFS. When I tried to use the WFS-DataStore in Geoserver, I couldn't even configure the WFS-DataStore. Entering a GET_CAPABILITIES_URL always ended in a "Could not find file..."-error.
This error has actually already been reported (http://www.nabble.com/WFS-as-datastore-t3945274.html) and jira-issue already exists (http://jira.codehaus.org/browse/GEOS-1164). Since I need to run Geoserver as cascading WFS quite urgently, I decided to try to fix this problem myself.
According to the response to the error report the problem is:
> As for you specific error, I believe that you're getting stuck because
> of a check we added lately. Basically, we were fed up of noticing
> shapefiles were badly configured (wrong path) only when trying to
> setup the feature type, so we added a generic check for URL existance
> on the file system... that is because both raster data and shapefiles
> use URL as the parameter that holds the "on the file system" path.
>
> That's obviously not working in your case, where the URL is a real
> internet URL for a change.
Since it was so well described, even I could locate the function that causes the problem, fix (somehow) the problem and now I can configure Geoserver as cascading WFS. To solve the problem I simply check the protocol of the URL and only perform the existence check if the protocol is "file". I only had to change the "special case check for url"-bit in the method "public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)" in "/web/src/main/java/org/vfny/geoserver/form/data/DataDataStoresEditorForm.java". It looks now like this:
//special case check for url
if (URL.class.equals(param.type)) {
String value = getParamValue(i);
if ((value != null) && !"".equals(value)) {
URL url = null;
try {
// if this does not throw an exception then cool
url = new URL(value);
if (url.getProtocol().equals("file")) {
//do a check to see if the file url is valid, report
// an error if it does not
File file = GeoserverDataDirectory.findDataFile(value);
FormUtils.checkFileExistsAndCanRead(file, errors);
}
//check for special case of file
try {
if (GeoserverDataDirectory.findDataFile(value).exists()) {
new URL("file://" + value);
setParamValues(i, "file://" + value);
//do a check to see if the file url is valid, report
// an error if it does not
File file = GeoserverDataDirectory.findDataFile(value);
FormUtils.checkFileExistsAndCanRead(file, errors);
}
} catch (MalformedURLException e1) {
//replace that with an adequate error message
String actionKey = "error.file.NotExists";
Object params = new Object { value };
errors.add("URL", new ActionMessage(actionKey, params));
}
}
return errors;
}
}
However this is my first encounter with the Geoserver code and I am not sure which other, possibly negative effects the changes I made in the code might have. So I wanted to ask you, if you could have a look at my solution and tell me if you think it's ok...
It would be great, if anyone could help me with that!
Thanks,
stefan
ps.
I also attached the my version of DataDataStoresEditorForm.java
(attachments)
DataDataStoresEditorForm.java (15.5 KB)