Hello,

I am writing a mailet that checks incoming mail to see if the first part of the recipient name matches an existing user. If it does, the mail gets forwarded to that user (with some additional processing).

For example, say the following users are set up:

red
red_blue
red_blue_green

If mail comes in for the following recipient:

red_blue_extra_info

then the user red_blue is matched and the mail gets forwarded on to red_blue (with some extra processing done on extra_info).

To make this work, my matcher needs to know what the current users are. I looked through the James code to see how it checks user names and came up with the following:


public Collection match(Mail mail) throws MessagingException {
System.out.println("Test...");
ComponentManager compMgr = (ComponentManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
UsersStore usersStore = null;
try {
usersStore = (UsersStore) compMgr.lookup(UsersStore.ROLE);
UsersRepository localusers = (UsersRepository) usersStore.getRepository("LocalUsers");


for(Iterator it = localusers.list(); it.hasNext();)
System.out.println(it.next());
} catch (ComponentException e) {
e.printStackTrace();
}
return null;
}


This works, but I want to make sure I'm not missing something important. Is this a good way to get the list of user names? I could instead use telnet and use the Remote interface to get the names that way, but that strikes me as inefficient.

According to the JavaDocs on the website MailContext used to have a "getUserRepository()" function which I could then directly query for a list of users. This is exactly what I need. I'm using James 2.1.3 -- why was this useful method removed?





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to