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

Fix missing request type in OnSystemRequest #315

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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
81 changes: 54 additions & 27 deletions app/controller/SettingsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,54 +345,81 @@ SDL.SettingsController = Em.Object.create(
* Method responsible for PolicyUpdate retry sequence
* abort parameter if set to true means that retry sequence if finished
*
* @param {Boolean} abort
* @param {Object} request_params
*/
policyUpdateRetry: function(abort) {
if(SDL.SDLModel.data.policyUpdateRetry.isIterationInProgress) {
policyUpdateRetry: function(request_params) {
if (SDL.SDLModel.data.policyUpdateRetry.isIterationInProgress) {
Em.Logger.log('PTU retry: iteration is in progress');
return;
}

clearTimeout(SDL.SDLModel.data.policyUpdateRetry.timer);
SDL.SDLModel.data.policyUpdateRetry.timer = null;

var sendOnSystemRequest = function() {
SDL.SDLModel.data.policyUpdateRetry.isIterationInProgress = false;
const default_params = {
requestType: 'PROPRIETARY',
fileName: SDL.SettingsController.policyUpdateFile,
url: SDL.SDLModel.data.policyURLs[0]
};
const params_to_send = request_params ? request_params : default_params;

FFW.BasicCommunication.OnSystemRequest(
'PROPRIETARY',
SDL.SettingsController.policyUpdateFile,
SDL.SDLModel.data.policyURLs[0]
params_to_send.requestType,
params_to_send.fileName,
params_to_send.url,
params_to_send.appID
);
}
if(abort !== 'ABORT' && !SDL.SDLModel.data.policyUpdateRetry.isRetry) {

if (!SDL.SDLModel.data.policyUpdateRetry.isRetry) {
Em.Logger.log('PTU retry: starting retry sequence');
SDL.SDLModel.data.policyUpdateRetry.isRetry = true;
return;
}

var length = SDL.SDLModel.data.policyUpdateRetry.retry.length;
if(length == SDL.SDLModel.data.policyUpdateRetry.try) {
if (length == SDL.SDLModel.data.policyUpdateRetry.try) {
Em.Logger.log('PTU retry: retry attempts exceeded. Sending the last system request');
SDL.SDLModel.data.policyUpdateRetry.isRetry = false;
}
if (abort !== 'ABORT' && SDL.SDLModel.data.policyUpdateRetry.isRetry) {

SDL.SDLModel.data.policyUpdateRetry.oldTimer =
SDL.SDLModel.data.policyUpdateRetry.retry[SDL.SDLModel.data.policyUpdateRetry.try] * 1000;

SDL.SDLModel.data.policyUpdateRetry.isIterationInProgress = true;
SDL.SDLModel.data.policyUpdateRetry.timer = setTimeout(
function() {
sendOnSystemRequest();
}, SDL.SDLModel.data.policyUpdateRetry.oldTimer
}, 1000
);
SDL.SDLModel.data.policyUpdateRetry.isIterationInProgress = true;
SDL.SDLModel.data.policyUpdateRetry.try++;
} else {
SDL.SDLModel.data.policyUpdateRetry.isRetry = false;
clearTimeout(SDL.SDLModel.data.policyUpdateRetry.timer);
SDL.SDLModel.data.policyUpdateRetry = {
timeout: null,
retry: [],
try: null,
timer: null,
oldTimer: 0
};
return;
}

SDL.SDLModel.data.policyUpdateRetry.oldTimer =
SDL.SDLModel.data.policyUpdateRetry.retry[SDL.SDLModel.data.policyUpdateRetry.try] * 1000;

SDL.SDLModel.data.policyUpdateRetry.timer = setTimeout(
function() {
sendOnSystemRequest();
}, SDL.SDLModel.data.policyUpdateRetry.oldTimer
);

SDL.SDLModel.data.policyUpdateRetry.isIterationInProgress = true;
SDL.SDLModel.data.policyUpdateRetry.try++;
Em.Logger.log(`PTU retry: retry attempt #${SDL.SDLModel.data.policyUpdateRetry.try}`);
},

/**
* @description Aborts policy table update retry sequence
*/
policyUpdateAbort: function() {
Em.Logger.log('PTU retry: retry sequence was aborted');
SDL.SDLModel.data.policyUpdateRetry.isRetry = false;
clearTimeout(SDL.SDLModel.data.policyUpdateRetry.timer);
SDL.SDLModel.data.policyUpdateRetry = {
timeout: null,
retry: [],
try: null,
timer: null,
oldTimer: 0
};
},

/**
Expand Down
4 changes: 2 additions & 2 deletions ffw/BasicCommunicationRPC.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ FFW.BasicCommunication = FFW.RPCObserver
messageCode = 'StatusUpToDate';
//Update is complete, stop retry sequence
if (FLAGS.ExternalPolicies === true) {
SDL.SettingsController.policyUpdateRetry('ABORT');
SDL.SettingsController.policyUpdateAbort();
}
SDL.SettingsController.policyUpdateFile = null;
this.GetPolicyConfigurationData({
Expand All @@ -463,7 +463,7 @@ FFW.BasicCommunication = FFW.RPCObserver
messageCode = 'StatusNeeded';
if (FLAGS.ExternalPolicies === true &&
SDL.SDLModel.data.policyUpdateRetry.isRetry) {
SDL.SettingsController.policyUpdateRetry();
SDL.SettingsController.policyUpdateRetry(null);
}
break;
}
Expand Down
8 changes: 1 addition & 7 deletions ffw/ExternalPolicies.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,9 @@ FFW.ExternalPolicies = Em.Object.create({
onPackMessage: function(evt) {
Em.Logger.log('ExternalPolicies onWSMessage ' + evt.data);
this.packResponseReady = true;
FFW.BasicCommunication.OnSystemRequest(
this.sysReqParams.requestType,
this.sysReqParams.fileName,
this.sysReqParams.url,
this.sysReqParams.appID
);
SDL.SettingsController.policyUpdateRetry(this.sysReqParams);

this.sysReqParams = {};

},
onUnpackMessage: function(evt) {
Em.Logger.log('ExternalPolicies onWSMessage ' + evt.data);
Expand Down