Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gp resource issue #1503

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading