Search in sources :

Example 1 with CommandDocument

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

the class JavaToWSContainer method checkParams.

public void checkParams(ErrorVisitor errs) throws ToolException {
    super.checkParams(errs);
    CommandDocument doc = super.getCommandDocument();
    if (doc.hasParameter(ToolConstants.CFG_FRONTEND)) {
        String ft = doc.getParameter(ToolConstants.CFG_FRONTEND);
        if (!ToolConstants.JAXWS_FRONTEND.equals(ft) && !ToolConstants.SIMPLE_FRONTEND.equals(ft)) {
            Message msg = new Message("INVALID_FRONTEND", LOG, new Object[] { ft });
            errs.add(new ErrorVisitor.UserError(msg.toString()));
        }
        if (ToolConstants.SIMPLE_FRONTEND.equals(ft) && doc.getParameter(ToolConstants.CFG_DATABINDING) != null && !ToolConstants.AEGIS_DATABINDING.equals(doc.getParameter(ToolConstants.CFG_DATABINDING))) {
            Message msg = new Message("INVALID_DATABINDING_FOR_SIMPLE", LOG);
            errs.add(new ErrorVisitor.UserError(msg.toString()));
        }
    }
    if (doc.hasParameter(ToolConstants.CFG_WRAPPERBEAN)) {
        String ft = doc.getParameter(ToolConstants.CFG_FRONTEND);
        if (ft != null && !ToolConstants.JAXWS_FRONTEND.equals(ft)) {
            Message msg = new Message("WRAPPERBEAN_WITHOUT_JAXWS", LOG);
            errs.add(new ErrorVisitor.UserError(msg.toString()));
        }
    }
    if (errs.getErrors().size() > 0) {
        Message msg = new Message("PARAMETER_MISSING", LOG);
        throw new ToolException(msg, new BadUsageException(getUsage(), errs));
    }
}
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)

Example 2 with CommandDocument

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

the class AbstractCXFToolContainer method getParametersMap.

/**
 * get all parameters in a map
 * @param stringArrayKeys contains keys, whose value should be string array
 */
protected Map<String, Object> getParametersMap(Set<String> stringArrayKeys) {
    Map<String, Object> map = new HashMap<>();
    CommandDocument doc = getCommandDocument();
    if (doc == null) {
        return map;
    }
    String[] keys = doc.getParameterNames();
    if (keys == null) {
        return map;
    }
    for (int i = 0; i < keys.length; i++) {
        if (stringArrayKeys.contains(keys[i])) {
            map.put(keys[i], doc.getParameters(keys[i]));
        } else {
            map.put(keys[i], doc.getParameter(keys[i]));
        }
    }
    return map;
}
Also used : HashMap(java.util.HashMap) CommandDocument(org.apache.cxf.tools.common.toolspec.parser.CommandDocument)

Example 3 with CommandDocument

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

the class WSDLToIDL method initialise.

private void initialise(ProcessorEnvironment env) throws ToolException {
    CommandDocument doc = super.getCommandDocument();
    if (env.optionSet(ToolConstants.CFG_BINDING)) {
        env.put(ToolConstants.CFG_BINDING, doc.getParameter("binding"));
    }
    if (env.optionSet(ToolConstants.CFG_PORTTYPE)) {
        env.put(ToolConstants.CFG_PORTTYPE, doc.getParameter("porttype"));
    }
    if (env.optionSet(ToolConstants.CFG_WSDLURL)) {
        String wsdlname = doc.getParameter("wsdlurl");
        env.put(ToolConstants.CFG_WSDLURL, wsdlname);
    }
    if (env.optionSet(ToolConstants.CFG_NAMESPACE)) {
        env.put(ToolConstants.CFG_NAMESPACE, doc.getParameter("namespace"));
    }
    if (env.optionSet(ToolCorbaConstants.CFG_WSDLOUTPUTFILE)) {
        env.put(ToolCorbaConstants.CFG_WSDLOUTPUTFILE, doc.getParameter("wsdloutputfile"));
    }
    if (env.optionSet(ToolCorbaConstants.CFG_IDLOUTPUTFILE)) {
        env.put(ToolCorbaConstants.CFG_IDLOUTPUTFILE, doc.getParameter("idloutputfile"));
    }
    if (env.optionSet(ToolConstants.CFG_OUTPUTDIR)) {
        env.put(ToolConstants.CFG_OUTPUTDIR, doc.getParameter("outputdir"));
    }
// need to add wrapped
}
Also used : CommandDocument(org.apache.cxf.tools.common.toolspec.parser.CommandDocument)

