You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Mikhail Fedotov <mi...@kittown.com> on 2002/02/16 15:36:05 UTC

EmaiTransformer & SQLTransformer

Hi!

> P.S. Anyone interested in a simple EmailTransformer -
>  i.e. a transformer that interprets email descriptions
>  and sends emails, but leaves the rest of the document
>  intact?

Count me.

I guess it would be perfect, for example, to get some
 addresses from database in SQLTransformer and send email
 to addresses returned, this gives simple way to build
 maillists, for example.

But this would be much more useful if SQLTransformer will
 look like Esql in terms of functionality. As I remember,
 it is way more simple. Something for my "keep in mind"
 list until I'll have time for coding this and contribute.
 
Mikhail

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: EmailTransformer and unit testing code

Posted by David Bigwood <db...@metatomix.com>.
Email Transformer
============

We would like to donate an Email transformer to the Cocoon project.
Attached is java file SendMailTransformer.java. Perhaps this could
be used in conjunction with Stuart's code to produce a finished product
- best of both worlds.

Transformer allows email messages to be generated from a Sax stream.
Support for TO, CC, BCC, Text and HTML formats (HTML can be included
in stream or accessed from a specified URL). Messages are generated
as MIME multipart. HTML body parts can be added directly between
<mtxsm:part type="text/html"> tags, or referenced from an external
URL, with the addition of a src attribute.

The smtphost tag will to using localhost 127.0.0.1 for sending
email if not specified in the XML stream or the sitemap (see below).

Namespace set as mtxsm="http://metatomix.com/sendmail/1.0#"
We would be willing to refactor this to remove the namespace.

XML structure for Sendmail Transformer:

<?xml version="1.0"?>
<root xmlns:mtxsm="http://metatomix.com/sendmail/1.0#">
  ...
  <mtxsm:sendmail confirmation="true">
    <mtxsm:from mtxsm:addr="sender@m3t4.com"
      mtxsm:name="Customer Service"/>
 <mtxsm:to mtxsm:addr="dbigwood@m3t4.com"
   mtxsm:name="David Bigwood"/>
 <mtxsm:cc mtxsm:addr="7819999999@messaging.nextel.com"
   mtxsm:name="David Bigwood"/>
 <mtxsm:bcc mtxsm:addr="davidabigwood@yahoo.com"
   mtxsm:name="DAB"/>
 <mtxsm:subject>Email Test</mtxsm:subject>
 <mtxsm:smtphost>mail.domain.com</mtxsm:smtphost>
 <mtxsm:multipart type="alternative">
   <mtxsm:part type="text/html">
     <html>
     <body>
     <h1>Email Transformer HTML message</h1>
        <p>Standard HTML tags inside XML tag for Mime body part.</p>
        </body>
        </html>
      </mtxsm:part>
      <mtxsm:part type="text/html"
        src="http://domain.com/mtxemail/html/message1.html" />
      <mtxsm:part type="text/plain">
        This is a text message that will be passed through
  as displayed here including line breaks
      </mtxsm:part>
    </mtxsm:multipart>
  </mtxsm:sendmail>
  ...
</root>

Sitemap:

With transformer configured as alias "MTXSendMail".

<map:match pattern="sendmail/**">
  <map:generate type="file" src="mail/mail.xml"/>
  <map:transform type="MTXSendMail">
    <map:parameter name="mail.smtp.host" value="mail.domain.com"/>
    <map:parameter name="removetags" value="true"/>
  </map:transform>
  <map:serialize type="xml"/>
</map:match>

Where:

Data inside the 'mtxsm' namespace is removed from the passing stream
by setting the value of 'removetags' as true.

Success or failure of the send is notified to the stream by modifying
the <mtxsm:sendmail> tag by adding a confirmation attribute set to
true or false:

<mtxsm:sendmail confirmation="true|false" />

This is independent of the removetags setting in the sitemap.

-David Bigwood

----
David Bigwood
VP Engineering
Metatomix Inc






----- Original Message -----
From: "Stuart Roebuck" <st...@mac.com>
To: <co...@xml.apache.org>
Sent: Sunday, February 17, 2002 5:46 PM
Subject: Re: EmailTransformer and unit testing code


