You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Simon Mieth <si...@t-online.de> on 2003/09/19 14:03:44 UTC

CocoonBean followLink problem

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



Re: CocoonBean followLink problem

Posted by Upayavira <uv...@upaya.co.uk>.
Simon,

Thank you very much for this! I was aware of this being a problem (it 
has been reported by people on the Forrest list), but had suspected it 
to be something much deeper than what you have shown it to be.

You've also explained why, when using confirm-extensions="true" gave a 
different number of pages to confirm-extensions="false", which was 
puzzling me.

I've committed an updated bean with your patch in it, so the CVS CLI 
won't have this problem. It also has a few more features (see the 
cli.xconf in cocoon root), such as grouping of URIs that share properties.

Thanks very much for reporting this - you've saved me a lot of time!

Regards, Upayavira


Simon Mieth wrote:

>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
>
>
>  
>