Hi there,
I am currently trying to integrate cocoon 2.0.3 with a web application. The idea is to use cocoon as a reports engine to generate printable HTML documents.
I have basically downloaded cocoon-2.0.3-src.zip, built on Windows 2K (JDK 1.3.1), and deployed in Jboss 2.4.6 with tomcat 4.0.3.
In a first step, I chose to deploy cocoon as standalone, and simply add my own sitemap to the existing webapp:
<map:pipelines>
<map:pipeline>
<map:match pattern="CMReports/**">
<map:mount uri="CMReports" src=""CMReports/sitemap.xmap"" check-reload="yes"/>
</map:match>
</map:pipeline>
…
</map:pipelines>
And access the reports pages at http://localhost:8080/cocoon/Reports/myreport.html
In a second step, I added an action in my own sitemap, to perform session validation, so that reports can only be accessible via our web application, passing our session object to the pipeline.
CMReports/sitemap.xmap:
<?xml version="1.0" encoding="UTF-8"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<map:components>
<map:generators default="file"/>
<map:transformers default="xslt"/>
<map:readers default="resource"/>
<map:serializers default="html"/>
<map:selectors default="browser"/>
<map:matchers default="wildcard"/>
<map:actions>
<map:action name="ensureLoggedIn"
src=""com.kainos.cocoon.action.EnsureLoggedInAction"" />
</map:actions>
</map:components>
<map:pipelines>
<!-- HTML reports -->
<map:pipeline>
<map:match pattern="*.html">
<map:act type="ensureLoggedIn">
<map:generate type="serverpages" src=""documents/{1}.xsp"" />
<map:transform src=""stylesheets/{1}.xsl"" />
<map:serialize type="html" />
</map:act>
</map:match>
</map:pipeline>
</map:pipelines>
</map:sitemap>
And here is the code for the action:
public class EnsureLoggedInAction extends AbstractAction
{
public Map act(Redirector redirector_p,
SourceResolver resolver_p,
Map objectModel_p,
String sSource_p,
Parameters params_p)
{
Map map = null;
Request request = (Request) objectModel_p.get(Constants.REQUEST_OBJECT);
CSessionSB sessionSB = null;
// extract the session object passed as an attribute to the request object
sessionSB = (CSessionSB) request.getAttribute("coreSessionSB");
if (null == sessionSB)
{
return null;
}
try
{
sessionSB.ensureLoggedIn();
// the user is logged in, set the map to an empty map
map = EMPTY_MAP;
}
catch(CNotPermittedException e)
{
// nothing to do, map already equals to null
}
catch(RemoteException e)
{
// nothing we can do about it
}
finally
{
return map;
}
}
}
I also modified build.xml to include EnsureLoggedIn.class in web-inf/classes, but upon accessing the page via our web application, I get a resource not found exception
The requested URI "/cocoon/CMReports/CMUsers.html" was not found
I can only assume the addition of the login validation caused the problem, as the page was generated successfully prior to the addition of the action, but cannot see what is going wrong,
Is there any way of debugging actions?
Cedric Picard,
Software Engineer
Kainos Software Ltd.
This e-mail is confidential and is intended for the named recipient only. If
you receive it in error please destroy the message and all copies. Kainos
Software Ltd. does not accept liability for damage sustained as a result of
malicious software (e.g. viruses). Kainos does not accept liability for, or
permit, the creation of contracts on its behalf by e-mail, the publication of
any defamatory statement by its employees by e-mail, or changes subsequently
made to the original message. The Company's registered office is located at
4-6 Upper Crescent, Belfast, BT7 1NT, Northern Ireland, Tel +44 28 9057 1100.