@PathVariable String name,
@RequestBody JSONObj obj,
HttpServletRequest req) {
Catalog cat = geoServer.getCatalog();
LayerGroupInfo map = findMap(wsName, name, cat);
WorkspaceInfo ws = map.getWorkspace();
if(obj.has("name")){
map.setName( obj.str("name"));
}
if(obj.has("title")){
map.setTitle(obj.str("title"));
}
if(obj.has("abstract")){
map.setAbstract(obj.str("abstract"));
}
if(obj.has("proj")&&obj.has("bbox")){
CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84;
if( obj.has("proj")){
String srs = obj.str("proj");
try {
crs = CRS.decode(srs);
} catch (FactoryException e) {
LOG.log(Level.FINE, wsName+"."+name+" unrecorgnized proj:"+srs,e);
}
}
Envelope envelope = IO.bounds(obj.object("bbox"));
ReferencedEnvelope bounds = new ReferencedEnvelope( envelope, crs );
map.setBounds(bounds);
}
if(obj.has("layers")){
List<LayerInfo> layers = new ArrayList<LayerInfo>();
for(Iterator<Object> i = obj.array("layers").iterator();i.hasNext();){
JSONObj l = (JSONObj) i.next();
String n = l.str("workspace")+":"+l.str("name");
LayerInfo layer = cat.getLayerByName(n);
layers.add(layer);
}
map.layers().clear();
map.layers().addAll(layers);
}
// update configuration history
String user = SecurityContextHolder.getContext().getAuthentication().getName();
map.getMetadata().put("user", user );
Date modified = new Date();
Metadata.modified(map, modified);
Metadata.modified(ws, modified);
if(obj.has("change")){
map.getMetadata().put("change", obj.str("change") );
}
else {
map.getMetadata().put("change", "modified "+obj.keys() );
}
cat.save(map);
cat.save(ws);
recent.add(LayerGroupInfo.class, map);