mimeContent.getPart(), pw); DOMUtils.printAttribute(Constants.ATTR_TYPE,
/** * Validates mime:content elements. * @param mimeContents a list of mime:content elements. * @return true if any mime:content does not include the part attribute, * false otherwise */ private boolean hasInvalidMimeContent(List mimeContents) { // Going through a list of mime:content elements for (int i = 0; i < mimeContents.size(); i++) { // If a mime:content does not include the part attribute, return true if (((MIMEContent) mimeContents.get(i)).getPart() == null) return true; } // There are no invalid mime:contentS, return false return false; } }
/** * Validates mime:content elements. * @param mimeContents a list of mime:content elements. * @return true if any mime:content does not include the part attribute, * false otherwise */ private boolean hasInvalidMimeContent(List mimeContents) { // Going through a list of mime:content elements for (int i = 0; i < mimeContents.size(); i++) { // If a mime:content does not include the part attribute, return true if (((MIMEContent) mimeContents.get(i)).getPart() == null) return true; } // There are no invalid mime:contentS, return false return false; } }
/** * Returns the part value from MIMEContent element * @param part MIMEPart element * @return the part value from MIMEContent element */ private String getMIMEContentPart(MIMEPart part) { List list = part.getExtensibilityElements(); if(list.size() == 0) return null; return ((MIMEContent) list.get(0)).getPart(); }
/** * Returns the part value from MIMEContent element * @param part MIMEPart element * @return the part value from MIMEContent element */ private String getMIMEContentPart(MIMEPart part) { List list = part.getExtensibilityElements(); if(list.size() == 0) return null; return ((MIMEContent) list.get(0)).getPart(); }
/** * Returns the part value from MIMEContent element * @param part MIMEPart element * @return the part value from MIMEContent element */ private String getMIMEContentPart(MIMEPart part) { List list = part.getExtensibilityElements(); if(list.size() == 0) return null; return ((MIMEContent) list.get(0)).getPart(); }
/** * Returns the part value from MIMEContent element * @param part MIMEPart element * @return the part value from MIMEContent element */ private String getMIMEContentPart(MIMEPart part) { List list = part.getExtensibilityElements(); if(list.size() == 0) return null; return ((MIMEContent) list.get(0)).getPart(); }
/** * Returns part name specified in mime:content element that is not presented in wsdl:message * @param mimeContents a list of mime:content elements which part attributes are validated * @param message a wsdl:message * @return a part name */ private String getInvalidMimeContentPart(List mimeContents, Message message) { // Going throug all the mime:content elements for (int i = 0; i < mimeContents.size(); i++) { // Getting the part name of a mime:element String part = ((MIMEContent) mimeContents.get(i)).getPart(); // If the wsdl:message does not contain such part, return the part if (!message.getParts().keySet().contains(part)) return part; } // Return null if no one part is found return null; } }
/** * Returns part name specified in mime:content element that is not presented in wsdl:message * @param mimeContents a list of mime:content elements which part attributes are validated * @param message a wsdl:message * @return a part name */ private String getInvalidMimeContentPart(List mimeContents, Message message) { // Going throug all the mime:content elements for (int i = 0; i < mimeContents.size(); i++) { // Getting the part name of a mime:element String part = ((MIMEContent) mimeContents.get(i)).getPart(); // If the wsdl:message does not contain such part, return the part if (!message.getParts().keySet().contains(part)) return part; } // Return null if no one part is found return null; } }
private boolean doValidateMimeContentPartNames(Iterator mimeContents, String operationName) { // validate mime:content(s) in the mime:part as per R2909 String partName = null; while (mimeContents.hasNext()) { MIMEContent mimeContent = (MIMEContent)mimeContents.next(); String mimeContnetPart = mimeContent.getPart(); if (mimeContnetPart == null) { addErrorMessage("Operation(" + operationName + "): Must provide part attribute value for meme:content elements"); return false; } else { if (partName == null) { partName = mimeContnetPart; } else { if (!partName.equals(mimeContnetPart)) { addErrorMessage("Operation(" + operationName + "): Part attribute value for meme:content " + "elements are different"); return false; } } } } return true; } }
private void markSWAParts(List extensions, Binding srcBinding, Definition srcWsdl) throws WSDLException { Iterator extIt = extensions.iterator(); while (extIt.hasNext()) { Object o = extIt.next(); if (o instanceof MIMEMultipartRelated) { QName portTypeName = getDefinedPortType(srcBinding).getQName(); if (log.isTraceEnabled()) log.trace("SWA found on portType" + portTypeName); MIMEMultipartRelated mrel = (MIMEMultipartRelated)o; Iterator mimePartIt = mrel.getMIMEParts().iterator(); while (mimePartIt.hasNext()) { MIMEPart mimePartDesc = (MIMEPart)mimePartIt.next(); List mimePartExt = mimePartDesc.getExtensibilityElements(); if (!mimePartExt.isEmpty() && (mimePartExt.get(0) instanceof MIMEContent)) { MIMEContent mimeContent = (MIMEContent)mimePartExt.get(0); if (skippedSWAParts.get(portTypeName) == null) skippedSWAParts.put(portTypeName, new ArrayList<String>()); skippedSWAParts.get(portTypeName).add(mimeContent.getPart()); } } break; } } }
private boolean doValidateMimeContentPartNames(List<MIMEContent> mimeContents, String operationName) { // validate mime:content(s) in the mime:part as per R2909 String partName = null; for (MIMEContent mimeContent : mimeContents) { String mimeContnetPart = mimeContent.getPart(); if (mimeContnetPart == null) { addErrorMessage("Operation(" + operationName + "): Must provide part attribute value for meme:content elements"); return false; } if (partName == null) { partName = mimeContnetPart; } else { if (!partName.equals(mimeContnetPart)) { addErrorMessage("Operation(" + operationName + "): Part attribute value for meme:content " + "elements are different"); return false; } } } return true; } }
private boolean doValidateMimeContentPartNames(List<MIMEContent> mimeContents, String operationName) { // validate mime:content(s) in the mime:part as per R2909 String partName = null; for (MIMEContent mimeContent : mimeContents) { String mimeContnetPart = mimeContent.getPart(); if (mimeContnetPart == null) { addErrorMessage("Operation(" + operationName + "): Must provide part attribute value for meme:content elements"); return false; } if (partName == null) { partName = mimeContnetPart; } else { if (!partName.equals(mimeContnetPart)) { addErrorMessage("Operation(" + operationName + "): Part attribute value for meme:content " + "elements are different"); return false; } } } return true; } }
private static Set<String> getIgnorableParts(WSDLElement ext) { Set<String> parts = null; if (ext != null && ext.getExtensibilityElements() != null && ext.getExtensibilityElements().size() > 0 && ext.getExtensibilityElements().get(0) instanceof MIMEMultipartRelated) { MIMEMultipartRelated mpr = (MIMEMultipartRelated)ext.getExtensibilityElements().get(0); List<MIMEPart> mps = CastUtils.cast(mpr.getMIMEParts()); parts = new HashSet<>(mps.size()); for (Iterator<MIMEPart> it = mps.iterator(); it.hasNext();) { MIMEPart mp = it.next(); if (mp.getExtensibilityElements() != null && mp.getExtensibilityElements().size() > 0 && mp.getExtensibilityElements().get(0) instanceof MIMEContent) { parts.add(((MIMEContent)mp.getExtensibilityElements().get(0)).getPart()); } } } return parts; }
private static Set<String> getIgnorableParts(WSDLElement ext) { Set<String> parts = null; if (ext != null && ext.getExtensibilityElements() != null && ext.getExtensibilityElements().size() > 0 && ext.getExtensibilityElements().get(0) instanceof MIMEMultipartRelated) { MIMEMultipartRelated mpr = (MIMEMultipartRelated)ext.getExtensibilityElements().get(0); List<MIMEPart> mps = CastUtils.cast(mpr.getMIMEParts()); parts = new HashSet<>(mps.size()); for (Iterator<MIMEPart> it = mps.iterator(); it.hasNext();) { MIMEPart mp = it.next(); if (mp.getExtensibilityElements() != null && mp.getExtensibilityElements().size() > 0 && mp.getExtensibilityElements().get(0) instanceof MIMEContent) { parts.add(((MIMEContent)mp.getExtensibilityElements().get(0)).getPart()); } } } return parts; }
/** * Checks whether any mime:content element binds wsdl:part that is defined * with the element attribute and uses the content type "text/xml". * @param mimeContents a list of mime:content elements of binding operation. * @param message the corresponding wsdl:message element. * @return a mime:content element that uses a content type other than * "text/xml", null if no one such element is found. */ private MIMEContent getInvalidMimeContent(List mimeContents, Message message) { // Going through a list of mime:content elements for (int i = 0; i < mimeContents.size(); i++) { MIMEContent mimeContent = (MIMEContent) mimeContents.get(i); // Getting the corresponding wsdl:part Part part = message.getPart(mimeContent.getPart()); // If the part is defined with the element attribute if (part != null && part.getElementName() != null) { mimeContentFound = true; // If the type attribute value is other than "text/xml" if (!WSIConstants.CONTENT_TYPE_TEXT_XML.equals(mimeContent.getType())) { // return the invalid element return mimeContent; } } } return null; }
/** * Checks whether any mime:content element binds wsdl:part that is defined * with the element attribute and uses the content type "text/xml". * @param mimeContents a list of mime:content elements of binding operation. * @param message the corresponding wsdl:message element. * @return a mime:content element that uses a content type other than * "text/xml", null if no one such element is found. */ private MIMEContent getInvalidMimeContent(List mimeContents, Message message) { // Going through a list of mime:content elements for (int i = 0; i < mimeContents.size(); i++) { MIMEContent mimeContent = (MIMEContent) mimeContents.get(i); // Getting the corresponding wsdl:part Part part = message.getPart(mimeContent.getPart()); // If the part is defined with the element attribute if (part != null && part.getElementName() != null) { mimeContentFound = true; // If the type attribute value is other than "text/xml" if (!WSIConstants.CONTENT_TYPE_TEXT_XML.equals(mimeContent.getType())) { // return the invalid element return mimeContent; } } } return null; }
/** * Validates every mime:content element. If it references a wsdl:part that * is defined using neither the type attribute nor the element attribute * or using them together, it is invalid. * @param mimeContents a list of mime:content elements. * @param message the corresponding wsdl:message element for mime:contentS. * @return a value of the part attribute of an invalid mime:content * or null if all the mime:content elements are valid. */ private String getInvalidMimeContentPart(List mimeContents, Message message) { // Going throug all the mime:content elements for (int i = 0; i < mimeContents.size(); i++) { // Getting a value of the part attribute from a mime:element String partName = ((MIMEContent) mimeContents.get(i)).getPart(); // Getting the corresponging wsdl:part Part part = message.getPart(partName); // if it is defined and use neither the type attribute // nor the element attribute or use them together, return part value if (part != null && ((part.getTypeName() == null && part.getElementName() == null) || (part.getTypeName() != null && part.getElementName() != null))) { return partName; } } // Return null if no one part is found return null; }
public static org.apache.ode.bpel.iapi.Message parseResponseFromRESTService(BPELMessageContext partnerInvocationContext, PartnerRoleMessageExchange odePartnerMex) { org.apache.ode.bpel.iapi.Message messageToODE = odePartnerMex.createMessage( odePartnerMex.getOperation().getOutput().getMessage().getQName()); BindingOperation bindingOp = getBindingOperation(partnerInvocationContext, odePartnerMex.getOperationName()); BindingOutput bindingOutPut = getBindingOutPut(bindingOp); javax.wsdl.extensions.mime.MIMEContent mimeContent = getFirstExtensibilityElement(bindingOutPut, MIMEContent .class); if (mimeContent != null) { SOAPEnvelope soapEnv = partnerInvocationContext.getOutMessageContext().getEnvelope(); Iterator childElementsItr = soapEnv.getBody().getChildElements(); while (childElementsItr.hasNext()) { OMNode child = (OMNode) childElementsItr.next(); if (child.getType() == OMNode.ELEMENT_NODE) { Document doc = DOMUtils.newDocument(); Element domPart = doc.createElementNS(null, mimeContent.getPart()); domPart.appendChild(doc.importNode(OMUtils.toDOM((OMElement) child), true)); messageToODE.setPart(mimeContent.getPart(), domPart); return messageToODE; } } } throw new IllegalArgumentException("WSO2 BPS only support HTTP binding with mime output."); }
/** * Validates every mime:content element. If it references a wsdl:part that * is defined using neither the type attribute nor the element attribute * or using them together, it is invalid. * @param mimeContents a list of mime:content elements. * @param message the corresponding wsdl:message element for mime:contentS. * @return a value of the part attribute of an invalid mime:content * or null if all the mime:content elements are valid. */ private String getInvalidMimeContentPart(List mimeContents, Message message) { // Going throug all the mime:content elements for (int i = 0; i < mimeContents.size(); i++) { // Getting a value of the part attribute from a mime:element String partName = ((MIMEContent) mimeContents.get(i)).getPart(); // Getting the corresponging wsdl:part Part part = message.getPart(partName); // if it is defined and use neither the type attribute // nor the element attribute or use them together, return part value if (part != null && ((part.getTypeName() == null && part.getElementName() == null) || (part.getTypeName() != null && part.getElementName() != null))) { return partName; } } // Return null if no one part is found return null; }