You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by da...@apache.org on 2003/01/28 13:55:22 UTC
cvs commit: jakarta-james/proposals/imap2/java/org/apache/james JamesImap.java JamesImap.xinfo James.java James.xinfo
darrell 2003/01/28 04:55:22
Modified: proposals/imap2 build.xml
proposals/imap2/conf james-assembly.xml
Added: proposals/imap2/java/org/apache/james JamesImap.java
JamesImap.xinfo
Removed: proposals/imap2/java/org/apache/james James.java James.xinfo
Log:
Imap2 proposal:
* Added JamesImap.java, which extends James.java and
contains only imap-specific customisations.
* Modified assembly.xml to use JamesImap.java for MailServer
service.
Revision Changes Path
1.6 +1 -4 jakarta-james/proposals/imap2/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-james/proposals/imap2/build.xml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- build.xml 27 Jan 2003 13:03:10 -0000 1.5
+++ build.xml 28 Jan 2003 12:55:22 -0000 1.6
@@ -231,9 +231,6 @@
<exclude name="${constants.file}"/>
<exclude name="${poolconn.file}"/>
<exclude name="org/apache/james/userrepository/UsersLDAPRepository.java" unless="jndi.present"/>
-
- <!-- These file(s) are in both the proposal and the main trunk. -->
- <exclude name="org/apache/james/James.java"/>
</javac>
<!-- Copy .xinfo and .properties files from the core source, once again,
1.2 +1 -1 jakarta-james/proposals/imap2/conf/james-assembly.xml
Index: james-assembly.xml
===================================================================
RCS file: /home/cvs/jakarta-james/proposals/imap2/conf/james-assembly.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- james-assembly.xml 22 Nov 2002 02:09:50 -0000 1.1
+++ james-assembly.xml 28 Jan 2003 12:55:22 -0000 1.2
@@ -19,7 +19,7 @@
<!-- -->
<!-- The James block -->
- <block name="James" class="org.apache.james.James" >
+ <block name="James" class="org.apache.james.JamesImap" >
<!-- Specify which components will provide the services required by this
block. The roles are specified in the code and the .xinfo file. The names
1.1 jakarta-james/proposals/imap2/java/org/apache/james/JamesImap.java
Index: JamesImap.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.james;
import org.apache.james.core.MailImpl;
import org.apache.james.imapserver.ImapHost;
import org.apache.james.imapserver.store.ImapMailbox;
import org.apache.james.imapserver.store.MailboxException;
import org.apache.james.services.JamesUser;
import org.apache.james.userrepository.DefaultJamesUser;
import org.apache.mailet.MailAddress;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.component.ComponentManager;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
/**
* Core class for JAMES. Provides three primary services:
* <br> 1) Instantiates resources, such as user repository, and protocol
* handlers
* <br> 2) Handles interactions between components
* <br> 3) Provides container services for Mailets
*
*
* @version This is $Revision: 1.1 $
*/
public class JamesImap extends James
{
/**
* Whether James should use IMAP storage
*/
private boolean useIMAPstorage = false;
/**
* The host to be used for IMAP storage
*/
private ImapHost imapHost;
protected void initialiseInboxes( Configuration configuration,
ComponentManager componentManager ) throws Exception
{
try {
// Get storage config param
if ( configuration.getChild( "storage" ).getValue().equals( "IMAP" ) ) {
useIMAPstorage = true;
getLogger().info( "Using IMAP Store-System" );
}
}
catch ( Exception e ) {
// No storage entry found in config file
}
// Get the LocalInbox repository
if ( useIMAPstorage ) {
try {
// We will need to use a no-args constructor for flexibility
imapHost = ( ImapHost ) componentManager.lookup( ImapHost.ROLE );
}
catch ( Exception e ) {
getLogger().error( "Exception in IMAP Storage init: " + e.getMessage() );
throw e;
}
}
else {
super.initialiseInboxes(configuration, componentManager);
}
}
//Methods for MailetContext
protected void storeMail( String username, MimeMessage message, MailAddress recipient, MailAddress sender ) throws MessagingException
{
JamesUser user;
if ( useIMAPstorage ) {
ImapMailbox mbox = null;
try {
user = ( JamesUser ) getLocalusers().getUserByName( username );
mbox = imapHost.getInbox( user );
MailImpl mail = new MailImpl( message );
mbox.store( mail );
getLogger().info( "Message " + message.getMessageID() +
" stored in " +
mbox.getFullName() );
mbox = null;
}
catch ( Exception e ) {
getLogger().error( "Exception storing mail: " + e );
e.printStackTrace();
if ( mbox != null ) {
mbox = null;
}
throw new RuntimeException( "Exception storing mail: " + e );
}
}
else {
super.storeMail( username, message, recipient, sender );
}
}
/**
* Adds a user to this mail server. Currently just adds user to a
* UsersRepository.
* <p> As we move to IMAP support this will also create mailboxes and
* access control lists.
*
* @param userName String representing user name, that is the portion of
* an email address before the '@<domain>'.
* @param password String plaintext password
* @return boolean true if user added succesfully, else false.
*/
public boolean addUser(String userName, String password)
{
boolean success;
DefaultJamesUser user = new DefaultJamesUser(userName, "SHA");
user.setPassword(password);
user.initialize();
success = getLocalusers().addUser(user);
if ( useIMAPstorage && success ) {
try {
imapHost.createPrivateMailAccount( user );
getLogger().info( "New MailAccount created for" + userName );
}
catch ( MailboxException e ) {
return false;
}
}
return success;
}
}
1.1 jakarta-james/proposals/imap2/java/org/apache/james/JamesImap.xinfo
Index: JamesImap.xinfo
===================================================================
<?xml version="1.0"?>
<blockinfo>
<!-- section to describe block -->
<block>
<version>1.0</version>
</block>
<!-- services that are offered by this block -->
<services>
<service name="org.apache.james.services.MailServer" version="1.0" />
<service name="org.apache.mailet.MailetContext" version="1.0" />
</services>
<!-- interfaces that may be exported to manange this block -->
<management-access-points>
<service name="org.apache.james.JamesMBean"/>
</management-access-points>
<dependencies>
<dependency>
<service name="org.apache.james.services.DNSServer" version="1.0"/>
</dependency>
<dependency>
<service name="org.apache.james.services.MailStore" version="1.0"/>
</dependency>
<dependency>
<service name="org.apache.james.services.UsersStore" version="1.0"/>
</dependency>
<dependency>
<service name="org.apache.avalon.cornerstone.services.connection.ConnectionManager"
version="1.0"/>
</dependency>
<dependency>
<service name="org.apache.avalon.cornerstone.services.sockets.SocketManager" version="1.0"/>
</dependency>
<dependency>
<service name="org.apache.avalon.cornerstone.services.scheduler.TimeScheduler" version="1.0"/>
</dependency>
<dependency>
<service name="org.apache.avalon.cornerstone.services.datasource.DataSourceSelector" version="1.0"/>
</dependency>
<dependency>
<service name="org.apache.james.imapserver.ImapHost" version="1.0"/>
</dependency>
</dependencies>
</blockinfo>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>