Examples of URLDataSource


Examples of javax.activation.URLDataSource

    {
        // ====================================================================
        // Test Success - URL
        // ====================================================================
        this.email.attach(
            new URLDataSource(new URL(this.strTestURL)),
            "Test Attachment",
            "Test Attachment Desc");

        // ====================================================================
        // Test Exceptions
        // ====================================================================
        // null datasource
        try
        {
            final URLDataSource urlDs = null;
            this.email.attach(urlDs, "Test Attachment", "Test Attachment Desc");
            fail("Should have thrown an exception");
        }
        catch (final EmailException e)
        {
            assertTrue(true);
        }

        // invalid datasource
        try
        {
            final URLDataSource urlDs = new URLDataSource(createInvalidURL());
            this.email.attach(urlDs, "Test Attachment", "Test Attachment Desc");
            fail("Should have thrown an exception");
        }
        catch (final EmailException e)
        {
View Full Code Here

Examples of javax.activation.URLDataSource

        return email;
    }

    protected String getFromUrl(final URL url) throws Exception {

        final URLDataSource dataSource = new URLDataSource(url);
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        IOUtils.copy(dataSource.getInputStream(), baos);
        return new String(baos.toByteArray(), "UTF-8");
    }
View Full Code Here

Examples of javax.activation.URLDataSource

        TestHandlerXMLBinding handler = new TestHandlerXMLBinding();
        addHandlersProgrammatically(disp, handler);

        URL is = getClass().getResource("/messages/XML_GreetMeDocLiteralReq.xml");
        DataSource ds = new URLDataSource(is);

        try {
            disp.invoke(ds);
            fail("Did not get expected exception");
        } catch (HTTPException e) {
View Full Code Here

Examples of javax.activation.URLDataSource

        TestHandlerXMLBinding handler = new TestHandlerXMLBinding();
        addHandlersProgrammatically(disp, handler);

        URL is = getClass().getResource("/messages/XML_GreetMeDocLiteralReq.xml");
        DataSource ds = new URLDataSource(is);

        try {
            disp.invoke(ds);
            fail("Did not get expected exception");
        } catch (HTTPException e) {
View Full Code Here

Examples of javax.activation.URLDataSource

            return new LazyDataSource(contentId, atts);
        } else if (contentId.indexOf("://") == -1) {
            return new LazyDataSource(contentId, atts);
        } else {
            try {
                return new URLDataSource(new URL(contentId));
            } catch (MalformedURLException e) {
                throw new Fault(e);
            }
        }
       
View Full Code Here

Examples of javax.activation.URLDataSource

        if (src == null) {
            dh =
                (DataHandler)DataHandlerUtils
                    .getDataHandlerFromText(getText(), (type != null) ? type.toString() : null);
        } else {
            dh = new DataHandler(new URLDataSource(src));
        }
        return dh;
    }
View Full Code Here

Examples of javax.activation.URLDataSource

                    ds = new FileDataSource( attachment.getValue() );
                } else {
                    // If for some reason the URL does not return a content
                    // type then this type of datasource defaults to
                    // application/octet-stream.
                    ds = new URLDataSource( new URL( attachment.getValue() ) );
                }

                bodyPart = new MimeBodyPart();
                bodyPart.setDataHandler( new DataHandler( ds ) );
                bodyPart.setDisposition( Part.ATTACHMENT );
View Full Code Here

Examples of javax.activation.URLDataSource

            // the content with the attachment
            final MimeMultipart multipart = new MimeMultipart();
            message.setContent(multipart);
            final BodyPart attachment = new MimeBodyPart();
            attachment.setFileName("unknown-devices.zip");
            final DataSource ds = new URLDataSource(file.toURL());
            attachment.setDataHandler(new DataHandler(ds));
            attachment.setHeader("Content-ID","");
            multipart.addBodyPart(attachment);
            return message;
        } catch (Exception e) {
View Full Code Here

Examples of javax.activation.URLDataSource

    public String embed(URL url, String name)
            throws MessagingException
    {
        MimeBodyPart mbp = new MimeBodyPart();

        mbp.setDataHandler(new DataHandler(new URLDataSource(url)));
        mbp.setFileName(name);
        mbp.setDisposition("inline");
        String cid = org.apache.turbine.util.GenerateUniqueId.getIdentifier();
        mbp.addHeader("Content-ID", cid);
View Full Code Here

Examples of javax.activation.URLDataSource

                                 String name,
                                 String description,
                                 String disposition)
            throws MessagingException
    {
        return attach(new URLDataSource(url), name, description, disposition);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.