tim@52: package de.intevation.gnv.artifacts.context; tim@52: sascha@521: import java.awt.Color; sascha@521: import java.awt.Paint; sascha@521: tim@52: import java.io.FileInputStream; tim@52: import java.io.FileNotFoundException; tim@52: import java.io.IOException; tim@52: import java.io.InputStream; ingo@369: import java.io.File; ingo@369: tim@52: import java.util.Properties; sascha@426: import java.util.HashMap; sascha@438: import java.util.ArrayList; sascha@444: import java.util.Collections; sascha@444: sascha@444: import java.awt.Dimension; tim@52: tim@52: import org.apache.log4j.Logger; sascha@426: tim@52: import org.w3c.dom.Document; sascha@426: import org.w3c.dom.Element; sascha@426: import org.w3c.dom.NodeList; sascha@426: sascha@426: import de.intevation.gnv.geobackend.base.connectionpool.ConnectionPoolFactory; sascha@426: sascha@426: import de.intevation.gnv.geobackend.base.query.container.QueryContainerFactory; sascha@426: import de.intevation.gnv.geobackend.base.query.container.exception.QueryContainerException; sascha@426: sascha@426: import de.intevation.gnv.chart.XMLChartTheme; sascha@426: sascha@426: import de.intevation.gnv.artifacts.cache.CacheFactory; sascha@426: sascha@426: import de.intevation.gnv.raster.Palette; sascha@444: import de.intevation.gnv.raster.Filter; sascha@438: import de.intevation.gnv.raster.PaletteManager; sascha@426: sascha@426: import de.intevation.artifacts.ArtifactContextFactory; tim@52: tim@52: import de.intevation.artifactdatabase.Config; ingo@369: import de.intevation.artifactdatabase.XMLUtils; tim@52: tim@52: /** sascha@442: * @author Tim Englich (tim.englich@intevation.de) sascha@442: * @author Ingo Weinzierl (iweinzierl@intevation.de) sascha@442: * @author Sascha L. Teichmann (sascha.teichmann@intevation.de) tim@52: */ tim@52: public class GNVArtifactContextFactory implements ArtifactContextFactory { tim@52: /** tim@52: * the logger, used to log exceptions and additonaly information tim@52: */ tim@52: private static Logger log = Logger.getLogger(GNVArtifactContext.class); tim@171: sascha@426: public static final String XPATH_GEOBACKEND_CONFIGURATION = sascha@426: "artifact-database/geo-backend/backend-configuration"; tim@171: sascha@426: public static final String XPATH_GEOBACKEND_QUERYCONFIGURATION = sascha@426: "artifact-database/geo-backend/query-configuration"; tim@171: sascha@426: private final static String CACHECONFIGNODEPATH = sascha@426: "/artifact-database/ehcache/configuration"; tim@171: sascha@426: private final static String CHARTCONFIGNODEPATH = sascha@442: "/artifact-database/gnv/charttemplate/configuration"; sascha@426: sascha@426: public final static String PALETTES_PATH = sascha@442: "/artifact-database/gnv/palettes"; sascha@426: sascha@426: public final static String PALETTE_ITEMS = sascha@426: "palette"; sascha@426: sascha@443: public final static String HORIZONTAL_CROSS_SECTION_PROFILE_SAMPLES = sascha@443: "/artifact-database/gnv/horizontal-cross-section-profile/samples/@number"; ingo@358: sascha@474: public final static String HORIZONTAL_CROSS_SECTION_GROUND_INTERPOLATION = sascha@474: "/artifact-database/gnv/horizontal-cross-section/ground/@interpolation"; sascha@474: tim@468: public final static String HORIZONTAL_CROSS_SECTION_SAMPLES = tim@468: "/artifact-database/gnv/horizontal-cross-section/samples/@number"; tim@468: sascha@593: public final static String HORIZONTAL_CROSS_SECTION_EXTRAPOLATION_ROUNDS = sascha@593: "/artifact-database/gnv/horizontal-cross-section/extrapolation/@rounds"; sascha@593: sascha@472: public final static String HORIZONTAL_CROSS_SECTION_RESULT_SHAPEFILE_PATH = sascha@472: "/artifact-database/gnv/horizontal-cross-section/result-shapefile-directory/@path"; sascha@472: sascha@444: public final static String VERTICAL_CROSS_SECTION_SAMPLES = sascha@444: "/artifact-database/gnv/vertical-cross-section/samples"; sascha@444: sascha@444: public final static String VERTICAL_CROSS_SECTION_FILTERS = sascha@444: "/artifact-database/gnv/vertical-cross-section/filters/filter"; sascha@444: sascha@463: public final static String VERTICAL_CROSS_SECTION_GROUND_INTERPOLATION = sascha@463: "/artifact-database/gnv/vertical-cross-section/ground/@interpolation"; sascha@463: sascha@521: public final static String VERTICAL_CROSS_SECTION_GROUND_FILL_COLOR = sascha@521: "/artifact-database/gnv/vertical-cross-section/ground/@fill-color"; sascha@521: tim@52: /** tim@52: * Constructor tim@52: */ tim@52: public GNVArtifactContextFactory() { tim@52: super(); tim@52: log.debug("GNVArtifactContextFactory.Constructor"); tim@52: } tim@52: tim@52: /** tim@52: * @see de.intevation.artifacts.ArtifactContextFactory#createArtifactContext(org.w3c.dom.Document) tim@52: */ tim@52: public Object createArtifactContext(Document config) { ingo@358: GNVArtifactContext returnValue = null; tim@52: try { tim@52: log.debug("GNVArtifactContextFactory.createArtifactContext"); tim@52: log.info("Initialisation of the Geo-BackendConnectionPool"); tim@171: String backendConfigurationFile = Config.getStringXPath(config, tim@171: XPATH_GEOBACKEND_CONFIGURATION); sascha@426: backendConfigurationFile = Config.replaceConfigDir( sascha@426: backendConfigurationFile); tim@203: tim@52: Properties properties = getProperties(backendConfigurationFile); tim@52: ConnectionPoolFactory cpf = ConnectionPoolFactory.getInstance(); tim@52: cpf.initializeConnectionPool(properties); tim@171: tim@52: log.info("Initialisation of the QueryContainer"); tim@171: String queryConfigurationFile = Config.getStringXPath(config, tim@171: XPATH_GEOBACKEND_QUERYCONFIGURATION); sascha@426: queryConfigurationFile = Config.replaceConfigDir( sascha@426: queryConfigurationFile); tim@203: tim@52: Properties queryProperties = getProperties(queryConfigurationFile); tim@52: QueryContainerFactory qcf = QueryContainerFactory.getInstance(); tim@52: qcf.initializeQueryContainer(queryProperties); tim@171: tim@99: log.info("Initialisation of the Cache"); tim@171: String cacheConfigurationFile = Config.getStringXPath(config, tim@171: CACHECONFIGNODEPATH); sascha@426: cacheConfigurationFile = Config.replaceConfigDir( sascha@426: cacheConfigurationFile); sascha@426: tim@99: CacheFactory cf = CacheFactory.getInstance(); tim@99: cf.initializeCache(cacheConfigurationFile); tim@171: tim@52: returnValue = new GNVArtifactContext(config); ingo@358: sascha@426: configurePalettes(config, returnValue); sascha@426: sascha@426: configureChartTemplate(config, returnValue); sascha@426: sascha@443: configureHorizontalCrossSectionProfile(config, returnValue); sascha@426: tim@468: configureHorizontalCrossSection(config,returnValue); tim@468: sascha@444: configureVerticalCrossSection(config, returnValue); sascha@444: tim@52: } catch (FileNotFoundException e) { tim@171: log.error(e, e); tim@52: } catch (IOException e) { tim@171: log.error(e, e); tim@171: } catch (QueryContainerException e) { tim@171: log.error(e, e); tim@52: } tim@52: return returnValue; tim@52: } tim@52: sascha@444: protected void configureVerticalCrossSection( sascha@444: Document config, sascha@444: GNVArtifactContext context sascha@444: ) { sascha@444: log.info("configuration of vertical cross section"); sascha@444: configureVerticalCrossSectionSamples(config, context); sascha@444: configureVerticalCrossSectionFilters(config, context); sascha@463: configureVerticalCrossSectionGroundInterpolation(config, context); sascha@521: configureVerticalCrossSectionGroundFillColor(config, context); sascha@521: } sascha@521: sascha@521: protected void configureVerticalCrossSectionGroundFillColor( sascha@521: Document config, sascha@521: GNVArtifactContext context sascha@521: ) { sascha@521: log.info("configuration of vertical cross section ground fill color"); sascha@521: sascha@521: String fillColor = Config.getStringXPath( sascha@521: config, sascha@521: VERTICAL_CROSS_SECTION_GROUND_FILL_COLOR); sascha@521: sascha@521: Paint fill = sascha@521: GNVArtifactContext.DEFAULT_VERTICAL_CROSS_SECTION_GROUND_FILL; sascha@521: sascha@521: if (fillColor != null sascha@521: && (fillColor = fillColor.trim()).length() != 0) { sascha@521: try { sascha@521: Color color = Color.decode(fillColor); sascha@521: log.info("ground fill color: #" + sascha@521: Integer.toHexString(color.getRGB())); sascha@521: fill = color; sascha@521: } sascha@521: catch (NumberFormatException nfe) { sascha@521: log.error("'" + fillColor + "' is not a valid color"); sascha@521: } sascha@521: } sascha@521: sascha@521: context.put( sascha@521: GNVArtifactContext sascha@521: .VERTICAL_CROSS_SECTION_GROUND_FILL_KEY, sascha@521: fill); sascha@463: } sascha@463: sascha@463: protected void configureVerticalCrossSectionGroundInterpolation( sascha@463: Document config, sascha@463: GNVArtifactContext context sascha@463: ) { sascha@463: log.info("configuration of vertical cross section ground interpolation"); sascha@463: String interpolation = Config.getStringXPath( sascha@463: config, sascha@463: VERTICAL_CROSS_SECTION_GROUND_INTERPOLATION); sascha@463: sascha@463: if (interpolation == null sascha@463: || (interpolation = interpolation.trim()).length() == 0) { sascha@463: interpolation = GNVArtifactContext sascha@463: .DEFAULT_VERTICAL_CROSS_SECTION_GROUND_INTERPOLATION; sascha@463: } sascha@463: sascha@463: log.info("ground interpolation: " + interpolation); sascha@463: sascha@463: context.put( sascha@463: GNVArtifactContext sascha@463: .VERTICAL_CROSS_SECTION_GROUND_INTERPOLATION_KEY, sascha@463: interpolation); sascha@444: } sascha@444: sascha@444: protected void configureVerticalCrossSectionFilters( sascha@444: Document config, sascha@444: GNVArtifactContext context sascha@444: ) { sascha@444: log.info("configuration of vertical cross section filters"); sascha@444: sascha@444: NodeList filters = Config.getNodeSetXPath( sascha@444: VERTICAL_CROSS_SECTION_FILTERS); sascha@444: sascha@444: ArrayList filterFactories = sascha@444: new ArrayList(); sascha@444: sascha@444: if (filters == null) { sascha@444: log.warn("no filters found"); sascha@444: } sascha@444: else { sascha@444: for (int i = 0, N = filters.getLength(); i < N; ++i) { sascha@444: Element filterElement = (Element)filters.item(i); sascha@444: String factoryName = filterElement.getAttribute("factory"); sascha@444: if ((factoryName = factoryName.trim()).length() > 0) { sascha@444: try { sascha@444: Class clazz = Class.forName(factoryName); sascha@444: Filter.Factory filterFactory = sascha@444: (Filter.Factory)clazz.newInstance(); sascha@444: filterFactories.add(filterFactory); sascha@444: } sascha@444: catch (ClassNotFoundException cnfe) { sascha@444: log.error("filter class not found", cnfe); sascha@444: } sascha@444: catch (InstantiationException ie) { sascha@444: log.error("cannot instantiate filter factory", ie); sascha@444: } sascha@444: catch (IllegalAccessException iae) { sascha@444: log.error("cannot access filter factory", iae); sascha@444: } sascha@444: catch (ClassCastException cce) { sascha@444: log.error("not a filter factory class", cce); sascha@444: } sascha@444: } sascha@444: else { sascha@444: log.error("No factory name given"); sascha@444: } sascha@444: } sascha@444: } sascha@444: sascha@444: log.info("number of filters: " + filterFactories.size()); sascha@444: sascha@444: context.put( sascha@444: GNVArtifactContext.VERTICAL_CROSS_SECTION_FILTER_FACTORIES_KEY, sascha@444: Collections.unmodifiableList(filterFactories)); sascha@444: } sascha@444: sascha@444: protected void configureVerticalCrossSectionSamples( sascha@444: Document config, sascha@444: GNVArtifactContext context sascha@444: ) { sascha@444: log.info("configuration of vertical cross section samples"); sascha@444: sascha@444: Element samples = (Element)Config.getNodeXPath( sascha@444: VERTICAL_CROSS_SECTION_SAMPLES); sascha@444: sascha@444: Dimension sampleSize = new Dimension( sascha@444: GNVArtifactContext.DEFAULT_VERTICAL_CROSS_SECTION_SAMPLES); sascha@444: sascha@444: if (samples == null) { sascha@444: log.warn("no samples found"); sascha@444: } sascha@444: else { sascha@444: String widthString = samples.getAttribute("width"); sascha@444: if ((widthString = widthString.trim()).length() > 0) { sascha@444: try { sascha@444: sampleSize.width = Math.max(1, Integer.parseInt(widthString)); sascha@444: } sascha@444: catch (NumberFormatException nfe) { sascha@444: log.error("invalid value for width: '" + widthString + "'"); sascha@444: } sascha@444: } sascha@444: String heightString = samples.getAttribute("height"); sascha@444: if ((heightString = heightString.trim()).length() > 0) { sascha@444: try { sascha@444: sampleSize.height = Math.max(1, Integer.parseInt(heightString)); sascha@444: } sascha@444: catch (NumberFormatException nfe) { sascha@444: log.error("invalid value for height: '" + heightString + "'"); sascha@444: } sascha@444: } sascha@444: } sascha@444: log.info("samples (width x height): " + sascha@444: sampleSize.width + " x " + sampleSize.height); sascha@444: sascha@444: context.put( sascha@444: GNVArtifactContext.VERTICAL_CROSS_SECTION_SAMPLES_KEY, sascha@444: sampleSize); sascha@444: sascha@444: } sascha@444: sascha@443: protected void configureHorizontalCrossSectionProfile( sascha@443: Document config, sascha@443: GNVArtifactContext context sascha@443: ) sascha@443: { sascha@443: log.info("configuration of horizontal cross section profile"); sascha@443: sascha@443: String numSamples = Config.getStringXPath( sascha@443: config, sascha@443: HORIZONTAL_CROSS_SECTION_PROFILE_SAMPLES); sascha@443: sascha@443: Integer samples = sascha@443: GNVArtifactContext.DEFAULT_HORIZONTAL_CROSS_SECTION_PROFILE_SAMPLES; sascha@443: sascha@443: if (numSamples == null) { sascha@443: log.warn("No number of samples found."); sascha@443: } sascha@443: else { sascha@443: try { sascha@443: samples = Integer.valueOf(numSamples); sascha@443: } sascha@443: catch (NumberFormatException nfe) { sascha@443: log.warn("Invalid integer for number of samples"); sascha@443: } sascha@443: } sascha@443: sascha@443: log.info("# horizontal cross section profile samples: " + samples); sascha@443: sascha@443: context.put( sascha@443: GNVArtifactContext.HORIZONTAL_CROSS_SECTION_PROFILE_SAMPLES_KEY, sascha@443: samples); sascha@443: } tim@468: tim@468: protected void configureHorizontalCrossSection( sascha@472: Document config, sascha@472: GNVArtifactContext context sascha@472: ) { sascha@472: log.info("configuration of horizontal cross section"); sascha@472: sascha@472: configureHorizontalCrossSectionSamples(config, context); sascha@593: configureHorizontalCrossSectionExtrapolation(config, context); sascha@472: configureHorizontalCrossSectionResultShapeFilePath(config, context); sascha@474: configureHorizontalCrossSectionGroundInterpolation(config, context); sascha@474: } sascha@474: sascha@593: protected void configureHorizontalCrossSectionExtrapolation( sascha@593: Document config, sascha@593: GNVArtifactContext context sascha@593: ) sascha@593: { sascha@593: log.info( sascha@593: "configuration of horizontal cross section extrapolation"); sascha@593: sascha@593: String extrapolationRoundsValue = Config.getStringXPath( sascha@593: config, sascha@593: HORIZONTAL_CROSS_SECTION_EXTRAPOLATION_ROUNDS); sascha@593: sascha@593: Integer extrapolationRounds = sascha@593: GNVArtifactContext.DEFAULT_HORIZONTAL_CROSS_SECTION_EXTRAPOLATION_ROUNDS; sascha@593: sascha@593: if (extrapolationRoundsValue != null sascha@593: && (extrapolationRoundsValue = extrapolationRoundsValue.trim()).length() > 0 sascha@593: ) { sascha@593: try { sascha@593: extrapolationRounds = sascha@593: Integer.valueOf(extrapolationRoundsValue); sascha@593: } sascha@593: catch (NumberFormatException nfe) { sascha@593: log.error( sascha@593: "'" + extrapolationRoundsValue + "' is not a valid integer"); sascha@593: } sascha@593: } sascha@593: sascha@593: log.info("extrapolation rounds: " + extrapolationRounds); sascha@593: sascha@593: context.put( sascha@593: GNVArtifactContext sascha@593: .HORIZONTAL_CROSS_SECTION_EXTRAPOLATION_ROUNDS_KEY, sascha@593: extrapolationRounds); sascha@593: } sascha@593: sascha@474: protected void configureHorizontalCrossSectionGroundInterpolation( sascha@474: Document config, sascha@474: GNVArtifactContext context sascha@474: ) sascha@474: { sascha@474: log.info( sascha@474: "configuration of horizontal cross section ground interpolation"); sascha@474: sascha@474: String interpolation = Config.getStringXPath( sascha@474: config, sascha@474: HORIZONTAL_CROSS_SECTION_GROUND_INTERPOLATION); sascha@474: sascha@474: if (interpolation == null sascha@474: || (interpolation = interpolation.trim()).length() == 0) { sascha@474: interpolation = GNVArtifactContext sascha@474: .DEFAULT_HORIZONTAL_CROSS_SECTION_GROUND_INTERPOLATION; sascha@474: } sascha@474: sascha@474: log.info("ground interpolation: " + interpolation); sascha@474: sascha@474: context.put( sascha@474: GNVArtifactContext sascha@474: .HORIZONTAL_CROSS_SECTION_GROUND_INTERPOLATION_KEY, sascha@474: interpolation); sascha@472: } sascha@472: sascha@472: protected void configureHorizontalCrossSectionResultShapeFilePath( sascha@472: Document config, sascha@472: GNVArtifactContext context sascha@472: ) sascha@472: { sascha@472: log.info( sascha@472: "configuration of horizontal cross section result shape file path"); sascha@472: sascha@472: File dir = sascha@472: GNVArtifactContext. sascha@472: DEFAULT_HORIZONTAL_CROSS_SECTION_PROFILE_SHAPEFILE_PATH; sascha@472: sascha@472: String path = Config.getStringXPath( sascha@472: config, sascha@472: HORIZONTAL_CROSS_SECTION_RESULT_SHAPEFILE_PATH); sascha@472: sascha@472: if (path != null && (path = path.trim()).length() > 0) { sascha@472: dir = new File(Config.replaceConfigDir(path)); sascha@472: } sascha@472: else { sascha@472: log.warn("No 'result-shapefile-directory' given"); sascha@472: } sascha@472: sascha@472: log.info("writing shape files to '" sascha@472: + dir.getAbsolutePath() + "'"); sascha@472: sascha@472: context.put( sascha@472: GNVArtifactContext sascha@472: .HORIZONTAL_CROSS_SECTION_RESULT_SHAPEFILE_PATH_KEY, sascha@472: dir); sascha@472: } sascha@472: sascha@472: protected void configureHorizontalCrossSectionSamples( sascha@472: Document config, sascha@472: GNVArtifactContext context sascha@472: ) sascha@472: { sascha@472: log.info("configuration of horizontal cross section samples"); sascha@472: String numSamples = Config.getStringXPath( sascha@472: config, sascha@472: HORIZONTAL_CROSS_SECTION_SAMPLES); sascha@472: sascha@472: Integer samples = sascha@472: GNVArtifactContext.DEFAULT_HORIZONTAL_CROSS_SECTION_SAMPLES; sascha@472: sascha@472: if (numSamples == null) { sascha@472: log.warn("No number of samples found."); sascha@472: } sascha@472: else { sascha@472: try { sascha@472: samples = Integer.valueOf(numSamples); sascha@472: } sascha@472: catch (NumberFormatException nfe) { sascha@472: log.warn("Invalid integer for number of samples"); sascha@472: } sascha@472: } sascha@472: sascha@472: log.info("# horizontal cross section profile samples: " + samples); sascha@472: sascha@472: context.put( sascha@472: GNVArtifactContext.HORIZONTAL_CROSS_SECTION_SAMPLES_KEY, sascha@472: samples); sascha@472: } sascha@472: sascha@443: sascha@426: protected void configureChartTemplate( sascha@426: Document config, sascha@426: GNVArtifactContext context sascha@426: ) { sascha@426: log.info("Initialisation of chart template"); sascha@426: String chartConfigFile = Config.getStringXPath( sascha@426: config, CHARTCONFIGNODEPATH sascha@426: ); sascha@426: sascha@426: XMLChartTheme theme = new XMLChartTheme("XMLChartTheme"); sascha@443: sascha@443: if (chartConfigFile == null) { sascha@443: log.warn("no configuration file for chart template found"); sascha@426: } sascha@426: else { sascha@443: chartConfigFile = Config.replaceConfigDir(chartConfigFile); sascha@443: log.debug("Parse xml configuration of " + chartConfigFile); sascha@443: sascha@443: Document tmpl = XMLUtils.parseDocument(new File(chartConfigFile)); sascha@443: if (tmpl != null) { sascha@443: theme.applyXMLConfiguration(tmpl); sascha@443: } sascha@443: else { sascha@443: log.error( sascha@443: "Cannot load chart template from '" + sascha@443: chartConfigFile + "'"); sascha@443: } sascha@426: } sascha@426: sascha@443: context.put(GNVArtifactContext.CHART_TEMPLATE_KEY, theme); sascha@426: } sascha@426: sascha@426: protected void configurePalettes( sascha@426: Document config, sascha@426: GNVArtifactContext context sascha@426: ) { sascha@426: log.info("configure palettes"); sascha@426: sascha@438: HashMap palettes = new HashMap(); sascha@426: sascha@442: Element node = (Element)Config.getNodeXPath(config, PALETTES_PATH); sascha@426: sascha@426: if (node == null) { sascha@426: log.error("No palettes found"); sascha@426: } sascha@426: else { sascha@442: NodeList pals = node.getElementsByTagName(PALETTE_ITEMS); sascha@442: for (int i = 0, N = pals==null?0:pals.getLength(); i < N; ++i) { sascha@426: Element pal = (Element)pals.item(i); sascha@438: String name = pal.getAttribute("name"); sascha@438: String description = pal.getAttribute("description"); sascha@438: String filename = pal.getAttribute("file"); sascha@438: String parameterIds = pal.getAttribute("parameter-ids"); sascha@426: sascha@438: if (name == null || (name = name.trim()).length() == 0) { sascha@426: log.error("Palette has no 'name' attribute."); sascha@426: } sascha@438: else if (filename == null sascha@438: || (filename = filename.trim()).length() == 0) { sascha@438: log.error("Palette '" + name + "' has no 'file' attribute."); sascha@438: } sascha@438: else if (parameterIds == null sascha@438: || (parameterIds = parameterIds.trim()).length() == 0) { sascha@438: log.error("no parameter ids given for '" + name + "'"); sascha@426: } sascha@426: else { sascha@438: ArrayList ids = new ArrayList(); sascha@438: for (String idString: parameterIds.split("[\t ,]+")) { sascha@438: try { sascha@438: ids.add(Integer.valueOf(idString)); sascha@438: } sascha@438: catch (NumberFormatException nfe) { sascha@438: log.error( sascha@438: "parameter id '" + idString + "' is integer"); sascha@438: } sascha@438: } sascha@426: filename = Config.replaceConfigDir(filename); sascha@426: Document document = XMLUtils.parseDocument( sascha@426: new File(filename)); sascha@426: if (document == null) { sascha@426: log.error("Cannot load palette file '" + sascha@426: filename + "'"); sascha@426: } sascha@426: else { sascha@438: PaletteManager manager = new PaletteManager( sascha@438: name, sascha@438: description, sascha@438: new Palette(document)); sascha@438: for (Integer id: ids) { sascha@438: palettes.put(id, manager); sascha@438: } sascha@426: } sascha@426: } sascha@438: } // for all palettes sascha@426: } sascha@426: sascha@443: context.put(GNVArtifactContext.PALETTES_KEY, palettes); sascha@426: } sascha@426: tim@52: /** tim@52: * @param filePath tim@52: * @return tim@52: * @throws FileNotFoundException tim@52: * @throws IOException tim@52: */ tim@52: private Properties getProperties(String filePath) sascha@426: throws FileNotFoundException, IOException sascha@426: { sascha@172: InputStream inputStream = null; sascha@172: try { sascha@172: inputStream = new FileInputStream(filePath); sascha@172: Properties properties = new Properties(); sascha@172: properties.load(inputStream); sascha@172: return properties; sascha@172: } sascha@172: finally { sascha@172: if (inputStream != null) { sascha@172: try { inputStream.close(); } sascha@172: catch (IOException ioe) {} sascha@172: } sascha@172: } tim@52: } tim@52: }