Search in sources :

Example 6 with BadUsageException

use of org.apache.cxf.tools.common.toolspec.parser.BadUsageException in project cxf by apache.

the class WSDLToSoap method execute.

public void execute(boolean exitOnFinish) {
    WSDLToSoapProcessor processor = new WSDLToSoapProcessor();
    try {
        super.execute(exitOnFinish);
        if (!hasInfoOption()) {
            ToolContext env = new ToolContext();
            env.setParameters(getParametersMap(getArrayKeys()));
            if (isVerboseOn()) {
                env.put(ToolConstants.CFG_VERBOSE, Boolean.TRUE);
            }
            env.put(ToolConstants.CFG_CMD_ARG, getArgument());
            validate(env);
            setEnvParamDefValues(env);
            processor.setEnvironment(env);
            processor.process();
        }
    } catch (ToolException ex) {
        if (ex.getCause() instanceof BadUsageException) {
            printUsageException(TOOL_NAME, (BadUsageException) ex.getCause());
        }
        err.println();
        err.println("WSDLToSoap Error : " + ex.getMessage());
        if (isVerboseOn()) {
            ex.printStackTrace(err);
        }
    } catch (Exception ex) {
        err.println();
        err.println("WSDLToSoap Error : " + ex.getMessage());
        if (isVerboseOn()) {
            ex.printStackTrace(err);
        }
    } finally {
        tearDown();
    }
}
Also used : BadUsageException(org.apache.cxf.tools.common.toolspec.parser.BadUsageException) ToolContext(org.apache.cxf.tools.common.ToolContext) ToolException(org.apache.cxf.tools.common.ToolException) WSDLToSoapProcessor(org.apache.cxf.tools.misc.processor.WSDLToSoapProcessor) ToolException(org.apache.cxf.tools.common.ToolException) BadUsageException(org.apache.cxf.tools.common.toolspec.parser.BadUsageException)

Example 7 with BadUsageException

use of org.apache.cxf.tools.common.toolspec.parser.BadUsageException in project cxf by apache.

the class WSDLToXML method execute.

public void execute(boolean exitOnFinish) {
    WSDLToXMLProcessor processor = new WSDLToXMLProcessor();
    try {
        super.execute(exitOnFinish);
        if (!hasInfoOption()) {
            ToolContext env = new ToolContext();
            env.setParameters(getParametersMap(getArrayKeys()));
            if (isVerboseOn()) {
                env.put(ToolConstants.CFG_VERBOSE, Boolean.TRUE);
            }
            env.put(ToolConstants.CFG_CMD_ARG, getArgument());
            validate(env);
            setEnvParamDefValues(env);
            processor.setEnvironment(env);
            processor.process();
        }
    } catch (ToolException ex) {
        if (ex.getCause() instanceof BadUsageException) {
            printUsageException(TOOL_NAME, (BadUsageException) ex.getCause());
        }
        err.println();
        err.println("WSDLToXML Error: " + ex.getMessage());
        if (isVerboseOn()) {
            ex.printStackTrace(err);
        }
    } catch (Exception ex) {
        err.println();
        err.println("WSDLToXML Error: " + ex.getMessage());
        if (isVerboseOn()) {
            ex.printStackTrace(err);
        }
    } finally {
        tearDown();
    }
}
Also used : WSDLToXMLProcessor(org.apache.cxf.tools.misc.processor.WSDLToXMLProcessor) BadUsageException(org.apache.cxf.tools.common.toolspec.parser.BadUsageException) ToolContext(org.apache.cxf.tools.common.ToolContext) ToolException(org.apache.cxf.tools.common.ToolException) ToolException(org.apache.cxf.tools.common.ToolException) BadUsageException(org.apache.cxf.tools.common.toolspec.parser.BadUsageException)

Example 8 with BadUsageException

use of org.apache.cxf.tools.common.toolspec.parser.BadUsageException in project cxf by apache.

the class XSDToWSDL method execute.

