use of org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.WrapperElement in project cxf by apache.
the class WrapperStyleNameCollisionValidator method isValidOperation.
private boolean isValidOperation(OperationInfo operation) {
ToolContext context = service.getProperty(ToolContext.class.getName(), ToolContext.class);
boolean c = context.optionSet(ToolConstants.CFG_AUTORESOLVE);
boolean valid = false;
if (operation.getUnwrappedOperation() == null) {
valid = true;
}
String operationName = operation.getName().getLocalPart();
operationName = ProcessorUtil.mangleNameToVariableName(operationName);
JAXWSBinding binding = operation.getExtensor(JAXWSBinding.class);
if (binding != null) {
if (!binding.isEnableWrapperStyle()) {
valid = true;
} else if (binding.getMethodName() != null) {
operationName = binding.getMethodName();
}
}
binding = operation.getInterface().getExtensor(JAXWSBinding.class);
if (binding != null) {
if (!binding.isEnableWrapperStyle()) {
valid = true;
} else if (binding.getMethodName() != null) {
operationName = binding.getMethodName();
}
}
binding = operation.getInterface().getService().getDescription().getExtensor(JAXWSBinding.class);
if (binding != null) {
if (!binding.isEnableWrapperStyle()) {
valid = true;
} else if (binding.getMethodName() != null) {
operationName = binding.getMethodName();
}
}
valid |= checkBare(context, operationName);
if (valid) {
return true;
}
MessagePartInfo input = null;
MessagePartInfo output = null;
if (operation.getInput() != null && operation.getInput().getMessagePartsNumber() == 1) {
input = operation.getInput().getFirstMessagePart();
}
if (operation.getOutput() != null && operation.getOutput().getMessagePartsNumber() == 1) {
output = operation.getOutput().getFirstMessagePart();
}
if (!c) {
Map<String, QName> names = new HashMap<>();
if (input != null) {
for (WrapperElement element : ProcessorUtil.getWrappedElement(context, input.getElementQName())) {
String mappedName = mapElementName(operation, operation.getUnwrappedOperation().getInput(), element);
if (names.containsKey(mappedName) && (names.get(mappedName) == element.getSchemaTypeName() || names.get(mappedName).equals(element.getSchemaTypeName()))) {
handleErrors(names.get(mappedName), element);
return false;
}
names.put(mappedName, element.getSchemaTypeName());
}
}
if (output != null) {
List<WrapperElement> els = ProcessorUtil.getWrappedElement(context, output.getElementQName());
if (els.size() > 1) {
for (WrapperElement element : els) {
String mappedName = mapElementName(operation, operation.getUnwrappedOperation().getOutput(), element);
QName mn = names.get(mappedName);
if (names.containsKey(mappedName) && !(mn == element.getSchemaTypeName() || (mn != null && mn.equals(element.getSchemaTypeName())))) {
handleErrors(names.get(mappedName), element);
return false;
}
names.put(mappedName, element.getSchemaTypeName());
}
}
}
}
return true;
}
Aggregations