Package javax.activation

Examples of javax.activation.FileDataSource


    OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
    OMElement pingElem = fac.createOMElement(MTOMPing, namespace);
    OMElement attachmentElem = fac.createOMElement("Attachment", namespace);
   
      String imageName = "test-resources" + File.separator + "mtom-image.jpg";
      FileDataSource dataSource;
    try {
      dataSource = new FileDataSource (new File (imageName));
    } catch (Exception e) {
      throw AxisFault.makeFault (e);
    }
   
      DataHandler dataHandler = new DataHandler(dataSource);
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

        // The following is just wrong. Even if the DataHandler has a stream, we should still
        // apply the threshold.
        try {
            DataSource ds = handler.getDataSource();
            if (ds instanceof FileDataSource) {
                FileDataSource fds = (FileDataSource)ds;
                File file = fds.getFile();
                if (file.length() < threshold) {
                    return null;
                }
            } else if (ds.getClass().getName().endsWith("ObjectDataSource")) {
                Object o = handler.getContent();
View Full Code Here

    public PreflightParser(File file) throws IOException
    {
        super(file);
        this.setLenient(false);
        this.originalDocument = new FileDataSource(file);
    }
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

            return;
        }
        PreflightDocument document = null;
        try
        {
            FileDataSource bds = new FileDataSource(path);
            PreflightParser parser = new PreflightParser(bds);
            parser.parse();
            document = parser.getPreflightDocument();
            document.validate();
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

        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

            return;
        }
        PreflightDocument document = null;
        try
        {
            FileDataSource bds = new FileDataSource(path);
            PreflightParser parser = new PreflightParser(bds);
            parser.parse();
            document = parser.getPreflightDocument();
            document.validate();
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.