Package org.apache.cxf.tools.common

Examples of org.apache.cxf.tools.common.ToolException


                                                                                 prefixManager, nameManager);
            serviceBuilder.walk();
            String serviceJavascript = serviceBuilder.getCode();
            writer.append(serviceJavascript);
        } catch (FileNotFoundException e) {
            throw new ToolException(e);
        } catch (IOException e) {
            throw new ToolException(e);
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    throw new ToolException(e);
                }
            }
        }

        System.setProperty(JAVA_CLASS_PATH, oldClassPath);
View Full Code Here


            result = nameFromClz;
        }

        // rename the exising wsdl file
        if (result.exists() && !result.renameTo(new File(result.getParent(), result.getName()))) {
            throw new ToolException(new Message("OUTFILE_EXISTS", LOG));
        }
        return result;
    }
View Full Code Here

        if (paramAnn == null) {
            String error = "Unsupported parameter style: " + paramStyle;
            if (PLAIN_PARAM_STYLE.equals(paramStyle)) {
                error += ", plain style parameters have to be wrapped by representations";   
            }
            throw new ToolException(error);
        }
        return paramAnn;
    }
View Full Code Here

            addresses.put(name, address);
            LOG.log(Level.FINE, "FOUND_ADDRESSER", sb);
            return address;
        } catch (Exception e) {
            Message msg = new Message("FOUND_NO_ADDRESSER", LOG, sb);
            throw new ToolException(msg);
        }
    }
View Full Code Here

            customizing(outputdir, name, imports.keySet());
        } catch (WSDLException wex) {
            wex.printStackTrace();
        } catch (FileNotFoundException fnfe) {
            throw new ToolException("Output file " + file + " not found", fnfe);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return def;
    }
