cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thors...@apache.org
Subject svn commit: r1221209 - /cocoon/cocoon3/trunk/cocoon-shiro/src/main/java/org/apache/cocoon/shiro/rest/AbstractShiroLogin.java
Date Tue, 20 Dec 2011 11:49:53 GMT
Author: thorsten
Date: Tue Dec 20 11:49:52 2011
New Revision: 1221209

URL: http://svn.apache.org/viewvc?rev=1221209&view=rev
Log:
Refactoring AbstractLogin to expose the error/success response in an overridable method. Suggestion
by Ajay Deshwal.

Modified:
    cocoon/cocoon3/trunk/cocoon-shiro/src/main/java/org/apache/cocoon/shiro/rest/AbstractShiroLogin.java

Modified: cocoon/cocoon3/trunk/cocoon-shiro/src/main/java/org/apache/cocoon/shiro/rest/AbstractShiroLogin.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-shiro/src/main/java/org/apache/cocoon/shiro/rest/AbstractShiroLogin.java?rev=1221209&r1=1221208&r2=1221209&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-shiro/src/main/java/org/apache/cocoon/shiro/rest/AbstractShiroLogin.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-shiro/src/main/java/org/apache/cocoon/shiro/rest/AbstractShiroLogin.java
Tue Dec 20 11:49:52 2011
@@ -18,6 +18,7 @@
  */
 package org.apache.cocoon.shiro.rest;
 
+import java.net.MalformedURLException;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -81,12 +82,20 @@ public abstract class AbstractShiroLogin
             Map<String, Object> data = new HashMap<String, Object>();
             data.put("error", true);
             data.put("to", getTo());
-            return new URLResponse(getErrorLogin(), data);
+            return getErrorResponse(data);
         } else {
-            return new RedirectResponse(getTo());
+            return getSuccessResponse();
         }
     }
 
+    protected RestResponse getSuccessResponse(){
+      return new RedirectResponse(getTo());
+    }
+
+    protected RestResponse getErrorResponse(Map<String, Object> data) throws MalformedURLException{
+       return new URLResponse(getErrorLogin(), data);
+    }
+
     public RestResponse doGet() throws Exception {
         Subject subject = SecurityUtils.getSubject();
         Session session = subject.getSession();
@@ -109,4 +118,4 @@ public abstract class AbstractShiroLogin
         }
         return to;
     }
-}
\ No newline at end of file
+}



Mime
View raw message