Example 4 with CommandDocument

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

the class WSDLToIDL method execute.

public void execute(boolean exitOnFinish) {
    try {
        super.execute(exitOnFinish);
        if (!hasInfoOption()) {
            ProcessorEnvironment env = new ProcessorEnvironment();
            env.setParameters(getParametersMap(getArrayKeys()));
            if (isVerboseOn()) {
                env.put(ToolConstants.CFG_VERBOSE, Boolean.TRUE);
            }
            env.put(ToolConstants.CFG_CMD_ARG, args);
            CommandDocument doc = super.getCommandDocument();
            if (doc.hasParameter("corba")) {
                env.put(ToolCorbaConstants.CFG_CORBA, Boolean.TRUE);
            }
            if (doc.hasParameter("idl")) {
                env.put(ToolCorbaConstants.CFG_IDL, Boolean.TRUE);
            }
            initialise(env);
            validate(env);
            WSDLToCorbaProcessor corbaProcessor = new WSDLToCorbaProcessor();
            corbaProcessor.setEnvironment(env);
            corbaProcessor.process();
        }
    } catch (ToolException ex) {
        err.println("Error : " + ex.getMessage());
        if (ex.getCause() instanceof BadUsageException) {
            printUsageException(TOOL_NAME, (BadUsageException) ex.getCause());
        }
        err.println();
        if (isVerboseOn()) {
            ex.printStackTrace(err);
        }
        throw ex;
    } catch (Exception ex) {
        err.println("Error : " + ex.getMessage());
        err.println();
        if (isVerboseOn()) {
            ex.printStackTrace(err);
        }
        throw new ToolException(ex.getMessage(), ex.getCause());
    }
}
Also used : BadUsageException(org.apache.cxf.tools.common.toolspec.parser.BadUsageException) ProcessorEnvironment(org.apache.cxf.tools.corba.common.ProcessorEnvironment) WSDLToCorbaProcessor(org.apache.cxf.tools.corba.processors.wsdl.WSDLToCorbaProcessor) CommandDocument(org.apache.cxf.tools.common.toolspec.parser.CommandDocument) ToolException(org.apache.cxf.tools.common.ToolException) ToolException(org.apache.cxf.tools.common.ToolException) BadUsageException(org.apache.cxf.tools.common.toolspec.parser.BadUsageException)

Example 5 with CommandDocument

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

the class IDLToWSDL method initialise.

