[Geoserver-devel] DataStoreConfig/Form/Action fixed to handle Param correctly

PostgisDataStoreFactory has been updated with strongly typed Param objects now.

Param has the following fields:
- key - key used to locate value in map
- description - describes parameter for end-user
- type - Class expected by DataStore
- required - true if required
- sample - true

The Param class now has:
-parse( String text )
-text( Object value )

PostgisDataStoreFactory has example of overiding these two methods to handle Charset. Most classes (Integer,String,Date) can be used directly without modification. Param makes use of reflection for parse( text ) - searching for a constructor that takes a single String as argument. Param uses toString for text( value ).

At the higher level Param defines:
- handle( String text ) - used to isolate parse from null and "", wraps any exception in a IOException
- lookUp( Map ) - safely lookup value in map, will promote to actual Value if a String is found

I know I am working up hill here especially with a Bean/BeanInfo based DataStoreFactory lurking on the email list.
I hope lookUp/handle can ease the burden of DataStore writers and clients move over to strongly typed parameters.

Example from PostgisDataStore:

new Param("dbtype", String.class, "must be 'postgis'", true, "postgis");
new Param("host", String.class, "postgis host machine", true, "localhost");
new Param("port", Integer.class, "postgis connection port", true, new Integer(5432));
new Param("database", String.class,"postgis database");
new Param("user", String.class,"user name to login as");
new Param("passwd", String.class,"password used to login", false);
new Param("charset", Charset.class,"character set", false, "ISO-8859-1") {
            public Object parse(String text) throws IOException {
                return Charset.forName(text);
            }
            public String text(Object value) {
                return ((Charset) value).name();
            }
        };
NAMESPACE = new Param("namespace", String.class,"namespace prefix used", false);

Of note:
- Use of sample value for charset, dbtype,host, port
- Use of custom parse/text for charset

Using the Params:
public DataStore createDataStore(Map params) throws IOException {
        String host = (String) HOST.lookUp(params);
        String user = (String) USER.lookUp(params);
        String passwd = (String) PASSWD.lookUp(params);
        Integer port = (Integer) PORT.lookUp(params);
        String database = (String) DATABASE.lookUp(params);
        Charset charSet = (Charset) CHARSET.lookUp(params);
        String namespace = (String) NAMESPACE.lookUp(params);

        // Try processing params first so we can get an error message
        // back to the user
        //
        if (!canProcess(params)) {
            return null;
        }
         ...
}

Questions:
- namespace: postgis seems use a "namespace" entry as a way to seed the DataStore with the expected namespace prefix for use in FeatureType. Should all datastore do this?
- user & passwd: Similarly should all datastores use these as a standard?

It would be nice if these kind of tags were standard (would allow for use of password field in generated html).
For those thinking in terms of Java Beans, we may wish to define an interface that has common properties: namespace, user and password.

Cheers.
Jody