Commit 11038c15 authored by Andrea Aime's avatar Andrea Aime
Browse files

[GEOS-7186] The WPS Download process cannot use output formats plugged via a factory

parent dd10b5bf
......@@ -32,6 +32,9 @@ import org.geotools.util.logging.Logging;
import org.opengis.filter.Filter;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.util.ProgressListener;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import com.vividsolutions.jts.geom.Geometry;
......@@ -47,7 +50,7 @@ import com.vividsolutions.jts.geom.Geometry;
*/
@SuppressWarnings("deprecation")
@DescribeProcess(title = "Enterprise Download Process", description = "Downloads Layer Stream and provides a ZIP.")
public class DownloadProcess implements GSProcess {
public class DownloadProcess implements GSProcess, ApplicationContextAware {
/** The LOGGER. */
private static final Logger LOGGER = Logging.getLogger(DownloadProcess.class);
......@@ -60,6 +63,8 @@ public class DownloadProcess implements GSProcess {
private WPSResourceManager resourceManager;
private ApplicationContext context;
/**
* Instantiates a new download process.
*
......@@ -183,7 +188,7 @@ public class DownloadProcess implements GSProcess {
// VECTOR
//
// perform the actual download of vectorial data accordingly to the request inputs
internalOutput = new VectorDownload(limits, resourceManager).execute(
internalOutput = new VectorDownload(limits, resourceManager, context).execute(
(FeatureTypeInfo) resourceInfo, mimeType, roi, clip, filter, targetCRS,
progressListener);
......@@ -196,7 +201,8 @@ public class DownloadProcess implements GSProcess {
//
CoverageInfo cInfo = (CoverageInfo) resourceInfo;
// convert/reproject/crop if needed the coverage
internalOutput = new RasterDownload(limits, resourceManager).execute(mimeType,
internalOutput = new RasterDownload(limits, resourceManager, context)
.execute(mimeType,
progressListener, cInfo, roi, targetCRS, clip, filter);
} else {
......@@ -292,4 +298,10 @@ public class DownloadProcess implements GSProcess {
throw processException;
}
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.context = applicationContext;
}
}
\ No newline at end of file
......@@ -5,9 +5,6 @@
*/
package org.geoserver.wps.gs.download;
import it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl;
import it.geosolutions.io.output.adapter.OutputStreamAdapter;
import java.io.File;
import java.io.IOException;
import java.util.List;
......@@ -42,9 +39,13 @@ import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.datum.PixelInCell;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.util.ProgressListener;
import org.springframework.context.ApplicationContext;
import com.vividsolutions.jts.geom.Geometry;
import it.geosolutions.imageio.stream.output.FileImageOutputStreamExtImpl;
import it.geosolutions.io.output.adapter.OutputStreamAdapter;
/**
* Implements the download services for raster data. If limits are configured this class will use {@link LimitedImageOutputStream}, which raises an
* exception when the download size exceeded the limits.
......@@ -62,15 +63,24 @@ class RasterDownload {
/** The resource manager for handling the used resources. */
private WPSResourceManager resourceManager;
/**
* The application context used to look-up PPIO factories
*/
private ApplicationContext context;
/**
* Constructor, takes a {@link DownloadEstimatorProcess}.
*
* @param limits the {@link DownloadEstimatorProcess} to check for not exceeding the download limits.
* @param limits the {@link DownloadEstimatorProcess} to check for not exceeding the download
* limits.
* @param resourceManager the {@link WPSResourceManager} to handl generated resources
* @param context
*/
public RasterDownload(DownloadServiceConfiguration limits, WPSResourceManager resourceManager) {
public RasterDownload(DownloadServiceConfiguration limits, WPSResourceManager resourceManager,
ApplicationContext context) {
this.limits = limits;
this.resourceManager = resourceManager;
this.context = context;
}
/**
......@@ -285,8 +295,10 @@ class RasterDownload {
}
// Search a proper PPIO
ProcessParameterIO ppio_ = DownloadUtilities.find(new Parameter<GridCoverage2D>(
"fakeParam", GridCoverage2D.class), null, mimeType, false);
Parameter<GridCoverage2D> gridParam = new Parameter<GridCoverage2D>("fakeParam",
GridCoverage2D.class);
ProcessParameterIO ppio_ = DownloadUtilities.find(gridParam, context, mimeType,
false);
if (ppio_ == null) {
throw new ProcessException("Don't know how to encode in mime type " + mimeType);
} else if (!(ppio_ instanceof ComplexPPIO)) {
......
......@@ -34,6 +34,7 @@ import org.opengis.filter.spatial.Intersects;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.util.ProgressListener;
import org.springframework.context.ApplicationContext;
import com.vividsolutions.jts.geom.Geometry;
......@@ -54,15 +55,19 @@ class VectorDownload {
/** The resource manager for handling the used resources. */
private WPSResourceManager resourceManager;
private ApplicationContext context;
/**
* Constructor, takes a {@link DownloadServiceConfiguration} and a {@link WPSResourceManager}.
*
* @param limits the {@link DownloadServiceConfiguration} to check for not exceeding the download limits.
* @param resourceManager the {@link WPSResourceManager} to handle generated resources
*/
public VectorDownload(DownloadServiceConfiguration limits, WPSResourceManager resourceManager) {
public VectorDownload(DownloadServiceConfiguration limits, WPSResourceManager resourceManager,
ApplicationContext context) {
this.limits = limits;
this.resourceManager = resourceManager;
this.context = context;
}
/**
......@@ -220,7 +225,8 @@ class VectorDownload {
}
// Search a proper PPIO
ProcessParameterIO ppio_ = DownloadUtilities.find(new Parameter<SimpleFeatureCollection>(
"fakeParam", SimpleFeatureCollection.class), null, mimeType, false);
"fakeParam", SimpleFeatureCollection.class),
context, mimeType, false);
if (ppio_ == null) {
throw new ProcessException("Don't know how to encode in mime type " + mimeType);
} else if (!(ppio_ instanceof ComplexPPIO)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment