* checking the parts HashMap. If it is not parsed yet then call
* the getNextPart() till we find the required part.
*/
public DataHandler getDataHandler(String blobContentID) throws OMException {
Part bodyPart;
blobContentID = "<" + blobContentID + ">";
boolean attachmentFound = false;
// // without the following part a Null Pointer Exception is thrown
//
if (bodyPartsMap.containsKey(blobContentID)) {
bodyPart = (Part) bodyPartsMap.get(blobContentID);
attachmentFound = true;
DataHandler dh;
try {
dh = bodyPart.getDataHandler();
} catch (MessagingException e) {
throw new OMException("Problem with Mime Body Part No "
+ partIndex + ". " + e);
}
return dh;
} else {
try {
while (true) {
bodyPart = this.getNextPart();
if (bodyPart == null) {
return null;
}
if (bodyPartsMap.containsKey(blobContentID)) {
bodyPart = (Part) bodyPartsMap.get(blobContentID);
DataHandler dh = bodyPart.getDataHandler();
return dh;
}
}
} catch (MessagingException e) {
throw new OMException("Invalid Mime Message " + e.toString());