use of org.apache.cxf.bindings.xformat.XMLBindingMessageFormat in project cxf by apache.
the class XMLFormatValidator method checkXMLFormat.
private boolean checkXMLFormat(BindingInfo binding) {
Collection<BindingOperationInfo> bos = binding.getOperations();
boolean result = true;
boolean needRootNode = false;
for (BindingOperationInfo bo : bos) {
OperationInfo op = binding.getInterface().getOperation(bo.getName());
needRootNode = false;
final int inputPartsNum = op.getInput().getMessagePartsNumber();
if (inputPartsNum == 0 || inputPartsNum > 1) {
needRootNode = true;
}
if (needRootNode) {
String path = "Binding(" + binding.getName().getLocalPart() + "):BindingOperation(" + bo.getName() + ")";
List<XMLBindingMessageFormat> inExtensors = bo.getInput().getExtensors(XMLBindingMessageFormat.class);
Iterator<XMLBindingMessageFormat> itIn = null;
if (inExtensors != null) {
itIn = inExtensors.iterator();
}
if (!findXMLFormatRootNode(itIn, bo, path + "-input")) {
return false;
}
// Input check correct, continue to check output binding
if (op.getOutput() != null) {
needRootNode = false;
final int outputPartsNum = op.getOutput().getMessagePartsNumber();
if (outputPartsNum == 0 || outputPartsNum > 1) {
needRootNode = true;
}
if (needRootNode) {
List<XMLBindingMessageFormat> outExtensors = bo.getOutput().getExtensors(XMLBindingMessageFormat.class);
Iterator<XMLBindingMessageFormat> itOut = null;
if (outExtensors != null) {
itOut = outExtensors.iterator();
}
result = result && findXMLFormatRootNode(itOut, bo, path + "-Output");
if (!result) {
return false;
}
}
}
}
}
return true;
}
Aggregations