Skip to content

Commit 06b7e50

Browse files
committed
Move methods from jakarta to com.sun.mail
Signed-off-by: Jorge Bescos Gascon <[email protected]>
1 parent cb1f427 commit 06b7e50

File tree

6 files changed

+246
-145
lines changed

6 files changed

+246
-145
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0, which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the
10+
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11+
* version 2 with the GNU Classpath Exception, which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
*/
16+
17+
package com.sun.mail.util;
18+
19+
import jakarta.mail.internet.MimeBodyPart;
20+
21+
/**
22+
* Allows to modify properties that are not possible
23+
* to modify when using {@link MimeBodyPart}.
24+
*
25+
*/
26+
public class MimeBodyPartPropOverrider extends MimeBodyPart {
27+
28+
/**
29+
* Overrides the property of mail.mime.setdefaulttextcharset.
30+
* @param setDefaultTextCharset Enable/disable setDefaultTextCharset
31+
*/
32+
public void setDefaultTextCharset(boolean setDefaultTextCharset) {
33+
this.setDefaultTextCharset = setDefaultTextCharset;
34+
}
35+
36+
/**
37+
* Overrides the property of mail.mime.setContentTypeFileName.
38+
* @param setContentTypeFileName Enable/disable setContentTypeFileName
39+
*/
40+
public void setContentTypeFileName(boolean setContentTypeFileName) {
41+
this.setContentTypeFileName = setContentTypeFileName;
42+
}
43+
44+
/**
45+
* Overrides the property of mail.mime.encodeFileName.
46+
* @param encodeFileName Enable/disable encodeFileName
47+
*/
48+
public void setEncodeFileName(boolean encodeFileName) {
49+
this.encodeFileName = encodeFileName;
50+
}
51+
52+
/**
53+
* Overrides the property of mail.mime.decodeFileName.
54+
* @param decodeFileName Enable/disable decodeFileName
55+
*/
56+
public void setDecodeFileName(boolean decodeFileName) {
57+
this.decodeFileName = decodeFileName;
58+
}
59+
60+
/**
61+
* Overrides the property of mail.mime.ignoreMultipartEncoding.
62+
* @param ignoreMultipartEncoding Enable/disable ignoreMultipartEncoding
63+
*/
64+
public void setIgnoreMultipartEncoding(boolean ignoreMultipartEncoding) {
65+
this.ignoreMultipartEncoding = ignoreMultipartEncoding;
66+
}
67+
68+
/**
69+
* Overrides the property of mail.mime.cacheMultipart.
70+
* @param cacheMultipart Enable/disable cacheMultipart
71+
*/
72+
public void setCacheMultipart(boolean cacheMultipart) {
73+
this.cacheMultipart = cacheMultipart;
74+
}
75+
76+
/**
77+
* Overrides the property of mail.mime.cachedContent.
78+
* @param cachedContent Enable/disable cachedContent
79+
*/
80+
public void setCachedContent(Object cachedContent) {
81+
this.cachedContent = cachedContent;
82+
}
83+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
* Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0, which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the
10+
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11+
* version 2 with the GNU Classpath Exception, which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
*/
16+
17+
package com.sun.mail.util;
18+
19+
import jakarta.mail.Session;
20+
import jakarta.mail.internet.MimeMessage;
21+
22+
/**
23+
* Allows to modify properties that are not possible
24+
* to modify when using {@link MimeMessage}.
25+
*
26+
*/
27+
public class MimeMessagePropOverrider extends MimeMessage {
28+
29+
/**
30+
* {@inheritDoc}
31+
* @param session the Sesssion
32+
*/
33+
public MimeMessagePropOverrider(Session session) {
34+
super(session);
35+
}
36+
37+
/**
38+
* Overrides the property of mail.mime.setdefaulttextcharset.
39+
* @param setDefaultTextCharset Enable/disable setDefaultTextCharset
40+
*/
41+
public void setDefaultTextCharset(boolean setDefaultTextCharset) {
42+
this.setDefaultTextCharset = setDefaultTextCharset;
43+
}
44+
45+
/**
46+
* Overrides the property of mail.mime.setContentTypeFileName.
47+
* @param setContentTypeFileName Enable/disable setContentTypeFileName
48+
*/
49+
public void setContentTypeFileName(boolean setContentTypeFileName) {
50+
this.setContentTypeFileName = setContentTypeFileName;
51+
}
52+
53+
/**
54+
* Overrides the property of mail.mime.encodeFileName.
55+
* @param encodeFileName Enable/disable encodeFileName
56+
*/
57+
public void setEncodeFileName(boolean encodeFileName) {
58+
this.encodeFileName = encodeFileName;
59+
}
60+
61+
/**
62+
* Overrides the property of mail.mime.decodeFileName.
63+
* @param decodeFileName Enable/disable decodeFileName
64+
*/
65+
public void setDecodeFileName(boolean decodeFileName) {
66+
this.decodeFileName = decodeFileName;
67+
}
68+
69+
/**
70+
* Overrides the property of mail.mime.ignoreMultipartEncoding.
71+
* @param ignoreMultipartEncoding Enable/disable ignoreMultipartEncoding
72+
*/
73+
public void setIgnoreMultipartEncoding(boolean ignoreMultipartEncoding) {
74+
this.ignoreMultipartEncoding = ignoreMultipartEncoding;
75+
}
76+
77+
/**
78+
* Overrides the property of mail.mime.cacheMultipart.
79+
* @param cacheMultipart Enable/disable cacheMultipart
80+
*/
81+
public void setCacheMultipart(boolean cacheMultipart) {
82+
this.cacheMultipart = cacheMultipart;
83+
}
84+
85+
/**
86+
* Overrides the property of mail.mime.cachedContent.
87+
* @param cachedContent Enable/disable cachedContent
88+
*/
89+
public void setCachedContent(Object cachedContent) {
90+
this.cachedContent = cachedContent;
91+
}
92+
93+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0, which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the
10+
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11+
* version 2 with the GNU Classpath Exception, which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
*/
16+
17+
package com.sun.mail.util;
18+
19+
import jakarta.mail.internet.MimePart;
20+
import jakarta.mail.internet.MimePartDataSource;
21+
22+
/**
23+
* Allows to modify properties that are not possible
24+
* to modify when using {@link MimePartDataSource}.
25+
*
26+
*/
27+
public class MimePartDataSourcePropOverrider extends MimePartDataSource {
28+
29+
/**
30+
* {@inheritDoc}
31+
* @param part the MimePart
32+
*/
33+
public MimePartDataSourcePropOverrider(MimePart part) {
34+
super(part);
35+
}
36+
37+
/**
38+
* Overrides the property of mail.mime.ignoreMultipartEncoding.
39+
* @param ignoreMultipartEncoding Enable/disable ignoreMultipartEncoding
40+
*/
41+
public void setIgnoreMultipartEncoding(boolean ignoreMultipartEncoding) {
42+
this.ignoreMultipartEncoding = ignoreMultipartEncoding;
43+
}
44+
}

mail/src/main/java/jakarta/mail/internet/MimeBodyPart.java

Lines changed: 7 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ public class MimeBodyPart extends BodyPart implements MimePart {
8080
static final boolean CACHE_MULTIPART = // accessed by MimeMessage
8181
PropUtil.getBooleanSystemProperty("mail.mime.cachemultipart", true);
8282

83-
private boolean setDefaultTextCharset = SET_DEFAULT_TEXT_CHARSET;
84-
private boolean setContentTypeFileName = SET_CONTENT_TYPE_FILE_NAME;
85-
private boolean encodeFileName = ENCODE_FILE_NAME;
86-
private boolean decodeFileName = DECODE_FILE_NAME;
87-
private boolean ignoreMultipartEncoding = IGNORE_MULTIPART_ENCODING;
88-
private boolean allowutf8 = ALLOW_UTF8;
89-
private boolean cacheMultipart = CACHE_MULTIPART;
83+
protected boolean setDefaultTextCharset = SET_DEFAULT_TEXT_CHARSET;
84+
protected boolean setContentTypeFileName = SET_CONTENT_TYPE_FILE_NAME;
85+
protected boolean encodeFileName = ENCODE_FILE_NAME;
86+
protected boolean decodeFileName = DECODE_FILE_NAME;
87+
protected boolean ignoreMultipartEncoding = IGNORE_MULTIPART_ENCODING;
88+
protected boolean allowutf8 = ALLOW_UTF8;
89+
protected boolean cacheMultipart = CACHE_MULTIPART;
9090

9191
/**
9292
* The DataHandler object representing this Part's content.
@@ -1712,61 +1712,4 @@ MimePart getPart() {
17121712
return part;
17131713
}
17141714
}
1715-
1716-
/**
1717-
* Overrides the property of mail.mime.setdefaulttextcharset.
1718-
* @param setDefaultTextCharset Enable/disable setDefaultTextCharset
1719-
*/
1720-
public void setDefaultTextCharset(boolean setDefaultTextCharset) {
1721-
this.setDefaultTextCharset = setDefaultTextCharset;
1722-
}
1723-
1724-
/**
1725-
* Overrides the property of mail.mime.setContentTypeFileName.
1726-
* @param setContentTypeFileName Enable/disable setContentTypeFileName
1727-
*/
1728-
public void setContentTypeFileName(boolean setContentTypeFileName) {
1729-
this.setContentTypeFileName = setContentTypeFileName;
1730-
}
1731-
1732-
/**
1733-
* Overrides the property of mail.mime.encodeFileName.
1734-
* @param encodeFileName Enable/disable encodeFileName
1735-
*/
1736-
public void setEncodeFileName(boolean encodeFileName) {
1737-
this.encodeFileName = encodeFileName;
1738-
}
1739-
1740-
/**
1741-
* Overrides the property of mail.mime.decodeFileName.
1742-
* @param decodeFileName Enable/disable decodeFileName
1743-
*/
1744-
public void setDecodeFileName(boolean decodeFileName) {
1745-
this.decodeFileName = decodeFileName;
1746-
}
1747-
1748-
/**
1749-
* Overrides the property of mail.mime.ignoreMultipartEncoding.
1750-
* @param ignoreMultipartEncoding Enable/disable ignoreMultipartEncoding
1751-
*/
1752-
public void setIgnoreMultipartEncoding(boolean ignoreMultipartEncoding) {
1753-
this.ignoreMultipartEncoding = ignoreMultipartEncoding;
1754-
}
1755-
1756-
/**
1757-
* Overrides the property of mail.mime.cacheMultipart.
1758-
* @param cacheMultipart Enable/disable cacheMultipart
1759-
*/
1760-
public void setCacheMultipart(boolean cacheMultipart) {
1761-
this.cacheMultipart = cacheMultipart;
1762-
}
1763-
1764-
/**
1765-
* Overrides the property of mail.mime.cachedContent.
1766-
* @param cachedContent Enable/disable cachedContent
1767-
*/
1768-
public void setCachedContent(Object cachedContent) {
1769-
this.cachedContent = cachedContent;
1770-
}
1771-
17721715
}

mail/src/main/java/jakarta/mail/internet/MimeMessage.java

Lines changed: 7 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -190,17 +190,17 @@ public class MimeMessage extends Message implements MimePart {
190190
// Should addresses in headers be parsed in "strict" mode?
191191
private boolean strict = true;
192192

193-
private boolean setDefaultTextCharset = SET_DEFAULT_TEXT_CHARSET;
194-
private boolean setContentTypeFileName = SET_CONTENT_TYPE_FILE_NAME;
195-
private boolean encodeFileName = ENCODE_FILE_NAME;
196-
private boolean decodeFileName = DECODE_FILE_NAME;
197-
private boolean ignoreMultipartEncoding = IGNORE_MULTIPART_ENCODING;
193+
protected boolean setDefaultTextCharset = SET_DEFAULT_TEXT_CHARSET;
194+
protected boolean setContentTypeFileName = SET_CONTENT_TYPE_FILE_NAME;
195+
protected boolean encodeFileName = ENCODE_FILE_NAME;
196+
protected boolean decodeFileName = DECODE_FILE_NAME;
197+
protected boolean ignoreMultipartEncoding = IGNORE_MULTIPART_ENCODING;
198198
/*
199199
* This is not a duplicate of allowutf8Headers. When mail.mime.allowutf8
200200
* is not defined, this value is 'true'. Meanwhile allowutf8Headers is 'false'
201201
*/
202-
private boolean allowutf8 = ALLOW_UTF8;
203-
private boolean cacheMultipart = CACHE_MULTIPART;
202+
protected boolean allowutf8 = ALLOW_UTF8;
203+
protected boolean cacheMultipart = CACHE_MULTIPART;
204204
// Is UTF-8 allowed in headers?
205205
private boolean allowutf8Headers = false;
206206

@@ -2337,60 +2337,4 @@ protected MimeMessage createMimeMessage(Session session)
23372337
throws MessagingException {
23382338
return new MimeMessage(session);
23392339
}
2340-
2341-
/**
2342-
* Overrides the property of mail.mime.setdefaulttextcharset.
2343-
* @param setDefaultTextCharset Enable/disable setDefaultTextCharset
2344-
*/
2345-
public void setDefaultTextCharset(boolean setDefaultTextCharset) {
2346-
this.setDefaultTextCharset = setDefaultTextCharset;
2347-
}
2348-
2349-
/**
2350-
* Overrides the property of mail.mime.setContentTypeFileName.
2351-
* @param setContentTypeFileName Enable/disable setContentTypeFileName
2352-
*/
2353-
public void setContentTypeFileName(boolean setContentTypeFileName) {
2354-
this.setContentTypeFileName = setContentTypeFileName;
2355-
}
2356-
2357-
/**
2358-
* Overrides the property of mail.mime.encodeFileName.
2359-
* @param encodeFileName Enable/disable encodeFileName
2360-
*/
2361-
public void setEncodeFileName(boolean encodeFileName) {
2362-
this.encodeFileName = encodeFileName;
2363-
}
2364-
2365-
/**
2366-
* Overrides the property of mail.mime.decodeFileName.
2367-
* @param decodeFileName Enable/disable decodeFileName
2368-
*/
2369-
public void setDecodeFileName(boolean decodeFileName) {
2370-
this.decodeFileName = decodeFileName;
2371-
}
2372-
2373-
/**
2374-
* Overrides the property of mail.mime.ignoreMultipartEncoding.
2375-
* @param ignoreMultipartEncoding Enable/disable ignoreMultipartEncoding
2376-
*/
2377-
public void setIgnoreMultipartEncoding(boolean ignoreMultipartEncoding) {
2378-
this.ignoreMultipartEncoding = ignoreMultipartEncoding;
2379-
}
2380-
2381-
/**
2382-
* Overrides the property of mail.mime.cacheMultipart.
2383-
* @param cacheMultipart Enable/disable cacheMultipart
2384-
*/
2385-
public void setCacheMultipart(boolean cacheMultipart) {
2386-
this.cacheMultipart = cacheMultipart;
2387-
}
2388-
2389-
/**
2390-
* Overrides the property of mail.mime.cachedContent.
2391-
* @param cachedContent Enable/disable cachedContent
2392-
*/
2393-
public void setCachedContent(Object cachedContent) {
2394-
this.cachedContent = cachedContent;
2395-
}
23962340
}

0 commit comments

Comments
 (0)