Update of /var/cvs/src/org/mmbase/bridge/implementation
In directory james.mmbase.org:/tmp/cvs-serv18062

Modified Files:
        BasicCloud.java BasicList.java BasicNodeManager.java 
Log Message:
checkNodes functionality was a bit broken. Fixed. Dropped 'autoconvert' 
property in BasicList, because not used anymore


See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/bridge/implementation


Index: BasicCloud.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/bridge/implementation/BasicCloud.java,v
retrieving revision 1.181
retrieving revision 1.182
diff -u -b -r1.181 -r1.182
--- BasicCloud.java     27 Feb 2008 11:47:54 -0000      1.181
+++ BasicCloud.java     12 Apr 2008 11:18:09 -0000      1.182
@@ -30,7 +30,7 @@
  * @author Rob Vermeulen
  * @author Pierre van Rooden
  * @author Michiel Meeuwissen
- * @version $Id: BasicCloud.java,v 1.181 2008/02/27 11:47:54 michiel Exp $
+ * @version $Id: BasicCloud.java,v 1.182 2008/04/12 11:18:09 michiel Exp $
  */
 public class BasicCloud implements Cloud, Cloneable, Comparable<Cloud>, 
SizeMeasurable, Serializable {
 
@@ -751,19 +751,18 @@
         return new 
BasicStringList(BasicCloudContext.mmb.getMMBaseCop().getAuthorization().getPossibleContexts(getUser()));
     }
 
