Skip to content

Commit

Permalink
Removed failure code for download
Browse files Browse the repository at this point in the history
  • Loading branch information
offtherailz committed Sep 26, 2022
1 parent f014bc0 commit f78bf3c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 76 deletions.
8 changes: 3 additions & 5 deletions web/client/epics/layerdownload.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import {

import { getLayerWFSCapabilities, getXMLFeature } from '../observables/wfs';
import { describeProcess } from '../observables/wps/describe';
import { download, downloadWithAttributesFilter } from '../observables/wps/download';
import { download } from '../observables/wps/download';
import { referenceOutputExtractor, makeOutputsExtractor, getExecutionStatus } from '../observables/wps/execute';

import { mergeFiltersToOGC } from '../utils/FilterUtils';
Expand Down Expand Up @@ -345,7 +345,7 @@ export const startFeatureExportDownload = (action$, store) =>
} : {})
},
notifyDownloadEstimatorSuccess: true,
attribute: propertyNames
attribute: isVectorLayer && propertyNames ? propertyNames : undefined
};
const newResult = {
id: uuidv1(),
Expand All @@ -357,9 +357,7 @@ export const startFeatureExportDownload = (action$, store) =>
outputsExtractor: makeOutputsExtractor(referenceOutputExtractor)
};

const executor = isVectorLayer && propertyNames ? downloadWithAttributesFilter : download;

return executor(action.url, wpsDownloadOptions, wpsExecuteOptions)
return download(action.url, wpsDownloadOptions, wpsExecuteOptions)
.takeUntil(action$.ofType(REMOVE_EXPORT_DATA_RESULT).filter(({id}) => id === newResult.id).take(1))
.flatMap((data) => {
if (data === 'DownloadEstimatorSuccess') {
Expand Down
72 changes: 1 addition & 71 deletions web/client/observables/wps/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export const download = (url, downloadOptions, executeOptions) => {
const resultOutput = downloadOptions.resultOutput || downloadOptions.outputFormat || 'application/zip';

const executeProcess$ = executeProcess(url, downloadXML({
...omit(downloadOptions, 'notifyDownloadEstimatorSuccess', 'attribute'),
...omit(downloadOptions, 'notifyDownloadEstimatorSuccess'),
outputAsReference: downloadOptions.asynchronous ? downloadOptions.outputAsReference : false,
resultOutput
}), executeOptions, {headers: {'Content-Type': 'application/xml', 'Accept': `application/xml, ${resultOutput}`}});
Expand All @@ -172,73 +172,3 @@ export const download = (url, downloadOptions, executeOptions) => {

return Observable.empty();
};


/**
* Execute gs:Download process and passes results to gs:Query, running gs:DownloadEstimator first
* @memberof observables.wps.download
* @param {string} url target url
* @param {object} downloadOptions options to use to construct payload xml for DownloadEstimator and Download processes(except notifyDownloadEstimatorSuccess). See {@link api/framework#observables.wps.download.exports.downloadXML|downloadXML}
* @param {boolean} downloadOptions.notifyDownloadEstimatorSuccess if true, the returned observable emits 'DownloadEstimatorSuccess' string after successful gs:DownloadEstimator run
* @param {object} executeOptions options to pass to executeProcess. See {@link api/framework#observables.wps.execute.exports.executeProcess|executeProcess}
*/
export const downloadWithAttributesFilter = (url, downloadOptions, executeOptions) => {
if (url && downloadOptions) {
const downloadEstimator$ = executeProcess(url, downloadEstimatorXML({
layerName: downloadOptions.layerName,
ROI: downloadOptions.ROI,
roiCRS: downloadOptions.roiCRS,
dataFilter: downloadOptions.dataFilter,
targetCRS: downloadOptions.targetCRS
}), {outputsExtractor: makeOutputsExtractor(literalDataOutputExtractor)});

// use the same format of outputFormat for result
// if resultOutput param is undefined
const resultOutput = downloadOptions.resultOutput || downloadOptions.outputFormat || 'application/zip';

const executeProcess$ = executeProcess(url, downloadXML({
...omit(downloadOptions, 'notifyDownloadEstimatorSuccess', 'attribute', 'asynchronous'),
asynchronous: true,
outputAsReference: true,
resultOutput: 'application/wfs-collection-1.0'
}), executeOptions, {headers: {'Content-Type': 'application/xml', 'Accept': `application/xml, application/wfs-collection-1.0`}});

return downloadEstimator$
.catch(() => {
throw new Error('DownloadEstimatorException');
})
.mergeMap((estimatorResult = []) => {
if (estimatorResult.length > 0 && estimatorResult[0].identifier === 'result' && estimatorResult[0].data === 'true') {
if (downloadOptions.notifyDownloadEstimatorSuccess) {
return Observable.of('DownloadEstimatorSuccess').concat(executeProcess$);
}
return executeProcess$;
}

throw new Error('DownloadEstimatorFailed');
})
.mergeMap((result) => {
if (result === 'DownloadEstimatorSuccess') {
return Observable.of('DownloadEstimatorSuccess');
}
if (result && result?.length === 1) {
return executeProcess(url, queryXML({
...omit(downloadOptions, 'notifyDownloadEstimatorSuccess'),
input: result[0],
filter: null,
outputAsReference: downloadOptions.asynchronous ? downloadOptions.outputAsReference : false,
resultOutput
}), executeOptions, {
headers: {
'Content-Type': 'application/xml',
'Accept': `application/xml, ${resultOutput}`
}
});
}

throw new Error('DownloadFailed');
});
}

return Observable.empty();
};

0 comments on commit f78bf3c

Please sign in to comment.