private void initialise(ProcessorEnvironment env) throws ToolException {
    CommandDocument doc = super.getCommandDocument();
    if (env.optionSet(ToolCorbaConstants.CFG_IDLFILE)) {
        String idl = doc.getParameter(ToolCorbaConstants.CFG_IDLFILE);
        env.put(ToolCorbaConstants.CFG_IDLFILE, idl);
    }
    if (env.optionSet(ToolCorbaConstants.CFG_TNS)) {
        env.put(ToolCorbaConstants.CFG_TNS, doc.getParameter(ToolCorbaConstants.CFG_TNS));
    }
    if (env.optionSet(ToolConstants.CFG_OUTPUTDIR)) {
        env.put(ToolConstants.CFG_OUTPUTDIR, doc.getParameter(ToolConstants.CFG_OUTPUTDIR));
    }
    if (env.optionSet(ToolCorbaConstants.CFG_ADDRESS)) {
        env.put(ToolCorbaConstants.CFG_ADDRESS, doc.getParameter(ToolCorbaConstants.CFG_ADDRESS));
    }
    if (env.optionSet(ToolCorbaConstants.CFG_SEQUENCE_OCTET_TYPE)) {
        env.put(ToolCorbaConstants.CFG_SEQUENCE_OCTET_TYPE, doc.getParameter(ToolCorbaConstants.CFG_SEQUENCE_OCTET_TYPE));
    }
    if (env.optionSet(ToolCorbaConstants.CFG_SCHEMA_NAMESPACE)) {
        env.put(ToolCorbaConstants.CFG_SCHEMA_NAMESPACE, doc.getParameter(ToolCorbaConstants.CFG_SCHEMA_NAMESPACE));
    }
    if (env.optionSet(ToolCorbaConstants.CFG_LOGICAL)) {
        env.put(ToolCorbaConstants.CFG_LOGICAL, doc.getParameter(ToolCorbaConstants.CFG_LOGICAL));
    }
    if (env.optionSet(ToolCorbaConstants.CFG_PHYSICAL)) {
        env.put(ToolCorbaConstants.CFG_PHYSICAL, doc.getParameter(ToolCorbaConstants.CFG_PHYSICAL));
    }
    if (env.optionSet(ToolCorbaConstants.CFG_SCHEMA)) {
        env.put(ToolCorbaConstants.CFG_SCHEMA, doc.getParameter(ToolCorbaConstants.CFG_SCHEMA));
    }
    if (env.optionSet(ToolCorbaConstants.CFG_WSDL_ENCODING)) {
        env.put(ToolCorbaConstants.CFG_WSDL_ENCODING, doc.getParameter(ToolCorbaConstants.CFG_WSDL_ENCODING));
    }
    if (env.optionSet(ToolCorbaConstants.CFG_IMPORTSCHEMA)) {
        env.put(ToolCorbaConstants.CFG_IMPORTSCHEMA, doc.getParameter(ToolCorbaConstants.CFG_IMPORTSCHEMA));
    }
    if (env.optionSet(ToolCorbaConstants.CFG_MODULETONS)) {
        env.put(ToolCorbaConstants.CFG_MODULETONS, doc.getParameter(ToolCorbaConstants.CFG_MODULETONS));
    }
    if (env.optionSet(ToolCorbaConstants.CFG_INCLUDEDIR)) {
        env.put(ToolCorbaConstants.CFG_INCLUDEDIR, doc.getParameters(ToolCorbaConstants.CFG_INCLUDEDIR));
    }
    if (env.optionSet(ToolCorbaConstants.CFG_WSDLOUTPUTFILE)) {
        env.put(ToolCorbaConstants.CFG_WSDLOUTPUTFILE, doc.getParameter(ToolCorbaConstants.CFG_WSDLOUTPUTFILE));
    }
    if (env.optionSet(ToolCorbaConstants.CFG_EXCLUDEMODULES)) {
        env.put(ToolCorbaConstants.CFG_EXCLUDEMODULES, doc.getParameter(ToolCorbaConstants.CFG_EXCLUDEMODULES));
    }
}
Also used : CommandDocument(org.apache.cxf.tools.common.toolspec.parser.CommandDocument)

Aggregations

CommandDocument (org.apache.cxf.tools.common.toolspec.parser.CommandDocument)6 ToolException (org.apache.cxf.tools.common.ToolException)3 BadUsageException (org.apache.cxf.tools.common.toolspec.parser.BadUsageException)3 Message (org.apache.cxf.common.i18n.Message)2 ErrorVisitor (org.apache.cxf.tools.common.toolspec.parser.ErrorVisitor)2 File (java.io.File)1 HashMap (java.util.HashMap)1 ProcessorEnvironment (org.apache.cxf.tools.corba.common.ProcessorEnvironment)1 WSDLToCorbaProcessor (org.apache.cxf.tools.corba.processors.wsdl.WSDLToCorbaProcessor)1