public void execute(boolean exitOnFinish) {
    XSDToWSDLProcessor processor = new XSDToWSDLProcessor();
    try {
        super.execute(exitOnFinish);
        if (!hasInfoOption()) {
            ToolContext env = new ToolContext();
            env.setParameters(getParametersMap(getArrayKeys()));
            if (isVerboseOn()) {
                env.put(ToolConstants.CFG_VERBOSE, Boolean.TRUE);
            }
            env.put(ToolConstants.CFG_CMD_ARG, getArgument());
            validate(env);
            processor.setEnvironment(env);
            processor.process();
        }
    } catch (ToolException ex) {
        if (ex.getCause() instanceof BadUsageException) {
            printUsageException(TOOL_NAME, (BadUsageException) ex.getCause());
        }
        err.println();
        err.println("XSDToWSDL Error: " + ex.getMessage());
        if (isVerboseOn()) {
            ex.printStackTrace(err);
        }
    } catch (Exception ex) {
        err.println();
        err.println("XSDToWSDL Error: " + ex.getMessage());
        if (isVerboseOn()) {
            ex.printStackTrace(err);
        }
    }
}
Also used : XSDToWSDLProcessor(org.apache.cxf.tools.misc.processor.XSDToWSDLProcessor) BadUsageException(org.apache.cxf.tools.common.toolspec.parser.BadUsageException) ToolContext(org.apache.cxf.tools.common.ToolContext) ToolException(org.apache.cxf.tools.common.ToolException) ToolException(org.apache.cxf.tools.common.ToolException) BadUsageException(org.apache.cxf.tools.common.toolspec.parser.BadUsageException)

Example 9 with BadUsageException

use of org.apache.cxf.tools.common.toolspec.parser.BadUsageException in project cxf by apache.

the class WSDLValidator method execute.

public void execute(boolean exitOnFinish) {
    try {
        super.execute(exitOnFinish);
        if (!hasInfoOption()) {
            ToolContext env = getContext();
            env.setParameters(getParametersMap(getArrayKeys()));
            env.put(ToolConstants.CFG_VALIDATE_WSDL, "all");
            env.put(ToolConstants.CFG_CMD_ARG, getArgument());
            WSDL11Validator wsdlValidator = new WSDL11Validator(null, env, getBus());
            if (wsdlValidator.isValid()) {
                System.out.println("Passed Validation : Valid WSDL ");
            }
        }
    } catch (ToolException ex) {
        err.println("WSDLValidator Error : " + ex.getMessage());
        if (ex.getCause() instanceof BadUsageException) {
            printUsageException(TOOL_NAME, (BadUsageException) ex.getCause());
        }
        err.println();
        if (isVerboseOn()) {
            err.println("[+] Verbose turned on");
            err.println();
            ex.printStackTrace(err);
        }
    } catch (Exception ex) {
        err.println("WSDLValidator Error : " + ex.getMessage());
        err.println();
        if (isVerboseOn()) {
            err.println("[+] Verbose turned on");
            err.println();
            ex.printStackTrace(err);
        }
    }
}
Also used : BadUsageException(org.apache.cxf.tools.common.toolspec.parser.BadUsageException) ToolContext(org.apache.cxf.tools.common.ToolContext) WSDL11Validator(org.apache.cxf.tools.validator.internal.WSDL11Validator) ToolException(org.apache.cxf.tools.common.ToolException) ToolException(org.apache.cxf.tools.common.ToolException) BadUsageException(org.apache.cxf.tools.common.toolspec.parser.BadUsageException)

Example 10 with BadUsageException

use of org.apache.cxf.tools.common.toolspec.parser.BadUsageException in project cxf by apache.

the class IDLToWSDL method checkParams.

