This is a special topic intended for helping developers and administrators recompile any unsupported custom data providers that did not get automatically re-registered when upgrading from ArcGIS Enterprise 11.x to ArcGIS Enterprise 12.0 and restarting stopped services. Not every step may apply to your situation, so carefully read each step in the guide. The end of this guide contains a full example of migrating the Yelp data provider from 11.x to 12.0. Each step in the guided walkthrough is illustrated in the example.
Guided walkthrough
Step 1. Replace the config module and /config/default.json
- Ensure that the npm module
configis not in your list ofdependenciesin the provider's package.json file. The file location is /providers/provider-name/package.json. If theconfigdependency is present in /providers/provider-name/package.json, then from the /providers/provider-name/ folder, runnpm uninstall config. - Create a new JSON file that will replace the functionality of the deprecated /config/default.json file. For ease of reference, this file can be placed in providers/provider-name/src/ directory. Give this JSON configuration file any name of your choosing.
- If your previous, unsupported provider did not make use of the /config/default.json file (i.e. it was just an empty object), then you do not need to create a new JSON configuration file. You can skip steps 1.3 and 1.4 and move to Step 2.
- Copy over the exact contents of the previous
default.jsonfile to the new JSON configuration file. - Now
requirethis file in your model.js and in any other files that referenced "config". For instance if your model.js file has the line at the top:const config = require("config");then replace it withconst config = require(./. As long as your variable is named the same and you copied over the original default.json exactly, this should work seamlessly.<my-new-config-name >.json);
Step 2. Replace host and id with service parameters
-
If you are using the
hostproperty in your unsupported provider, in the /providers/provider-name/cdconfig.json file create an object in theproperties.servicearray with the propertiesParameters key,label, anddescription. If you are also usingidin your old provider, create another object in theproperties.servicearray.Parameters - If your previous, unsupported provider did not make use of the
hostandidparameters, then you do not need to create any objects in theservicearray. You can skip steps 2.2, 2.3, and 2.4 and move to Step 3.Parameters
- If your previous, unsupported provider did not make use of the
-
Provide a value for
keythat you will use to access the parameter in your code. It is best to use snake or camel case. Provide a value forlabelthat will show up in user interfaces such as ArcGIS Portal Home and Enterprise Manager. Provide a value fordescriptionthat will show up in user interfaces such as ArcGIS Portal Home and Enterprise Manager and will clearly describe the parameter. Click here for more details on service parameters. -
Update your model.js code in the places where you previously referenced
hostand/orid. For instance if you had the lineconst db, the replacement line would beTable Name = req.params.host const db. Parameter values are accessed on theTable Name = req.params. <my-new-key-value > req.paramsobject as before. -
Test your code in the development environment. Refer to the topic on service parameters for testing information. Export the new provider as a .cpdk file, and register it with ArcGIS Server.
Step 3. Update the service JSON
- In the ArcGIS Sever Administrator Directory, go to Home > service > nameOfStoppedService.FeatureServer > edit.
- Locate the section of service JSON called
custom.Data Provider Info - If
customcontains a key calledData Provider Info forwardleave its value as is. If it does not, there is no need to add the key.User Identity - Delete the keys
dataandProvider Host data. Add an empty object calledProvider Id service.Parameters - If your custom data provider does not make use of any service parameters, then save the edits and restart the service. Your upgrade for this service is complete.
- If
- If your custom data provider uses service parameters, add them to the
serviceobject as follows:Parameters "service. Restart the service. Your upgrade for this service is complete.Parameters" : {"key1" : "value", "key2" : "value", "key3" : "value"}
Yelp data provider example
This example will illustrate all the steps above by showing all the code changes required to upgrade the Yelp data provider.
Replacing the config module and /config/default.json
- The package.json no longer contains the
configmodule in thedependencies.
{
"name": "yelp-data-provider",
"version": "11.4.0",
"description": "Template for customdata provider",
"main": "src/index.js",
"scripts": {
"test": "mocha 'test/**/*.test.js'",
"start": "node src/index.js"
},
"dependencies": {
"config": "^3.2.5",
- The configuration JSON was copied from /default/config.json to yelp-data-config.json.
{
"yelp": {
"apiKey": "<API KEY>"
}
}- On line 1 of the model.js file, the Yelp configuration file is now 'required in' rather than referencing the
configmodule.
const config = require("config");
const parseGeoJSON = require("./parseGeoJSON");
const yelp = require("yelp-fusion");
const yelpClient = yelp.client(config.yelp.apiKey);
function Model() {}
Model.prototype.getData = function (req, callback) {
const host = req.params.host;
const id = req.params.id;
yelpClient
.search({
categories: host,
Replacing host and id with service parameters
- The boilerplate cdconfig.json no longer contains the
propertieshostsanddisablewhen creating a provider in the 12.0 SDK.Id Param - The boilerplate cdconfig.json contains an empty
servicearray. The two parametersParameters categoryandcitywere added to replace the oldhostandid.
{
"name": "yelp-data-provider",
"arcgisVersion": "11.4.0",
"parentServiceType": "FeatureServer",
"customdataRuntimeVersion": "1",
"type": "provider",
"properties": {
"hosts": true,
"disableIdParam": false
},
"fileName": "yelp-data-provider.cdpk"
- Each instance of the use of
hostandidhas been updated in model.js to usecategoryandcity.
const config = require("config");
const parseGeoJSON = require("./parseGeoJSON");
const yelp = require("yelp-fusion");
const yelpClient = yelp.client(config.yelp.apiKey);
function Model() {}
Model.prototype.getData = function (req, callback) {
const host = req.params.host;
const id = req.params.id;
yelpClient
.search({
categories: host,
Updating the service JSON
- The
customobject contains an optional key calledData Provider Info forwardthat was introduced at ArcGIS Enterprise 11.5. Click here to read more about theUser Identity forwardproperty.User Identity - The keys
dataandProvider Host dataare no longer included.Provider Id - The
serviceobject must contain all keys defined in the provider's cdconfig.json file, and values must be provided for each of these keys.Parameters
{
"serviceName": "yelpRedlands",
"jsonProperties": {
"customDataProviderInfo": {
"dataProviderName": "yelp-data-provider",
"dataProviderHost": "restaurants",
"dataProviderId": "redlands"
}
},
"type": "FeatureServer",
"description": "",