boolean isAbstract = false; boolean publish = true; NamedNodeMap atts = element.getAttributes(); String bus = element.getAttribute("bus"); if (StringUtils.isEmpty(bus)) { addBusWiringAttribute(bean, BusWiringType.CONSTRUCTOR); } else { String val = node.getValue(); String pre = node.getPrefix(); String name = node.getLocalName(); Element elem = DOMUtils.getFirstElement(element); while (elem != null) { String name = elem.getLocalName(); if ("properties".equals(name)) { Map<?, ?> map = ctx.getDelegate().parseMapElement(elem, bean.getBeanDefinition()); setFirstChildAsProperty(elem, ctx, bean, name); elem = DOMUtils.getNextElement(elem);
String clsName = ""; if (rw == null) { clsName = getPackageName(selected) + ".jaxws." + StringUtils.capitalize(selected.getName()); } else { clsName = rw.className();
public boolean addSchemaDocument(SchemaCollection col, List<String> tnsList, Document d, String systemId, boolean hackAroundEmptyNamespaceIssue) { String ns = d.getDocumentElement().getAttribute("targetNamespace"); if (StringUtils.isEmpty(ns)) { if (DOMUtils.getFirstElement(d.getDocumentElement()) == null) { hackAroundEmptyNamespaceIssue = true; return hackAroundEmptyNamespaceIssue; d.getDocumentElement().setAttribute("targetNamespace", ns); Node n = d.getDocumentElement().getFirstChild(); while (n != null) { if (n instanceof Element) { n = n.getNextSibling();
private Document doEmptyNamespaceHack(Document d) { boolean hasStuffToRemove = false; Element el = DOMUtils.getFirstElement(d.getDocumentElement()); while (el != null) { if ("import".equals(el.getLocalName()) && StringUtils.isEmpty(el.getAttribute("targetNamespace"))) { hasStuffToRemove = true; break; } el = DOMUtils.getNextElement(el); } if (hasStuffToRemove) { // create a copy of the dom so we // can modify it. d = copy(d); el = DOMUtils.getFirstElement(d.getDocumentElement()); while (el != null) { if ("import".equals(el.getLocalName()) && StringUtils.isEmpty(el.getAttribute("targetNamespace"))) { d.getDocumentElement().removeChild(el); el = DOMUtils.getFirstElement(d.getDocumentElement()); } else { el = DOMUtils.getNextElement(el); } } } return d; }
node = node.getParentNode(); NamedNodeMap atts = el.getAttributes(); for (int i = 0; i < atts.getLength(); i++) { Node currentAttribute = atts.item(i); String currentLocalName = currentAttribute.getLocalName(); String currentPrefix = currentAttribute.getPrefix(); if (searchPrefix.equals(currentLocalName) && XMLNAMESPACE.equals(currentPrefix)) { return currentAttribute.getNodeValue(); } else if (StringUtils.isEmpty(searchPrefix) && XMLNAMESPACE.equals(currentLocalName) && StringUtils.isEmpty(currentPrefix)) { return currentAttribute.getNodeValue(); Node parent = el.getParentNode(); if (parent instanceof Element) { return getNamespace(parent, searchPrefix);
private boolean matches(Element el) { if (el.getLocalName().equals(name.getLocalPart()) && el.getNamespaceURI().equals(name.getNamespaceURI())) { if (!StringUtils.isEmpty(attributeName) && !StringUtils.isEmpty(attributeValue)) { String v = el.getAttribute(attributeName); if (attributeValue.equals(v) || (StringUtils.isEmpty(v) && isDefaultAttributeValue)) { return true; } } else { return true; } } return false; } private boolean matches(Element el, Stack<XNode> stack) {
public static String getAttribute(Element element, QName attName) { Attr attr; if (StringUtils.isEmpty(attName.getNamespaceURI())) { attr = element.getAttributeNode(attName.getLocalPart()); } else { attr = element.getAttributeNodeNS(attName.getNamespaceURI(), attName.getLocalPart()); } return attr == null ? null : attr.getValue(); }
Node nd2 = null; if (nd == null) { nd2 = getDocument().getDocumentElement(); } else { nd2 = nd.getFirstChild(); userData = nd2.getUserData("new"); } catch (Throwable t) { if (nd2.getNodeType() == Node.ELEMENT_NODE && local.equals(nd2.getLocalName()) && StringUtils.isEmpty(nd2.getNamespaceURI()) && userData != null) { adjustOverlaidNode(nd2, null);
public void writeStartElement(String local) throws XMLStreamException { isOverlaidStack.add(0, isOverlaid); if (isOverlaid) { Element nd = getCurrentNode(); Node nd2 = null; if (nd == null) { nd2 = getDocument().getDocumentElement(); } else { nd2 = nd.getFirstChild(); } while (nd2 != null) { if (nd2.getNodeType() == Node.ELEMENT_NODE && local.equals(nd2.getLocalName()) && StringUtils.isEmpty(nd2.getNamespaceURI())) { setChild((Element)nd2, false); return; } nd2 = nd2.getNextSibling(); } } isOverlaid = false; super.writeStartElement(local); }
XmlSchema addSchemaElement(SchemaTypeSystem sts, Document doc, Element elem, String file) throws URISyntaxException { doc.appendChild(elem); elem = DOMUtils.getFirstElement(elem); while (elem != null) { if (elem.getLocalName().equals("import")) { URI uri = new URI(file); String loc = elem.getAttribute("schemaLocation"); if (!StringUtils.isEmpty(loc)) { URI locUri = uri.resolve(loc); String newLoc = locUri.toString(); getSchema(sts, newLoc); } } elem = DOMUtils.getNextElement(elem); } XmlSchema schema = dataBinding.addSchemaDocument(serviceInfo, schemas, doc, file); doc.removeChild(doc.getDocumentElement()); schemaMap.put(file, schema); return schema; } protected XmlSchema getSchema(SchemaTypeSystem sts, String file) {
public void handleMessage(Message message) { BindingOperationInfo bop = message.getExchange().getBindingOperationInfo(); XMLStreamWriter xmlWriter = message.getContent(XMLStreamWriter.class); Service service = message.getExchange().getService(); if (service.getDataBinding().getDeclaredNamespaceMappings() != null) { pfx = service.getDataBinding().getDeclaredNamespaceMappings().get(name.getNamespaceURI()); pfx = StaxUtils.getUniquePrefix(xmlWriter, name.getNamespaceURI(), false); xmlWriter.setPrefix(pfx, name.getNamespaceURI()); xmlWriter.writeStartElement(pfx, name.getLocalPart(), name.getNamespaceURI()); if (StringUtils.isEmpty(pfx)) { xmlWriter.writeDefaultNamespace(name.getNamespaceURI()); } else { xmlWriter.writeNamespace(pfx, name.getNamespaceURI());
public <T> T getPort(EndpointReferenceType endpointReference, Class<T> type, WebServiceFeature... features) { endpointReference = EndpointReferenceUtils.resolve(endpointReference, bus); QName serviceQName = EndpointReferenceUtils.getServiceName(endpointReference, bus); String portName = EndpointReferenceUtils.getPortName(endpointReference); QName portQName = null; if (portName != null && serviceQName != null) { String ns = serviceQName.getNamespaceURI(); if (StringUtils.isEmpty(ns)) { //hack to workaround a xalan bug for (QName qn : portInfos.keySet()) { if (portName.equals(qn.getLocalPart())) { ns = qn.getNamespaceURI(); } } } if (StringUtils.isEmpty(ns) && serviceName != null) { ns = serviceName.getNamespaceURI(); } portQName = new QName(ns, portName); } return createPort(portQName, endpointReference, type, features); }
@Override public void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean) { String bus = element.getAttribute("bus"); factbean.getBeanDefinition()); try { if (StringUtils.isEmpty(bus)) { addBusWiringAttribute(bean, BusWiringType.CONSTRUCTOR); } else { getRequiredElementsList(element, ctx, new QName(HTTP_NETTY_SERVER_NS, "engine"), bean); if (!list.isEmpty()) { bean.addPropertyValue("enginesList", list);
private void writeMessage(Message message, QName name, boolean executeBare) { XMLStreamWriter xmlWriter = message.getContent(XMLStreamWriter.class); try { String pfx = name.getPrefix(); if (StringUtils.isEmpty(pfx)) { pfx = "ns1"; } StaxUtils.writeStartElement(xmlWriter, pfx, name.getLocalPart(), name.getNamespaceURI()); if (executeBare) { new BareOutInterceptor().handleMessage(message); } xmlWriter.writeEndElement(); } catch (XMLStreamException e) { throw new Fault(new org.apache.cxf.common.i18n.Message("STAX_WRITE_EXC", BUNDLE, e)); } } }
private QName getFaultName(WebFault wf, Class<?> cls, OperationInfo op) { String ns = wf.targetNamespace(); if (StringUtils.isEmpty(ns)) { ns = op.getName().getNamespaceURI(); } String name = wf.name(); if (StringUtils.isEmpty(name)) { name = cls.getSimpleName(); } return new QName(ns, name); }
public static List<Element> getSchemas(Server server, String id) { Message message = PhaseInterceptorChain.getCurrentMessage(); String base = (String)message.get(Message.REQUEST_URL); String ctxUri = (String)message.get(Message.PATH_INFO); WSDLGetUtils utils = new WSDLGetUtils(); EndpointInfo info = server.getEndpoint().getEndpointInfo(); Map<String, String> locs = utils.getSchemaLocations(message, base, ctxUri, info); List<Element> ret = new LinkedList<>(); for (Map.Entry<String, String> xsd : locs.entrySet()) { if (StringUtils.isEmpty(id) || id.equals(xsd.getKey())) { String query = xsd.getValue().substring(xsd.getValue().indexOf('?') + 1); Map<String, String> params = UrlUtils.parseQueryString(query); ret.add(utils.getDocument(message, base, params, ctxUri, info).getDocumentElement()); } } return ret; }
if (!soapFault.getNamespaceURI().equals(((SoapFault)ex).getFaultCode().getNamespaceURI()) && SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE .equals(((SoapFault)ex).getFaultCode().getNamespaceURI())) { if (StringUtils.isEmpty(((SoapFault)ex).getLang())) { soapFault.setFaultString(((SoapFault)ex).getReason()); } else { Node nd = soapFault.getOwnerDocument().importNode(((SoapFault)ex).getDetail(), true); nd = nd.getFirstChild(); soapFault.addDetail(); while (nd != null) { Node next = nd.getNextSibling(); soapFault.getDetail().appendChild(nd); nd = next;
protected String getFaultCodePrefix(XMLStreamWriter writer, QName faultCode) throws XMLStreamException { String codeNs = faultCode.getNamespaceURI(); String prefix = null; if (codeNs.length() > 0) { prefix = faultCode.getPrefix(); if (!StringUtils.isEmpty(prefix)) { String boundNS = writer.getNamespaceContext().getNamespaceURI(prefix); if (StringUtils.isEmpty(boundNS)) { writer.writeNamespace(prefix, codeNs); } else if (!codeNs.equals(boundNS)) { prefix = null; } } if (StringUtils.isEmpty(prefix)) { prefix = StaxUtils.getUniquePrefix(writer, codeNs, true); } } return prefix; }
private Element loadRemotePolicy(String uri, String defName) { ExtendedURIResolver resolver = new ExtendedURIResolver(); InputSource src = resolver.resolve(uri, "classpath:"); if (null == src) { return null; } XMLStreamReader reader = null; try { reader = StaxUtils.createXMLStreamReader(src); Document doc = StaxUtils.read(reader); uri = getPolicyId(doc.getDocumentElement()); if (StringUtils.isEmpty(uri)) { Attr att = doc.createAttributeNS(PolicyConstants.WSU_NAMESPACE_URI, "wsu:" + PolicyConstants.WSU_ID_ATTR_NAME); att.setNodeValue(defName); doc.getDocumentElement().setAttributeNodeNS(att); } return doc.getDocumentElement(); } catch (XMLStreamException e) { LOG.log(Level.WARNING, e.getMessage()); return null; } finally { try { StaxUtils.close(reader); } catch (XMLStreamException e) { LOG.log(Level.WARNING, e.getMessage()); } } }
if (StringUtils.isEmpty(portName)) { portName = wsAnnotations.get(x).portName(); if (StringUtils.isEmpty(namespace)) { namespace = wsAnnotations.get(x).targetNamespace(); if (StringUtils.isEmpty(name)) { name = wsAnnotations.get(x).name(); namespace = wsProviderAnnotation.targetNamespace(); if (StringUtils.isEmpty(portName) && !StringUtils.isEmpty(name)) { portName = name + "Port"; if (StringUtils.isEmpty(portName)) { portName = implementorClass.getSimpleName() + "Port"; if (StringUtils.isEmpty(namespace)) { namespace = getDefaultNamespace(implementorClass); return new QName(namespace, portName);