opengeo/geoserver-exts — pull request #4 by rmarianski (2012-07-14 17:27:48+00:00)
Title: Printng reorg

@ischneider - can you review this re-organization? The diff is a little overwhelming because I moved a lot around, so I'll try to explain all the different pieces and the reasoning behind it.

I tried to favor composition over inheritance, so things are structured in terms of smaller readers and writers that handle the different necessary cases. I also tried to move away from the stateful rending approach, by having each piece of the process as a separate concern. So the general flow is to obtain a reader that represents the template source, have a parser convert that into a Document, and then have a writer that takes the document and writes it to a stream. My thinking is that having these as separate pieces should also make it easier to re-use them in different scenarios by mixing and matching them in different ways. In particular I tried to make the writers agnostic of the request or restlet, so that generating the output formats can be directly used in other contexts.

The dispatch uses the same PrintFinder class, but instantiates it with a different reader depending on which route matches. It then figures out what the appropriate writer should be based on the request, and instantiates it appropriately. After that the requests go through the same flow with the differences captured by these readers and writers. I was thinking of adding another reader that pulls the template in from a separate uri, which can now just be added by creating another reader for this scenario.

I noticed that you had some logic to clean up bad html. I added in TagSoup when parsing the input xml into a Document, so that should hopefully cover us from invalid html from clients. I'm hoping that this "just works" for our purposes, but if not I added a flag to turn it off if necessary and we can tackle that separately if/when it comes up.

There's also a handler for posting in new freemarker templates. I save these to the location you were using, under printng/templates.

And I added more unit tests for the different scenarios. It's not 100%, but I think it covers the most important cases.

I also moved the HtmlMap and HtmlMapLayer classes that you had into a separate experimental package.

I don't have any comments describing things, but if we decide to go down this path I'd be happy to add them in.

Thanks for reading if you got this far!