Re: [Freeipa-devel] [PATCH] 0237-no-redirect-on-unknown-error

2011-06-20 Thread Endi Sukma Dewata

On 6/17/2011 3:00 PM, Adam Young wrote:

This version does the whitelist approach


ACK and pushed to master.

--
Endi S. Dewata

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 0237-no-redirect-on-unknown-error

2011-06-17 Thread Adam Young

On 06/15/2011 09:23 PM, Endi Sukma Dewata wrote:

On 6/15/2011 6:44 PM, Adam Young wrote:

On 06/15/2011 02:37 PM, Adam Young wrote:

Part 2

https://fedorahosted.org/freeipa/ticket/1281



Now iterates through a list of known error types.


If the server is down (service ipa stop) it throws an error with name 
'NS_ERROR_NOT_AVAILABLE' which is not in the list, so it still does a 
redirection.


There is another problem too, if the error name matches the list it 
doesn't call report_error().


Maybe this should be done the other way around. Instead of listing the 
errors not to redirect, we should list the errors which require 
redirection, i.e. IPA Error 4001 (entry not found).


This is optional, in ipa.js:337 we could add the IPA error code into 
the error_thrown object. This way the error can be checked more 
reliably using error code rather than error name.



This version does the whitelist approach
From b07476f92e2ad6f1f3844348127967166bb51d02 Mon Sep 17 00:00:00 2001
From: Adam Young 
Date: Wed, 15 Jun 2011 14:34:54 -0400
Subject: [PATCH] no redirect on unknown error If the error name is indicates
 a server wide error, do not attempt to redirect.

this variation has a whitelist of errors on which to redirect.

https://fedorahosted.org/freeipa/ticket/1281
---
 install/ui/entity.js |   31 ++-
 1 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/install/ui/entity.js b/install/ui/entity.js
index 8ccdb8ea26820f3ec48ab73c5c5b3fb202ba157d..afe1e24b2c0f775a0bc3d17104a09d26d943b00b 100644
--- a/install/ui/entity.js
+++ b/install/ui/entity.js
@@ -136,20 +136,33 @@ IPA.facet = function (spec) {
 details.append(''+error_thrown.message+'');
 };
 