>
> On Sunday, February 17, 2002, at 09:00 pm, Stefano Mazzocchi wrote:
>
> > Stuart Roebuck wrote:
> >>
> >> Well I've got got an EmailTransformer I've produced for a current
> >> project,
> >>   it's not too elegant at the moment, but it works, and it has some
> >> generic
> >> unit test code that folk might be interested in for testing the
> >> processing
> >> of a transformer - I don't think there's much unit test code in the
> >> current Cocoon codebase, infact I think I might be responsible for all
of
> >> it!!.
> >>
> >> If anyone can find the time to relocate it appropriately in the cocoon
> >> class hierarchy, I have a number of bits of unit testing infrastructure
> >> that might be handy to other folk:
> >>
> >>         Mock Classes for Avalon:
> >>                 avalon.excalibur.DataSourceComponent
> >>         Mock Classes for Framework:
> >>                 avalon.framework.ComponentManager
> >>                 avalon.framework.Configuration
> >>         Mock Classes for Cocoon:
> >>                 cocoon.environment.Redirector
> >>                 cocoon.environment.Request
> >>                 cocoon.environment.Session
> >>                 cocoon.environment.Source
> >>                 cocoon.environment.SourceResolver
> >>
> >> These provide sufficient glue to unit test quite a lot of actions,
> >> generators and transformers in isolation which could also be handy for
> >> some kinds of performance testing.
> >>
> >> Anyone interested?
> >
> > I'd be. Make them available somewhere and post the URL.
>
> I've posted them at:
>
> <http://www.adolos.co.uk/temp/mocks_and_email_transformer.tgz>
>
> I've put the email transformer in there because it is the only bit of
> general use that demonstrates the use of the Mock Classes.  There will be
> a number of updates to the Email Transformer this week to integrate
> facilities for constructing multi-part MIME emails with file attachments,
> based on the SendMail utility class which I have included in this archive.
>
> Here's a clip from a unit test for another custom Form Mail action we have
> under development, it shows the mock classes in use:
>
> >     private AbstractAction action;
> >     private SessionMock session;
> >     private Redirector redirector;
> >     private SourceResolver sourceResolver;
> >     private RequestMock request;
> >     private Response response;
> >     private Parameters parameters;
> >     private Map objectModel;
> >     private MockConnection connection;
> >     private MockStatement statement;
> >
> >     public void setUp() {
> >         this.action = new EmailFormAction();
> >         this.session = new SessionMock();
> >         this.redirector = new RedirectorMock();
> >         this.sourceResolver = new SourceResolverMock();
> >         this.request = new RequestMock();
> >         this.response = new CommandLineResponse();
> >         this.parameters = new Parameters();
> >         this.objectModel = new HashMap();
> >         this.objectModel.put(Constants.REQUEST_OBJECT, this.request);
> >         this.objectModel.put(Constants.RESPONSE_OBJECT, this.response);
> >     }
> >
> >
> >     public void testEmailForm() throws Exception {
> >         this.parameters.setParameter("smtphost","smtp.demon.co.uk");
> >         this.parameters.setParameter("from","testing@adolos.co.uk");
> >
this.parameters.setParameter("to","stuart.roebuck@adolos.co.uk");
> >         this.parameters.setParameter("subject","Testing
EmailFormAction")
> > ;
> >         this.parameters.setParameter("body","Default body test.");
> >         this.parameters.setParameter("testing","yes");
> >
> >         this.request.mockSetParameter("name","Stuart Roebuck");
> >
this.request.mockSetParameter("email","stuart.roebuck@adolos.com"
> > );
> >         this.request.mockSetParameter("answer","cat");
> >         this.request.mockSetParameter("answer","dog");
> >         this.request.mockSetParameter("_submit","submit");
> >         // This subject and body above should override the values set
> > below:
> >         this.request.mockSetParameter("_email_subject", "New subject");
> >         this.request.mockSetParameter("_email_body", "This comes before
> > the results");
> >
> >         Map map = action.act(this.redirector, this.sourceResolver,
> > this.objectModel, "src", this.parameters);
> >         assertEquals("testing@adolos.co.uk", (String) map.get("from"));
> >         assertEquals("stuart.roebuck@adolos.co.uk", (String)
map.get("to"
> > ));
> >         assertEquals("Testing EmailFormAction", (String)
map.get("subject"
> > ));
> >         assertEquals("Default body test.\n" +
> >                      "email = stuart.roebuck@adolos.com\n" +
> >                      "name = Stuart Roebuck\n" +
> >                      "answer = cat,dog\n",
> >                      (String) map.get("body"));
> >     }
>
> If it finds a home I'll try to set aside some time to add some comments
> and send them in as patches.
>
> Stuart.
>
>
>
>             Public Key - 1024D/88DD65AF 2001-11-23 Stuart Roebuck (Adolos)
>       Key fingerprint = 89D9 E405 F8B1 9B22 0FA2  F2C1 9E57 5AB1 88DD 65AF
> -------------------------------------------------------------------------
> Stuart Roebuck                                  stuart.roebuck@adolos.com
> Systems Architect                             Java, XML, MacOS X, XP, etc.
> ADOLOS                                           <http://www.adolos.com/>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
>
>

Re: EmailTransformer and unit testing code

Posted by Stuart Roebuck <st...@mac.com>.
On Sunday, February 17, 2002, at 09:00 pm, Stefano Mazzocchi wrote:

> Stuart Roebuck wrote:
>>
>> Well I've got got an EmailTransformer I've produced for a current 
>> project,
>>   it's not too elegant at the moment, but it works, and it has some 
>> generic
>> unit test code that folk might be interested in for testing the 
>> processing
>> of a transformer - I don't think there's much unit test code in the
>> current Cocoon codebase, infact I think I might be responsible for all of
>> it!!.
>>
>> If anyone can find the time to relocate it appropriately in the cocoon
>> class hierarchy, I have a number of bits of unit testing infrastructure
>> that might be handy to other folk:
>>
>>         Mock Classes for Avalon:
>>                 avalon.excalibur.DataSourceComponent
>>         Mock Classes for Framework:
>>                 avalon.framework.ComponentManager
>>                 avalon.framework.Configuration
>>         Mock Classes for Cocoon:
>>                 cocoon.environment.Redirector
>>                 cocoon.environment.Request
>>                 cocoon.environment.Session
>>                 cocoon.environment.Source
>>                 cocoon.environment.SourceResolver
>>
>> These provide sufficient glue to unit test quite a lot of actions,
>> generators and transformers in isolation which could also be handy for
>> some kinds of performance testing.
>>
>> Anyone interested?
>
> I'd be. Make them available somewhere and post the URL.

I've posted them at:

	<http://www.adolos.co.uk/temp/mocks_and_email_transformer.tgz>

I've put the email transformer in there because it is the only bit of 
general use that demonstrates the use of the Mock Classes.  There will be 
a number of updates to the Email Transformer this week to integrate 
facilities for constructing multi-part MIME emails with file attachments, 
based on the SendMail utility class which I have included in this archive.

Here's a clip from a unit test for another custom Form Mail action we have 
under development, it shows the mock classes in use:

>     private AbstractAction action;
>     private SessionMock session;
>     private Redirector redirector;
>     private SourceResolver sourceResolver;
>     private RequestMock request;
>     private Response response;
>     private Parameters parameters;
>     private Map objectModel;
>     private MockConnection connection;
>     private MockStatement statement;
>
>     public void setUp() {
>         this.action = new EmailFormAction();
>         this.session = new SessionMock();
>         this.redirector = new RedirectorMock();
>         this.sourceResolver = new SourceResolverMock();
>         this.request = new RequestMock();
>         this.response = new CommandLineResponse();
>         this.parameters = new Parameters();
>         this.objectModel = new HashMap();
>         this.objectModel.put(Constants.REQUEST_OBJECT, this.request);
>         this.objectModel.put(Constants.RESPONSE_OBJECT, this.response);
>     }
>
>
>     public void testEmailForm() throws Exception {
>         this.parameters.setParameter("smtphost","smtp.demon.co.uk");
>         this.parameters.setParameter("from","testing@adolos.co.uk");
>         this.parameters.setParameter("to","stuart.roebuck@adolos.co.uk");
>         this.parameters.setParameter("subject","Testing EmailFormAction")
> ;
>         this.parameters.setParameter("body","Default body test.");
>         this.parameters.setParameter("testing","yes");
>
>         this.request.mockSetParameter("name","Stuart Roebuck");
>         this.request.mockSetParameter("email","stuart.roebuck@adolos.com"
> );
>         this.request.mockSetParameter("answer","cat");
>         this.request.mockSetParameter("answer","dog");
>         this.request.mockSetParameter("_submit","submit");
>         // This subject and body above should override the values set 
> below:
>         this.request.mockSetParameter("_email_subject", "New subject");
>         this.request.mockSetParameter("_email_body", "This comes before 
> the results");
>
>         Map map = action.act(this.redirector, this.sourceResolver, 
> this.objectModel, "src", this.parameters);
>         assertEquals("testing@adolos.co.uk", (String) map.get("from"));
>         assertEquals("stuart.roebuck@adolos.co.uk", (String) map.get("to"
> ));
>         assertEquals("Testing EmailFormAction", (String) map.get("subject"
> ));
>         assertEquals("Default body test.\n" +
>                      "email = stuart.roebuck@adolos.com\n" +
>                      "name = Stuart Roebuck\n" +
>                      "answer = cat,dog\n",
>                      (String) map.get("body"));
>     }

If it finds a home I'll try to set aside some time to add some comments 
and send them in as patches.

Stuart.



            Public Key - 1024D/88DD65AF 2001-11-23 Stuart Roebuck (Adolos)
      Key fingerprint = 89D9 E405 F8B1 9B22 0FA2  F2C1 9E57 5AB1 88DD 65AF
-------------------------------------------------------------------------
Stuart Roebuck                                  stuart.roebuck@adolos.com
Systems Architect                             Java, XML, MacOS X, XP, etc.
ADOLOS                                           <http://www.adolos.com/>


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: EmailTransformer and unit testing code

Posted by Stefano Mazzocchi <st...@apache.org>.
Stuart Roebuck wrote:
> 
> Well I've got got an EmailTransformer I've produced for a current project,
>   it's not too elegant at the moment, but it works, and it has some generic
> unit test code that folk might be interested in for testing the processing
> of a transformer - I don't think there's much unit test code in the
> current Cocoon codebase, infact I think I might be responsible for all of
> it!!.
> 
> If anyone can find the time to relocate it appropriately in the cocoon
> class hierarchy, I have a number of bits of unit testing infrastructure
> that might be handy to other folk:
> 
>         Mock Classes for Avalon:
>                 avalon.excalibur.DataSourceComponent
>         Mock Classes for Framework:
>                 avalon.framework.ComponentManager
>                 avalon.framework.Configuration
>         Mock Classes for Cocoon:
>                 cocoon.environment.Redirector
>                 cocoon.environment.Request
>                 cocoon.environment.Session
>                 cocoon.environment.Source
>                 cocoon.environment.SourceResolver
> 
> These provide sufficient glue to unit test quite a lot of actions,
> generators and transformers in isolation which could also be handy for
> some kinds of performance testing.
> 
> Anyone interested?

I'd be. Make them available somewhere and post the URL.

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<st...@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


EmailTransformer and unit testing code

Posted by Stuart Roebuck <st...@mac.com>.
Well I've got got an EmailTransformer I've produced for a current project,
  it's not too elegant at the moment, but it works, and it has some generic 
unit test code that folk might be interested in for testing the processing 
of a transformer - I don't think there's much unit test code in the 
current Cocoon codebase, infact I think I might be responsible for all of 
it!!.

If anyone can find the time to relocate it appropriately in the cocoon 
class hierarchy, I have a number of bits of unit testing infrastructure 
that might be handy to other folk:

	Mock Classes for Avalon:
		avalon.excalibur.DataSourceComponent
	Mock Classes for Framework:
		avalon.framework.ComponentManager
		avalon.framework.Configuration
	Mock Classes for Cocoon:
		cocoon.environment.Redirector
		cocoon.environment.Request
		cocoon.environment.Session
		cocoon.environment.Source
		cocoon.environment.SourceResolver

These provide sufficient glue to unit test quite a lot of actions, 
generators and transformers in isolation which could also be handy for 
some kinds of performance testing.

Anyone interested?

Stuart.

On Saturday, February 16, 2002, at 02:36 pm, Mikhail Fedotov wrote:

> Hi!
>
>> P.S. Anyone interested in a simple EmailTransformer -
>>  i.e. a transformer that interprets email descriptions
>>  and sends emails, but leaves the rest of the document
>>  intact?
>
> Count me.
>
> I guess it would be perfect, for example, to get some
>  addresses from database in SQLTransformer and send email
>  to addresses returned, this gives simple way to build
>  maillists, for example.
>
> But this would be much more useful if SQLTransformer will
>  look like Esql in terms of functionality. As I remember,
>  it is way more simple. Something for my "keep in mind"
>  list until I'll have time for coding this and contribute.
>
> Mikhail
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
>
>

            Public Key - 1024D/88DD65AF 2001-11-23 Stuart Roebuck (Adolos)
      Key fingerprint = 89D9 E405 F8B1 9B22 0FA2  F2C1 9E57 5AB1 88DD 65AF
-------------------------------------------------------------------------
Stuart Roebuck                                  stuart.roebuck@adolos.com
Systems Architect                             Java, XML, MacOS X, XP, etc.
ADOLOS                                           <http://www.adolos.com/>


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: Patch for ESQL Logicsheet

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 16.Feb.2002 -- 04:58 PM, Andreas Neuenschwander wrote:
> Can someone apply this small patch to the esql.xsl logicsheet?

Thanks for your patch. It is applied. Please cross check.

	Chris.

-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: Patch for ESQL Logicsheet

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 17.Feb.2002 -- 11:41 AM, Nicola Ken Barozzi wrote:
> From: "Andreas Neuenschwander" <an...@andi.ch>
> 
> > Hi there,
> >
> > Can someone apply this small patch to the esql.xsl logicsheet?
> 
> Thank you very much for the patch. :-)
> 
> To help developers in applying patches, we ask to insert the patch in
> Bugzilla http://nagoya.apache.org/bugzilla/ , so that we can easily keep
> track of pending patches and keep history.
> 
> Please insert the patch there, it will be reviewed by Cocoon committers
> ASAP.

Hi.

Had a look at the patch. Needs additional modification of get-update-count
template. Will check it in on Monday.

Please use context diffs in future (diff -c).

	Chris.

-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: Patch for ESQL Logicsheet

Posted by Nicola Ken Barozzi <ba...@nicolaken.com>.
From: "Andreas Neuenschwander" <an...@andi.ch>

> Hi there,
>
> Can someone apply this small patch to the esql.xsl logicsheet?

Thank you very much for the patch. :-)

To help developers in applying patches, we ask to insert the patch in
Bugzilla http://nagoya.apache.org/bugzilla/ , so that we can easily keep
track of pending patches and keep history.

Please insert the patch there, it will be reviewed by Cocoon committers
ASAP.

Thank you.

--
Nicola Ken Barozzi                 xml-cocoon@nicolaken.com
            - verba volant, scripta manent -
   (discussions get forgotten, just code remains)
---------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Patch for ESQL Logicsheet

Posted by Andreas Neuenschwander <an...@andi.ch>.
Hi there,

Can someone apply this small patch to the esql.xsl logicsheet?

The orig_esql.xsl was taken from the cocoon2.0.1-src distribution.

This patch prevents a compile time error in nested esql statements.
(Explained in detail in my previous email)


[root@ISIS java]# diff orig_esql.xsl
/home/develop/repository/patched_esql.xsl
524,525c524
< int _esql_update_count = _esql_query.getStatement().getUpdateCount();
< if (_esql_update_count &gt;= 0) {
---
> if (_esql_query.getStatement().getUpdateCount() &gt;= 0) {


Thx,

    Andi




---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: EmaiTransformer & SQLTransformer

Posted by Mikhail Fedotov <mi...@kittown.com>.
Hi!

> I guess it would be perfect, for example, to get some
>  addresses from database in SQLTransformer and send email
>  to addresses returned, this gives simple way to build
>  maillists, for example.

Hmm, just figured out that this can be done by using
 aggregator with ESQL. Most times.

Also, I've got some ideas about subcomponent object model.

The picture:

              /-- subpipeline1 --\
pipeline1 -(1)-                  -(2)- pipeline2
              \-- subpipeline2 --/

I.e. one pipeline starts, splits, and then results are
 being aggregate. Subpipelines are executing some
 transformers like executing SQL queries in one and sending
 email in another.

First stage is about splitting things apart, and second
 about aggregating. But that if we'll just aggregate ? Then
 all we have to specify is that we aggregate subpipelines,
 and they BOTH requre as a source SAX stream at (1). 

ps. BTW, is there any "request-time" caching implemented ?
 This can be useful for some non-cacheable resources that
 are used several times while processing request, this is
 one of such cases.

Mikhail

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org