return collision;
}
@SuppressWarnings("unchecked")
private void processFault(JavaMethod method, FaultInfo faultMessage) throws ToolException {
JavaModel model = method.getInterface().getJavaModel();
String name = NameUtil.mangleNameToClassName(faultMessage.getName().getLocalPart());
String namespace = faultMessage.getName().getNamespaceURI();
String packageName = ProcessorUtil.parsePackageName(namespace, context.mapPackageName(namespace));
if (namespace.equals(method.getInterface().getNamespace())) {
packageName = method.getInterface().getPackageName();
}
JAXWSBinding jaxwsBinding = faultMessage.getExtensor(JAXWSBinding.class);
if (jaxwsBinding != null) {
if (jaxwsBinding.getPackage() != null) {
packageName = jaxwsBinding.getPackage();
}
if (jaxwsBinding.getJaxwsClass() != null
&& jaxwsBinding.getJaxwsClass().getClassName() != null) {
name = jaxwsBinding.getJaxwsClass().getClassName();
}
}
while (isNameCollision(packageName, name)) {
name = name + "_Exception";
}
String fullClassName = packageName + "." + name;
collector.addExceptionClassName(packageName, name, fullClassName);
boolean samePackage = method.getInterface().getPackageName().equals(packageName);
method.addException(new JavaException(name, samePackage ? name : fullClassName, namespace));
List<MessagePartInfo> faultParts = faultMessage.getMessageParts();
JavaExceptionClass expClass = new JavaExceptionClass(model);
expClass.setName(name);
expClass.setNamespace(namespace);
expClass.setPackageName(packageName);
for (MessagePartInfo part : faultParts) {
String fName = null;
String fNamespace = null;
if (part.getElementQName() != null) {
fNamespace = part.getElementQName().getNamespaceURI();
//fNamespace = part.getConcreteName().getNamespaceURI();
fName = part.getConcreteName().getLocalPart();
} else {
fNamespace = part.getTypeQName().getNamespaceURI();
fName = part.getConcreteName().getLocalPart();
}
if (StringUtils.isEmpty(fNamespace)) {
fNamespace = namespace;
}
String fType = ProcessorUtil.getType(part, context, false);
//REVISIT - custom JAXB package names
String fPackageName = method.getInterface().getPackageName();
JavaField fField = new JavaField(fName, fType, fNamespace);
fField.setQName(ProcessorUtil.getElementName(part));
if (!method.getInterface().getPackageName().equals(fPackageName)) {
fField.setClassName(ProcessorUtil.getFullClzName(part, context, false));
}
if (!fType.equals(ProcessorUtil.resolvePartType(part))) {
fField.setClassName(ProcessorUtil.getType(part, context, true));
}
expClass.addField(fField);
}
model.addExceptionClass(packageName + "." + name, expClass);
}