Package javax.activation

Examples of javax.activation.FileDataSource


            body.setContent(text, mimetype);
            return body;
        }

        private BodyPart createAttachment(File f) throws MessagingException {
            DataSource source = new FileDataSource( f );
            MimeBodyPart attachment = new MimeBodyPart();
            attachment.setDataHandler( new DataHandler( source ) );
            attachment.setFileName( f.getName() );
            return attachment;
        }
View Full Code Here


            payload = factory.createOMElement("uploadFileUsingMTOM", ns);
            OMElement request = factory.createOMElement("request", ns);
            OMElement image = factory.createOMElement("image", ns);

            log.info("Sending file : " + fileName + " as MTOM");
            FileDataSource fileDataSource = new FileDataSource(new File(fileName));
            DataHandler dataHandler = new DataHandler(fileDataSource);
            OMText textData = factory.createOMText(dataHandler, true);
            image.addChild(textData);
            request.addChild(image);
            payload.addChild(request);
View Full Code Here

            OperationClient mepClient = sender.createClient(ServiceClient.ANON_OUT_IN_OP);

            MessageContext mc = new MessageContext();

            log.info("Sending file : " + fileName + " as SwA");
            FileDataSource fileDataSource = new FileDataSource(new File(fileName));
            DataHandler dataHandler = new DataHandler(fileDataSource);
            String attachmentID = mc.addAttachment(dataHandler);


            SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
View Full Code Here

       
        if (null != attachments) {
      for (int i1 = 0; i1 < this.attachments.length; i1++) {
              oMultiP.addBodyPart(oBodyP = new MimeBodyPart());
              String sFile = this.attachments[i1];
              oBodyP.setDataHandler(new DataHandler(new FileDataSource(sFile)));
              oBodyP.setFileName(sFile.substring(1 + sFile.lastIndexOf("\\")));
          }
        }
       
        for (MimeBodyPart part : attachmentParts) {
View Full Code Here

                if (!file.exists() || !file.canRead()) {
                    throw new BuildException("File \"" + file.getAbsolutePath()
                         + "\" does not exist or is not "
                         + "readable.");
                }
                FileDataSource fileData = new FileDataSource(file);
                DataHandler fileDataHandler = new DataHandler(fileData);

                body.setDataHandler(fileDataHandler);
                body.setFileName(file.getName());
                attachments.addBodyPart(body);
View Full Code Here

        System.out.println(target);
        ValidationResult result = null;
        try
        {
            PreflightParser parser = new PreflightParser(new FileDataSource(target));
            parser.parse();
            document = (PreflightDocument) parser.getPDDocument();
            document.validate();
            result = document.getResult();
        }
View Full Code Here

        PreflightDocument document = null;
        System.out.println(target);
        ValidationResult result = null;
        try
        {
            PreflightParser parser = new PreflightParser(new FileDataSource(target));
            parser.parse();
            document = (PreflightDocument) parser.getPDDocument();
            document.validate();
            result = document.getResult();
        }
View Full Code Here

        int size = lfd.size();
        for (int i = 0; i < loop; i++)
        {
            File file = lfd.get(i % size);
            long startLTime = System.currentTimeMillis();
            PreflightParser parser = new PreflightParser(new FileDataSource(file));
            parser.parse();
            PreflightDocument document = parser.getPreflightDocument();
            document.validate();
            ValidationResult result = document.getResult();
            if (!result.isValid())
View Full Code Here

     * @return
     * @throws Exception
     */
    protected PreflightContext createContext() throws Exception
    {
        DataSource ds = new FileDataSource("src/test/resources/pdfa-with-annotations-square.pdf");
        PDDocument doc = PDDocument.load(ds.getInputStream());
        PreflightDocument preflightDocument = new PreflightDocument(doc.getDocument(), Format.PDF_A1B);
        PreflightContext ctx = new PreflightContext(ds);
        ctx.setDocument(preflightDocument);
        preflightDocument.setContext(ctx);
        return ctx;
View Full Code Here

            int status = 0;
            if (!outputXml) {
                // simple list of files
                for (File file2 : ftp)
                {
                    status |= runSimple(new FileDataSource(file2));
                }
                System.exit(status);
            } else {
                Transformer transformer = TransformerFactory.newInstance().newTransformer();
                transformer.setOutputProperty(OutputKeys.INDENT, "yes");
                transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
                XmlResultParser xrp = new XmlResultParser();
                if (isGroup) {
                    Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
                    Element root = document.createElement("preflights");
                    document.appendChild(root);
                    root.setAttribute("count", String.format("%d", ftp.size()));
                    for (File file : ftp)
                    {
                        Element result = xrp.validate(document,new FileDataSource(file));
                        root.appendChild(result);
                    }
                    transformer.transform(new DOMSource(document), new StreamResult(new File(args[posFile]+".preflight.xml")));
                } else {
                    // isBatch
                    for (File file : ftp)
                    {
                        Element result = xrp.validate(new FileDataSource(file));
                        Document document = result.getOwnerDocument();
                        document.appendChild(result);
                        transformer.transform(new DOMSource(document), new StreamResult(new File(file.getAbsolutePath()+".preflight.xml")));
                    }
                }
            }
           
           
           
        } else {
            // only one file
            FileDataSource fd = new FileDataSource(args[posFile]);
            if (!outputXml) {
                // simple validation
                System.exit(runSimple(fd));
            } else {
                // generate xml output
View Full Code Here

TOP

Related Classes of javax.activation.FileDataSource

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.