You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by fadi qutaishat <fa...@yahoo.com> on 2005/04/05 17:01:15 UTC
Could some help in this!
Hi all, I have the following situation :
<map:pipeline>
<map:match pattern="login">
<map:generate src="project/login.xml"/>
<map:transform src="project/login.xsl">
<map:parameter name="use-request-parameters" value="true"/>
</map:transform>
<map:transform type="sql">
<map:parameter name="use-connection" value="newdb"/>
</map:transform>
<map:serialize type="xml"/>
</map:match>
<map:match pattern="do-session">
<map:generate src="project/buildusersession.xml"/>
<map:transform type="session"/>
<map:serialize type="xml"/>
</map:match>
</map:pipeline>
The second match pattern builds a session context and loads its data from the first match pattern. How can I tell cocoon to automatically execute the second match pattern (i.e. without explicitly requesting it via the Internet explorer). is it possible to do this ?
Many thanks,
Fadi
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Re: Could some help in this!
Posted by Philippe Guillard <pg...@citycita.net>.
Hum,
Maybe using redirection. But it seems you want to show a login page and
then put user info in the session : you maybe should use Authantication
framework?
Phil
fadi qutaishat wrote:
>Hi all, I have the following situation :
>
>
>
><map:pipeline>
>
><map:match pattern="login">
>
><map:generate src="project/login.xml"/>
>
><map:transform src="project/login.xsl">
>
><map:parameter name="use-request-parameters" value="true"/>
>
> </map:transform>
>
><map:transform type="sql">
>
><map:parameter name="use-connection" value="newdb"/>
>
> </map:transform>
>
> <map:serialize type="xml"/>
>
> </map:match>
>
>
>
><map:match pattern="do-session">
>
><map:generate src="project/buildusersession.xml"/>
>
><map:transform type="session"/>
>
><map:serialize type="xml"/>
>
></map:match>
>
></map:pipeline>
>
>
>
>The second match pattern builds a session context and loads its data from the first match pattern. How can I tell cocoon to automatically execute the second match pattern (i.e. without explicitly requesting it via the Internet explorer). is it possible to do this ?
>
>
>
>Many thanks,
>
>Fadi
>
>
>
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam? Yahoo! Mail has the best spam protection around
>http://mail.yahoo.com
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Could some help in this!
Posted by Grzegorz Sikora <sz...@op.pl>.
Hello fadi,
Tuesday, April 5, 2005, 5:01:15 PM, you wrote:
fq> The second match pattern builds a session context and loads
fq> its data from the first match pattern. How can I tell cocoon to
fq> automatically execute the second match pattern (i.e. without
fq> explicitly requesting it via the Internet explorer). is it
fq> possible to do this ?
Maybe flowscript would be better approach ... but I've written simple action
which can call another pipeline and eventually creates sitemap
parameter with returned XML as DOM tree:
import org.apache.avalon.excalibur.component.ComponentHandler;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.acting.ConfigurableComposerAction;
import org.apache.cocoon.components.sax.XMLByteStreamCompiler;
import org.apache.cocoon.components.sax.XMLByteStreamFragment;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.generation.FileGenerator;
import org.apache.cocoon.xml.AbstractXMLConsumer;
import org.w3c.dom.Document;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
public class CallPipelineAction extends ConfigurableComposerAction implements
Disposable, ThreadSafe {
ComponentHandler generatorHandler;
public void configure(Configuration conf) throws ConfigurationException {
try {
this.generatorHandler = ComponentHandler.getComponentHandler(
FileGenerator.class, conf, this.manager, null,
null,
null,
null,
"N/A"
);
this.generatorHandler.enableLogging(getLogger());
this.generatorHandler.initialize();
} catch (Exception e) {
throw new ConfigurationException("Cannot set up component handler", e);
}
}
public void dispose() {
if (this.generatorHandler != null) {
this.generatorHandler.dispose();
this.generatorHandler = null;
}
}
public Map act(Redirector redirector, SourceResolver resolver,
Map objectModel, String source, Parameters parameters) throws Exception {
String pipeline = parameters.getParameter("pipeline");
String discard = parameters.getParameter("discard", "false");
String outputParamName = parameters.getParameter("output", "output");
FileGenerator generator = (FileGenerator) this.generatorHandler.get();
XMLByteStreamCompiler compiler = null;
Map map = new HashMap();
try {
Parameters genParams = new Parameters();
generator.enableLogging(getLogger());
generator.setup(resolver, objectModel, pipeline, genParams);
if (discard.equals("true")) {
generator.setConsumer(new AbstractXMLConsumer() {
});
generator.generate();
} else {
compiler = new XMLByteStreamCompiler();
generator.setConsumer(compiler);
generator.generate();
XMLByteStreamFragment fragment = new XMLByteStreamFragment(compiler
.getSAXFragment());
DocumentBuilder builder = DocumentBuilderFactory.newInstance()
.newDocumentBuilder();
Document doc = builder.newDocument();
fragment.toDOM(doc);
Request request = ObjectModelHelper.getRequest(objectModel);
request.setAttribute(outputParamName, doc);
}
} catch (Exception e) {
if (getLogger().isErrorEnabled())
getLogger().error("Error while calling another pipeline " + e);
map = null;
} finally {
generatorHandler.put(generator);
}
return map;
}
}
Sample usage:
<map:act type="call-pipeline">
<map:parameter name="pipeline"
value="cocoon:/some-pipe-2-execute"/>
<map:parameter name="discard" value="true"/>
</map:act>
--
Best regards,
Grzegorz Sikora
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org