use of org.apache.cxf.tools.common.ToolException in project cxf by apache.
the class Wrapper method isWrapperBeanClassNotExist.
public boolean isWrapperBeanClassNotExist() {
try {
Message msg = new Message("LOADING_WRAPPER_CLASS", LOG, getJavaClass().getFullClassName());
LOG.log(Level.FINE, msg.toString());
getWrapperClass();
return false;
} catch (ToolException e) {
return true;
}
}
use of org.apache.cxf.tools.common.ToolException in project cxf by apache.
the class WSDLToJava method main.
public static void main(String[] pargs) {
System.setProperty("org.apache.cxf.JDKBugHacks.defaultUsesCaches", "true");
CommandInterfaceUtils.commandCommonMain();
WSDLToJava w2j = new WSDLToJava(pargs);
try {
w2j.run(new ToolContext());
} catch (ToolException ex) {
System.err.println();
System.err.println("WSDLToJava Error: " + ex.getMessage());
System.err.println();
if (w2j.isVerbose()) {
ex.printStackTrace();
}
if (w2j.isExitOnFinish()) {
System.exit(1);
}
} catch (Exception ex) {
System.err.println("WSDLToJava Error: " + ex.getMessage());
System.err.println();
if (w2j.isVerbose()) {
ex.printStackTrace();
}
if (w2j.isExitOnFinish()) {
System.exit(1);
}
}
if (w2j.isExitOnFinish()) {
System.exit(0);
}
}
use of org.apache.cxf.tools.common.ToolException in project cxf by apache.
the class WSDLToJavaContainer method processClientJar.
private void processClientJar(ToolContext context) {
ClassCollector oldCollector = context.get(ClassCollector.class);
ClassCollector newCollector = new ClassCollector();
String oldClassDir = (String) context.get(ToolConstants.CFG_CLASSDIR);
File tmpDir = FileUtils.createTmpDir();
context.put(ToolConstants.CFG_CLASSDIR, tmpDir.getAbsolutePath());
newCollector.setTypesClassNames(oldCollector.getTypesClassNames());
newCollector.setSeiClassNames(oldCollector.getSeiClassNames());
newCollector.setExceptionClassNames(oldCollector.getExceptionClassNames());
newCollector.setServiceClassNames(oldCollector.getServiceClassNames());
context.put(ClassCollector.class, newCollector);
new ClassUtils().compile(context);
generateLocalWSDL(context);
File clientJarFile = new File((String) context.get(ToolConstants.CFG_OUTPUTDIR), (String) context.get(ToolConstants.CFG_CLIENT_JAR));
JarOutputStream jarout = null;
try {
jarout = new JarOutputStream(Files.newOutputStream(clientJarFile.toPath()), new Manifest());
createClientJar(tmpDir, jarout);
jarout.close();
} catch (Exception e) {
LOG.log(Level.SEVERE, "FAILED_TO_CREAT_CLIENTJAR", e);
Message msg = new Message("FAILED_TO_CREAT_CLIENTJAR", LOG);
throw new ToolException(msg, e);
}
context.put(ToolConstants.CFG_CLASSDIR, oldClassDir);
context.put(ClassCollector.class, oldCollector);
}
use of org.apache.cxf.tools.common.ToolException in project cxf by apache.
the class WSDLToJavaContainer method validate.
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());
}
}
}
use of org.apache.cxf.tools.common.ToolException in project cxf by apache.
the class WSDLToJavaContainer method execute.
public void execute() throws ToolException {
if (hasInfoOption()) {
return;
}
buildToolContext();
boolean isWsdlList = context.optionSet(ToolConstants.CFG_WSDLLIST);
if (isWsdlList) {
BufferedReader reader = null;
try {
ToolContext initialContextState = context.makeCopy();
String wsdlURL = (String) context.get(ToolConstants.CFG_WSDLURL);
wsdlURL = URIParserUtil.getAbsoluteURI(wsdlURL);
URL url = new URL(wsdlURL);
InputStream is = (InputStream) url.getContent();
reader = new BufferedReader(new InputStreamReader(is));
String tempLine = null;
while ((tempLine = reader.readLine()) != null) {
ToolContext freshContext = initialContextState.makeCopy();
freshContext.put(ToolConstants.CFG_WSDLURL, tempLine);
setContext(freshContext);
buildToolContext();
processWsdl();
}
if (context.getErrorListener().getErrorCount() > 0) {
context.getErrorListener().throwToolException();
}
} catch (IOException e) {
throw new ToolException(e);
} finally {
try {
if (reader != null) {
reader.close();
}
} catch (IOException e) {
throw new ToolException(e);
}
}
} else {
processWsdl();
if (context.getErrorListener().getErrorCount() > 0) {
context.getErrorListener().throwToolException();
}
}
}
Aggregations