CapabilitiesRequest capRequest = new CapabilitiesRequest("WMS");
capRequest.setHttpServletRequest(request);
WMS wms = capRequest.getWMS();
Data catalog = wms.getData();
Collection ftypes = catalog.getFeatureTypeInfos().values();
FeatureTypeInfo layer;
// 2) delete any existing generated files in the generation directory
ServletContext sc = request.getSession().getServletContext();
File rootDir = GeoserverDataDirectory.getGeoserverDataDirectory(sc);
File previewDir = new File(sc.getRealPath("data/generated"));
//File previewDir = new File(rootDir, "data/generated");
if (!previewDir.exists())
previewDir.mkdirs();
try {
emptyGeneratedDirectory(previewDir); // clear the contents of the directory
} catch (ConfigurationException e) {
e.printStackTrace();
}
// 3) Go through each FeatureType and collect information && write out config files
for (Iterator it = ftypes.iterator(); it.hasNext();)
{
layer = (FeatureTypeInfo) it.next();
Envelope bbox = layer.getLatLongBoundingBox();
if (layer.isEnabled())
{
// prepare strings for web output
ftList.add(layer.getNameSpace().getPrefix()+"_"+layer.getFeatureType().getTypeName()); // FeatureType name
ftnsList.add(layer.getNameSpace().getPrefix()+":"+layer.getFeatureType().getTypeName() );
dsList.add(layer.getDataStoreInfo().getId()); // DataStore info
// bounding box of the FeatureType
bboxList.add(bbox.getMinX()+", "+bbox.getMinY()+", "+bbox.getMaxX()+", "+bbox.getMaxY());
//save out the mapbuilder files
makeMapBuilderFiles(previewDir, layer, bbox);