Hi all,

i trying to integrate Cocoon via CocoonBean into my application. This work really 
fine, but  the "followLinks" don't  process every last link in every page.
After trying with CLI, i got the same problem. I looked into the Source 
CocoonBean.java and found in the method process() the possible problem/bug.

Every page is search for links and all were found, but every last found target will 
removed.

-- codepart from CocoonBean.process() --

       while (targetMap.size() > 0) {
            Target target = (Target) targetMap.keySet().iterator().next();
            try {
                if (!allProcessedLinks.containsKey(target)) {
                    if (precompileOnly) {
                        processXSP(target.getSourceURI());
                    } else if (this.followLinks) {



// Here are all links searched and the put into the targetMap



                        i = processTarget(target).iterator();
                        while (i.hasNext()) {
                            target = (Target) i.next(); 
                            targetMap.put(target, target); 
                        }




                    } else {
                        processTarget(target);
                    }
                }
            } catch (ResourceNotFoundException rnfe) {
                this.sendBrokenLinkWarning(target.getSourceURI(), rnfe.getMessage());
            }


 //but here the last target will removed here


            targetMap.remove(target);
            nCount++;


-- end codepart --

After changing this to the following

-- my codepart to CocoonBean.process() --

       while (targetMap.size() > 0) {
            Target target = (Target) targetMap.keySet().iterator().next();
            try {
                if (!allProcessedLinks.containsKey(target)) {
                    if (precompileOnly) {
                        processXSP(target.getSourceURI());
                    } else if (this.followLinks) {
                        i = processTarget(target).iterator();
                        while (i.hasNext()) {



// my changes here


                            Target child = (Target) i.next(); 
                            targetMap.put(child, child); 


                        }

                    } else {
                        processTarget(target);
                    }
                }
            } catch (ResourceNotFoundException rnfe) {
                this.sendBrokenLinkWarning(target.getSourceURI(), rnfe.getMessage());
            }

            targetMap.remove(target);
            nCount++;


-- end codepart --

it will as expected.

I don't know if these broke other thing, so i applied the patch with this email.


I hope it helps and thanks for Cocoon,

Simon


--- cocoon-2.1.1/src/java/org/apache/cocoon/bean/CocoonBean.java	2003-09-05 11:14:48.000000000 +0200
+++ src/java/org/apache/cocoon/bean/CocoonBean.java	2003-09-19 13:07:03.000000000 +0200
@@ -293,8 +293,8 @@
                     } else if (this.followLinks) {
                         i = processTarget(target).iterator();
                         while (i.hasNext()) {
-                            target = (Target) i.next();
-                            targetMap.put(target, target);
+                            Target child = (Target) i.next();
+                            targetMap.put(child, child);
                         }
                     } else {
                         processTarget(target);

Reply via email to