Package org.apache.cxf.tools.util

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


    String className = "Hello";

    @Test
    public void testKeep() throws Exception {
        gen = new DummyGenerator();
        util = new FileWriterUtil(output.toString(), null);

        context = new ToolContext();
        context.put(ToolConstants.CFG_OUTPUTDIR, output.toString());
        gen.setEnvironment(context);
View Full Code Here


    }

    @Test
    public void testOverwrite() throws Exception {
        gen = new DummyGenerator();
        util = new FileWriterUtil(output.toString(), null);

        context = new ToolContext();
        context.put(ToolConstants.CFG_OUTPUTDIR, output.toString());

        gen.setEnvironment(context);
View Full Code Here

        return false;
    }

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

        writeWSDL(def, outputWriter);
    }
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, null);
        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, env.get(OutputStreamCreator.class));
        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, env.get(OutputStreamCreator.class));
        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") + newName);
            throw new ToolException(msg, ioe);
        }
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 = new BufferedOutputStream(new FileOutputStream(wsdlFile));
                    wsdlWriter.writeWSDL(wsdlDef, wsdlOs);
                    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

                }
                generator.setAttributes("targetNamespaces", ns);
            }

            try {
                generator.doWrite(getTemplate(), new FileWriterUtil(xjb.getParent(), getOutputStreamCreator())
                    .getWriter(xjb, "UTF-8"));
            } catch (Exception e) {
                e.printStackTrace();
            }
View Full Code Here

           
                File file = generator.parseOutputName(wrapperClass.getPackageName(),
                                                      wrapperClass.getName());
                generatedFiles.add(file);
           
                generator.doWrite(TEMPLATE, new FileWriterUtil(file.getParent(), getOutputStreamCreator())
                    .getWriter(file, (String)getToolContext().get(ToolConstants.CFG_ENCODING)));
           
                generator.clearAttributes();
            }
       
View Full Code Here

        return false;
    }

    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

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.