All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.vfny.geoserver.action.data.DataCoveragesNewAction Maven / Gradle / Ivy

There is a newer version: 1.7.0
Show newest version
/* 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.vfny.geoserver.action.data;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.geotools.coverage.grid.GridCoverage2D;
import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader;
import org.geotools.coverage.grid.io.AbstractGridFormat;
import org.geotools.parameter.DefaultParameterDescriptor;
import org.opengis.coverage.grid.Format;
import org.opengis.coverage.grid.GridCoverage;
import org.opengis.coverage.grid.GridCoverageReader;
import org.opengis.parameter.GeneralParameterValue;
import org.opengis.parameter.InvalidParameterValueException;
import org.opengis.parameter.ParameterDescriptor;
import org.opengis.parameter.ParameterNotFoundException;
import org.opengis.parameter.ParameterValue;
import org.opengis.parameter.ParameterValueGroup;
import org.vfny.geoserver.action.ConfigAction;
import org.vfny.geoserver.config.CoverageConfig;
import org.vfny.geoserver.config.DataConfig;
import org.vfny.geoserver.form.data.DataCoveragesNewForm;
import org.vfny.geoserver.global.ConfigurationException;
import org.vfny.geoserver.global.CoverageStoreInfo;
import org.vfny.geoserver.global.Data;
import org.vfny.geoserver.global.GeoserverDataDirectory;
import org.vfny.geoserver.global.UserContainer;
import org.vfny.geoserver.util.CoverageUtils;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * DataCoveragesNewAction purpose.
 *
 * 

* Description of DataCoveragesNewAction ... *

* *

* Capabilities: *

* *
    *
  • Coverage: description
  • *
* *

* Example Use: *

* *

 *     DataCoveragesNewAction x = new DataCoveragesNewAction(...);
 * 
* * @author rgould, Refractions Research, Inc. * @author cholmesny * @author $Author: Alessio Fabiani ([email protected]) $ (last * modification) * @author $Author: Simone Giannecchini ([email protected]) $ (last * modification) * @version $Id: DataCoveragesNewAction.java,v 1.15 2004/09/17 16:34:47 * cholmesny Exp $ */ public class DataCoveragesNewAction extends ConfigAction { public final static String NEW_COVERAGE_KEY = "newCoverage"; public ActionForward execute(ActionMapping mapping, ActionForm incomingForm, UserContainer user, HttpServletRequest request, HttpServletResponse response) throws ConfigurationException { final DataCoveragesNewForm form = (DataCoveragesNewForm) incomingForm; final String formatID = form.getSelectedNewCoverage(); final Data catalog = getData(); CoverageStoreInfo cvStoreInfo = catalog.getFormatInfo(formatID); if (cvStoreInfo == null) { cvStoreInfo = new CoverageStoreInfo(getDataConfig().getDataFormat(formatID).toDTO(), catalog); } CoverageConfig coverageConfig = newCoverageConfig(cvStoreInfo, formatID, request); user.setCoverageConfig(coverageConfig); return mapping.findForward("config.data.coverage.editor"); } /** * Static method so that the CoverageStore editor can do the same thing that the new one * does.*/ public static CoverageConfig newCoverageConfig(CoverageStoreInfo cvStoreInfo, String formatID, HttpServletRequest request) throws ConfigurationException { //GridCoverage gc = null; final Format format = cvStoreInfo.getFormat(); AbstractGridCoverage2DReader reader = (AbstractGridCoverage2DReader) cvStoreInfo.getReader(); if (reader == null) { reader = (AbstractGridCoverage2DReader) ((AbstractGridFormat) format).getReader(GeoserverDataDirectory .findDataFile(cvStoreInfo.getUrl())); } if (reader == null) { throw new ConfigurationException( "Could not obtain a reader for the CoverageDataSet. Please check the CoverageDataSet configuration!"); } CoverageConfig coverageConfig = new CoverageConfig(formatID, format, reader, request); request.setAttribute(NEW_COVERAGE_KEY, "true"); request.getSession().setAttribute(DataConfig.SELECTED_COVERAGE, coverageConfig); return coverageConfig; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy