01: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
02: * This code is licensed under the GPL 2.0 license, availible at the root
03: * application directory.
04: */
05: package org.geoserver.wms.kvp;
06:
07: import org.geoserver.ows.KvpParser;
08: import org.vfny.geoserver.config.PaletteManager;
09: import org.vfny.geoserver.wms.WmsException;
10: import org.vfny.geoserver.wms.responses.palette.InverseColorMapOp;
11:
12: import java.awt.image.IndexColorModel;
13:
14: /**
15: *
16: * @author Simone Giannecchini, GeoSolutions SAS
17: *
18: */
19: public class PaletteKvpParser extends KvpParser {
20: public PaletteKvpParser() {
21: super ("palette", IndexColorModel.class);
22: }
23:
24: public Object parse(String value) throws Exception {
25: // palette
26: try {
27: final InverseColorMapOp model = PaletteManager
28: .getPalette(value);
29: if (model == null) {
30: throw new WmsException("Palette " + value
31: + " could not be found "
32: + "in $GEOSERVER_DATA_DIR/palettes directory");
33: }
34:
35: return model;
36: } catch (Exception e) {
37: throw new WmsException(e, "Palette " + value
38: + " could not be loaded", null);
39: }
40: }
41: }
|