Package org.apache.cxf.tools.common

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


            validate(context);
            FrontEndProfile frontend = context.get(FrontEndProfile.class);

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

            WSDLConstants.WSDLVersion version = getWSDLVersion();

            String wsdlURL = (String)context.get(ToolConstants.CFG_WSDLURL);
            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<Definition> builder = (AbstractWSDLBuilder<Definition>)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());
                    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);
                    }

                } else {
                    // TODO: wsdl2.0 support
                }
            }
            Map<String, InterfaceInfo> interfaces = new LinkedHashMap<String, InterfaceInfo>();

            Map<String, Element> schemas = (Map<String, Element>)serviceList.get(0)
                .getProperty(WSDLServiceBuilder.WSDL_SCHEMA_ELEMENT_LIST);
            if (schemas == null) {
                schemas = new java.util.HashMap<String, Element>();
                ServiceInfo serviceInfo = serviceList.get(0);
                for (SchemaInfo schemaInfo : serviceInfo.getSchemas()) {
                    if (schemaInfo.getElement() != null && schemaInfo.getSystemId() == null) {
                        String sysId = schemaInfo.getElement().getAttribute("targetNamespce");
                        if (sysId == null) {
                            sysId = serviceInfo.getTargetNamespace();
                        }
                        schemas.put(sysId, schemaInfo.getElement());
                    }
                    if (schemaInfo.getElement() != null && schemaInfo.getSystemId() != null) {
                        schemas.put(schemaInfo.getSystemId(), schemaInfo.getElement());
                    }
                }
            }
            context.put(ToolConstants.SCHEMA_MAP, schemas);
            context.put(ToolConstants.PORTTYPE_MAP, interfaces);
            context.put(ClassCollector.class, new ClassCollector());
            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);
                }
            }
            generateTypes();

            for (ServiceInfo service : serviceList) {

                context.put(ServiceInfo.class, service);

                validate(service);

                // Build the JavaModel from the ServiceModel
                processor.setEnvironment(context);
                processor.process();

                if (!isSuppressCodeGen()) {
                    // Generate artifacts
                    for (FrontEndGenerator generator : frontend.getGenerators()) {
                        generator.generate(context);
                    }
                }
            }

            // 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);
                }
            }
        }

    }
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

            }
        }

        if (qname == null) {
            Message msg = new Message("SERVICE_NOT_FOUND", LOG, new Object[] {serviceName});
            throw new ToolException(msg);
        }

        return qname;
    }
View Full Code Here

        String outdir = (String)env.get(ToolConstants.CFG_OUTPUTDIR);
        if (outdir != null) {
            File dir = new File(outdir);
            if (!dir.exists()) {
                Message msg = new Message("DIRECTORY_NOT_EXIST", LOG, outdir);
                throw new ToolException(msg);
            }
            if (!dir.isDirectory()) {
                Message msg = new Message("NOT_A_DIRECTORY", LOG, outdir);
                throw new ToolException(msg);
            }
        }

        if (env.optionSet(ToolConstants.CFG_COMPILE)) {
            String clsdir = (String)env.get(ToolConstants.CFG_CLASSDIR);
            if (clsdir != null) {
                File dir = new File(clsdir);
                if (!dir.exists()) {
                    Message msg = new Message("DIRECTORY_NOT_EXIST", LOG, clsdir);
                    throw new ToolException(msg);
                }
            }
        }

        String wsdl = (String)env.get(ToolConstants.CFG_WSDLURL);
        if (StringUtils.isEmpty(wsdl)) {
            Message msg = new Message("NO_WSDL_URL", LOG);
            throw new ToolException(msg);
        }

        env.put(ToolConstants.CFG_WSDLURL, URIParserUtil.normalize(wsdl));
        if (!env.containsKey(ToolConstants.CFG_WSDLLOCATION)) {
            //make sure the "raw" form is used for the wsdlLocation
View Full Code Here

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

        if (!doc.hasParameter("wsdlurl")) {
            errors.add(new ErrorVisitor.UserError("WSDL/SCHEMA URL has to be specified"));
        }
        if (errors.getErrors().size() > 0) {
            Message msg = new Message("PARAMETER_MISSING", LOG);
            throw new ToolException(msg, new BadUsageException(getUsage(), errors));
        }
    }
View Full Code Here

            try {
                pns = (String[])env.get(ToolConstants.CFG_JSPACKAGEPREFIX);
            } catch (ClassCastException e) {
                Message msg = new Message("INVALID_PREFIX_MAPPING", LOG,
                                          env.get(ToolConstants.CFG_JSPACKAGEPREFIX));
                throw new ToolException(msg);
            }
            for (int j = 0; j < pns.length; j++) {
                int pos = pns[j].indexOf("=");
                String jsprefix = pns[j];
                if (pos != -1) {
View Full Code Here

    public void generateTypes() throws ToolException {
        DataBindingProfile dataBindingProfile = context.get(DataBindingProfile.class);
        if (dataBindingProfile == null) {
            Message msg = new Message("FOUND_NO_DATABINDING", LOG);
            throw new ToolException(msg);
        }
        dataBindingProfile.initialize(context);
        if (passthrough()) {
            return;
        }
View Full Code Here

        String outdir = (String)env.get(ToolConstants.CFG_OUTPUTDIR);
        if (outdir != null) {
            File dir = new File(outdir);
            if (!dir.exists()) {
                Message msg = new Message("DIRECTORY_NOT_EXIST", LOG, outdir);
                throw new ToolException(msg);
            }
            if (!dir.isDirectory()) {
                Message msg = new Message("NOT_A_DIRECTORY", LOG, outdir);
                throw new ToolException(msg);
            }
        }

        if (env.optionSet(ToolConstants.CFG_COMPILE)) {
            String clsdir = (String)env.get(ToolConstants.CFG_CLASSDIR);
            if (clsdir != null) {
                File dir = new File(clsdir);
                if (!dir.exists()) {
                    Message msg = new Message("DIRECTORY_NOT_EXIST", LOG, clsdir);
                    throw new ToolException(msg);
                }
            }
        }

        String wsdl = (String)env.get(ToolConstants.CFG_WSDLURL);
        if (StringUtils.isEmpty(wsdl)) {
            Message msg = new Message("NO_WSDL_URL", LOG);
            throw new ToolException(msg);
        }

        env.put(ToolConstants.CFG_WSDLURL, URIParserUtil.normalize(wsdl));

        String[] bindingFiles;
View Full Code Here

    public void validate(final ServiceInfo service) throws ToolException {
        for (ServiceValidator validator : getServiceValidators()) {
            service.setProperty(ToolContext.class.getName(), context);
            validator.setService(service);
            if (!validator.isValid()) {
                throw new ToolException(validator.getErrorMessage());
            }
        }
    }
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.