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