use of javax.mail.internet.InternetHeaders in project logging-log4j2 by apache.
the class SmtpManager method sendEvents.
/**
* Send the contents of the cyclic buffer as an e-mail message.
* @param layout The layout for formatting the events.
* @param appendEvent The event that triggered the send.
*/
public void sendEvents(final Layout<?> layout, final LogEvent appendEvent) {
if (message == null) {
connect(appendEvent);
}
try {
final LogEvent[] priorEvents = removeAllBufferedEvents();
// LOG4J-310: log appendEvent even if priorEvents is empty
final byte[] rawBytes = formatContentToBytes(priorEvents, appendEvent, layout);
final String contentType = layout.getContentType();
final String encoding = getEncoding(rawBytes, contentType);
final byte[] encodedBytes = encodeContentToBytes(rawBytes, encoding);
final InternetHeaders headers = getHeaders(contentType, encoding);
final MimeMultipart mp = getMimeMultipart(encodedBytes, headers);
final String subject = data.subject.toSerializable(appendEvent);
sendMultipartMessage(message, mp, subject);
} catch (final MessagingException | IOException | RuntimeException e) {
logError("Caught exception while sending e-mail notification.", e);
throw new LoggingException("Error occurred while sending email", e);
}
}
use of javax.mail.internet.InternetHeaders in project nexus-repository-r by sonatype-nexus-community.
the class RPackagesBuilder method writePackageInfo.
private void writePackageInfo(final OutputStreamWriter writer, final Map<String, String> packageInfo) throws IOException {
InternetHeaders headers = new InternetHeaders();
headers.addHeader(P_PACKAGE, packageInfo.get(P_PACKAGE));
headers.addHeader(P_VERSION, packageInfo.get(P_VERSION));
headers.addHeader(P_DEPENDS, packageInfo.get(P_DEPENDS));
headers.addHeader(P_IMPORTS, packageInfo.get(P_IMPORTS));
headers.addHeader(P_SUGGESTS, packageInfo.get(P_SUGGESTS));
headers.addHeader(P_LINKINGTO, packageInfo.get(P_LINKINGTO));
headers.addHeader(P_LICENSE, packageInfo.get(P_LICENSE));
headers.addHeader(P_NEEDS_COMPILATION, packageInfo.get(P_NEEDS_COMPILATION));
Enumeration<String> headerLines = headers.getAllHeaderLines();
while (headerLines.hasMoreElements()) {
String line = headerLines.nextElement();
writer.write(line, 0, line.length());
writer.write('\n');
}
writer.write('\n');
}
use of javax.mail.internet.InternetHeaders in project legacy-webos by JayCanuck.
the class PackageInfo method getControlHeaders.
/**
* Add the defined package data to an RFC822 formatted header formatted for a Debian package
* control file.
* Order of fields determined from:
* <a href="http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-binarycontrolfiles">Debian Policy Manual</a>
*/
public InternetHeaders getControlHeaders() {
final InternetHeaders headers = new InternetHeaders();
headers.addHeader(_name.getField(), _name.getFieldValue());
headers.addHeader(_version.getField(), _version.getFieldValue());
headers.addHeader(_section.getField(), _section.getFieldValue());
headers.addHeader(_priority.getField(), _priority.getFieldValue());
headers.addHeader(_architecture.getField(), _architecture.getFieldValue());
if (_dependencies.size() > 0) {
headers.addHeader(_dependencies.getField(), _dependencies.getFieldValue());
}
if (_conflicts.size() > 0) {
headers.addHeader(_conflicts.getField(), _conflicts.getFieldValue());
}
if (_replacements.size() > 0) {
headers.addHeader(_replacements.getField(), _replacements.getFieldValue());
}
headers.addHeader(_maintainer.getField(), _maintainer.getFieldValue());
headers.addHeader(_description.getField(), _description.getFieldValue());
if (_source != null) {
headers.addHeader(_source.getField(), _source.getFieldValue());
}
return headers;
}
Aggregations