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