Package org.geoserver.wcs.kvp

Source Code of org.geoserver.wcs.kvp.IdentifierKvpParser

/* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
* This code is licensed under the GPL 2.0 license, availible at the root
* application directory.
*/
package org.geoserver.wcs.kvp;

import static org.vfny.geoserver.wcs.WcsException.WcsExceptionCode.InvalidParameterValue;

import org.geoserver.catalog.Catalog;
import org.geoserver.catalog.LayerInfo;
import org.geoserver.ows.kvp.CodeTypeKvpParser;
import org.vfny.geoserver.wcs.WcsException;

public class IdentifierKvpParser extends CodeTypeKvpParser {

    private Catalog catalog;

    public IdentifierKvpParser(Catalog catalog) {
        super("identifier", "wcs");
        this.catalog = catalog;
    }

    @Override
    public Object parse(String value) throws Exception {
        LayerInfo layer = catalog.getLayerByName(value);
        if (layer == null || layer.getType() != LayerInfo.Type.RASTER)
            throw new WcsException("Could not find coverage '" + value + "'",
                    InvalidParameterValue, "identifier");
        return super.parse(value);
    }

}
TOP

Related Classes of org.geoserver.wcs.kvp.IdentifierKvpParser

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.