[Yanel-commits] rev 25472 - public/yanel/contributions/resources/redirect/src/java/org/wyona/yanel/impl/resources

michi at wyona.com michi at wyona.com
Tue Jun 26 10:57:43 CEST 2007


Author: michi
Date: 2007-06-26 10:57:43 +0200 (Tue, 26 Jun 2007)
New Revision: 25472

Modified:
   public/yanel/contributions/resources/redirect/src/java/org/wyona/yanel/impl/resources/RedirectResource.java
Log:
more obsolete methods deleted, bug re no custom config fixed, bug re custom config fixed, formatting fixed

Modified: public/yanel/contributions/resources/redirect/src/java/org/wyona/yanel/impl/resources/RedirectResource.java
===================================================================
--- public/yanel/contributions/resources/redirect/src/java/org/wyona/yanel/impl/resources/RedirectResource.java	2007-06-26 08:37:23 UTC (rev 25471)
+++ public/yanel/contributions/resources/redirect/src/java/org/wyona/yanel/impl/resources/RedirectResource.java	2007-06-26 08:57:43 UTC (rev 25472)
@@ -68,6 +68,9 @@
         return vd;
     }
 
+    /**
+     *
+     */
     public View getView(String viewId) throws Exception {
         return getView(viewId, null);
     }
@@ -78,39 +81,42 @@
     public View getView(String viewId, String revisionName) throws Exception {
         View view = new View();
         view.setResponse(false); // this resource writes the response itself
-        HttpServletRequest request = getRequest();
+
         HttpServletResponse response = getResponse();
 
         String defaultHref = getResourceConfigProperty("href");
+
+        if (defaultHref == null) throw new Exception("No default redirect has been set!");
+
+        response.setStatus(307);
+        response.setHeader("Location", defaultHref);
         
         String currentUser = null;
-        Identity identity = getIdentity(request);
+        Identity identity = getIdentity(getRequest());
         if (identity != null) {
             currentUser = identity.getUsername();
         }
         
-        ResourceConfiguration rc = getConfiguration();
-        Document customConfigDoc = rc.getCustomConfiguration();
-        if (customConfigDoc != null) {
-            Configuration config = ConfigurationUtil.toConfiguration(customConfigDoc.getDocumentElement());
-            Configuration[] redirectConfigs = config.getChildren("user");
-                if (redirectConfigs.length == 0) return null;
+        if (currentUser != null) {
+            ResourceConfiguration rc = getConfiguration();
+            Document customConfigDoc = rc.getCustomConfiguration();
+            if (customConfigDoc != null) {
+                Configuration config = ConfigurationUtil.toConfiguration(customConfigDoc.getDocumentElement());
+                Configuration[] redirectConfigs = config.getChildren("user");
+                
                 for (int i = 0; i < redirectConfigs.length; i++) {
                     try {
                         if (redirectConfigs[i].getAttribute("name") == currentUser || (currentUser).equals(redirectConfigs[i].getAttribute("name"))) {
                             response.setStatus(307);
                             response.setHeader("Location", redirectConfigs[i].getAttribute("href"));
-                        } else {
-                            response.setStatus(307);
-                            response.setHeader("Location", defaultHref);
                         }
                     } catch (Exception e) {
                         log.error(e.getMessage(), e);
-                        return null;
+                        throw e;
                     }
                 }
+            }
         }
-
         return view;
     }
     
@@ -137,37 +143,6 @@
     }
 
     /**
-     *
-     */
-    public String getPropertyType(String name) {
-        log.warn("Not implemented yet!");
-        return null;
-    }
-
-    /**
-     *
-     */
-    public Object getProperty(String name) {
-        log.warn("Not implemented yet!");
-        return null;
-    }
-
-    /**
-     *
-     */
-    public String[] getPropertyNames() {
-        log.warn("Not implemented yet!");
-        return null;
-    }
-
-    /**
-     *
-     */
-    public void setProperty(String name, Object value) {
-        log.warn("Not implemented yet!");
-    }
-    
-    /**
      * Gets the identity from the session associated with the given request.
      * @param request
      * @return identity or null if there is no identity in the session for the current
@@ -184,5 +159,4 @@
         }
         return null;
     }
-
 }




More information about the Yanel-commits mailing list