Package org.apache.cxf.tools.util

Examples of org.apache.cxf.tools.util.FileWriterUtil


        //complete
    }

    public static void writeWSDL(Definition def, String outputdir, String wsdlOutput)
        throws WSDLException, IOException {    
        FileWriterUtil fw = new FileWriterUtil(outputdir);
        Writer outputWriter = fw.getWriter("", wsdlOutput);

        writeWSDL(def, outputWriter);  
    }
View Full Code Here


        try {
            WSDLASTVisitor visitor = new WSDLASTVisitor(tns);
            visitor.visit(idlTree);
            if (outputWriter == null) {
                FileWriterUtil fw = new FileWriterUtil(outputDir);
                outputWriter = fw.getWriter("", idl + ".wsdl");
            }
            Definition def = visitor.getDefinition();
            Binding[] bindings = visitor.getCorbaBindings();
            generateCORBAService(def, bindings);
            visitor.writeDefinition(outputWriter);
View Full Code Here

        }

        File outputdir = createOutputDir(file);
        Definition def = null;
        try {
            Writer os = new FileWriterUtil(file.getParent(),
                                           getOutputStreamCreator()).getWriter(file, "UTF-8");
            WSDLWriter wsdlWriter = WSDLFactory.newInstance().newWSDLWriter();

            ServiceWSDLBuilder builder = new ServiceWSDLBuilder(getBus(), getServiceModel());
            builder.setUseSchemaImports(this.allowImports());

            String name = file.getName();
            if (name.endsWith(".wsdl")) {
                name = name.substring(0, name.lastIndexOf(".wsdl"));
            }
            builder.setBaseFileName(name);
            Map<String, SchemaInfo> imports = new HashMap<String, SchemaInfo>();
            def = builder.build(imports);
            wsdlWriter.writeWSDL(def, os);
            os.close();

            if (def.getImports().size() > 0) {
                for (Import wsdlImport : WSDLDefinitionBuilder.getImports(def)) {
                    Definition wsdlDef = wsdlImport.getDefinition();
                    File wsdlFile = null;
                    if (!StringUtils.isEmpty(wsdlImport.getLocationURI())) {
                        wsdlFile = new File(outputdir,  wsdlImport.getLocationURI());
                    } else {
                        wsdlFile = new File(outputdir, wsdlDef.getQName().getLocalPart() + ".wsdl");
                    }
                    OutputStream wsdlOs = null;
                    try {
                        wsdlOs = new BufferedOutputStream(new FileOutputStream(wsdlFile));
                        wsdlWriter.writeWSDL(wsdlDef, wsdlOs);
                    } finally {
                        if (wsdlOs != null) {
                            wsdlOs.close();
                        }
                    }
                }
            }

            for (Map.Entry<String, SchemaInfo> imp : imports.entrySet()) {
                File impfile = new File(file.getParentFile(), imp.getKey());
                Element el = imp.getValue().getElement();
                updateImports(el, imports);
                os = new FileWriterUtil(impfile.getParent(),
                                        getToolContext().get(OutputStreamCreator.class)).getWriter(impfile, "UTF-8");
                XMLUtils.writeTo(el, os, 2);
                os.close();
            }
View Full Code Here

                if (imp.getSourceURI() != null && !imp.getSourceURI().contains(".wsdl#")) {
                    String schemaFileName = sourceMap.get(imp.getTargetNamespace());
                    File impfile = new File(wsdlFile.getParentFile(), schemaFileName);
                    Element el = imp.getSchemaDocument().getDocumentElement();
                    updateImports(el, sourceMap);
                    os = new FileWriterUtil(impfile.getParent(), context.get(OutputStreamCreator.class))
                        .getWriter(impfile, "UTF-8");
                    XMLUtils.writeTo(el, os, 2);
                    os.close();
                }
            }
View Full Code Here

    protected boolean isCollision(String packageName, String filename, String ext) throws ToolException {
        if (env.optionSet(ToolConstants.CFG_GEN_OVERWRITE)) {
            return false;
        }
        FileWriterUtil fw = new FileWriterUtil((String)env.get(ToolConstants.CFG_OUTPUTDIR));
        return fw.isCollision(packageName, filename + ext);
    }
View Full Code Here

    protected boolean wantToKeep() {
        return env.optionSet(ToolConstants.CFG_GEN_NEW_ONLY);
    }

    protected Writer parseOutputName(String packageName, String filename, String ext) throws ToolException {
        FileWriterUtil fw = null;
        Writer writer = null;

        if (wantToKeep() && isCollision(packageName, filename, ext)) {
            Message msg = new Message("SKIP_GEN", LOG, packageName + "." + filename + ext);
            LOG.log(Level.INFO, msg.toString());
            return null;
        }

        fw = new FileWriterUtil((String)env.get(ToolConstants.CFG_OUTPUTDIR));
        try {
            writer = fw.getWriter(packageName, filename + ext);
        } catch (IOException ioe) {
            Message msg = new Message("FAIL_TO_WRITE_FILE", LOG, packageName + "." + filename + ext);
            throw new ToolException(msg, ioe);
        }
View Full Code Here

                if (imp.getSourceURI() != null && !imp.getSourceURI().contains(".wsdl#")) {
                    String schemaFileName = sourceMap.get(imp.getTargetNamespace());
                    File impfile = new File(wsdlFile.getParentFile(), schemaFileName);
                    Element el = imp.getSchemaDocument().getDocumentElement();
                    updateImports(el, sourceMap);
                    os = new FileWriterUtil(impfile.getParent())
                        .getWriter(impfile, "UTF-8");
                    XMLUtils.writeTo(el, os, 2);
                    os.close();
                }
            }
View Full Code Here

        return parseOutputName(packageName, filename, ".java");
    }

    public File parseOutputName(String packageName, String filename, String ext) throws ToolException {
        FileUtils.mkDir(new File(this.baseDir));
        FileWriterUtil fw = new FileWriterUtil(this.baseDir);
        try {
            return fw.getFileToWrite(packageName, filename + ext);
        } catch (IOException ioe) {
            Message msg = new Message("FAIL_TO_WRITE_FILE", LOG, packageName + "." + filename + ext);
            throw new ToolException(msg, ioe);
        }
    }
View Full Code Here

                outputDir = outputDir + "/";
            }
        } else {
            outputDir = "./";
        }
        FileWriterUtil fw = new FileWriterUtil(outputDir);
        try {
            writer = fw.getWriter("", newName);
        } catch (IOException ioe) {
            Message msg = new Message("FAIL_TO_WRITE_FILE",
                                      LOG,
                                      env.get(ToolConstants.CFG_OUTPUTDIR)
                                      + System.getProperty("file.seperator")
View Full Code Here

                outputDir = outputDir + "/";
            }
        } else {
            outputDir = "./";
        }
        FileWriterUtil fw = new FileWriterUtil(outputDir);
        try {
            writer = fw.getWriter("", newName);
        } catch (IOException ioe) {
            Message msg = new Message("FAIL_TO_WRITE_FILE",
                                      LOG,
                                      env.get(ToolConstants.CFG_OUTPUTDIR)
                                      + System.getProperty("file.seperator")
View Full Code Here

TOP

Related Classes of org.apache.cxf.tools.util.FileWriterUtil

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.