Package org.geoserver.csw

Source Code of org.geoserver.csw.GetRepositoryItem

/* (c) 2014 Open Source Geospatial Foundation - all rights reserved
* (c) 2001 - 2013 OpenPlans
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
package org.geoserver.csw;

import java.io.IOException;
import org.geoserver.csw.store.CatalogStore;
import org.geoserver.csw.store.RepositoryItem;
import org.geoserver.ows.HttpErrorCodeException;
import org.geoserver.platform.ServiceException;

/**
* Runs the GetRepositoryItem request
*
* @author Alessio Fabiani - GeoSolutions
*/
public class GetRepositoryItem {

    CSWInfo csw;

    CatalogStore store;

    public GetRepositoryItem(CSWInfo csw, CatalogStore store) {
        this.csw = csw;
        this.store = store;
    }

    /**
     * Returns the requested RepositoryItem
     *
     * @param request
     * @return
     */
    public RepositoryItem run(GetRepositoryItemType request)  {
        try {
            RepositoryItem item = store.getRepositoryItem(request.getId());
            if(item == null) {
                // by spec we have to return a 404
                throw new HttpErrorCodeException(404, "No repository item found for id " + request.getId());
            }
            return item;
        } catch (IOException e) {
            throw new ServiceException("Failed to load the repository item", e);
        }
    }
}
TOP

Related Classes of org.geoserver.csw.GetRepositoryItem

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.