Skip to content

Commit

Permalink
Merge pull request #1503 from Esri/gp-resource-issue
Browse files Browse the repository at this point in the history
Gp resource issue
  • Loading branch information
jmhauck authored Sep 20, 2024
2 parents ca9081d + 095a620 commit 4b3ce8a
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/common/src/resources/getItemResourcesPaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ export function getItemResourcesPaths(
}
}

// GP Services
if (itemTemplate.type === "Geoprocessing Service") {
return res.indexOf("webtool") > -1;
}

return result;
});
// create the filePaths
Expand Down
52 changes: 52 additions & 0 deletions packages/common/test/resources/getItemResourcesPaths.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,58 @@ describe("getItemResourcesPaths :: ", () => {
expect(getResSpy.calls.argsFor(0)[0]).withContext("should get resources for template item").toBe("bc3");
});
});

it("filters out geoprocessing service resources", () => {
const getResSpy = spyOn(restHelpersModule, "getItemResources").and.resolveTo({
total: 4,
start: 1,
num: 0,
nextStart: -1,
resources: [
{
resource: "webtool.json",
created: 1591306005000,
size: 13850,
access: "inherit",
},
{
resource: "other.json",
created: 1591306005000,
size: 13850,
access: "inherit",
},
],
});

const itemTemplate: IItemTemplate = templates.getItemTemplateSkeleton();
itemTemplate.itemId = "bc3";
itemTemplate.type = "Geoprocessing Service";

return getItemResourcesPaths(itemTemplate, "4de", MOCK_USER_SESSION, 1).then((response) => {
expect(Array.isArray(response)).withContext("should return an array").toBe(true);
expect(response.length).withContext("filter out non webtool files").toBe(2);

expect(response).toEqual(
[
{
itemId: "bc3",
url: "https://myorg.maps.arcgis.com/sharing/rest/content/items/bc3/resources/webtool.json",
folder: "bc3",
filename: "webtool.json",
},
{
itemId: "bc3",
url: "https://myorg.maps.arcgis.com/sharing/rest/content/items/bc3/info/metadata/metadata.xml",
folder: "bc3_info_metadata",
filename: "metadata.xml",
},
],
"should return full path of the file in the storage item",
);
expect(getResSpy.calls.count()).withContext("should get resources").toBe(1);
expect(getResSpy.calls.argsFor(0)[0]).withContext("should get resources for template item").toBe("bc3");
});
});
});

describe("getItemResourcesPaths, template version 0", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/creator/src/createItemTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export function createItemTemplate(
}

/**
* Remove webtoolDefinition resource from Geoprocessing Service
* Remove webtool resource files from Geoprocessing Service
* This needs to be done after fetched so we can read from the file before we remove it
*
* @param template The current template
Expand Down

0 comments on commit 4b3ce8a

Please sign in to comment.