Package org.apache.james.mime4j.dom

Examples of org.apache.james.mime4j.dom.Body


                if (!attachmentFilter.isEligible(att)) {
                    continue;
                }
                final Map<String, Object> attProps = new HashMap<String, Object>();
                parseHeaderToProps(att.getHeader(), attProps);
                Body body = att.getBody();
                if (body instanceof BinaryBody) {
                    attProps.put(CONTENT, ((BinaryBody) body).getInputStream());
                } else if (body instanceof TextBody) {
                    attProps.put(CONTENT, ((TextBody) body).getInputStream());
                }
View Full Code Here


        if (eligibleExtensions != null && !eligibleExtensions.contains(ext)) {
            return false;
        }
       
        // size check
        final Body body = attachment.getBody();
        try {
            if (
                    body instanceof BinaryBody
                    && IOUtils.toByteArray(((BinaryBody) body).getInputStream()).length > maxSize
                    ||
View Full Code Here

     */
    private static BodyPart createRandomBinaryAttachment(int numberOfBytes) throws IOException {
        byte[] data = new byte[numberOfBytes];
        new Random().nextBytes(data);

        Body body = new StorageBodyFactory().binaryBody(new ByteArrayInputStream(data));

        BodyPart bodyPart = new BodyPart();
        bodyPart.setContentDisposition("attachment", "file"+Math.random());
        bodyPart.setBody(body, "application/octet-stream");

View Full Code Here

    private static BodyPart createRandomBinaryPart(int numberOfBytes)
            throws IOException {
        byte[] data = new byte[numberOfBytes];
        new Random().nextBytes(data);

        Body body = new StorageBodyFactory()
                .binaryBody(new ByteArrayInputStream(data));

        BodyPart bodyPart = new BodyPart();
        bodyPart.setBody(body, "application/octet-stream");
        bodyPart.setContentTransferEncoding("base64");
View Full Code Here

        /*
         * Add the node encapsulating the entity Header.
         */
        node.add(createNode(entity.getHeader()));

        Body body = entity.getBody();

        if (body instanceof Multipart) {
            /*
             * The body of the entity is a Multipart.
             */
 
View Full Code Here

        // The parser has a "setContentDecoding" method. We should
        // simply instantiate the MimeStreamParser with that method.

        // final String enc = bd.getTransferEncoding();

        final Body body;

        /*
        final InputStream decodedStream;
        if (MimeUtil.ENC_BASE64.equals(enc)) {
            decodedStream = new Base64InputStream(is);
View Full Code Here

        if (header == null)
            throw new IllegalArgumentException("Missing header");

        writeHeader(header, out);

        final Body body = entity.getBody();
        if (body == null)
            throw new IllegalArgumentException("Missing body");

        boolean binaryBody = body instanceof BinaryBody;
        OutputStream encOut = encodeStream(out, entity
View Full Code Here

     */
    public Body removeBody() {
        if (body == null)
            return null;

        Body body = this.body;
        this.body = null;
        body.setParent(null);

        return body;
    }
View Full Code Here

    public void testSetBody() throws Exception {
        Entity entity = new BodyPart();
        assertNull(entity.getBody());

        Body body = new BasicBodyFactory().textBody("test");
        assertNull(body.getParent());

        entity.setBody(body);
        assertSame(body, entity.getBody());
        assertSame(entity, body.getParent());
    }
View Full Code Here

    }

    public void testSetBodyTwice() throws Exception {
        Entity entity = new BodyPart();

        Body b1 = new BasicBodyFactory().textBody("foo");
        Body b2 = new BasicBodyFactory().textBody("bar");

        entity.setBody(b1);
        try {
            entity.setBody(b2);
            fail();
View Full Code Here

TOP

Related Classes of org.apache.james.mime4j.dom.Body

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.