-    void   checkNodes(BasicNodeList resultNodeList, Query query) {
+    List<MMObjectNode> checkNodes(List<MMObjectNode> in, Query query) {
+
+        
+        List<MMObjectNode> resultNodeList = new ArrayList<MMObjectNode>(in);
+            
         Authorization auth = 
BasicCloudContext.mmb.getMMBaseCop().getAuthorization();
-        resultNodeList.autoConvert = false; // make sure no conversion to Node 
happen, until we are ready.
 
         if (log.isTraceEnabled()) {
             log.trace(resultNodeList);
         }
 
         log.debug("Starting read-check");
-        // resultNodeList is now a BasicNodeList; read restriction should only 
be applied now
-        // assumed is though, that it contain _only_ MMObjectNodes..
-
-        // get authorization for this call only
 
         List<Step> steps = query.getSteps();
         Step nodeStep = null;
@@ -771,27 +770,23 @@
             nodeStep = ((NodeQuery) query).getNodeStep();
         }
         log.debug("Creating iterator");
-        ListIterator<Node> li = resultNodeList.listIterator();
+        ListIterator<MMObjectNode> li = resultNodeList.listIterator();
         while (li.hasNext()) {
-            Node o = li.next();
+            MMObjectNode node = li.next();
             log.debug("next");
-            if (log.isDebugEnabled()) {
-                log.debug(o.getClass().getName());
-            }
-            Node node = o;
             boolean mayRead = true;
             for (int j = 0; mayRead && (j < steps.size()); ++j) {
                 Step step = steps.get(j);
                 int nodenr;
                 if (step.equals(nodeStep)) {
-                    nodenr = node.getIntValue("number");
+                    nodenr = node.getNumber();
                 } else {
                     String pref = step.getAlias();
                     if (pref == null) {
                         pref = step.getTableName();
                     }
                     String fn = pref + ".number";
-                    if (node.getNodeManager().hasField(fn)) {
+                    if (node.getBuilder().hasField(fn)) {
                         nodenr = node.getIntValue(pref + ".number");
                     } else {
                         log.warn("Could not check step " + step + ". Because, 
the field '" + fn + "' is not found in the node " + node + " which is in the 
result of " + query.toSql());
@@ -807,8 +802,7 @@
                 li.remove();
             }
         }
-        resultNodeList.autoConvert = true;
-
+        return resultNodeList;
 
     }
 
@@ -832,13 +826,15 @@
         // create resultNodeList
         NodeManager  tempNodeManager = new VirtualNodeManager(query, this);
 
-        BasicNodeList resultNodeList = new BasicNodeList(resultList, 
tempNodeManager);
-        resultNodeList.setProperty(NodeList.QUERY_PROPERTY, query);
 
         if (! checked) {
-            checkNodes(resultNodeList, query);
+            resultList = checkNodes(resultList, query);
         }
 
+        BasicNodeList resultNodeList = new BasicNodeList(resultList, 
tempNodeManager);
+        resultNodeList.setProperty(NodeList.QUERY_PROPERTY, query);
+
+
         return resultNodeList;
     }
 


Index: BasicList.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/bridge/implementation/BasicList.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- BasicList.java      27 Feb 2008 11:47:26 -0000      1.31
+++ BasicList.java      12 Apr 2008 11:18:09 -0000      1.32
@@ -18,7 +18,7 @@
  * This is the base class for all basic implementations of the bridge lists.
  *
  * @author Pierre van Rooden
- * @version $Id: BasicList.java,v 1.31 2008/02/27 11:47:26 michiel Exp $
+ * @version $Id: BasicList.java,v 1.32 2008/04/12 11:18:09 michiel Exp $
  */
 public class BasicList<E extends Comparable<? super E>> extends ArrayList<E> 
implements BridgeList<E>  {
 
@@ -26,9 +26,7 @@
 
     private Map<Object, Object> properties = new HashMap<Object, Object>();
 
-    // during inititializion of the list, you sometimes want to switch off
-    // also when everything is certainly converted
-    boolean autoConvert = true;
+    private boolean converted = false;
 
     BasicList() {
         super();
@@ -92,11 +90,7 @@
 
     @Override
     public E get(int index) {
-        if (autoConvert) {
             return convert(super.get(index), index);
-        } else {
-            return super.get(index);
-        }
     }
 
     public void sort() {
@@ -108,34 +102,24 @@
     }
 
 
-    @Override
-    public void add(int index, E o) {
-        autoConvert = true;
-        super.add(index, o);
-    }
-
-    @Override
-    public boolean add(E o) {
-        autoConvert = true;
-        return super.add(o);
-    }
-
     /**
      * @since MMBase-1.6.2
      */
     protected void convertAll() {
+        if (! converted) {
         log.debug("convert all");
         for (int i = 0; i < size(); i++) {
             convert(super.get(i), i);
         }
-        autoConvert = false;
+            converted = true;
+        }
     }
 
 
     @Override
     public Object[] toArray() { // needed when you e.g. want to sort the list.
         // make sure every element is of the right type, otherwise sorting can 
happen on the wrong type.
-        if (autoConvert) convertAll();
+        convertAll();
         return super.toArray();
     }
 
@@ -176,7 +160,6 @@
         }
 
         public void add(E o) {
-            BasicList.this.autoConvert = true;
             iterator.add(o);
         }
 


Index: BasicNodeManager.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/bridge/implementation/BasicNodeManager.java,v
retrieving revision 1.133
retrieving revision 1.134
diff -u -b -r1.133 -r1.134
--- BasicNodeManager.java       21 Jun 2007 13:46:51 -0000      1.133
+++ BasicNodeManager.java       12 Apr 2008 11:18:09 -0000      1.134
@@ -38,7 +38,7 @@
  * @author Rob Vermeulen
  * @author Pierre van Rooden
  * @author Michiel Meeuwissen
- * @version $Id: BasicNodeManager.java,v 1.133 2007/06/21 13:46:51 michiel Exp 
$
+ * @version $Id: BasicNodeManager.java,v 1.134 2008/04/12 11:18:09 michiel Exp 
$
 
  */
 public class BasicNodeManager extends BasicNode implements NodeManager {
@@ -373,16 +373,15 @@
             boolean useCache = query.getCachePolicy().checkPolicy(query);
             List<MMObjectNode> resultList = 
builder.getStorageConnector().getNodes(query, useCache);
             
+            if (! checked) {
+                resultList = cloud.checkNodes(resultList, query);
+            }
+
             BasicNodeList resultNodeList;
             NodeManager nm = query.getNodeManager();
             resultNodeList = new BasicNodeList(resultList, cloud);
-
             resultNodeList.setProperty(NodeList.QUERY_PROPERTY, query);
 
-            if (! checked) {
-                cloud.checkNodes(resultNodeList, query);
-            }
-
             return resultNodeList;
         } catch (SearchQueryException sqe) {
             throw new BridgeException(sqe);
_______________________________________________
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to