james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefano Debenedetti <...@webaccess.mozquito.com>
Subject a MimeMessage serializer to ietf's XML format for email
Date Fri, 13 Sep 2002 17:29:53 GMT
Hello James developers,

1) first I really would like to thank you for the great James software.

2) Then I attach a first attempt at implementing this:

http://www.ietf.org/internet-drafts/draft-klyne-message-rfc822-xml-03.txt

(it's an XML format for rfc822 semantics)

Please find attached a class that inherits from MimeMessage and adds a 
writeTo method that also accepts namespace prefix configuration parameters.

I am quite new to java programming so there probably are design flaws 
and pitfalls that I am missing, I would love to hear your comments about 
that. A known bug is that it doesn't handle properly rfc822 charset 
escaping in the subject.

3) Also, for using that class I thought a different kind of repository 
was a good idea but I encountered some problems that make me think now 
that probably I should have done it some other way:

I wanted to use a ToRepository mailet like this:

<mailet match="SubjectStartsWith=[PUBLISH]" class="ToRepository">
	<repositoryPath>file:///Inetpub/data/mail</repositoryPath>
	<passThrough> true </passThrough>
</mailet>

but then I found out that different kind of repositories are triggered 
on a per-protocol name basis in James so that I would need to use a 
different protocol name for triggering a special repository that stores 
mail as XML, for example:

<mailet match="SubjectStartsWith=[PUBLISH]" class="ToRepository">
	<repositoryPath>publish:///Inetpub/data/mail</repositoryPath>
	<passThrough> true </passThrough>
</mailet>

so that a custom version of the AvalonMailRepository could be used, in 
which I changed only the store method but left intact all Avalon 
infrastructure for handling the phisical repository because I thought 
that was handy.
The problem then was that during initialization of my custom version of 
the AvalonMailRepository I got an error from Cornerstone's 
RepositoryManager trying to feed the URL for the repository to a 
java.net.URL and getting an "Unknown protocol exception" back from it.
So I used this instead:

<mailet match="SubjectStartsWith=[PUBLISH]" class="ToRepository">
	<repositoryPath>http:///Inetpub/data/mail</repositoryPath>
	<passThrough> true </passThrough>
</mailet>

and got past that but there still was another problem: the 
File_Persistent_Stream_Repository used by AvalonMailRepository is 
checking that the URL used starts with "file://" (it doesn't really use 
it so is it a useless check?) so I had to make another change to the 
special version of AvalonMailRepository substituting "http" with "file" 
as a protocol name inside the configure method, therefore losing the 
advantage of having the protocol name as a generic repository selector, 
at least to my eyes.
Anyway, that was enough to see that XML serializer work but it seems 
that further steps for really using this mechanism are flawed in a 
similar way, for example I found out that I should also write a custom 
version of File_Persistent_Stream_Repository if I want, say, a different 
  file extension than ".FileStreamStore", ouch.

So I stopped there and wrote you this mail, should I just perform the 
publishing from within a mailet and forget about the repository idea?

Also, how can a repository know what kind of filter triggered it? 
(Suppose I want the "[PUBLISH]" tag removed from the subject line before 
saving...)

Please excuse the length of the mail and all the nonsense that I 
probably wrote, while I eagerly wait for any suggestions and comments, 
please throw some light on my java programming :-)

Thanks a lot, ciao
ste


Mime
View raw message