Source:
public StreamRawData execute( @DescribeParameter(name="typeName", description="Collection to download") String typeName, @DescribeParameter(name="cqlFilter", description="CQL Filter to apply", min=0) String cqlFilter, @DescribeParameter(name="callbackUrl", description="Callback URL", min=0) URL callbackUrl, @DescribeParameter(name="callbackParams", description="Parameters to append to the callback", min=0) String callbackParams, ProgressListener progressListener ) throws ProcessException { logger.info("execute"); try { LayerInfo layerInfo = catalog.getLayerByName(typeName); if (layerInfo == null) { throw new ProcessException(String.format("Failed to find typename '%s'", typeName)); } String dataPath = GeoServerResourceLoader.lookupGeoServerDataDirectory(context); GeoServerDataDirectory dataDirectory = new GeoServerDataDirectory(new File(dataPath)); String typeNamePath = dataDirectory.get(layerInfo).dir().getAbsolutePath(); String filePath = typeNamePath + "/" + NETCDF_FILENAME; NcdfDefinition definition = decodeDefinition(filePath); String dataStoreName = definition.getDataSource().getDataStoreName(); DataStoreInfo dsinfo = catalog.getDataStoreByName(dataStoreName); JDBCDataStore store = (JDBCDataStore) dsinfo.getDataStore(null); NcdfEncoderBuilder encoderBuilder = new NcdfEncoderBuilder(); encoderBuilder.setTmpCreationDir(workingDir) .setDefinition(definition) .setFilterExpr(cqlFilter) .setDataStore(store) .setSchema(store.getDatabaseSchema()); final File outputFile = getResourceManager().getTemporaryResource(".zip").file(); try ( NcdfEncoder encoder = encoderBuilder.create(); FileOutputStream os = new FileOutputStream(outputFile)) { encoder.prepare(new ZipFormatter(os)); while (encoder.writeNext()) { if (progressListener.isCanceled()) { throw new ProcessDismissedException("The job has been cancelled"); } } } notifySuccess(callbackUrl, callbackParams); FileInputStream fileInputStream = new FileInputStream(outputFile); return new StreamRawData("application/zip", fileInputStream, "zip"); } catch (Exception e) { notifyFailure(callbackUrl, callbackParams); throw new ProcessException(e); } }

Target:
public FileRawData execute( @DescribeParameter(name="typeName", description="Collection to download") String typeName, @DescribeParameter(name="cqlFilter", description="CQL Filter to apply", min=0) String cqlFilter, @DescribeParameter(name="callbackUrl", description="Callback URL", min=0) URL callbackUrl, @DescribeParameter(name="callbackParams", description="Parameters to append to the callback", min=0) String callbackParams, ProgressListener progressListener ) throws ProcessException { logger.info("execute"); try { LayerInfo layerInfo = catalog.getLayerByName(typeName); if (layerInfo == null) { throw new ProcessException(String.format("Failed to find typename '%s'", typeName)); } String dataPath = GeoServerResourceLoader.lookupGeoServerDataDirectory(context); GeoServerDataDirectory dataDirectory = new GeoServerDataDirectory(new File(dataPath)); String typeNamePath = dataDirectory.get(layerInfo).dir().getAbsolutePath(); String filePath = typeNamePath + "/" + NETCDF_FILENAME; NcdfDefinition definition = decodeDefinition(filePath); String dataStoreName = definition.getDataSource().getDataStoreName(); DataStoreInfo dsinfo = catalog.getDataStoreByName(dataStoreName); JDBCDataStore store = (JDBCDataStore) dsinfo.getDataStore(null); NcdfEncoderBuilder encoderBuilder = new NcdfEncoderBuilder(); encoderBuilder.setTmpCreationDir(workingDir) .setDefinition(definition) .setFilterExpr(cqlFilter) .setDataStore(store) .setSchema(store.getDatabaseSchema()); final File outputFile = getResourceManager().getTemporaryResource(".zip").file(); try ( NcdfEncoder encoder = encoderBuilder.create(); FileOutputStream os = new FileOutputStream(outputFile)) { encoder.prepare(new ZipFormatter(os)); while (encoder.writeNext()) { if (progressListener.isCanceled()) { throw new ProcessDismissedException("The job has been cancelled"); } } } notifySuccess(callbackUrl, callbackParams); return new FileRawData(outputFile, "application/zip", "zip"); } catch (Exception e) { notifyFailure(callbackUrl, callbackParams); throw new ProcessException(e); } }