}
}
}
// set the namespace uri
NamespaceInfo namespace = catalog.getNamespaceByPrefix( info.getWorkspace().getName() );
connectionParameters.put( "namespace", namespace.getURI() );
// ensure the parameters are valid
if ( !factory.canProcess( connectionParameters ) ) {
//TODO: log the parameters at the debug level
throw new RestletException( "Unable to configure datastore, bad parameters.", Status.SERVER_ERROR_INTERNAL );
}
//add or update the datastore info
if ( add ) {
catalog.add( info );
}
else {
catalog.save( info );
}
//check configure parameter, if set to none to not try to configure
// data feature types
String configure = form.getFirstValue( "configure" );
if ( "none".equalsIgnoreCase( configure ) ) {
getResponse().setStatus( Status.SUCCESS_CREATED );
return;
}
//load the datastore
try {
DataStore ds = (DataStore) info.getDataStore(null);
String[] featureTypeNames = ds.getTypeNames();
for ( int i = 0; i < featureTypeNames.length; i++ ) {
//unless configure specified "all", only configure the first feature type
if ( !"all".equalsIgnoreCase( configure ) && i > 0 ) {
break;
}
FeatureSource fs = ds.getFeatureSource(featureTypeNames[i]);
FeatureTypeInfo ftinfo = null;
if ( add ) {
//auto configure the feature type as well
ftinfo = builder.buildFeatureType(fs);
builder.lookupSRS(ftinfo, true);
builder.setupBounds(ftinfo);
}
else {
ftinfo = catalog.getFeatureTypeByName( namespace.getPrefix(), featureTypeNames[i] );
}
//update the bounds
ReferencedEnvelope bounds = fs.getBounds();
ftinfo.setNativeBoundingBox( bounds );