//
UserContainer user = Requests.getUserContainer( request );
DataStoreConfig dsConfig = user.getDataStoreConfig();
//
// dsConfig is the only way to get a factory
DataStoreFactorySpi factory = dsConfig.getFactory();
Param[] info = factory.getParametersInfo();
Map connectionParams = new HashMap();
// Convert Params into the kind of Map we actually need
//
for (int i = 0; i < paramKeys.size(); i++) {
String key = (String) getParamKey(i);
Param param = DataStoreUtils.find(info, key);
if (param == null) {
errors.add("paramValue[" + i + "]",
new ActionError("error.dataStoreEditor.param.missing", key,
factory.getDescription()));
continue;
}
//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);
}
catch(MalformedURLException e) {
//check for special case of file
try {
if (new File(value).exists()) {
new URL("file://" + value);
setParamValues(i,"file://" + value);
}
}
catch (MalformedURLException e1) {
//let this paramter die later
}
}
}
}
Object value;
try {
value = param.lookUp(getParams());
if(value instanceof String)
value = param.parse((String)value);
} catch (IOException erp) {
errors.add("paramValue[" + i + "]",
new ActionError("error.dataStoreEditor.param.parse", key,
param.type, erp));
continue;
}catch(Throwable t){//thrown by param.parse()
errors.add("paramValue[" + i + "]",
new ActionError("error.dataStoreEditor.param.parse", key,
param.type, t));
continue;
}
if ((value == null) && param.required) {
errors.add("paramValue[" + i + "]",
new ActionError("error.dataStoreEditor.param.required", key));
continue;
}
if (value != null) {
connectionParams.put(key, value);
}
}
// put magic namespace into the mix
//
//connectionParams.put("namespace", getNamespaceId());
dump("form", connectionParams );
// Factory will provide even more stringent checking
//
if (!factory.canProcess( connectionParams )) {
errors.add("paramValue",
new ActionError("error.datastoreEditor.validation"));
}
return errors;