use of org.apache.cxf.common.i18n.Message in project cxf by apache.
the class JavaToJSProcessor method getOutputFile.
protected File getOutputFile(File nameFromClz, String defaultOutputFile) {
String output = (String) context.get(ToolConstants.CFG_OUTPUTFILE);
String dir = (String) context.get(ToolConstants.CFG_OUTPUTDIR);
if (dir == null) {
dir = "./";
}
File result;
if (output != null) {
result = new File(output);
if (!result.isAbsolute()) {
result = new File(new File(dir), output);
}
} else {
result = new File(new File(dir), defaultOutputFile);
}
if (nameFromClz != null) {
result = nameFromClz;
}
// rename the exising wsdl file
if (result.exists() && !result.renameTo(new File(result.getParent(), result.getName()))) {
throw new ToolException(new Message("OUTFILE_EXISTS", LOG));
}
return result;
}
use of org.apache.cxf.common.i18n.Message 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.common.i18n.Message in project cxf by apache.
the class ReflectionServiceFactoryBean method setFaultClassInfo.
private void setFaultClassInfo(OperationInfo o, Method selected) {
Class<?>[] types = selected.getExceptionTypes();
Map<FaultInfo, List<MessagePartInfo>> mpiMap = null;
if (types.length > 0) {
// early iterate over FaultInfo before cycling on exception types
// as fi.getMessageParts() is very time-consuming due to elements
// copy in ArrayList constructor
mpiMap = new HashMap<>();
for (FaultInfo fi : o.getFaults()) {
mpiMap.put(fi, fi.getMessageParts());
}
}
for (int i = 0; i < types.length; i++) {
Class<?> exClass = types[i];
Class<?> beanClass = getBeanClass(exClass);
if (beanClass == null) {
continue;
}
QName name = getFaultName(o.getInterface(), o, exClass, beanClass);
for (Entry<FaultInfo, List<MessagePartInfo>> entry : mpiMap.entrySet()) {
FaultInfo fi = entry.getKey();
List<MessagePartInfo> mpis = entry.getValue();
if (mpis.size() != 1) {
Message message = new Message("NO_FAULT_PART", LOG, fi.getFaultName());
LOG.log(Level.WARNING, message.toString());
}
for (MessagePartInfo mpi : mpis) {
final String ns;
if (mpi.isElement()) {
ns = mpi.getElementQName().getNamespaceURI();
} else {
ns = mpi.getTypeQName().getNamespaceURI();
}
if (mpi.getConcreteName().getLocalPart().equals(name.getLocalPart()) && name.getNamespaceURI().equals(ns)) {
fi.setProperty(Class.class.getName(), exClass);
mpi.setTypeClass(beanClass);
sendEvent(Event.OPERATIONINFO_FAULT, o, exClass, fi);
}
}
}
}
}
use of org.apache.cxf.common.i18n.Message in project cxf by apache.
the class ClassUtils method compile.
public void compile(ToolContext context) throws ToolException {
Compiler compiler = (Compiler) context.get(ToolConstants.COMPILER);
if (compiler == null) {
compiler = new Compiler();
}
if (context.isVerbose()) {
compiler.setVerbose(true);
}
compiler.setEncoding((String) context.get(ToolConstants.CFG_ENCODING));
if (context.get(ToolConstants.CFG_CLASSDIR) != null) {
compiler.setOutputDir((String) context.get(ToolConstants.CFG_CLASSDIR));
}
String javaClasspath = System.getProperty("java.class.path");
if (javaClasspath != null) {
if (context.get(ToolConstants.CFG_OUTPUTDIR) != null) {
compiler.setClassPath(javaClasspath + File.pathSeparatorChar + context.get(ToolConstants.CFG_OUTPUTDIR));
} else {
compiler.setClassPath(javaClasspath);
}
}
String outPutDir = (String) context.get(ToolConstants.CFG_OUTPUTDIR);
Set<String> dirSet = new HashSet<>();
ClassCollector classCollector = context.get(ClassCollector.class);
List<String> fileList = new ArrayList<>();
Iterator<String> ite = classCollector.getGeneratedFileInfo().iterator();
while (ite.hasNext()) {
String fileName = ite.next();
fileName = fileName.replace('.', File.separatorChar);
String dirName = fileName.substring(0, fileName.lastIndexOf(File.separator) + 1);
String path = outPutDir + File.separator + dirName;
if (dirSet.add(path)) {
File file = new File(path);
if (file.isDirectory() && file.list() != null) {
for (String str : file.list()) {
if (str.endsWith("java")) {
fileList.add(path + str);
} else {
// copy generated xml file or others to class directory
Path otherFile = Paths.get(path, str);
String suffix = "xml";
if (Files.isReadable(otherFile) && str.regionMatches(true, str.length() - suffix.length(), suffix, 0, suffix.length()) && context.get(ToolConstants.CFG_CLASSDIR) != null) {
String targetDir = (String) context.get(ToolConstants.CFG_CLASSDIR);
try {
Files.copy(otherFile, Files.createDirectories(Paths.get(targetDir, dirName)).resolve(str));
} catch (IOException e) {
Message msg = new Message("FAIL_TO_COPY_GENERATED_RESOURCE_FILE", LOG);
throw new ToolException(msg, e);
}
}
}
}
// JAXB plugins will generate extra files under the runtime directory
// Those files can not be allocated into the ClassCollector
File jaxbRuntime = new File(path, "runtime");
if (jaxbRuntime.isDirectory() && jaxbRuntime.exists()) {
List<File> files = FileUtils.getFilesUsingSuffix(jaxbRuntime, ".java");
files.forEach(f -> fileList.add(f.toString()));
}
}
}
}
if (!compiler.compileFiles(fileList.toArray(new String[0]))) {
Message msg = new Message("FAIL_TO_COMPILE_GENERATE_CODES", LOG);
throw new ToolException(msg);
}
}
use of org.apache.cxf.common.i18n.Message in project cxf by apache.
the class JavaMethod method addParameter.
public void addParameter(JavaParameter param) {
if (hasParameter(param.getName())) {
JavaParameter paramInList = getParameter(param.getName());
if (isEquiv(paramInList.getClassName(), param.getClassName()) && paramInList.isIN() || paramInList.isINOUT()) {
// removeParameter(paramInList);
replaceParameter(paramInList, param);
return;
}
Message message = new Message("PARAMETER_ALREADY_EXIST", LOG, param.getName(), getName(), paramInList.getType(), param.getType());
throw new ToolException(message);
}
if (param.getType() == null && param.getClassName() == null) {
Message msg = new Message("FAIL_TO_CREATE_JAVA_PARAMETER", LOG, param.name, this.getName());
throw new ToolException(msg);
}
param.setMethod(this);
parameters.add(param);
}
Aggregations