Update of /var/cvs/contributions/didactor2/src/core/java/nl/didactor/filter
In directory james.mmbase.org:/tmp/cvs-serv21643/nl/didactor/filter

Modified Files:
        ProviderFilter.java 
Log Message:



See also: 
http://cvs.mmbase.org/viewcvs/contributions/didactor2/src/core/java/nl/didactor/filter


Index: ProviderFilter.java
===================================================================
RCS file: 
/var/cvs/contributions/didactor2/src/core/java/nl/didactor/filter/ProviderFilter.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- ProviderFilter.java 31 Jul 2007 15:57:28 -0000      1.13
+++ ProviderFilter.java 1 Feb 2008 14:13:01 -0000       1.14
@@ -28,11 +28,12 @@
 import org.mmbase.util.logging.*;
 
 /**
- * Redirects request based on information supplied by the jumpers builder.
+ * This files provides e.g. didactor specific stuff which are available and 
likely needed during
+ * most requests.
+ * Request scope vars are 'provider', 'education', 'class'.
  *
-
  * @author Michiel Meeuwissen
- * @version $Id: ProviderFilter.java,v 1.13 2007/07/31 15:57:28 michiel Exp $
+ * @version $Id: ProviderFilter.java,v 1.14 2008/02/01 14:13:01 michiel Exp $
  */
 public class ProviderFilter implements Filter, MMBaseStarter, 
NodeEventListener, RelationEventListener {
     private static final Logger log = 
Logging.getLoggerInstance(ProviderFilter.class);
@@ -69,6 +70,10 @@
         EventManager.getInstance().addEventListener(this);        
     }
 
+    /**
+     * If something changes in provider or education nodes, clear the caches. 
Does not happen very
+     * often, so more subtlety is not needed.
+     */
     public void notify(NodeEvent event) {
         String builder = event.getBuilderName();
         if ("providers".equals(builder) || "educations".equals(builder)) {
@@ -86,6 +91,10 @@
         }
     }
 
+    /**
+     * Utility method. In didactor the current provider/education are 
determined using related url
+     * objects to provider and education objects. This method does the needed 
queries.
+     */
     protected Node selectByRelatedUrl(NodeList nodes, String url) {
         log.debug("Select  for " + url);
         NodeIterator ni = nodes.nodeIterator();
@@ -105,6 +114,10 @@
         return null;
     }
 
+
+    /**
+     * With education, provider a certain locale is defined. Determin it.
+     */
     protected Locale findLocale(Node provider, Node education) {
         Locale locale;
         {
@@ -159,6 +172,12 @@
         return nl.didactor.security.Authentication.getCurrentUserNode(cloud);
     }
 
+
+    /**
+     * Determin the education
+     * @param provider If provider already determined, it can be given.
+     * @param
+     */
     protected Node getEducation(Cloud cloud, Node provider, String[] urls, 
Map<String, Object> attributes) {
         
         Node education = null;
@@ -198,7 +217,7 @@
             log.debug("Found education " + education.getNumber());
             attributes.put("education", education.getNumber()); 
         } else {
-            attributes.put("education", null);
+            //attributes.put("education", null);
         }
         return education;
     }
@@ -243,12 +262,13 @@
         HttpSession session = req.getSession(false);        
 
 
-        String educationParameter = useParameters && session != null ? 
(String) session.getAttribute("education") : null;
-        if (educationParameter == null && useParameters) educationParameter = 
req.getParameter("education");
+        String parameterEducation = useParameters && session != null ? 
(String) session.getAttribute("education") : null;
+        if ((parameterEducation == null || parameterEducation.length() == 0) 
&& useParameters) parameterEducation = req.getParameter("education");
+        if (parameterEducation != null && parameterEducation.length() == 0) 
parameterEducation = null;
 
-        if (educationParameter != null && useParameters && session != null) {
+        if (parameterEducation != null && useParameters && session != null) {
             // remember some explicit education parameter in the session.
-            session.setAttribute("education", educationParameter);
+            session.setAttribute("education", parameterEducation);
         }
 
         String providerParameter  = useParameters ? 
req.getParameter("provider") : null;
@@ -270,7 +290,7 @@
             userAttributes.put("user", user == null ? 0 : user.getNumber());
         }
 
-        String key = serverName + contextPath + ':' + educationParameter + ':' 
+ providerParameter;
+        String key = serverName + contextPath + ':' + parameterEducation + ':' 
+ providerParameter;
         Map<String, Object> attributes = providerCache.get(key);
         if (attributes == null) {
 
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to