From ae11f28757abc6f4c9f65c390ea70b1f9d59b6fc Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Fri, 17 Aug 2012 09:00:56 +0200 Subject: [PATCH] improve session timeout handling at the repository grid --- .../js/repository/sonia.repository.grid.js | 3 ++- .../webapp/resources/js/rest/sonia.rest.js | 25 +++++++++++++++++++ .../resources/js/rest/sonia.rest.jsonstore.js | 25 +------------------ 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.grid.js b/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.grid.js index a9428d2413..b4ddf8ff7d 100644 --- a/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.grid.js +++ b/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.grid.js @@ -109,7 +109,8 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, { load: { fn: this.storeLoad, scope: this - } + }, + exception: Sonia.rest.ExceptionHandler } }); diff --git a/scm-webapp/src/main/webapp/resources/js/rest/sonia.rest.js b/scm-webapp/src/main/webapp/resources/js/rest/sonia.rest.js index 0c1676bf80..93576b3a04 100644 --- a/scm-webapp/src/main/webapp/resources/js/rest/sonia.rest.js +++ b/scm-webapp/src/main/webapp/resources/js/rest/sonia.rest.js @@ -30,3 +30,28 @@ */ Ext.ns("Sonia.rest"); + +Sonia.rest.exceptionTitleText = 'Error'; +Sonia.rest.exceptionMsgText = 'Could not load items. Server returned status: {0}'; + +Sonia.rest.ExceptionHandler = function(proxy, type, action, options, response, arg){ + var status = response.status; + if (debug){ + console.debug('store returned statuscode ' + status); + } + if ( status == 200 && action == 'read' && response.responseText == 'null' ){ + if ( debug ){ + console.debug( 'empty array, clear whole store' ); + } + this.removeAll(); + } else { + if (debug){ + console.debug( 'error during store load, status: ' + status ); + } + main.handleRestFailure( + response, + Sonia.rest.exceptionTitleText, + String.format(Sonia.rest.exceptionMsgText, status) + ); + } +} \ No newline at end of file diff --git a/scm-webapp/src/main/webapp/resources/js/rest/sonia.rest.jsonstore.js b/scm-webapp/src/main/webapp/resources/js/rest/sonia.rest.jsonstore.js index 0aa5768ac3..b6d8a53245 100644 --- a/scm-webapp/src/main/webapp/resources/js/rest/sonia.rest.jsonstore.js +++ b/scm-webapp/src/main/webapp/resources/js/rest/sonia.rest.jsonstore.js @@ -31,36 +31,13 @@ Sonia.rest.JsonStore = Ext.extend( Ext.data.JsonStore, { - errorTitleText: 'Error', - errorMsgText: 'Could not load items. Server returned status: {0}', - constructor: function(config) { if ( ! config.listeners ){ config.listeners = {}; } // fix jersey empty array problem config.listeners.exception = { - fn: function(proxy, type, action, options, response, arg){ - var status = response.status; - if (debug){ - console.debug('store returned statuscode ' + status); - } - if ( status == 200 && action == 'read' && response.responseText == 'null' ){ - if ( debug ){ - console.debug( 'empty array, clear whole store' ); - } - this.removeAll(); - } else { - if (debug){ - console.debug( 'error during store load, status: ' + status ); - } - main.handleRestFailure( - response, - this.errorTitleText, - this.errorMsgText - ); - } - }, + fn: Sonia.rest.ExceptionHandler, scope: this }