use of com.sun.tools.ws.wsdl.document.Message in project metro-jax-ws by eclipse-ee4j.
the class WSDLModeler method validateParameterName.
private boolean validateParameterName(List<Parameter> params) {
if (options.isExtensionMode()) {
return true;
}
Message msg = getInputMessage();
for (Parameter param : params) {
if (param.isOUT()) {
continue;
}
if (param.getCustomName() != null) {
if (Names.isJavaReservedWord(param.getCustomName())) {
error(param.getEntity(), ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_CUSTOM_NAME(info.operation.getName(), param.getCustomName()));
return false;
}
// Custom name should be a valid variable name
if (!param.getCustomName().matches("^[_$a-zA-Z][_$\\w]*$")) {
error(param.getEntity(), ModelerMessages.WSDLMODELER_INVALID_OPERATION_INVALID_JAVA_VARIABLE_NAME_CUSTOM_NAME(info.operation.getName(), param.getCustomName()));
return false;
}
return true;
}
// process doclit wrapper style
if (param.isEmbedded() && !(param.getBlock().getType() instanceof RpcLitStructure)) {
if (Names.isJavaReservedWord(param.getName())) {
error(param.getEntity(), ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_WRAPPER_STYLE(info.operation.getName(), param.getName(), param.getBlock().getName()));
return false;
}
} else {
// non-wrapper style and rpclit
if (Names.isJavaReservedWord(param.getName())) {
error(param.getEntity(), ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_NON_WRAPPER_STYLE(info.operation.getName(), msg.getName(), param.getName()));
return false;
}
}
}
boolean isRequestResponse = info.portTypeOperation.getStyle() == OperationStyle.REQUEST_RESPONSE;
if (isRequestResponse) {
msg = getOutputMessage();
for (Parameter param : params) {
if (param.isIN()) {
continue;
}
if (param.getCustomName() != null) {
if (Names.isJavaReservedWord(param.getCustomName())) {
error(param.getEntity(), ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_CUSTOM_NAME(info.operation.getName(), param.getCustomName()));
return false;
}
return true;
}
// process doclit wrapper style
if (param.isEmbedded() && !(param.getBlock().getType() instanceof RpcLitStructure)) {
if (param.isReturn()) {
continue;
}
if (!param.getName().equals("return") && Names.isJavaReservedWord(param.getName())) {
error(param.getEntity(), ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_WRAPPER_STYLE(info.operation.getName(), param.getName(), param.getBlock().getName()));
return false;
}
} else {
if (param.isReturn()) {
continue;
}
// non-wrapper style and rpclit
if (Names.isJavaReservedWord(param.getName())) {
error(param.getEntity(), ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_NON_WRAPPER_STYLE(info.operation.getName(), msg.getName(), param.getName()));
return false;
}
}
}
}
return true;
}
use of com.sun.tools.ws.wsdl.document.Message in project metro-jax-ws by eclipse-ee4j.
the class WSDLParser method parseDefinitionsNoImport.
private Definitions parseDefinitionsNoImport(TWSDLParserContextImpl context, Document doc) {
Element e = doc.getDocumentElement();
// at this poinjt we expect a wsdl or schema document to be fully qualified
if (e.getNamespaceURI() == null || (!e.getNamespaceURI().equals(WSDLConstants.NS_WSDL) || !e.getLocalName().equals("definitions"))) {
return null;
}
context.push();
context.registerNamespaces(e);
Definitions definitions = new Definitions(context.getDocument(), forest.locatorTable.getStartLocation(e));
String name = XmlUtil.getAttributeOrNull(e, Constants.ATTR_NAME);
definitions.setName(name);
String targetNamespaceURI = XmlUtil.getAttributeOrNull(e, Constants.ATTR_TARGET_NAMESPACE);
definitions.setTargetNamespaceURI(targetNamespaceURI);
boolean gotDocumentation = false;
boolean gotTypes = false;
for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext(); ) {
Element e2 = Util.nextElement(iter);
if (e2 == null)
break;
if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_DOCUMENTATION)) {
if (gotDocumentation) {
errReceiver.error(forest.locatorTable.getStartLocation(e2), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName()));
return null;
}
gotDocumentation = true;
if (definitions.getDocumentation() == null)
definitions.setDocumentation(getDocumentationFor(e2));
} else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_TYPES)) {
if (gotTypes && !options.isExtensionMode()) {
errReceiver.error(forest.locatorTable.getStartLocation(e2), WsdlMessages.PARSING_ONLY_ONE_TYPES_ALLOWED(Constants.TAG_DEFINITIONS));
return null;
}
gotTypes = true;
// that will be needed to create jaxb model
if (!options.isExtensionMode())
validateSchemaImports(e2);
} else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_MESSAGE)) {
Message message = parseMessage(context, definitions, e2);
definitions.add(message);
} else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_PORT_TYPE)) {
PortType portType = parsePortType(context, definitions, e2);
definitions.add(portType);
} else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_BINDING)) {
Binding binding = parseBinding(context, definitions, e2);
definitions.add(binding);
} else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_SERVICE)) {
Service service = parseService(context, definitions, e2);
definitions.add(service);
} else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_IMPORT)) {
definitions.add(parseImport(context, definitions, e2));
} else if (XmlUtil.matchesTagNS(e2, SchemaConstants.QNAME_IMPORT)) {
errReceiver.warning(forest.locatorTable.getStartLocation(e2), WsdlMessages.WARNING_WSI_R_2003());
} else {
// possible extensibility element -- must live outside the WSDL namespace
checkNotWsdlElement(e2);
if (!handleExtension(context, definitions, e2)) {
checkNotWsdlRequired(e2);
}
}
}
context.pop();
context.fireDoneParsingEntity(WSDLConstants.QNAME_DEFINITIONS, definitions);
return definitions;
}
use of com.sun.tools.ws.wsdl.document.Message in project metro-jax-ws by eclipse-ee4j.
the class WSDLModeler method getHeaderMessage.
private Message getHeaderMessage(MessagePart part, TWSDLExtensible ext) {
Iterator<SOAPHeader> headers = getHeaderExtensions(ext).iterator();
while (headers.hasNext()) {
SOAPHeader header = headers.next();
if (!header.isLiteral()) {
continue;
}
com.sun.tools.ws.wsdl.document.Message headerMessage = findMessage(header.getMessage(), document);
if (headerMessage == null) {
continue;
}
MessagePart headerPart = headerMessage.getPart(header.getPart());
if (headerPart == part) {
return headerMessage;
}
}
return null;
}
use of com.sun.tools.ws.wsdl.document.Message in project metro-jax-ws by eclipse-ee4j.
the class WSDLModeler method setMessagePartsBinding.
protected boolean setMessagePartsBinding(StyleAndUse styleAndUse) {
SOAPBody inBody = getSOAPRequestBody();
Message inMessage = getInputMessage();
if (!setMessagePartsBinding(inBody, inMessage, styleAndUse, true)) {
return false;
}
if (isRequestResponse()) {
SOAPBody outBody = getSOAPResponseBody();
Message outMessage = getOutputMessage();
return setMessagePartsBinding(outBody, outMessage, styleAndUse, false);
}
return true;
}
use of com.sun.tools.ws.wsdl.document.Message in project metro-jax-ws by eclipse-ee4j.
the class WSDLModeler method getParameterOrder.
protected List<MessagePart> getParameterOrder() {
List<MessagePart> params = new ArrayList<>();
String parameterOrder = info.portTypeOperation.getParameterOrder();
java.util.List<String> parameterList;
boolean parameterOrderPresent = false;
if ((parameterOrder != null) && !(parameterOrder.trim().equals(""))) {
parameterList = XmlUtil.parseTokenList(parameterOrder);
parameterOrderPresent = true;
} else {
parameterList = new ArrayList<>();
}
Message inputMessage = getInputMessage();
Message outputMessage = getOutputMessage();
List<MessagePart> outputParts = null;
List<MessagePart> inputParts = inputMessage.getParts();
// reset the mode and ret flag, as MEssagePArts aer shared across ports
for (MessagePart part : inputParts) {
part.setMode(Mode.IN);
part.setReturn(false);
}
if (isRequestResponse()) {
outputParts = outputMessage.getParts();
for (MessagePart part : outputParts) {
part.setMode(Mode.OUT);
part.setReturn(false);
}
}
if (parameterOrderPresent) {
boolean validParameterOrder = true;
Iterator<String> paramOrders = parameterList.iterator();
// response message, we completely ignore the parameterOrder hint
while (paramOrders.hasNext()) {
String param = paramOrders.next();
boolean partFound = false;
for (MessagePart part : inputParts) {
if (param.equals(part.getName())) {
partFound = true;
break;
}
}
// if not found, check in output parts
if (!partFound) {
for (MessagePart part : outputParts) {
if (param.equals(part.getName())) {
partFound = true;
break;
}
}
}
if (!partFound) {
warning(info.operation.getEntity(), ModelerMessages.WSDLMODELER_INVALID_PARAMETERORDER_PARAMETER(param, info.operation.getName().getLocalPart()));
validParameterOrder = false;
}
}
List<MessagePart> inputUnlistedParts = new ArrayList<>();
List<MessagePart> outputUnlistedParts = new ArrayList<>();
// gather input Parts
if (validParameterOrder) {
for (String param : parameterList) {
MessagePart part = inputMessage.getPart(param);
if (part != null) {
params.add(part);
continue;
}
if (isRequestResponse()) {
MessagePart outPart = outputMessage.getPart(param);
if (outPart != null) {
params.add(outPart);
}
}
}
for (MessagePart part : inputParts) {
if (!parameterList.contains(part.getName())) {
inputUnlistedParts.add(part);
}
}
if (isRequestResponse()) {
// at most one output part should be unlisted
for (MessagePart part : outputParts) {
if (!parameterList.contains(part.getName())) {
MessagePart inPart = inputMessage.getPart(part.getName());
// dont add inout as unlisted part
if ((inPart != null) && inPart.getDescriptor().equals(part.getDescriptor())) {
inPart.setMode(Mode.INOUT);
} else {
outputUnlistedParts.add(part);
}
} else {
// param list may contain it, check if its INOUT
MessagePart inPart = inputMessage.getPart(part.getName());
// dont add inout as unlisted part
if ((inPart != null) && inPart.getDescriptor().equals(part.getDescriptor())) {
inPart.setMode(Mode.INOUT);
} else if (!params.contains(part)) {
params.add(part);
}
}
}
if (outputUnlistedParts.size() == 1) {
MessagePart resultPart = outputUnlistedParts.get(0);
resultPart.setReturn(true);
params.add(resultPart);
outputUnlistedParts.clear();
}
}
// add the input and output unlisted parts
params.addAll(inputUnlistedParts);
params.addAll(outputUnlistedParts);
return params;
}
// parameterOrder attribute is not valid, we ignore it
warning(info.operation.getEntity(), ModelerMessages.WSDLMODELER_INVALID_PARAMETER_ORDER_INVALID_PARAMETER_ORDER(info.operation.getName().getLocalPart()));
parameterList.clear();
}
List<MessagePart> outParts = new ArrayList<>();
// construct input parameter list with the same order as in input message
params.addAll(inputParts);
if (isRequestResponse()) {
for (MessagePart part : outputParts) {
MessagePart inPart = inputMessage.getPart(part.getName());
if (inPart != null && part.getDescriptorKind() == inPart.getDescriptorKind() && part.getDescriptor().equals(inPart.getDescriptor())) {
inPart.setMode(Mode.INOUT);
continue;
}
outParts.add(part);
}
// append the out parts to the parameterList
for (MessagePart part : outParts) {
if (outParts.size() == 1) {
part.setReturn(true);
}
params.add(part);
}
}
return params;
}
Aggregations