log.info(
String.format("Sending photo from PhotoEntry id '%s' to admins...", photoEntry.getId()));
AdminConfig adminConfig = adminConfigDao.getAdminConfig();
MailService mailService = MailServiceFactory.getMailService();
Message message = new Message();
try {
String fromAddress = adminConfig.getFromAddress();
if (util.isNullOrEmpty(fromAddress)) {
throw new IllegalArgumentException("No from address found in configuration.");
}
message.setSubject("Unable to submit photo to Picasa");
message.setSender(fromAddress);
message.setTextBody("YouTube Direct was unable to upload a photo submission to Picasa.\n\n"
+ "There might be a service issue, or your Picasa configuration might be incorrect.\n\n"
+ "The photo in question is attached.");
BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
byte[] photoBytes = blobstoreService.fetchData(
photoEntry.getBlobKey(), 0, photoEntry.getOriginalFileSize() - 1);
MailService.Attachment photoAttachment =
new MailService.Attachment(photoEntry.getOriginalFileName(), photoBytes);
message.setAttachments(photoAttachment);
mailService.sendToAdmins(message);
log.info("Email sent to admins.");
} catch (IOException e) {
log.log(Level.WARNING, "", e);