public void checkParams(ErrorVisitor errors) throws ToolException {
    CommandDocument doc = super.getCommandDocument();
    if (!doc.hasParameter(ToolCorbaConstants.CFG_IDLFILE)) {
        errors.add(new ErrorVisitor.UserError("IDL file has to be specified"));
    }
    if ((doc.hasParameter(ToolCorbaConstants.CFG_SCHEMA)) && (doc.hasParameter(ToolCorbaConstants.CFG_IMPORTSCHEMA))) {
        errors.add(new ErrorVisitor.UserError("Options -n & -T cannot be used together"));
    }
    if ((doc.hasParameter(ToolCorbaConstants.CFG_MODULETONS)) && ((doc.hasParameter(ToolCorbaConstants.CFG_LOGICAL)) || (doc.hasParameter(ToolCorbaConstants.CFG_PHYSICAL)) || (doc.hasParameter(ToolCorbaConstants.CFG_SCHEMA)) || (doc.hasParameter(ToolCorbaConstants.CFG_IMPORTSCHEMA)))) {
        errors.add(new ErrorVisitor.UserError("Options -mns and -L|-P|-T|-n cannot be use together"));
    }
    if (doc.hasParameter(ToolCorbaConstants.CFG_SEQUENCE_OCTET_TYPE)) {
        String sequenceOctetType = doc.getParameter(ToolCorbaConstants.CFG_SEQUENCE_OCTET_TYPE);
        if (sequenceOctetType != null && (!(sequenceOctetType.equals(ToolCorbaConstants.CFG_SEQUENCE_OCTET_TYPE_BASE64BINARY) || sequenceOctetType.equals(ToolCorbaConstants.CFG_SEQUENCE_OCTET_TYPE_HEXBINARY)))) {
            errors.add(new ErrorVisitor.UserError("Invalid value specified for -s option"));
        }
    }
    if (doc.hasParameter(ToolCorbaConstants.CFG_ADDRESSFILE)) {
        String addressFileName = doc.getParameter(ToolCorbaConstants.CFG_ADDRESSFILE);
        File addressFile = new File(addressFileName);
        if (!addressFile.canRead() || !addressFile.isFile()) {
            errors.add(new ErrorVisitor.UserError("Invalid value specified for -f option\n" + "\"" + addressFileName + "\" cannot be read"));
        }
    }
    if (errors.getErrors().size() > 0) {
        Message msg = new Message("PARAMETER_MISSING", LOG);
        throw new ToolException(msg, new BadUsageException(getUsage(), errors));
    }
}
Also used : Message(org.apache.cxf.common.i18n.Message) BadUsageException(org.apache.cxf.tools.common.toolspec.parser.BadUsageException) CommandDocument(org.apache.cxf.tools.common.toolspec.parser.CommandDocument) ToolException(org.apache.cxf.tools.common.ToolException) ErrorVisitor(org.apache.cxf.tools.common.toolspec.parser.ErrorVisitor) File(java.io.File)

Aggregations

ToolException (org.apache.cxf.tools.common.ToolException)11 BadUsageException (org.apache.cxf.tools.common.toolspec.parser.BadUsageException)11 ToolContext (org.apache.cxf.tools.common.ToolContext)7 CommandDocument (org.apache.cxf.tools.common.toolspec.parser.CommandDocument)3 HashSet (java.util.HashSet)2 Message (org.apache.cxf.common.i18n.Message)2 ErrorVisitor (org.apache.cxf.tools.common.toolspec.parser.ErrorVisitor)2 ProcessorEnvironment (org.apache.cxf.tools.corba.common.ProcessorEnvironment)2 File (java.io.File)1 Processor (org.apache.cxf.tools.common.Processor)1 IDLToWSDLProcessor (org.apache.cxf.tools.corba.processors.idl.IDLToWSDLProcessor)1 WSDLToCorbaProcessor (org.apache.cxf.tools.corba.processors.wsdl.WSDLToCorbaProcessor)1 JavaToJSProcessor (org.apache.cxf.tools.java2js.processor.JavaToJSProcessor)1 WSDLToServiceProcessor (org.apache.cxf.tools.misc.processor.WSDLToServiceProcessor)1 WSDLToSoapProcessor (org.apache.cxf.tools.misc.processor.WSDLToSoapProcessor)1 WSDLToXMLProcessor (org.apache.cxf.tools.misc.processor.WSDLToXMLProcessor)1 XSDToWSDLProcessor (org.apache.cxf.tools.misc.processor.XSDToWSDLProcessor)1 WSDL11Validator (org.apache.cxf.tools.validator.internal.WSDL11Validator)1