32 |
* connection into a {@link String} with {@link #toPropertiesString()} and |
* connection into a {@link String} with {@link #toPropertiesString()} and |
33 |
* re-import the String with {@link #parsePropertiesString(String)}. |
* re-import the String with {@link #parsePropertiesString(String)}. |
34 |
*/ |
*/ |
35 |
public class WfsServerSettings extends HashMap<Object, Object> { |
public class WfsServerSettings extends ServerSettings<Object, Object> { |
36 |
|
|
37 |
public enum Key { |
public enum Key { |
38 |
BASE_URL, VERSION |
BASE_URL, VERSION |
83 |
} |
} |
84 |
} |
} |
85 |
|
|
86 |
/** |
private static final URL defaultURl; |
87 |
* Character used to separate the parameters when serializing settings to a |
static { |
88 |
* String |
try { |
89 |
*/ |
defaultURl = new URL("http://localhost:8080/geoserver/ows"); |
90 |
private static final String DELIMITER = "|"; |
} catch (MalformedURLException e) { |
91 |
|
throw new RuntimeException(e); |
92 |
|
} |
93 |
|
} |
94 |
|
|
95 |
/** |
/** |
96 |
* Opens a GUI that asks the use define a DB connection. |
* Opens a GUI that asks the use define a DB connection. |
211 |
wfs.setTitle(split[i++]); |
wfs.setTitle(split[i++]); |
212 |
wfs.setBaseUrl(new URL(split[i++])); |
wfs.setBaseUrl(new URL(split[i++])); |
213 |
wfs.setVersion(WfsProtocollVersion.valueOf(split[i++])); |
wfs.setVersion(WfsProtocollVersion.valueOf(split[i++])); |
214 |
wfs.setMaxFeatures(java.lang.Integer.valueOf(split[i++])); |
wfs.setMaxFeatures(intOrNull(split[i++])); |
215 |
wfs.setTimeout(java.lang.Integer.valueOf(split[i++])); |
wfs.setTimeout(intOrNull(split[i++])); |
216 |
wfs.setLenient(java.lang.Boolean.valueOf(split[i++])); |
wfs.setLenient(java.lang.Boolean.valueOf(split[i++])); |
217 |
wfs.setHttpProtocol(HttpProtocol.parse(split[i++])); |
wfs.setHttpProtocol(HttpProtocol.parse(split[i++])); |
218 |
|
|
219 |
String userRaw = split[i++]; |
wfs.setUsername(stringOrNull(split[i++])); |
|
wfs.setUsername(userRaw.equals("null") ? null : userRaw); |
|
220 |
|
|
221 |
String pwdRaw = split[i++]; |
wfs.setPassword(stringOrNull(split[i++])); |
|
wfs.setPassword(pwdRaw.equals("null") ? null : pwdRaw); |
|
222 |
|
|
223 |
return wfs; |
return wfs; |
224 |
} catch (Exception e) { |
} catch (Exception e) { |
225 |
Log.warn("couldn't parse " + propString); |
Log.warn("couldn't parse " + propString, e); |
226 |
return null; |
return null; |
227 |
} |
} |
228 |
|
|
229 |
} |
} |
230 |
|
|
231 |
private String[] cachedTypeNames = null; |
private String[] cachedTypeNames = null; |
|
private String title; |
|
232 |
|
|
233 |
public WfsServerSettings() { |
public WfsServerSettings() { |
234 |
try { |
this(defaultURl, WfsProtocollVersion.v1_0_0); |
|
setBaseUrl(new URL("http://localhost:8080/geoserver/ows")); |
|
|
} catch (MalformedURLException e) { |
|
|
throw new RuntimeException(e); |
|
|
} |
|
235 |
} |
} |
236 |
|
|
237 |
public WfsServerSettings(URL baseUrl, WfsProtocollVersion version) { |
public WfsServerSettings(URL baseUrl, WfsProtocollVersion version) { |
238 |
setVersion(version); |
setVersion(version); |
239 |
setBaseUrl(baseUrl); |
setBaseUrl(baseUrl); |
240 |
|
setLenient(false); |
241 |
} |
} |
242 |
|
|
243 |
public URL getBaseUrl() { |
public URL getBaseUrl() { |
264 |
return (java.lang.Integer) get(WFSDataStoreFactory.TIMEOUT.key); |
return (java.lang.Integer) get(WFSDataStoreFactory.TIMEOUT.key); |
265 |
} |
} |
266 |
|
|
|
public String getTitle() { |
|
|
if (title == null) |
|
|
return toString(); |
|
|
return title; |
|
|
} |
|
|
|
|
267 |
public WfsProtocollVersion getVersion() { |
public WfsProtocollVersion getVersion() { |
268 |
return (WfsProtocollVersion) get(Key.VERSION); |
return (WfsProtocollVersion) get(Key.VERSION); |
269 |
} |
} |
363 |
serialized.append(DELIMITER); |
serialized.append(DELIMITER); |
364 |
|
|
365 |
serialized.append(getPassword()); |
serialized.append(getPassword()); |
366 |
serialized.append(DELIMITER); |
// serialized.append(DELIMITER); |
367 |
|
|
368 |
return serialized.toString(); |
return serialized.toString(); |
369 |
} |
} |
406 |
} |
} |
407 |
} |
} |
408 |
|
|
|
public void setTitle(String title) { |
|
|
if (title != null) { |
|
|
if (title.contains(DELIMITER)) |
|
|
throw new IllegalArgumentException("Title may not contain " |
|
|
+ DELIMITER); |
|
|
if (title.contains(WfsServerList.DELIMITER)) |
|
|
throw new IllegalArgumentException("Title may not contain " |
|
|
+ WfsServerList.DELIMITER); |
|
|
} |
|
|
this.title = title; |
|
|
} |
|
|
|
|
409 |
public void setPassword(String password) { |
public void setPassword(String password) { |
410 |
if (password != null && password.isEmpty()) |
if (password != null && password.isEmpty()) |
411 |
password = null; |
password = null; |