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 no...@apache.org on 2010/09/20 14:01:09 UTC
svn commit: r998900 - in /james/server/trunk:
core-api/src/main/java/org/apache/james/services/
core-library/src/test/java/org/apache/james/services/
spoolmanager/src/main/java/org/apache/james/
Author: norman
Date: Mon Sep 20 12:01:08 2010
New Revision: 998900
URL: http://svn.apache.org/viewvc?rev=998900&view=rev
Log:
Remove deprecated methods from MailServer. If we want to break interfaces then we should do it now..
Modified:
james/server/trunk/core-api/src/main/java/org/apache/james/services/MailServer.java
james/server/trunk/core-library/src/test/java/org/apache/james/services/MailServerTestAllImplementations.java
james/server/trunk/spoolmanager/src/main/java/org/apache/james/JamesMailServer.java
james/server/trunk/spoolmanager/src/main/java/org/apache/james/JamesMailetContext.java
Modified: james/server/trunk/core-api/src/main/java/org/apache/james/services/MailServer.java
URL: http://svn.apache.org/viewvc/james/server/trunk/core-api/src/main/java/org/apache/james/services/MailServer.java?rev=998900&r1=998899&r2=998900&view=diff
==============================================================================
--- james/server/trunk/core-api/src/main/java/org/apache/james/services/MailServer.java (original)
+++ james/server/trunk/core-api/src/main/java/org/apache/james/services/MailServer.java Mon Sep 20 12:01:08 2010
@@ -21,13 +21,9 @@
package org.apache.james.services;
-import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
-
import javax.mail.MessagingException;
-import javax.mail.internet.MimeMessage;
-import java.io.InputStream;
-import java.util.Collection;
+
+import org.apache.mailet.Mail;
/**
* The interface for Phoenix blocks to the James MailServer
@@ -53,34 +49,6 @@ public interface MailServer
String ALL = "AllMailUsers";
/**
- * Pass a MimeMessage to this MailServer for processing
- *
- * @param sender - the sender of the message
- * @param recipients - a Collection of String objects of recipients
- * @param msg - the MimeMessage of the headers and body content of
- * the outgoing message
- * @throws MessagingException - if the message fails to parse
- *
- * @deprecated You can use MailetContext service for this purpose
- */
- void sendMail(MailAddress sender, Collection<MailAddress> recipients, MimeMessage msg)
- throws MessagingException;
-
- /**
- * Pass a MimeMessage to this MailServer for processing
- *
- * @param sender - the sender of the message
- * @param recipients - a Collection of String objects of recipients
- * @param msg - an InputStream containing the headers and body content of
- * the outgoing message
- * @throws MessagingException - if the message fails to parse
- *
- * @deprecated You can use MailetContext service for this purpose
- */
- void sendMail(MailAddress sender, Collection<MailAddress> recipients, InputStream msg)
- throws MessagingException;
-
- /**
* Pass a Mail to this MailServer for processing
*
* @param mail the Mail to be processed
@@ -88,18 +56,7 @@ public interface MailServer
*/
void sendMail(Mail mail)
throws MessagingException;
-
- /**
- * Pass a MimeMessage to this MailServer for processing
- *
- * @param message the message
- * @throws MessagingException
- *
- * @deprecated You can use MailetContext service for this purpose
- */
- void sendMail(MimeMessage message)
- throws MessagingException;
-
+
/**
* Generate a new identifier/name for a mail being processed by this server.
@@ -109,19 +66,6 @@ public interface MailServer
String getId();
/**
- * Adds a new user to the mail system with userName. For POP3 style stores
- * this may only involve adding the user to the UsersStore.
- *
- * @param userName - the name of the user
- * @return a reference to an initialised mailbox
- *
- * @deprecated addUser should not be considered a property of a MailServer
- * We could have readonly userbases providing full MailServer implementations.
- * Look at the UsersRepository.addUser(username, password) method.
- */
- boolean addUser(String userName, String password);
-
- /**
* Checks if a server is serviced by mail context
*
* @param serverName - name of server.
Modified: james/server/trunk/core-library/src/test/java/org/apache/james/services/MailServerTestAllImplementations.java
URL: http://svn.apache.org/viewvc/james/server/trunk/core-library/src/test/java/org/apache/james/services/MailServerTestAllImplementations.java?rev=998900&r1=998899&r2=998900&view=diff
==============================================================================
--- james/server/trunk/core-library/src/test/java/org/apache/james/services/MailServerTestAllImplementations.java (original)
+++ james/server/trunk/core-library/src/test/java/org/apache/james/services/MailServerTestAllImplementations.java Mon Sep 20 12:01:08 2010
@@ -57,44 +57,5 @@ abstract public class MailServerTestAllI
assertFalse("next id is different", id1.equals(id2));
}
- public void testAddUser() throws Exception {
-
- // addUser acts on field localUsers for class org.apache.james.James
- // thus, it is unrelated to getUserInbox() for the only known implementation of MailServer
- // TODO clarify this
-
- MailServer mailServer = createMailServer();
-
- String userName = "testUserName";
-
- if (canTestUserExists())
- {
- assertFalse("this is a fresh user", isUserExisting(mailServer, userName+"@localhost"));
- }
-
- boolean allowsPasswordlessUser = allowsPasswordlessUser();
- try {
- boolean success = mailServer.addUser(userName, null);
- if (!allowsPasswordlessUser) fail("null pwd was accepted unexpectedly");
- if (!success) fail("null pwd was not accepted unexpectedly");
- } catch (Exception e) {
- if (allowsPasswordlessUser) fail("null pwd not accepted unexpectedly (with exception)");
- }
-
- userName = userName + "_next";
- String password = "password";
-
- boolean success = mailServer.addUser(userName, password);
- if (!success) fail("user has not been added");
-
- if (canTestUserExists())
- {
- assertTrue("user is present now", isUserExisting(mailServer, userName));
- }
-
- boolean successAgain = mailServer.addUser(userName, password);
- if (successAgain) fail("user has been added two times");
-
- }
-
+
}
Modified: james/server/trunk/spoolmanager/src/main/java/org/apache/james/JamesMailServer.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/JamesMailServer.java?rev=998900&r1=998899&r2=998900&view=diff
==============================================================================
--- james/server/trunk/spoolmanager/src/main/java/org/apache/james/JamesMailServer.java (original)
+++ james/server/trunk/spoolmanager/src/main/java/org/apache/james/JamesMailServer.java Mon Sep 20 12:01:08 2010
@@ -21,22 +21,14 @@
package org.apache.james;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.SequenceInputStream;
import java.net.UnknownHostException;
import java.util.Collection;
-import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
-import javax.mail.Address;
import javax.mail.MessagingException;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeMessage;
import javax.mail.internet.ParseException;
import org.apache.commons.configuration.ConfigurationException;
@@ -45,10 +37,6 @@ import org.apache.commons.logging.Log;
import org.apache.james.api.dnsservice.DNSService;
import org.apache.james.api.domainlist.DomainList;
import org.apache.james.api.domainlist.ManageableDomainList;
-import org.apache.james.api.user.UsersRepository;
-import org.apache.james.core.MailHeaders;
-import org.apache.james.core.MailImpl;
-import org.apache.james.impl.jamesuser.JamesUsersRepository;
import org.apache.james.lifecycle.Configurable;
import org.apache.james.lifecycle.LifecycleUtil;
import org.apache.james.lifecycle.LogEnabled;
@@ -56,20 +44,10 @@ import org.apache.james.queue.MailQueue;
import org.apache.james.queue.MailQueueFactory;
import org.apache.james.services.MailServer;
import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
/**
- * 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$
-
+ *
*/
-@SuppressWarnings("unchecked")
public class JamesMailServer
implements MailServer, LogEnabled, Configurable {
@@ -83,13 +61,6 @@ public class JamesMailServer
*/
private HierarchicalConfiguration conf = null;
-
- /**
- * The user repository for this mail server. Contains all the users with inboxes
- * on this server.
- */
- private UsersRepository localusers;
-
/**
* The collection of domain/server names for which this instance of James
* will receive and process mail.
@@ -151,7 +122,8 @@ public class JamesMailServer
}
- @PostConstruct
+ @SuppressWarnings("unchecked")
+ @PostConstruct
public void init() throws Exception {
logger.info("JAMES init...");
@@ -159,16 +131,7 @@ public class JamesMailServer
queue = queueFactory.getQueue("spool");
if (conf.getKeys("usernames").hasNext()) {
- HierarchicalConfiguration userNamesConf = conf.configurationAt("usernames");
-
- if (localusers instanceof JamesUsersRepository) {
- logger.warn("<usernames> parameter in James block is deprecated. Please configure this data in UsersRepository block: configuration injected for backward compatibility");
- ((JamesUsersRepository) localusers).setIgnoreCase(userNamesConf.getBoolean("[@ignoreCase]", false));
- ((JamesUsersRepository) localusers).setEnableAliases(userNamesConf.getBoolean("[@enableAliases]", false));
- ((JamesUsersRepository) localusers).setEnableForwarding(userNamesConf.getBoolean("[@enableForwarding]", false));
- } else {
- logger.error("<usernames> parameter is no more supported. Backward compatibility is provided when using an AbstractUsersRepository but this repository is a "+localusers.getClass().toString());
- }
+ throw new ConfigurationException("<usernames> parameter in James block was removed. Please configure this data in UsersRepository block: configuration injected for backward compatibility");
}
if (conf.getKeys("servernames").hasNext()) {
@@ -245,59 +208,6 @@ public class JamesMailServer
/**
- * Place a mail on the spool for processing
- *
- * @param message the message to send
- *
- * @throws MessagingException if an exception is caught while placing the mail
- * on the spool
- */
- public void sendMail(MimeMessage message) throws MessagingException {
- MailAddress sender = new MailAddress((InternetAddress)message.getFrom()[0]);
- Collection<MailAddress> recipients = new HashSet<MailAddress>();
- Address addresses[] = message.getAllRecipients();
- if (addresses != null) {
- for (int i = 0; i < addresses.length; i++) {
- // Javamail treats the "newsgroups:" header field as a
- // recipient, so we want to filter those out.
- if ( addresses[i] instanceof InternetAddress ) {
- recipients.add(new MailAddress((InternetAddress)addresses[i]));
- }
- }
- }
- sendMail(sender, recipients, message);
- }
-
- /**
- * @see org.apache.james.services.MailServer#sendMail(MailAddress, Collection, MimeMessage)
- */
- public void sendMail(MailAddress sender, Collection recipients, MimeMessage message)
- throws MessagingException {
- try {
- sendMail(sender, recipients, message.getInputStream());
- } catch (IOException e) {
- throw new MessagingException("Unable to send message",e);
- }
- }
-
-
- /**
- * @see org.apache.james.services.MailServer#sendMail(MailAddress, Collection, InputStream)
- */
- public void sendMail(MailAddress sender, Collection recipients, InputStream msg)
- throws MessagingException {
- // parse headers
- MailHeaders headers = new MailHeaders(msg);
-
- // if headers do not contains minimum REQUIRED headers fields throw Exception
- if (!headers.isValid()) {
- throw new MessagingException("Some REQURED header field is missing. Invalid Message");
- }
- ByteArrayInputStream headersIn = new ByteArrayInputStream(headers.toByteArray());
- sendMail(new MailImpl(getId(), sender, recipients, new SequenceInputStream(headersIn, msg)));
- }
-
- /**
* @see org.apache.james.services.MailServer#sendMail(Mail)
*/
public void sendMail(Mail mail) throws MessagingException {
@@ -377,24 +287,6 @@ public class JamesMailServer
return false;
}
}
-
- /**
- * Adds a user to this mail server. Currently just adds user to a
- * UsersRepository.
- *
- * @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.
- *
- * @deprecated we deprecated this in the MailServer interface and this is an implementation
- * this component depends already depends on a UsersRepository: clients could directly
- * use the addUser of the usersRepository.
- */
- public boolean addUser(String userName, String password) {
- return localusers.addUser(userName, password);
- }
-
/**
* @see org.apache.james.services.MailServer#supportVirtualHosting()
*/
Modified: james/server/trunk/spoolmanager/src/main/java/org/apache/james/JamesMailetContext.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/JamesMailetContext.java?rev=998900&r1=998899&r2=998900&view=diff
==============================================================================
--- james/server/trunk/spoolmanager/src/main/java/org/apache/james/JamesMailetContext.java (original)
+++ james/server/trunk/spoolmanager/src/main/java/org/apache/james/JamesMailetContext.java Mon Sep 20 12:01:08 2010
@@ -32,6 +32,7 @@ import java.util.Vector;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
+import javax.mail.Address;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.internet.InternetAddress;
@@ -352,35 +353,54 @@ public class JamesMailetContext implemen
log.info(arg0, arg1);
}
- /*
- * (non-Javadoc)
- * @see org.apache.mailet.MailetContext#sendMail(javax.mail.internet.MimeMessage)
+ /**
+ * Place a mail on the spool for processing
+ *
+ * @param message the message to send
+ *
+ * @throws MessagingException if an exception is caught while placing the mail
+ * on the spool
*/
public void sendMail(MimeMessage message) throws MessagingException {
- mailServer.sendMail(message);
+ MailAddress sender = new MailAddress((InternetAddress)message.getFrom()[0]);
+ Collection<MailAddress> recipients = new HashSet<MailAddress>();
+ Address addresses[] = message.getAllRecipients();
+ if (addresses != null) {
+ for (int i = 0; i < addresses.length; i++) {
+ // Javamail treats the "newsgroups:" header field as a
+ // recipient, so we want to filter those out.
+ if ( addresses[i] instanceof InternetAddress ) {
+ recipients.add(new MailAddress((InternetAddress)addresses[i]));
+ }
+ }
+ }
+ sendMail(sender, recipients, message);
}
/*
* (non-Javadoc)
- * @see org.apache.mailet.MailetContext#sendMail(org.apache.mailet.Mail)
+ * @see org.apache.mailet.MailetContext#sendMail(org.apache.mailet.MailAddress, java.util.Collection, javax.mail.internet.MimeMessage)
*/
- public void sendMail(Mail mail) throws MessagingException {
- mailServer.sendMail(mail);
+ @SuppressWarnings("unchecked")
+ public void sendMail(MailAddress sender, Collection recipients, MimeMessage message)
+ throws MessagingException {
+ sendMail(sender, recipients, message, Mail.DEFAULT);
}
/*
* (non-Javadoc)
- * @see org.apache.mailet.MailetContext#sendMail(org.apache.mailet.MailAddress, java.util.Collection, javax.mail.internet.MimeMessage)
+ * @see org.apache.mailet.MailetContext#sendMail(org.apache.mailet.Mail)
*/
- public void sendMail(MailAddress sender, Collection recipients, MimeMessage msg) throws MessagingException {
- mailServer.sendMail(sender, recipients, msg);
+ public void sendMail(Mail mail) throws MessagingException {
+ mailServer.sendMail(mail);
}
/*
* (non-Javadoc)
* @see org.apache.mailet.MailetContext#sendMail(org.apache.mailet.MailAddress, java.util.Collection, javax.mail.internet.MimeMessage, java.lang.String)
*/
- public void sendMail(MailAddress sender, Collection recipients, MimeMessage message, String state) throws MessagingException {
+ @SuppressWarnings("unchecked")
+ public void sendMail(MailAddress sender, Collection recipients, MimeMessage message, String state) throws MessagingException {
MailImpl mail = new MailImpl(mailServer.getId(), sender, recipients, message);
try {
mail.setState(state);
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org