View Full Code Here

                }
                if (context.getErrorListener().getErrorCount() > 0) {
                    context.getErrorListener().throwToolException();
                }
            } catch (IOException e) {
                throw new ToolException(e);
            } finally {
                try {
                    if (reader != null) {
                        reader.close();
                    }
                } catch (IOException e) {
                    throw new ToolException(e);
                }
            }
        } else {
            processWsdl();
            if (context.getErrorListener().getErrorCount() > 0) {
View Full Code Here

        //            ToolConstants.CFG_NO_ADDRESS_BINDING);
        validate(context);
        FrontEndProfile frontend = context.get(FrontEndProfile.class);

        if (frontend == null) {
            throw new ToolException(new Message("FOUND_NO_FRONTEND", LOG));
        }

        WSDLConstants.WSDLVersion version = getWSDLVersion();

        String wsdlURL = (String)context.get(ToolConstants.CFG_WSDLURL);

        @SuppressWarnings("unchecked")
        List<ServiceInfo> serviceList = (List<ServiceInfo>)context.get(ToolConstants.SERVICE_LIST);
        if (serviceList == null) {
            serviceList = new ArrayList<ServiceInfo>();

            // Build the ServiceModel from the WSDLModel
            if (version == WSDLConstants.WSDLVersion.WSDL11) {
                AbstractWSDLBuilder builder = frontend.getWSDLBuilder();
                builder.setContext(context);
                builder.setBus(getBus());
                context.put(Bus.class, getBus());
                wsdlURL = URIParserUtil.getAbsoluteURI(wsdlURL);
                builder.build(wsdlURL);
                builder.customize();
                Definition definition = builder.getWSDLModel();

                context.put(Definition.class, definition);

                builder.validate(definition);

                WSDLServiceBuilder serviceBuilder = new WSDLServiceBuilder(getBus());
                if (context.isVerbose()) {
                    serviceBuilder.setUnwrapLogLevel(Level.INFO);
                }
                serviceBuilder.setIgnoreUnknownBindings(true);
                String allowRefs = (String)context.get(ToolConstants.CFG_ALLOW_ELEMENT_REFS);
                if (!StringUtils.isEmpty(allowRefs)
                    || context.optionSet(ToolConstants.CFG_ALLOW_ELEMENT_REFS)) {
                    if (allowRefs.length() > 0 && allowRefs.charAt(0) == '=') {
                        allowRefs = allowRefs.substring(1);
                    }
                    if (StringUtils.isEmpty(allowRefs)) {
                        allowRefs = "true";
                    }
                    serviceBuilder.setAllowElementRefs(Boolean.valueOf(allowRefs));
                }
                String serviceName = (String)context.get(ToolConstants.CFG_SERVICENAME);

                if (serviceName != null) {
                    List<ServiceInfo> services = serviceBuilder
                        .buildServices(definition, getServiceQName(definition));
                    serviceList.addAll(services);
                } else if (definition.getServices().size() > 0) {
                    serviceList = serviceBuilder.buildServices(definition);
                } else {
                    serviceList = serviceBuilder.buildMockServices(definition);
                }
                //remove definition from cache so that won't fail when encounter same wsdl file
                //name but different wsdl content(CXF-3340)
                getBus().getExtension(WSDLManager.class).removeDefinition(definition);
            } else {
                // TODO: wsdl2.0 support
            }
        }
        context.put(ToolConstants.SERVICE_LIST, serviceList);
       
        Map<String, InterfaceInfo> interfaces = new LinkedHashMap<String, InterfaceInfo>();

        ServiceInfo service0 = serviceList.get(0);
        SchemaCollection schemaCollection = service0.getXmlSchemaCollection();
        context.put(ToolConstants.XML_SCHEMA_COLLECTION, schemaCollection);
       
        context.put(ToolConstants.PORTTYPE_MAP, interfaces);
       
        context.put(ClassCollector.class, createClassCollector());
        Processor processor = frontend.getProcessor();
        if (processor instanceof ClassNameProcessor) {
            processor.setEnvironment(context);
            for (ServiceInfo service : serviceList) {

                context.put(ServiceInfo.class, service);

                ((ClassNameProcessor)processor).processClassNames();

                context.put(ServiceInfo.class, null);
            }
        }
       
        if (context.optionSet(ToolConstants.CFG_NO_TYPES)) {
            context.remove(ToolConstants.CFG_TYPES);
            context.remove(ToolConstants.CFG_ALL);
            context.remove(ToolConstants.CFG_COMPILE);
        }
       
        generateTypes();
        if (context.getErrorListener().getErrorCount() > 0) {
            return;
        }

        for (ServiceInfo service : serviceList) {
            context.put(ServiceInfo.class, service);

            if (context.basicValidateWSDL()) {
                validate(service);
            }

            if (context.getErrorListener().getErrorCount() == 0) {
                // Build the JavaModel from the ServiceModel
                processor.setEnvironment(context);
                processor.process();
            }
        }
        if (context.getErrorListener().getErrorCount() > 0) {
            return;
        }
       
        if (context.optionSet(ToolConstants.CFG_CLIENT_JAR)) {
            enforceWSDLLocation(context);
        }
       
        if (!isSuppressCodeGen()) {
            // Generate artifacts
            for (FrontEndGenerator generator : frontend.getGenerators()) {
                generator.generate(context);
            }
        }
        context.remove(ToolConstants.SERVICE_LIST);

        // Build projects: compile classes and copy resources etc.
        if (context.optionSet(ToolConstants.CFG_COMPILE)) {
            new ClassUtils().compile(context);
        }

        if (context.isExcludeNamespaceEnabled()) {
            try {
                removeExcludeFiles();
            } catch (IOException e) {
                throw new ToolException(e);
            }
        }
        if (context.optionSet(ToolConstants.CFG_CLIENT_JAR)) {
            processClientJar(context);
        }
View Full Code Here

            createClientJar(tmpDir, jarout);
            jarout.close();
        } catch (Exception e) {
            LOG.log(Level.SEVERE, "FAILED_TO_CREAT_CLIENTJAR", e);
            Message msg = new Message("FAILED_TO_CREAT_CLIENTJAR", LOG);
            throw new ToolException(msg, e);
        }   
        context.put(ToolConstants.CFG_CLASSDIR, oldClassDir);
        context.put(ClassCollector.class, oldCollector);
    }
View Full Code Here

                input.close();
                jarout.closeEntry();
            }
        } catch (Exception e) {
            Message msg = new Message("FAILED_ADD_JARENTRY", LOG);
            throw new ToolException(msg, e);
        }
    }
View Full Code Here

            if (ex.getCause() instanceof BadUsageException) {
                printUsageException(toolName, (BadUsageException)ex.getCause());
            }
            throw ex;
        } catch (Exception ex) {
            throw new ToolException(ex);
        } finally {
            tearDown();
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.tools.common.ToolException

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.