/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
import javax.activation.*;
/**
* An IMAP body part.
*
* @author John Mani
* @author Bill Shannon
*/
// processed values ..
private boolean headersLoaded = false;
private static final boolean decodeFileName =
super();
// generate content-type
}
/* Override this method to make it a no-op, rather than throw
* an IllegalWriteException. This will permit IMAPBodyParts to
* be inserted in newly crafted MimeMessages, especially when
* forwarding or replying to messages.
*/
protected void updateHeaders() {
return;
}
}
}
return type;
}
return bs.disposition;
}
throw new IllegalWriteException("IMAPBodyPart is read-only");
}
}
}
}
throw new IllegalWriteException("IMAPBodyPart is read-only");
}
return description;
return null;
try {
} catch (UnsupportedEncodingException ex) {
}
return description;
}
throws MessagingException {
throw new IllegalWriteException("IMAPBodyPart is read-only");
}
try {
} catch (UnsupportedEncodingException ex) {
}
}
return filename;
}
throw new IllegalWriteException("IMAPBodyPart is read-only");
}
// Acquire MessageCacheLock, to freeze seqnum.
synchronized(message.getMessageCacheLock()) {
try {
// Check whether this message is expunged
// Else, vanila IMAP4, no partial fetch
BODY b;
if (pk)
else
if (b != null)
is = b.getByteArrayInputStream();
} catch (ConnectionException cex) {
throw new FolderClosedException(
} catch (ProtocolException pex) {
}
}
throw new MessagingException("No content");
else
return is;
}
/**
* Return the MIME format stream of headers for this body part.
*/
loadHeaders(); // will be needed below
// Acquire MessageCacheLock, to freeze seqnum.
synchronized(message.getMessageCacheLock()) {
try {
// Check whether this message got expunged
if (p.isREV1()) {
if (b == null)
throw new MessagingException("Failed to fetch headers");
throw new MessagingException("Failed to fetch headers");
return bis;
} else {
// Can't read it from server, have to fake it
new SharedByteArrayOutputStream(0);
try {
// Write out the header
@SuppressWarnings("unchecked")
= super.getAllHeaderLines();
while (hdrLines.hasMoreElements())
// The CRLF separator between header and content
} catch (IOException ioex) {
// should never happen
} finally {
try {
} catch (IOException cex) { }
}
}
} catch (ConnectionException cex) {
throw new FolderClosedException(
} catch (ProtocolException pex) {
}
}
}
/**
* Return the MIME format stream corresponding to this message part.
*
* @return the MIME format stream
* @since JavaMail 1.4.5
*/
/*
* The IMAP protocol doesn't support returning the entire
* part content in one operation so we have to fake it by
* concatenating the header stream and the content stream.
*/
}
throws MessagingException {
dh = new DataHandler(
);
dh = new DataHandler(
new IMAPNestedMessage(message,
);
}
return super.getDataHandler();
}
throw new IllegalWriteException("IMAPBodyPart is read-only");
}
throw new IllegalWriteException("IMAPBodyPart is read-only");
}
throw new IllegalWriteException("IMAPBodyPart is read-only");
}
loadHeaders();
}
throws MessagingException {
throw new IllegalWriteException("IMAPBodyPart is read-only");
}
throws MessagingException {
throw new IllegalWriteException("IMAPBodyPart is read-only");
}
throw new IllegalWriteException("IMAPBodyPart is read-only");
}
@SuppressWarnings("unchecked")
loadHeaders();
return super.getAllHeaders();
}
@SuppressWarnings("unchecked")
throws MessagingException {
loadHeaders();
return super.getMatchingHeaders(names);
}
@SuppressWarnings("unchecked")
throws MessagingException {
loadHeaders();
return super.getNonMatchingHeaders(names);
}
throw new IllegalWriteException("IMAPBodyPart is read-only");
}
@SuppressWarnings("unchecked")
loadHeaders();
return super.getAllHeaderLines();
}
@SuppressWarnings("unchecked")
throws MessagingException {
loadHeaders();
return super.getMatchingHeaderLines(names);
}
@SuppressWarnings("unchecked")
throws MessagingException {
loadHeaders();
return super.getNonMatchingHeaderLines(names);
}
if (headersLoaded)
return;
// "headers" should never be null since it's set in the constructor.
// If something did go wrong this will fix it, but is an unsynchronized
// assignment of "headers".
headers = new InternetHeaders();
// load headers
// Acquire MessageCacheLock, to freeze seqnum.
synchronized(message.getMessageCacheLock()) {
try {
// Check whether this message got expunged
if (p.isREV1()) {
if (b == null)
throw new MessagingException("Failed to fetch headers");
throw new MessagingException("Failed to fetch headers");
} else {
// RFC 1730 does not provide for fetching BodyPart headers
// So, just dump the RFC1730 BODYSTRUCTURE into the
// headerStore
// Content-Type
// Content-Transfer-Encoding
// Content-Description
// Content-ID
// Content-MD5
}
} catch (ConnectionException cex) {
throw new FolderClosedException(
} catch (ProtocolException pex) {
}
}
headersLoaded = true;
}
}