use of org.apache.cxf.service.model.MessagePartInfo in project cxf by apache.
the class ParameterProcessor method buildParamModelsWithoutOrdering.
private void buildParamModelsWithoutOrdering(JavaMethod method, MessageInfo inputMessage, MessageInfo outputMessage) throws ToolException {
boolean wrapped = method.isWrapperStyle();
if (wrapped) {
if (inputMessage != null) {
List<MessagePartInfo> inputParts = inputMessage.getMessageParts();
MessagePartInfo inputPart = !inputParts.isEmpty() ? inputParts.iterator().next() : null;
List<QName> inputWrapElement = null;
if (inputPart != null && inputPart.isElement()) {
inputWrapElement = ProcessorUtil.getWrappedElementQNames(context, inputPart.getElementQName());
}
if (inputWrapElement != null) {
for (QName item : inputWrapElement) {
String fullJavaName = dataBinding.getWrappedElementType(inputPart.getElementQName(), item);
if (StringUtils.isEmpty(fullJavaName)) {
wrapped = false;
break;
}
}
}
}
if (outputMessage != null) {
List<MessagePartInfo> outputParts = outputMessage.getMessageParts();
MessagePartInfo outputPart = !outputParts.isEmpty() ? outputParts.iterator().next() : null;
List<QName> outputWrapElement = null;
if (outputPart != null && outputPart.isElement()) {
outputWrapElement = ProcessorUtil.getWrappedElementQNames(context, outputPart.getElementQName());
}
if (outputWrapElement != null) {
for (QName item : outputWrapElement) {
String fullJavaName = dataBinding.getWrappedElementType(outputPart.getElementQName(), item);
if (StringUtils.isEmpty(fullJavaName)) {
wrapped = false;
break;
}
}
}
}
if (!wrapped) {
// could not map one of the parameters to a java type, need to drop down to bare style
method.setWrapperStyle(false);
}
}
if (inputMessage != null) {
if (method.isWrapperStyle()) {
processWrappedInput(method, inputMessage);
} else {
processInput(method, inputMessage);
}
}
if (outputMessage == null) {
processReturn(method, null);
} else {
if (method.isWrapperStyle()) {
processWrappedOutput(method, inputMessage, outputMessage);
} else {
processOutput(method, inputMessage, outputMessage);
}
}
}
use of org.apache.cxf.service.model.MessagePartInfo 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);
}
}
use of org.apache.cxf.service.model.MessagePartInfo in project cxf by apache.
the class UniqueBodyValidator method isValidEndpoint.
private boolean isValidEndpoint(EndpointInfo endpoint) {
BindingInfo binding = endpoint.getBinding();
Map<QName, QName> uniqueNames = new HashMap<>();
Map<QName, Set<String>> actions = new HashMap<>();
Collection<BindingOperationInfo> bos = binding.getOperations();
for (BindingOperationInfo bo : bos) {
OperationInfo op = binding.getInterface().getOperation(bo.getName());
if (op.getInput() != null && op.getInput().getMessagePartsNumber() == 1) {
MessagePartInfo part = op.getInput().getFirstMessagePart();
if (part.getElementQName() == null) {
continue;
}
QName mName = part.getElementQName();
String action = getWSAAction(op.getInput());
QName opName = uniqueNames.get(mName);
Set<String> opActions = actions.get(mName);
if (opName != null && opActions != null && !opActions.contains(action)) {
opName = null;
}
if (opName != null) {
Message msg = new Message("NON_UNIQUE_BODY", LOG, endpoint.getName(), op.getName(), opName, mName);
addErrorMessage(msg.toString());
return false;
}
uniqueNames.put(mName, op.getName());
if (action != null) {
if (opActions == null) {
opActions = new HashSet<>();
actions.put(mName, opActions);
}
opActions.add(action);
}
}
for (BindingFaultInfo fault : bo.getFaults()) {
if (fault.getFaultInfo().getMessagePartsNumber() > 1) {
Message msg = new Message("FAULT_WITH_MULTIPLE_PARTS", LOG, fault.getFaultInfo().getName().getLocalPart());
addErrorMessage(msg.toString());
return false;
}
}
}
return true;
}
use of org.apache.cxf.service.model.MessagePartInfo in project cxf by apache.
the class WrapperStyleNameCollisionValidator method mapElementName.
private String mapElementName(OperationInfo op, MessageInfo mi, WrapperElement element) {
MessagePartInfo mpi = mi.getMessagePart(element.getElementName());
JAXWSBinding bind = op.getExtensor(JAXWSBinding.class);
if (bind != null && bind.getJaxwsParas() != null) {
for (JAXWSParameter par : bind.getJaxwsParas()) {
if (mi.getName().getLocalPart().equals(par.getMessageName()) && mpi.getName().getLocalPart().equals(par.getElementName().getLocalPart())) {
return par.getName();
}
}
}
return mpi.getElementQName().getLocalPart();
}
use of org.apache.cxf.service.model.MessagePartInfo 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