byte[] messageByteArray = ((ByteArrayOutputStream) byteOutput) .toByteArray(); RawMessage message = new RawMessage(); message.setData(ByteBuffer.wrap(messageByteArray)); req.setRawMessage(message);
public RawMessage unmarshall(StaxUnmarshallerContext context) throws Exception { RawMessage rawMessage = new RawMessage(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return rawMessage; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("Data", targetDepth)) { rawMessage.setData(ByteBufferStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return rawMessage; } } } }
public RawMessage unmarshall(StaxUnmarshallerContext context) throws Exception { RawMessage rawMessage = new RawMessage(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { int xmlEvent = context.nextEvent(); if (xmlEvent == XmlPullParser.END_DOCUMENT) break; if (xmlEvent == XmlPullParser.START_TAG) { if (context.testExpression("Data", targetDepth)) { rawMessage .setData(ByteBufferStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) { break; } } } return rawMessage; }
private RawMessage createRawMessage(MimeMessage mimeMessage) { ByteArrayOutputStream out; try { out = new ByteArrayOutputStream(); mimeMessage.writeTo(out); } catch (IOException e) { throw new MailPreparationException(e); } catch (MessagingException e) { throw new MailParseException(e); } return new RawMessage(ByteBuffer.wrap(out.toByteArray())); } }
private RawMessage createRawMessage(MimeMessage mimeMessage) { ByteArrayOutputStream out; try { out = new ByteArrayOutputStream(); mimeMessage.writeTo(out); } catch (IOException e) { throw new MailPreparationException(e); } catch (MessagingException e) { throw new MailParseException(e); } return new RawMessage(ByteBuffer.wrap(out.toByteArray())); } }
RawMessage mail2Content(Email email) throws IOException, MessagingException, EmailException { email.buildMimeMessage(); ByteArrayOutputStream out = new ByteArrayOutputStream(); email.getMimeMessage().writeTo(out); return new RawMessage().withData(ByteBuffer.wrap(out.toByteArray())); }
RawMessage rawMessage = new RawMessage(ByteBuffer.wrap(outputStream.toByteArray()));
byte[] messageByteArray = ((ByteArrayOutputStream) byteOutput) .toByteArray(); RawMessage message = new RawMessage(); message.setData(ByteBuffer.wrap(messageByteArray)); req.setRawMessage(message);
public RawMessage unmarshall(StaxUnmarshallerContext context) throws Exception { RawMessage rawMessage = new RawMessage(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return rawMessage; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("Data", targetDepth)) { rawMessage.setData(ByteBufferStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return rawMessage; } } } }