+that.redirect_on_error = function(){
+var current_entity = that.entity;
+while (current_entity.containing_entity){
+current_entity = current_entity.containing_entity;
+}
+IPA.nav.show_page(
+current_entity.name,
+that.entity.redirect_facet);
+};
+
+var redirect_errors =
+["IPA Error 4001"];
+
 that.on_error = function(xhr, text_status, error_thrown) {
+
+/*If the error is in talking to the server, don't attempt to redirect,
+  as there is nothing any other facet can do either. */
 if (that.entity.redirect_facet )
 {
-var current_entity = that.entity;
-while (current_entity.containing_entity){
-current_entity = current_entity.containing_entity;
+for (var i =0; i <  redirect_errors.length; i += 1){
+if (error_thrown.name ===  redirect_errors[i]){
+that.redirect_on_error();
+return;
+}
 }
-IPA.nav.show_page(
-current_entity.name,
-that.entity.redirect_facet);
-return;
-}else{
-that.report_error(error_thrown);
 }
+that.report_error(error_thrown);
 };
 
 
-- 
1.7.5.2

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Re: [Freeipa-devel] [PATCH] 0237-no-redirect-on-unknown-error

2011-06-15 Thread Endi Sukma Dewata

On 6/15/2011 6:44 PM, Adam Young wrote:

On 06/15/2011 02:37 PM, Adam Young wrote:

Part 2

https://fedorahosted.org/freeipa/ticket/1281



Now iterates through a list of known error types.


If the server is down (service ipa stop) it throws an error with name 
'NS_ERROR_NOT_AVAILABLE' which is not in the list, so it still does a 
redirection.


There is another problem too, if the error name matches the list it 
doesn't call report_error().


Maybe this should be done the other way around. Instead of listing the 
errors not to redirect, we should list the errors which require 
redirection, i.e. IPA Error 4001 (entry not found).


This is optional, in ipa.js:337 we could add the IPA error code into the 
error_thrown object. This way the error can be checked more reliably 
using error code rather than error name.


--
Endi S. Dewata

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 0237-no-redirect-on-unknown-error

2011-06-15 Thread Adam Young

On 06/15/2011 02:37 PM, Adam Young wrote:

Part 2

https://fedorahosted.org/freeipa/ticket/1281

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Now iterates through a list of known error types.
From de7eac32830e2e509858b28696aeddb8e3ba1e83 Mon Sep 17 00:00:00 2001
From: Adam Young 
Date: Wed, 15 Jun 2011 14:34:54 -0400
Subject: [PATCH] no redirect on unknown error If the error name is indicates
 a server wide error, do not attempt to redirect.

https://fedorahosted.org/freeipa/ticket/1281
---
 install/ui/entity.js |   32 
 1 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/install/ui/entity.js b/install/ui/entity.js
index 107c3c4d429fce2161ec209bb4c04d82ecea0d4c..70053fd1003e9a7c171d744253c69c8a07959205 100644
--- a/install/ui/entity.js
+++ b/install/ui/entity.js
@@ -136,17 +136,33 @@ IPA.facet = function (spec) {
 details.append(''+error_thrown.message+'');
 };
 
+that.redirect_on_error = function(){
+var current_entity = that.entity;
+while (current_entity.containing_entity){
+current_entity = current_entity.containing_entity;
+}
+IPA.nav.show_page(
+current_entity.name,
+that.entity.redirect_facet);
+};
+
+var no_redirect_errors =
+["Internal Server Error",
+ "Unknown Error",
+ "Kerberos ticket no longer valid."];
+
 that.on_error = function(xhr, text_status, error_thrown) {
+
+/*If the error is in talking to the server, don't attempt to redirect,
+  as there is nothing any other facet can do either. */
+for (var i =0; i <  no_redirect_errors.length; i += 1){
+if (error_thrown.name ===  no_redirect_errors[i]){
+return;
+}
+}
 if (that.entity.redirect_facet )
 {
-var current_entity = that.entity;
-while (current_entity.containing_entity){
-current_entity = current_entity.containing_entity;
-}
-IPA.nav.show_page(
-current_entity.name,
-that.entity.redirect_facet);
-return;
+that.redirect_on_error();
 }else{
 that.report_error(error_thrown);
 }
-- 
1.7.5.2

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Re: [Freeipa-devel] [PATCH] 0237-no-redirect-on-unknown-error

2011-06-15 Thread Adam Young

On 06/15/2011 02:37 PM, Adam Young wrote:

Part 2

https://fedorahosted.org/freeipa/ticket/1281

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


From d23d22ca6465753bd6588fa98cd9b87feebffd2a Mon Sep 17 00:00:00 2001
From: Adam Young 
Date: Wed, 15 Jun 2011 14:34:54 -0400
Subject: [PATCH] no redirect on unknown error If the error name is Unknown
 Error, it currently means that the server is down.  While
 we should do better error handling for this in the future,
 currently at least we will stop trying to redirect.

---
 install/ui/entity.js |   24 
 1 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/install/ui/entity.js b/install/ui/entity.js
index 107c3c4d429fce2161ec209bb4c04d82ecea0d4c..8b07fe1e38b27f4b7d4314fb92693cef196b7fce 100644
--- a/install/ui/entity.js
+++ b/install/ui/entity.js
@@ -136,17 +136,25 @@ IPA.facet = function (spec) {
 details.append(''+error_thrown.message+'');
 };
 
+that.redirect_on_error = function(){
+var current_entity = that.entity;
+while (current_entity.containing_entity){
+current_entity = current_entity.containing_entity;
+}
+IPA.nav.show_page(
+current_entity.name,
+that.entity.redirect_facet);
+};
+
 that.on_error = function(xhr, text_status, error_thrown) {
+/*If the server is down, don't attempt to redirect, 
+  as there is nothing any other facet can do either. */
+if (error_thrown.name === "Unknown Error"){
+return;
+}
 if (that.entity.redirect_facet )
 {
-var current_entity = that.entity;
-while (current_entity.containing_entity){
-current_entity = current_entity.containing_entity;
-}
-IPA.nav.show_page(
-current_entity.name,
-that.entity.redirect_facet);
-return;
+that.redirect_on_error();
 }else{
 that.report_error(error_thrown);
 }
-- 
1.7.5.2

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel