Document on http://james.apache.org/server/3/config-system.html

"In combination with james-database.properties and META-INF/persistence.xml, the datasource to access the database is defined in spring-server.xml"

Eric

On 06/15/2012 09:07 AM, Eric Charles wrote:
Hi Jerry,

Glad you made it work :)

You can find the datasource definition in the spring-server.xml located
in $JAMES_HOME/conf/META-INF/org/apache/james/spring-server.xml (at the
bottom of the file, section "Database DataSource", it is indeed defined
as a org.apache.commons.dbcp.BasicDataSource with best-effort regarding
the eviction... parameters).

Obviously, this should be further documented on
http://james.apache.org/server/3/config-system.html where we although
describe the james-database.properties and link to the spring-server.xml
file...

Thx, Eric


On 06/15/2012 01:21 AM, Jerry Tian wrote:
Hi, Eric,

Thanks for your hint. This bug finally turned out to be my mistake on
new line characters("\r\n", not "\n") used in mail body stream.

Now the server is switched to MySQL as backend mail storage. There is
one thing I can't find out myself with respect to this deployment
configuration.

There is only one collection opened by James after starting it up. I
am guessing James is using Apache's common DBCP as its database
connection pool(since I found this JAR in "lib" directory), but how do
I configure it? A grep within the James directory doen't yield useful
search results, and the manual on website also doesn't mention it.

Regards.

On Mon, Jun 4, 2012 at 1:26 AM, Eric Charles<e...@apache.org> wrote:
Hi Jerry,

Not sure what's happening there. The String you give is not empty, so it
should work.

Kickoff your debuger and follow the path all the way down... Check
also what
is stored in your Derby database (database files are located under
${your.james.home}/var/store/derby - you will have to stop james and
connect
via a jdbc client with the correct connect string
jdbc:derby:/${your.james.home}/var/store/derby).

Thx, Eric


On 06/03/2012 04:00 PM, Jerry Tian wrote:

Hi, Eric,

Thanks for your help, kinda on the move these days, sorry for the late
reply.

BTW, I am also thinking of using a IMAP client to manipulate the mail
store, this seems more "safe" but less efficient. So, for better
efficiency, I still prefer the direct way.


On Thu, May 31, 2012 at 1:32 AM, Eric Charles<e...@apache.org> wrote:

Hi Jerry,

Why do you want to store anything if you want to act as a proxy?
Shouldn't
you always delegate the request to the remote imap server?


You are right, it do include 2-way data transfer, and the James server
is acting as a gateway, the previous proxy concept is not accurate.

It is used to bring a legacy client and a third party service together.


To try to answer your question:
- which mailstore do you use: memory?


Now, the test and debug installation is using the default Derby
database, which should be the memory mail store you mentioned. In
production env, MySQL
is our choice.

- are you accessing the same mailstore when invoke getMessages()?


Yes.


Print also the content of the msgContent string before callen
append().


=========================================

Subject: Coming soon
From: a...@def.com<a...@def.com>
X-Universally-Unique-Identifier: 3f4e6172-042b-4363-8edb-a366751f8163
Content-Type: text/html;
charset=utf-8
X-Uniform-Type-Identifier: com.apple.mail-note
Message-Id:<a95c1844-a3cb-4726-9c3d-d8c9031a6...@def.com>
Date: Thu, 24 May 2012 16:19:31 +0800
X-Mail-Created-Date: Thu, 24 May 2012 16:19:31 +0800
Content-Transfer-Encoding: 7bit
Mime-Version: 1.0 (1.0)

Coming soon

=========================================

This is the message I dumped before append(). Hope it helps.


Thx, Eric


On 05/30/2012 05:20 PM, Jerry Tian wrote:


Hi, Jame developers,

I am building a proxy/gateway using james-imap-processor sub-module.
Currently I directly put my testing logic into the actual processor.

In org.apache.james.imap.processor.SearchProcessor, before the actual
searching happening, I am trying to insert/save some fake mails into
mailbox using the provided MailboxManager.

This is the code, more of a hack, which is borrowed from the
AppendProcessor.

=========================================
//add this message into mailbox.
String msgContent =
this.getNewMsgStreamContent(noteData.getNoteTitle(),

noteData.getNoteTitle(),//noteData.getNoteContent(),
new
Date(noteData.getCreatedAt()),
inoteUID,
null,
userId,
userDomain);

logger.info("using raw msg content generated: " +
msgContent);

final MailboxPath mailboxPath = ...;
final SelectedMailbox selectedMailbox =
imapSession.getSelected();
final boolean isSelectedMailbox = selectedMailbox
!= null&&
selectedMailbox.getPath().equals(mailboxPath);

mailbox.appendMessage(new
ByteArrayInputStream(msgContent.getBytes("ISO-8859-1")),
new
Date(noteData.getCreatedAt()),
mailboxSession,
!isSelectedMailbox,
new Flags());
=========================================

And the referred getNewMsgStreamContent method is as below(the
template used is dumped before using the same client and server):

=========================================
private String getNewMsgStreamContent(String title, String
content,
Date cDate, String inoteUUID, String msgUUID, String userId, String
domain) {
final SimpleDateFormat sdf = new SimpleDateFormat("EEE, d
MMM yyyy
HH:mm:ss Z");

if (cDate == null) {
cDate = new Date();
}
String currDate = sdf.format(cDate);

if (inoteUUID == null) {
inoteUUID = UUID.randomUUID().toString();
}

if (msgUUID == null) {
msgUUID = UUID.randomUUID().toString() + "@" +
domain;
}

String syncUser = userId + "@" + domain;

return NEW_MSG_TPL.replaceAll("__TITLE__", title)
.replaceAll("__SYNC_USER__", syncUser)
.replaceAll("__INOTE_UUID__", inoteUUID)
.replaceAll("__MSG_UUID__", msgUUID)
.replaceAll("__CDATE__", currDate)
.replaceAll("__BODY__", content);
}

=========================================

From my test, the above method will produce a message as this:

=========================================

Subject: Coming soon
From: a...@def.com<a...@def.com>
X-Universally-Unique-Identifier: 3f4e6172-042b-4363-8edb-a366751f8163
Content-Type: text/html;
charset=utf-8
X-Uniform-Type-Identifier: com.apple.mail-note
Message-Id:<a95c1844-a3cb-4726-9c3d-d8c9031a6...@def.com>
Date: Thu, 24 May 2012 16:19:31 +0800
X-Mail-Created-Date: Thu, 24 May 2012 16:19:31 +0800
Content-Transfer-Encoding: 7bit
Mime-Version: 1.0 (1.0)

Coming soon

=========================================

Although the invoking of appendMessage generates no exception so far,
it turns out only an empty mail record is stored in this mail box.
That is, the messageManager.getMessages(MessageRange,
FetchGroup.HEADERS, mailboxSession) does returns newly added records
in search result, but only MessageResult.getUid() returns a valid
value, and all other header values are missing(different from the
normal mail records from real clients).

Any clue why this is happening? And is there a more developer
friendly
way to directly save a "fake" mail into user's mailbox?

Thanks a lot.

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org


--
eric | http://about.echarles.net | @echarles

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org


--
eric | http://about.echarles.net | @echarles

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org



--
eric | http://about.echarles.net | @echarles

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to