Skip to content

Commit 194e5b7

Browse files
authored
Merge pull request #283 from ngageoint/arcgis-config-error
ArcGIS plugin would crash if authentication fails
2 parents afced8a + b141128 commit 194e5b7

File tree

2 files changed

+53
-37
lines changed

2 files changed

+53
-37
lines changed

.vscode/launch.json

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,30 @@
2727
"<node_internals>/**"
2828
],
2929
"cwd": "${workspaceFolder}/service"
30+
},
31+
{
32+
"name": "mage server instance",
33+
"type": "node",
34+
"request": "launch",
35+
"runtimeExecutable": "npm",
36+
"runtimeArgs": [
37+
"run",
38+
"start:dev"
39+
],
40+
"trace": true,
41+
"env": {
42+
"NODE_PATH": "${workspaceFolder}/instance/node_modules",
43+
"MAGE_MONGO_URL": "mongodb://127.0.0.1/magedb"
44+
},
45+
"cwd": "${workspaceFolder}/instance",
46+
"console": "integratedTerminal",
47+
"preLaunchTask": "service:build",
48+
"sourceMaps": true,
49+
"outFiles": [
50+
"${workspaceFolder}/service/lib/**/*.js",
51+
"${workspaceFolder}/plugins/sftp/service/lib/**/*.js",
52+
"${workspaceFolder}/plugins/arcgis/service/lib/**/*.js"
53+
]
3054
}
3155
],
3256
"compounds": [
@@ -47,4 +71,4 @@
4771
"stopAll": true
4872
}
4973
]
50-
}
74+
}

plugins/arcgis/service/src/ObservationProcessor.ts

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -212,48 +212,40 @@ export class ObservationProcessor {
212212
/**
213213
* Gets information on all the configured features service layers.
214214
* @param {ArcGISPluginConfig} config The plugins configuration.
215-
* @returns {Promise<void>}
216215
*/
217216
private async getFeatureServiceLayers(config: ArcGISPluginConfig) {
218217
const promises = [];
219218
for (const service of config.featureServices) {
220-
try {
221-
promises.push(this.handleFeatureService(service, config))
222-
} catch (err) {
223-
console.error(err);
224-
}
225-
}
226-
await Promise.all(promises);
227-
}
228-
229-
/**
230-
* Called when information on a feature service is returned from an arc server.
231-
* @param {FeatureServiceResult} featureService The feature service.
232-
* @param {FeatureServiceConfig} featureServiceConfig The feature service config.
233-
* @param {ArcGISPluginConfig} config The plugin configuration.
234-
*/
235-
private async handleFeatureService(featureServiceConfig: FeatureServiceConfig, config: ArcGISPluginConfig) {
236-
const identityManager = await this._identityService.signin(featureServiceConfig)
237-
const featureService = new FeatureService(console, featureServiceConfig, identityManager)
238-
const arcService = await featureService.getService();
239-
240-
for (const featureLayer of arcService.layers) {
241-
const featureLayerConfig = featureServiceConfig.layers.find(layer => layer.layer.toString() === featureLayer.name.toString());
242-
if (featureLayerConfig) {
243-
const url = `${featureServiceConfig.url}/${featureLayer.id}`;
244-
const layerInfo = await featureService.getLayer(featureLayer.id);
245-
if (featureLayer.geometryType != null) {
246-
// TODO The featureLayerConfig should contain the layer id
247-
featureLayerConfig.layer = featureLayer.id;
248-
const admin = new FeatureServiceAdmin(config, this._identityService, this._console)
249-
const eventIds = featureLayerConfig.eventIds || []
250-
const layerFields = await admin.updateLayer(featureServiceConfig, featureLayerConfig, layerInfo, this._eventRepo)
251-
const info = new LayerInfo(url, eventIds, { ...layerInfo, fields: layerFields } as LayerInfoResult);
252-
const layerProcessor = new FeatureLayerProcessor(info, config, identityManager, this._console);
253-
this._layerProcessors.push(layerProcessor);
219+
promises.push((async () => {
220+
try {
221+
this._console.info(`Getting feature service layers for ${service.url}`);
222+
const identityManager = await this._identityService.signin(service);
223+
const featureService = new FeatureService(console, service, identityManager)
224+
const arcService = await featureService.getService();
225+
226+
for (const featureLayer of arcService.layers) {
227+
const featureLayerConfig = service.layers.find(layer => layer.layer.toString() === featureLayer.name.toString());
228+
if (featureLayerConfig) {
229+
const url = `${service.url}/${featureLayer.id}`;
230+
const layerInfo = await featureService.getLayer(featureLayer.id);
231+
if (featureLayer.geometryType != null) {
232+
// TODO The featureLayerConfig should contain the layer id
233+
featureLayerConfig.layer = featureLayer.id;
234+
const admin = new FeatureServiceAdmin(config, this._identityService, this._console)
235+
const eventIds = featureLayerConfig.eventIds || []
236+
const layerFields = await admin.updateLayer(service, featureLayerConfig, layerInfo, this._eventRepo)
237+
const info = new LayerInfo(url, eventIds, { ...layerInfo, fields: layerFields } as LayerInfoResult);
238+
const layerProcessor = new FeatureLayerProcessor(info, config, identityManager, this._console);
239+
this._layerProcessors.push(layerProcessor);
240+
}
241+
}
242+
}
243+
} catch (err) {
244+
this._console.error(`Error getting feature service layers for ${service.url}:`, err);
254245
}
255-
}
246+
})());
256247
}
248+
await Promise.all(promises);
257249
}
258250

259251
/**

0 commit comments

Comments
 (0)