01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19:
20: package org.apache.synapse.transport.mail;
21:
22: import org.apache.axiom.om.util.UUIDGenerator;
23:
24: import javax.mail.internet.MimeMessage;
25: import javax.mail.MessagingException;
26: import javax.mail.Session;
27:
28: /**
29: * The default MimeMessage does not let us set a custom MessageID on a message being
30: * sent. This class allows us to overcome this limitation, but SMTP servers such as
31: * GMail, re-writes this to an ID they define. Thats why the custom header defined by
32: * MailConstants.MAIL_HEADER_X_MESSAGE_ID has been introduced, so that a client can
33: * find out the relationship of a response to his request
34: */
35: public class WSMimeMessage extends MimeMessage {
36:
37: WSMimeMessage(Session session) {
38: super (session);
39: }
40:
41: protected void updateMessageID() throws MessagingException {
42: if (getHeader(MailConstants.MAIL_HEADER_MESSAGE_ID) == null) {
43: setHeader(MailConstants.MAIL_HEADER_MESSAGE_ID,
44: UUIDGenerator.getUUID());
45: }
46: }
47:
48: }
|