Re: REST / Can't find URLResponseBuilder
Johannes Lichtenberger schrieb: On Sun, 2009-11-29 at 07:32 +0100, Jos Snellings wrote: In the samples, a typical use of StringTemplate is shown: a page is to be interpreted by the StringTemplate engine, and a number of properties are passed via the hashtable. The idea is that you would open a view on the object. So, - the query points to a resource - the controller decodes what the resource is and what you want (view it, update it?) - the way to view it could be: pass my resource to a StringTemplate invocation: new Page('stringtemplateinvocation',resource); However, I have not tried to elaborate this so far. Shall I post it when i have a useable example? Yes it would be great. My concern is that I don't want to display a template page. I want to process the request (the parameters Google Earth sends when zooming in) and within my Generator query a native XML database system and built the algorithmic logic inside the generator (what data out of the shreddered xml file is needed and has to be transformed with an XSLT stylesheet). So I basically know how RESTful webservices work, but I don't know how to use cocoon3 in this case (I assume new Page(...) isn't the right thing to return when I just want to pass the request params to my generator. So I don't want to use StringTemplate in this case (but it's nontheless a great thing). So the query points to a controller, which decides that it's a GET request (view) and passes the parameters on to my generator (which I still have to write). Would be great if you or someone else could help me out (it's a project in a course of our university ;-) and I thought cocoon is great for this concern (get RESTful parameters, hand it on to a generator which selects the needed data out of a shreddered xml file according to the parameters, then transform the xml fragments with a XSLT stylesheet and serialize the result, so that Google Earth can use the KML fragments generated). Hi, I'm not entirely sure I understand what you want to do (or to be more precise which parts already exist and which don't), but I'll try to improvise. I can imagine two approaches: 1. You can access HTTP request parameters from a generator (or any other PipelineComponent - a Controller is just a fancy PipelineComponent) as well. The SitemapServlet will add all HTTP request parameters to the invocation that is built to handle the request and will be passed to every PipelineComponent in the org.apache.cocoon.pipeline.component.PipelineComponent.setup(MapString, Object) method. The keys will be the names of the HTTP request parameters. Read the parameters in your generator, and then perform the rest of your logic. 2. Keep the controller and do all pre-processing necessary within the controller: the XML DB, XSLT (if you just want to use XLST have a look at org.apache.cocoon.sax.util.TransformationUtils) etc. When you are ready, store the data required for your generator in a parameter map (just like you did in the code fragment you posted) and delegate to a pipeline that uses your generator. The generator will be able to access the data the same way I described above. Only difference would be that in this case the key would be defined by your controller, while in the approach above the key would be determined by the name of the HTTP request parameter. hth, Steven Thank you, Johannes
Re: REST / Can't find URLResponseBuilder
Steven Dolg schrieb: Johannes Lichtenberger schrieb: On Sun, 2009-11-29 at 07:32 +0100, Jos Snellings wrote: In the samples, a typical use of StringTemplate is shown: a page is to be interpreted by the StringTemplate engine, and a number of properties are passed via the hashtable. The idea is that you would open a view on the object. So, - the query points to a resource - the controller decodes what the resource is and what you want (view it, update it?) - the way to view it could be: pass my resource to a StringTemplate invocation: new Page('stringtemplateinvocation',resource); However, I have not tried to elaborate this so far. Shall I post it when i have a useable example? Yes it would be great. My concern is that I don't want to display a template page. I want to process the request (the parameters Google Earth sends when zooming in) and within my Generator query a native XML database system and built the algorithmic logic inside the generator (what data out of the shreddered xml file is needed and has to be transformed with an XSLT stylesheet). So I basically know how RESTful webservices work, but I don't know how to use cocoon3 in this case (I assume new Page(...) isn't the right thing to return when I just want to pass the request params to my generator. So I don't want to use StringTemplate in this case (but it's nontheless a great thing). So the query points to a controller, which decides that it's a GET request (view) and passes the parameters on to my generator (which I still have to write). Would be great if you or someone else could help me out (it's a project in a course of our university ;-) and I thought cocoon is great for this concern (get RESTful parameters, hand it on to a generator which selects the needed data out of a shreddered xml file according to the parameters, then transform the xml fragments with a XSLT stylesheet and serialize the result, so that Google Earth can use the KML fragments generated). Hi, I'm not entirely sure I understand what you want to do (or to be more precise which parts already exist and which don't), but I'll try to improvise. I just found your other mail from earlier (REST / own generator) and it seems your only problem is to access the HTTP request parameters. If that's the case ditch the controller and access them in your generator like I explained in the first approach below. They are already there - no need to use a controller to make them accessible... I can imagine two approaches: 1. You can access HTTP request parameters from a generator (or any other PipelineComponent - a Controller is just a fancy PipelineComponent) as well. The SitemapServlet will add all HTTP request parameters to the invocation that is built to handle the request and will be passed to every PipelineComponent in the org.apache.cocoon.pipeline.component.PipelineComponent.setup(MapString, Object) method. The keys will be the names of the HTTP request parameters. Read the parameters in your generator, and then perform the rest of your logic. 2. Keep the controller and do all pre-processing necessary within the controller: the XML DB, XSLT (if you just want to use XLST have a look at org.apache.cocoon.sax.util.TransformationUtils) etc. When you are ready, store the data required for your generator in a parameter map (just like you did in the code fragment you posted) and delegate to a pipeline that uses your generator. The generator will be able to access the data the same way I described above. Only difference would be that in this case the key would be defined by your controller, while in the approach above the key would be determined by the name of the HTTP request parameter. hth, Steven Thank you, Johannes
Re: REST / Can't find URLResponseBuilder
On Sun, 2009-11-29 at 07:32 +0100, Jos Snellings wrote: In the samples, a typical use of StringTemplate is shown: a page is to be interpreted by the StringTemplate engine, and a number of properties are passed via the hashtable. The idea is that you would open a view on the object. So, - the query points to a resource - the controller decodes what the resource is and what you want (view it, update it?) - the way to view it could be: pass my resource to a StringTemplate invocation: new Page('stringtemplateinvocation',resource); However, I have not tried to elaborate this so far. Shall I post it when i have a useable example? Yes it would be great. My concern is that I don't want to display a template page. I want to process the request (the parameters Google Earth sends when zooming in) and within my Generator query a native XML database system and built the algorithmic logic inside the generator (what data out of the shreddered xml file is needed and has to be transformed with an XSLT stylesheet). So I basically know how RESTful webservices work, but I don't know how to use cocoon3 in this case (I assume new Page(...) isn't the right thing to return when I just want to pass the request params to my generator. So I don't want to use StringTemplate in this case (but it's nontheless a great thing). So the query points to a controller, which decides that it's a GET request (view) and passes the parameters on to my generator (which I still have to write). Would be great if you or someone else could help me out (it's a project in a course of our university ;-) and I thought cocoon is great for this concern (get RESTful parameters, hand it on to a generator which selects the needed data out of a shreddered xml file according to the parameters, then transform the xml fragments with a XSLT stylesheet and serialize the result, so that Google Earth can use the KML fragments generated). Thank you, Johannes
Re: REST / Can't find URLResponseBuilder
On Sat, 2009-11-28 at 07:43 +0100, Jos Snellings wrote: org.apache.cocoon.rest.jaxrs.response.URLResponseBuilder.java What version do you have in your project pom? It should be alpha 2 I guess. Or build it from the svn trunk, svn co http://svn.apache.org/repos/asf/cocoon/cocoon3 It is now a bit hard to keep everything consistent, as there are still changes made in the interfaces. Hm, it can't find alpha-2 (it really seems to be alpha-2 specific -- http://cocoon.apache.org/3.0/changes-report.html and it isn't released) and I'm not sure how to integrate the trunk version with maven. I've used the mvn commands described uhm somewhere (for mysite, myparent, mysample und mywebapp)... Downloading: http://repo1.maven.org/maven2/org/apache/cocoon/rest/cocoon-rest/3.0.0-alpha-2/cocoon-rest-3.0.0-alpha-2.jar [INFO] Unable to find resource 'org.apache.cocoon.rest:cocoon-rest:jar:3.0.0-alpha-2' in repository central (http://repo1.maven.org/maven2) Now I've changed it back to: return new Page(servlet:/controller/screen, data); and I have a generator, let's say: public class GoogleEarthGenerator extends AbstractGenerator { public void execute() { System.out.println(); } } How do I print out the reqparam from the data HashMap? I'm really new to Cocoon, but I need REST ;-) regards, Johannes
Re: REST / Can't find URLResponseBuilder
In the samples, a typical use of StringTemplate is shown: a page is to be interpreted by the StringTemplate engine, and a number of properties are passed via the hashtable. The idea is that you would open a view on the object. So, - the query points to a resource - the controller decodes what the resource is and what you want (view it, update it?) - the way to view it could be: pass my resource to a StringTemplate invocation: new Page('stringtemplateinvocation',resource); However, I have not tried to elaborate this so far. Shall I post it when i have a useable example? Cheers, Jos On Sat, 2009-11-28 at 14:14 +0100, Johannes Lichtenberger wrote: It is now a bit hard to keep everything consistent, as there are still changes made in the interfaces. Hm, it can't find alpha-2 (it really seems to be alpha-2 specific -- http://cocoon.apache.org/3.0/changes-report.html and it isn't released) and I'm not sure how to integrate the trunk version with maven. I've used the mvn commands described uhm somewhere (for mysite, myparent, mysample und mywebapp)... Downloading: http://repo1.maven.org/maven2/org/apache/cocoon/rest/cocoon-rest/3.0.0-alpha-2/cocoon-rest-3.0.0-alpha-2.jar [INFO] Unable to find resource
REST / Can't find URLResponseBuilder
Hello, the class URLResponseBuilder can't be resolved :( Now I have the following controller: public class GoogleEarthController implements Get { @SitemapParameter private String mGearth; @RequestParameter private String reqparam; @Override public RestResponse doGet() throws Exception { final MapString, Object data = new HashMapString, Object(); data.put(mGearth, mGearth); data.put(reqparam, reqparam); return new URLResponseBuilder.newInstance(servlet:/controller/screen, data).build(); } } And I'm still not sure how to get acess to my HashMap _within_ a pipeline: map:pipeline map:match pattern=gearth/{mGarth} controller:call controller=rest-controller select=com.treetank.cocoon.controller.GoogleEarthController map:parameter name=mGearth value={map:mGearth}/ /controller:call /map:match map:match pattern=controller/screen map:generate type=gearth / map:serialize type=xml / /map:match /map:pipeline Precisely within the gearth generator (which should serve dynamically KML content (well out of a native xml database which has to be transformed) to GoogleEarth depending on the parameters Google sent (should be fairly trivial once I figured out how to get acess to my HashMap and if returnin a URLResponseBuilder object is the right thing. regards, Johannes
Re: REST / Can't find URLResponseBuilder
org.apache.cocoon.rest.jaxrs.response.URLResponseBuilder.java What version do you have in your project pom? It should be alpha 2 I guess. Or build it from the svn trunk, svn co http://svn.apache.org/repos/asf/cocoon/cocoon3 It is now a bit hard to keep everything consistent, as there are still changes made in the interfaces. Jos On Sat, 2009-11-28 at 05:02 +0100, Johannes Lichtenberger wrote: URLResponseBuilder