catalog.add(featureType);
LOGGER.info( "Loaded feature type '" + featureType.getPrefixedName() + "'" );
// create a wms layer for the feature type
LayerInfo layer = factory.createLayer();
layer.setResource(featureType);
layer.setName(featureType.getName());
layer.setPath(ftInfoReader.wmsPath());
if ( layer.getPath() == null ) {
layer.setPath( "/" );
}
layer.setType(LayerInfo.Type.VECTOR);
String defaultStyleName = ftInfoReader.defaultStyle();
if ( defaultStyleName != null ) {
StyleInfo style = catalog.getStyleByName(defaultStyleName);
if ( style != null ) {
layer.setDefaultStyle(style);
}
}
List<String> styles = ftInfoReader.styles();
if(styles != null) {
for (String styleName : styles) {
StyleInfo style = catalog.getStyleByName(styleName);
if ( style != null ) {
layer.getStyles().add(style);
}
}
}
Map legendURL = ftInfoReader.legendURL();
if( legendURL != null ) {
LegendInfo legend = factory.createLegend();
legend.setHeight( (Integer) legendURL.get( "height" ) );
legend.setWidth( (Integer) legendURL.get( "width" ) );
legend.setFormat( (String) legendURL.get( "format" ) );
legend.setOnlineResource( (String) legendURL.get( "onlineResource" ) );
layer.setLegend( legend );
}
layer.setEnabled(featureType.isEnabled());
catalog.add(layer);
} catch( Exception e ) {
LOGGER.warning( "Error loadin '" + featureTypeDirectory.getName() + "/info.xml', ignoring" );
LOGGER.log( Level.INFO, "", e );
continue;
}
}
// for each coverage definition in coverage, read it
File coverages = new File(dir, "coverages");
if(!coverages.exists())
coverages.mkdir();
File[] coverageDirectories = coverages.listFiles();
for (int i = 0; i < coverageDirectories.length; i++) {
File coverageDirectory = coverageDirectories[i];
if (!coverageDirectory.isDirectory() || coverageDirectory.isHidden())
continue;
// load info.xml
File cInfoFile = new File(coverageDirectory, "info.xml");
if (!cInfoFile.exists()) {
LOGGER.fine("No info.xml found in directory: '" + coverageDirectory.getName() + "', ignoring");
continue;
}
LegacyCoverageInfoReader cInfoReader = new LegacyCoverageInfoReader();
try {
cInfoReader.read(cInfoFile);
CoverageInfo coverage = readCoverage(cInfoReader);
if ( coverage == null ) {
continue;
}
catalog.add(coverage);
// create a wms layer for the feature type
LayerInfo layer = factory.createLayer();
layer.setResource(coverage);
layer.setName(coverage.getName());
layer.setPath(cInfoReader.wmsPath());
if ( layer.getPath() == null ) {
layer.setPath( "/" );
}
layer.setType(LayerInfo.Type.RASTER);
String defaultStyleName = cInfoReader.defaultStyle();
if ( defaultStyleName != null ) {
StyleInfo style = catalog.getStyleByName(defaultStyleName);
if ( style != null ) {
layer.setDefaultStyle(style);
}
}
List<String> styles = cInfoReader.styles();
if(styles != null) {
for (String styleName : styles) {
StyleInfo style = catalog.getStyleByName(styleName);
if ( style != null ) {
layer.getStyles().add(style);
}
}
}
layer.setEnabled(coverage.isEnabled());
catalog.add(layer);
} catch(Exception e) {
LOGGER.warning( "Error loading '" + coverageDirectory.getName() + "/info.xml', ignoring" );
LOGGER.log( Level.INFO, "", e );