Skip to content
Open
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
41 changes: 40 additions & 1 deletion lib/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,26 @@ function run(instance, job_id, request_doc, asJson) {
// in case of errors
var result = { error : util.format('Starting job "%s" on %s failed',
job_id, instance), fault : res.body.fault };

// handle case of import job with res.body.fault.type === 'UnknownPropertyException'
// this must be a support user, so we need to re-run with normal job parameters form
if (job_id === 'sfcc-site-archive-import' && request_doc.file_name
&& res.body.fault && res.body.fault.type === 'UnknownPropertyException') {
if (!asJson) {
console.warn("internal users must use different form for import; re-running job", request_doc)
}

return run(instance, job_id, {
parameters: [
{
name: "ImportFile",
value: request_doc.file_name
}
]
}, asJson);
}
// TODO handle export as well

if (asJson) {
console.json(result);
} else {
Expand Down Expand Up @@ -160,6 +180,25 @@ function runSync(instance, job_id, request_doc, asJson, failFast) {
// in case of errors
var result = { error : util.format('Starting job "%s" on %s failed',
job_id, instance), fault : res.body.fault };

// handle case of import job with res.body.fault.type === 'UnknownPropertyException'
// this must be a support user, so we need to re-run with normal job parameters form
if (job_id === 'sfcc-site-archive-import' && request_doc.file_name
&& res.body.fault && res.body.fault.type === 'UnknownPropertyException') {
if (!asJson) {
console.warn("internal users must use different form for import; re-running job", request_doc)
}

return runSync(instance, job_id, {
parameters: [
{
name: "ImportFile",
value: request_doc.file_name
}
]
}, asJson);
}

if (asJson) {
console.json(result);
} else {
Expand Down Expand Up @@ -362,4 +401,4 @@ module.exports.api = {
});
});
}
};
};