Package org.apache.cxf.tools.common

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


        //            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) {
                @SuppressWarnings("unchecked")
                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());
                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();

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

                }
            }
        }

        Message msg = new Message("SERVICE_NOT_FOUND", LOG, new Object[] {serviceName});
        throw new ToolException(msg);
    }
View Full Code Here

        if (!isSuppressCodeGen()) {
            if (outdir != null) {
                File dir = new File(outdir);
                if (!dir.exists() && !dir.mkdirs()) {
                    Message msg = new Message("DIRECTORY_COULD_NOT_BE_CREATED", 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() && !dir.mkdirs()) {
                        Message msg = new Message("DIRECTORY_COULD_NOT_BE_CREATED", 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 (!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

    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

    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

        for (QName outElement : outputWrapElement) {
            if ("return".equals(outElement.getLocalPart())) {
                if (method.getReturn() != null) {
                    org.apache.cxf.common.i18n.Message msg =
                        new org.apache.cxf.common.i18n.Message("WRAPPER_STYLE_TWO_RETURN_TYPES", LOG);
                    throw new ToolException(msg);
                }
                JavaReturn jreturn = getReturnFromQName(outElement, outputPart);
                if (!qualified) {
                    jreturn.setTargetNamespace("");
                }
View Full Code Here

        if (bindingType == null) {
            org.apache.cxf.common.i18n.Message msg =
                new org.apache.cxf.common.i18n.Message("BINDING_SPECIFY_ONE_PROTOCOL",
                                                       LOG,
                                                       binding.getName());
            throw new ToolException(msg);
        }

        if (isSoapBinding()) {
            SoapBinding spbd = SOAPBindingUtil.getProxy(SoapBinding.class, this.bindingObj);
            jport.setStyle(SOAPBindingUtil.getSoapStyle(spbd.getStyle()));
View Full Code Here

            if (bindingType == null) {
                org.apache.cxf.common.i18n.Message msg =
                    new org.apache.cxf.common.i18n.Message("BINDING_SPECIFY_ONE_PROTOCOL",
                                                           LOG,
                                                           binding.getName());
                throw new ToolException(msg);
            }

            Collection<BindingOperationInfo> operations = binding.getOperations();
            for (BindingOperationInfo bop : operations) {
                processOperation(model, bop, binding);
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.