Permalink
Browse files

added hotfix for cache problem

  • Loading branch information...
1 parent 01c3b28 commit db0e77b45ea072657e6d1f2606b50ae57e4bd6be @kher kher committed Oct 3, 2013
Showing with 88 additions and 0 deletions.
  1. +9 −0 recipes/default.rb
  2. +2 −0 recipes/joincluster.rb
  3. +2 −0 recipes/unjoincluster.rb
  4. +75 −0 templates/default/zswebapi.js.erb
View
@@ -54,6 +54,15 @@
:install
end
+#HOT FIX for bug ZSRV-10761 at line 4
+# options.noCache = true;
+template "/usr/local/zend/gui/public/js/zswebapi.js" do
+ source "zswebapi.js.erb"
+ mode 0644
+ owner "root"
+ group "root"
+end
+
# Problem with CentOS api functions if server not restarted
service "zend-server" do
action :restart
View
@@ -18,4 +18,6 @@
execute "cluster-join-server" do
command join_command
ignore_failure false
+ retries 5
+ retry_delay 3
end
View
@@ -11,4 +11,6 @@
execute "cluster-unjoin-server" do
command unjoin_command
ignore_failure false
+ retries 5
+ retry_timeout 3
end
@@ -0,0 +1,75 @@
+Request.WebAPI = new Class({
+ Extends: Request.JSON,
+ initialize: function(options) {
+ options.noCache = true; // Fix for ZSRV-10761
+ this.parent(options);
+ var accept = 'application/vnd.zend.serverapi+json';
+ if (options.version != undefined) {
+ accept += (';version=' + options.version);
+ }
+
+ Object.append(this.headers, {
+ 'X-Accept': accept
+ });
+
+ this.addEvent('failure', function(response) {
+ var responseData = this.decodeResponse(response);
+
+ /// session expired, could not validate the request
+ if (responseData && responseData.errorData.errorCode == 'malformedRequest' && (! location.pathname.match('/Login'))) {
+ document.fireEvent('toastAlert', {'message': _t('Session expired, redirecting to login')});
+ this.redirectToLogin.delay(2000);
+ }
+ }.bind(this));
+ },
+ redirectToLogin: function() {
+ location = baseUrl() + '/Login?redirectTo=' + encodeURIComponent(location.href);
+ },
+ decodeResponse: function(response) {
+ var responseData = '';
+ if (JSON.validate(response.responseText)) {
+ responseData = JSON.decode(response.responseText);
+ }
+ if (! responseData) {
+ return {'errorData': {'errorCode': '', 'errorMessage': ''}};
+ }
+ return responseData;
+ }
+});
+
+Request.WebAPI.TasksPolling = new Class({
+ 'Extends': Request.WebAPI,
+ 'initialize': function(options) {
+ if (options.onPollingDone) {
+ this.addEvent('tasksComplete', options.onPollingDone);
+ delete options.onPollingDone;
+ }
+
+ if (options.onPollingFail) {
+ this.addEvent('tasksCompleteFail', options.onPollingFail);
+ delete options.onPollingFail;
+ } else {
+ this.addEvent('tasksCompleteFail', options.onFailure);
+ }
+
+ options.onSuccess = function() {
+ var url = baseUrl() + '/Api/tasksComplete';
+ var request = new Request.WebAPI({
+ url: url,
+ data:{},
+ onSuccess: function(response) {
+ if (undefined != response && response.responseData.tasksComplete == true) {
+ this.fireEvent('tasksComplete', response);
+ } else {
+ this.fireEvent.delay('700', this, ['success']);
+ }
+ }.bind(this),
+ onFailure: function(response) {
+ this.fireEvent('tasksCompleteFail', response);
+ }
+ }).get();
+ }.bind(this);
+
+ this.parent(options);
+ },
+});

0 comments on commit db0e77b

Please sign in to comment.