use of org.apache.cxf.common.i18n.Message in project cxf by apache.
the class JavaScriptContainer method setNamespaceJavascriptPrefixes.
public void setNamespaceJavascriptPrefixes(ToolContext env) {
Map<String, String> nsPrefixMap = new HashMap<>();
if (env.get(ToolConstants.CFG_JSPACKAGEPREFIX) != null) {
final String[] pns;
try {
pns = (String[]) env.get(ToolConstants.CFG_JSPACKAGEPREFIX);
} catch (ClassCastException e) {
Message msg = new Message("INVALID_PREFIX_MAPPING", LOG, env.get(ToolConstants.CFG_JSPACKAGEPREFIX));
throw new ToolException(msg);
}
for (String jsprefix : pns) {
int pos = jsprefix.indexOf('=');
if (pos != -1) {
String ns = jsprefix.substring(0, pos);
jsprefix = jsprefix.substring(pos + 1);
nsPrefixMap.put(ns, jsprefix);
}
}
env.put(ToolConstants.CFG_JSPREFIXMAP, nsPrefixMap);
}
}
use of org.apache.cxf.common.i18n.Message in project cxf by apache.
the class JavaScriptContainer method validate.
public void validate(ToolContext env) throws ToolException {
String outdir = (String) env.get(ToolConstants.CFG_OUTPUTDIR);
if (outdir != null) {
File dir = new File(outdir);
if (!dir.exists() && !dir.mkdirs()) {
Message msg = new Message("DIRECTORY_COULD_NOT_BE_CREATED", LOG, outdir);
throw new ToolException(msg);
}
if (!dir.isDirectory()) {
Message msg = new Message("NOT_A_DIRECTORY", LOG, outdir);
throw new ToolException(msg);
}
}
if (env.optionSet(ToolConstants.CFG_COMPILE)) {
String clsdir = (String) env.get(ToolConstants.CFG_CLASSDIR);
if (clsdir != null) {
File dir = new File(clsdir);
if (!dir.exists() && !dir.mkdirs()) {
Message msg = new Message("DIRECTORY_COULD_NOT_BE_CREATED", LOG, clsdir);
throw new ToolException(msg);
}
}
}
String wsdl = (String) env.get(ToolConstants.CFG_WSDLURL);
if (StringUtils.isEmpty(wsdl)) {
Message msg = new Message("NO_WSDL_URL", LOG);
throw new ToolException(msg);
}
env.put(ToolConstants.CFG_WSDLURL, URIParserUtil.normalize(wsdl));
String[] bindingFiles;
try {
bindingFiles = (String[]) env.get(ToolConstants.CFG_BINDING);
if (bindingFiles == null) {
return;
}
} catch (ClassCastException e) {
bindingFiles = new String[1];
bindingFiles[0] = (String) env.get(ToolConstants.CFG_BINDING);
}
for (int i = 0; i < bindingFiles.length; i++) {
bindingFiles[i] = URIParserUtil.getAbsoluteURI(bindingFiles[i]);
}
env.put(ToolConstants.CFG_BINDING, bindingFiles);
}
use of org.apache.cxf.common.i18n.Message 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));
try (JarOutputStream jarout = new JarOutputStream(Files.newOutputStream(clientJarFile.toPath()), new Manifest())) {
createClientJar(tmpDir, jarout);
} 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.common.i18n.Message in project cxf by apache.
the class WSDLToJavaContainer method generateTypes.
public void generateTypes() throws ToolException {
DataBindingProfile dataBindingProfile = context.get(DataBindingProfile.class);
if (dataBindingProfile == null) {
Message msg = new Message("FOUND_NO_DATABINDING", LOG);
throw new ToolException(msg);
}
dataBindingProfile.initialize(context);
if (passthrough()) {
return;
}
dataBindingProfile.generate(context);
}
use of org.apache.cxf.common.i18n.Message in project cxf by apache.
the class ParameterProcessor method processInput.
private void processInput(JavaMethod method, MessageInfo inputMessage) throws ToolException {
if (requireOutOfBandHeader()) {
try {
Class.forName("org.apache.cxf.binding.soap.SoapBindingFactory");
} catch (Exception e) {
LOG.log(Level.WARNING, new Message("SOAP_MISSING", LOG).toString());
}
}
JAXWSBinding mBinding = inputMessage.getOperation().getExtensor(JAXWSBinding.class);
for (MessagePartInfo part : inputMessage.getMessageParts()) {
if (isOutOfBandHeader(part) && !requireOutOfBandHeader()) {
continue;
}
JavaParameter param = getParameterFromPart(method, part, JavaType.Style.IN);
if (mBinding != null && mBinding.getJaxwsParas() != null) {
for (JAXWSParameter jwp : mBinding.getJaxwsParas()) {
if (part.getName().getLocalPart().equals(jwp.getPart())) {
param.setName(jwp.getName());
}
}
}
addParameter(part, method, param);
}
}
Aggregations