Author: eric
Date: Thu Jan 3 15:17:01 2013
New Revision: 1428396
URL: http://svn.apache.org/viewvc?rev=1428396&view=rev
Log:
SieveMailet's post() impl must use destination from supplied url, patch
contributed by Eike Kettner (JAMES-1464)
Modified:
james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/SieveMailet.java
Modified:
james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/SieveMailet.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/SieveMailet.java?rev=1428396&r1=1428395&r2=1428396&view=diff
==============================================================================
---
james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/SieveMailet.java
(original)
+++
james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/SieveMailet.java
Thu Jan 3 15:17:01 2013
@@ -65,17 +65,20 @@ public class SieveMailet extends SieveMa
public void setFileSystem(FileSystem fileSystem) {
this.fileSystem = fileSystem;
}
-
+
public void setFolder(String folder) {
this.folder = folder;
}
-
+
public SieveMailet() {
super();
}
- /* (non-Javadoc)
- * @see
org.apache.jsieve.mailet.SieveMailboxMailet#init(org.apache.mailet.MailetConfig)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.jsieve.mailet.SieveMailboxMailet#init(org.apache.mailet.
+ * MailetConfig)
*/
@Override
public void init(MailetConfig config) throws MessagingException {
@@ -111,8 +114,12 @@ public class SieveMailet extends SieveMa
}
}
- /* (non-Javadoc)
- * @see
org.apache.jsieve.mailet.SieveMailboxMailet#storeMail(org.apache.mailet.MailAddress,
org.apache.mailet.MailAddress, org.apache.mailet.Mail)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.jsieve.mailet.SieveMailboxMailet#storeMail(org.apache.mailet
+ * .MailAddress, org.apache.mailet.MailAddress, org.apache.mailet.Mail)
*/
@Override
public void storeMail(MailAddress sender, MailAddress recipient, Mail
mail) throws MessagingException {
@@ -123,22 +130,27 @@ public class SieveMailet extends SieveMa
} else {
s = "<>";
}
- // If no exception was thrown the message was successfully stored in
the mailbox
- log("Local delivered mail " + mail.getName() + " sucessfully from " +
s + " to " + recipient.toString() + " in folder " + this.folder);
+ // If no exception was thrown the message was successfully stored in
the
+ // mailbox
+ log("Local delivered mail " + mail.getName() + " sucessfully from " +
s + " to " + recipient.toString()
+ + " in folder " + this.folder);
}
-
- /* (non-Javadoc)
- * @see org.apache.jsieve.mailet.Poster#post(java.lang.String,
javax.mail.internet.MimeMessage)
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.jsieve.mailet.Poster#post(java.lang.String,
+ * javax.mail.internet.MimeMessage)
*/
@Override
public void post(String url, MimeMessage mail) throws MessagingException {
-
+
final int endOfScheme = url.indexOf(':');
-
+
if (endOfScheme < 0) {
throw new MessagingException("Malformed URI");
- }
-
+ }
+
else {
final String scheme = url.substring(0, endOfScheme);
@@ -149,7 +161,8 @@ public class SieveMailet extends SieveMa
// TODO: When user missing, append to a default location
throw new MessagingException("Shared mailbox is not
supported");
} else {
- // lowerCase the user - see
https://issues.apache.org/jira/browse/JAMES-1369
+ // lowerCase the user - see
+ // https://issues.apache.org/jira/browse/JAMES-1369
String user = url.substring(startOfUser,
endOfUser).toLowerCase();
final int startOfHost = endOfUser + 1;
final int endOfHost = url.indexOf('/', startOfHost);
@@ -192,9 +205,10 @@ public class SieveMailet extends SieveMa
}
if (destination.startsWith(session.getPathDelimiter() +
""))
destination = destination.substring(1);
-
- // Use the MailboxSession to construct the MailboxPath -
See JAMES-1326
- final MailboxPath path = new
MailboxPath(MailboxConstants.USER_NAMESPACE, user, this.folder);
+
+ // Use the MailboxSession to construct the MailboxPath -
See
+ // JAMES-1326
+ final MailboxPath path = new
MailboxPath(MailboxConstants.USER_NAMESPACE, user, destination);
try {
if (this.folder.equalsIgnoreCase(destination) &&
!(mailboxManager.mailboxExists(path, session))) {
mailboxManager.createMailbox(path, session);
@@ -206,7 +220,7 @@ public class SieveMailet extends SieveMa
}
mailbox.appendMessage(new
MimeMessageInputStream(mail), new Date(), session, true, null);
-
+
} catch (MailboxException e) {
throw new MessagingException("Unable to access
mailbox.", e);
} finally {
@@ -222,9 +236,9 @@ public class SieveMailet extends SieveMa
}
}
-
- }
-
+
+ }
+
else {
// TODO: add support for more protocols
// TODO: - for example mailto: for forwarding over SMTP
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]