List of usage examples for org.w3c.dom Node getLocalName
public String getLocalName();
From source file:org.apache.hadoop.gateway.filter.rewrite.impl.xml.XmlFilterReader.java
private QName extractQName(Node node) { QName qname;/*from www. jav a 2s . c o m*/ String localName = node.getLocalName(); if (localName == null) { qname = new QName(node.getNodeName()); } else { if (node.getPrefix() == null) { qname = new QName(node.getNamespaceURI(), localName); } else { qname = new QName(node.getNamespaceURI(), localName, node.getPrefix()); } } return qname; }
From source file:org.apache.maven.wagon.providers.webdav.WebDavWagon.java
private boolean isDirectory(String url) throws IOException, DavException { DavPropertyNameSet nameSet = new DavPropertyNameSet(); nameSet.add(DavPropertyName.create(DavConstants.PROPERTY_RESOURCETYPE)); PropFindMethod method = null;/* w w w. ja v a 2 s. c o m*/ try { method = new PropFindMethod(url, nameSet, DavConstants.DEPTH_0); execute(method); if (method.succeeded()) { MultiStatus multiStatus = method.getResponseBodyAsMultiStatus(); MultiStatusResponse response = multiStatus.getResponses()[0]; DavPropertySet propertySet = response.getProperties(HttpStatus.SC_OK); DavProperty<?> property = propertySet.get(DavConstants.PROPERTY_RESOURCETYPE); if (property != null) { Node node = (Node) property.getValue(); return node.getLocalName().equals(DavConstants.XML_COLLECTION); } } return false; } finally { if (method != null) { method.releaseConnection(); } } }
From source file:org.apache.ode.axis2.soapbinding.SoapMessageConverter.java
public void createSoapHeaders(SOAPEnvelope soapEnv, List<SOAPHeader> headerDefs, Message msgdef, org.apache.ode.bpel.iapi.Message message) throws AxisFault { for (SOAPHeader sh : headerDefs) handleSoapHeaderDef(soapEnv, sh, msgdef, message); org.apache.axiom.soap.SOAPHeader soaphdr = soapEnv.getHeader(); if (soaphdr == null) soaphdr = _soapFactory.createSOAPHeader(soapEnv); for (Node headerNode : message.getHeaderParts().values()) if (headerNode.getNodeType() == Node.ELEMENT_NODE) { if (soaphdr.getFirstChildWithName( new QName(headerNode.getNamespaceURI(), headerNode.getLocalName())) == null) { OMElement omHeaderNode = OMUtils.toOM((Element) headerNode, _soapFactory); SOAPHeaderBlock hb = soaphdr.addHeaderBlock(omHeaderNode.getLocalName(), omHeaderNode.getNamespace()); // add child elements OMNode omNode = null;//from www . j a v a 2 s . c o m for (Iterator iter = omHeaderNode.getChildren(); iter.hasNext();) { omNode = (OMNode) iter.next(); hb.addChild(omNode); } OMAttribute omatribute = null; // add attributes for (Iterator iter = omHeaderNode.getAllAttributes(); iter.hasNext();) { omatribute = (OMAttribute) iter.next(); hb.addAttribute(omatribute); } } } else { throw new OdeFault(__msgs.msgSoapHeaderMustBeAnElement(headerNode)); } }
From source file:org.apache.ode.axis2.util.SoapMessageConverter.java
public void createSoapHeaders(SOAPEnvelope soapEnv, List<SOAPHeader> headerDefs, Message msgdef, Map<String, Node> headers) throws AxisFault { if (msgdef == null) return;// ww w . j av a 2 s. c o m for (SOAPHeader sh : headerDefs) handleSoapHeaderDef(soapEnv, sh, msgdef, headers); org.apache.axiom.soap.SOAPHeader soaphdr = soapEnv.getHeader(); if (soaphdr == null) soaphdr = _soapFactory.createSOAPHeader(soapEnv); for (Node headerNode : headers.values()) if (headerNode.getNodeType() == Node.ELEMENT_NODE) { if (soaphdr.getFirstChildWithName( new QName(headerNode.getNamespaceURI(), headerNode.getLocalName())) == null) soaphdr.addChild(OMUtils.toOM((Element) headerNode, _soapFactory)); } else { throw new OdeFault(__msgs.msgSoapHeaderMustBeAnElement(headerNode)); } }
From source file:org.apache.ode.bpel.elang.xpath20.runtime.XPath20ExpressionRuntime.java
private Object evaluate(OExpression cexp, EvaluationContext ctx, QName type) throws FaultException, EvaluationException { try {//from w ww . j av a2 s .c o m OXPath20ExpressionBPEL20 oxpath20 = ((OXPath20ExpressionBPEL20) cexp); JaxpFunctionResolver funcResolver = new JaxpFunctionResolver(ctx, oxpath20); JaxpVariableResolver varResolver = new JaxpVariableResolver(ctx, oxpath20, ((XPathFactoryImpl) _xpf).getConfiguration()); XPath xpe = _xpf.newXPath(); xpe.setXPathFunctionResolver(funcResolver); xpe.setXPathVariableResolver(varResolver); xpe.setNamespaceContext(oxpath20.namespaceCtx); String xpath = ((OXPath10Expression) cexp).xpath; XPathExpression expr = xpe.compile(xpath); Node contextNode = ctx.getRootNode(); if (contextNode == null) { contextNode = DOMUtils.newDocument(); } // Create step nodes in XPath in case it is incompletely instantiated if (oxpath20.insertMissingData) { XPath20ExpressionModifier modifier = new XPath20ExpressionModifier(oxpath20.namespaceCtx, ((XPathFactoryImpl) _xpf).getConfiguration().getNamePool()); Node temp = ctx.getRootNode(); if (temp.getLocalName().equals("message") && temp.getNamespaceURI() == null) { int startind = xpath.indexOf('.'); int endind = xpath.indexOf('/'); if (startind != -1) { String part = null; if (endind != -1) { part = xpath.substring(startind + 1, endind); } else { part = xpath.substring(startind + 1); } Element partElem = DOMUtils.findChildByName((Element) temp, new QName(null, part)); if (partElem != null && partElem.getFirstChild() != null) { temp = partElem.getFirstChild(); } } } modifier.insertMissingData(expr, temp); } Object evalResult = expr.evaluate(contextNode, type); if (evalResult != null && __log.isDebugEnabled()) { __log.debug("Expression " + cexp.toString() + " generated result " + evalResult + " - type=" + evalResult.getClass().getName()); if (ctx.getRootNode() != null) __log.debug("Was using context node " + DOMUtils.domToString(ctx.getRootNode())); } return evalResult; } catch (XPathExpressionException e) { // Extracting the real cause from all this wrapping isn't a simple task Throwable cause = e.getCause() != null ? e.getCause() : e; if (cause instanceof XPathException) { Throwable th = ((XPathException) cause).getException(); if (th != null) { cause = th; if (cause.getCause() != null) cause = cause.getCause(); } } throw new EvaluationException("Error while executing an XPath expression: " + cause.toString(), cause); } catch (WrappedResolverException wre) { __log.debug("Could not evaluate expression because of ", wre); throw (FaultException) wre.getCause(); } catch (Throwable t) { __log.debug("Could not evaluate expression because of ", t); throw new EvaluationException("Error while executing an XPath expression: ", t); } }
From source file:org.apache.ode.bpel.engine.BpelRuntimeContextImpl.java
public Node convertEndpointReference(Element sourceNode, Node targetNode) { QName nodeQName;/*from ww w. ja v a2s. co m*/ if (targetNode.getNodeType() == Node.TEXT_NODE) { nodeQName = new QName(Namespaces.XML_SCHEMA, "string"); } else { // We have an element nodeQName = new QName(targetNode.getNamespaceURI(), targetNode.getLocalName()); } return _bpelProcess._engine._contexts.eprContext.convertEndpoint(nodeQName, sourceNode).toXML(); }
From source file:org.apache.ode.bpel.extvar.jdbc.DbExternalVariable.java
<T extends RowSubset> T parseXmlRow(T ret, Node rowel) throws ExternalVariableModuleException { if (rowel == null) return ret; NodeList nl = rowel.getChildNodes(); if (__log.isDebugEnabled()) __log.debug("parseXmlRow: element=" + rowel.getLocalName()); for (int i = 0; i < nl.getLength(); ++i) { Node n = nl.item(i);/*from www . j a v a 2 s. co m*/ if (n.getNodeType() != Node.ELEMENT_NODE) continue; String key = n.getLocalName(); String val = n.getTextContent(); if (__log.isDebugEnabled()) __log.debug("Extvar key: " + key + " value: " + val); Column column = ret.getColumn(key); if (column == null) { if (__log.isDebugEnabled()) __log.debug("No matching column for key '" + key + "'"); continue; } String nil = ((Element) n).getAttributeNS(XSI_NS, "nil"); if (nil != null && "true".equalsIgnoreCase(nil) && (val == null || val.trim().length() == 0)) { if (__log.isDebugEnabled()) __log.debug("Extvar key: " + key + " is null (xsi:nil)"); ret.put(key, null); } else { ret.put(key, column.fromText(val)); } } return ret; }
From source file:org.apache.ode.bpel.rtrep.v1.ASSIGN.java
private void replaceEndpointRefence(PartnerLinkInstance plval, Node rvalue) throws FaultException { // Eventually wrapping with service-ref element if we've been directly assigned some // value that isn't wrapped. if (rvalue.getNodeType() == Node.TEXT_NODE || (rvalue.getNodeType() == Node.ELEMENT_NODE && !rvalue.getLocalName().equals("service-ref"))) { Document doc = DOMUtils.newDocument(); Element serviceRef = doc.createElementNS(Namespaces.WSBPEL2_0_FINAL_SERVREF, "service-ref"); doc.appendChild(serviceRef);/*from w w w. j ava 2 s . c om*/ if (rvalue.getNodeType() == Node.TEXT_NODE) { serviceRef.appendChild(doc.importNode(rvalue, true)); } else { NodeList children = rvalue.getChildNodes(); for (int m = 0; m < children.getLength(); m++) { Node child = children.item(m); serviceRef.appendChild(doc.importNode(child, true)); } } rvalue = serviceRef; } getBpelRuntime().writeEndpointReference(plval, (Element) rvalue); }
From source file:org.apache.ode.bpel.rtrep.v2.ASSIGN.java
private void replaceEndpointRefence(PartnerLinkInstance plval, Node rvalue) throws FaultException { if (rvalue.getNodeType() == Node.ATTRIBUTE_NODE) throw new FaultException(getOAsssign().getOwner().constants.qnMismatchedAssignmentFailure, "Can't assign an attribute to an endpoint, you probably want to select the attribute text."); // Eventually wrapping with service-ref element if we've been directly assigned some // value that isn't wrapped. if (rvalue.getNodeType() == Node.TEXT_NODE || (rvalue.getNodeType() == Node.ELEMENT_NODE && !rvalue.getLocalName().equals("service-ref"))) { Document doc = DOMUtils.newDocument(); Element serviceRef = doc.createElementNS(Namespaces.WSBPEL2_0_FINAL_SERVREF, "service-ref"); doc.appendChild(serviceRef);/*from www. ja v a 2 s . c o m*/ NodeList children = rvalue.getChildNodes(); for (int m = 0; m < children.getLength(); m++) { Node child = children.item(m); serviceRef.appendChild(doc.importNode(child, true)); } rvalue = serviceRef; } getBpelRuntime().writeEndpointReference(plval, (Element) rvalue); }
From source file:org.apache.ode.bpel.rtrep.v2.xpath20.XPath20ExpressionRuntime.java
private Object evaluate(OExpression cexp, EvaluationContext ctx, QName type) throws FaultException { try {/*from w ww . j a v a 2 s . c o m*/ OXPath20ExpressionBPEL20 oxpath20 = ((OXPath20ExpressionBPEL20) cexp); System.setProperty("javax.xml.xpath.XPathFactory:" + NamespaceConstant.OBJECT_MODEL_SAXON, "net.sf.saxon.xpath.XPathFactoryImpl"); // JAXP based XPath 1.0 runtime does not work anymore after a XPath 2.0 has been evaluated if this is set. // System.setProperty("javax.xml.xpath.XPathFactory:"+XPathConstants.DOM_OBJECT_MODEL, // "net.sf.saxon.xpath.XPathFactoryImpl"); System.setProperty("javax.xml.xpath.XPathFactory:" + NamespaceConstant.OBJECT_MODEL_JDOM, "net.sf.saxon.xpath.XPathFactoryImpl"); System.setProperty("javax.xml.xpath.XPathFactory:" + NamespaceConstant.OBJECT_MODEL_XOM, "net.sf.saxon.xpath.XPathFactoryImpl"); System.setProperty("javax.xml.xpath.XPathFactory:" + NamespaceConstant.OBJECT_MODEL_DOM4J, "net.sf.saxon.xpath.XPathFactoryImpl"); XPathFactory xpf = XPathFactory.newInstance(NamespaceConstant.OBJECT_MODEL_SAXON); JaxpFunctionResolver funcResolver = new JaxpFunctionResolver(ctx, oxpath20); JaxpVariableResolver varResolver = new JaxpVariableResolver(ctx, oxpath20, ((XPathFactoryImpl) xpf).getConfiguration()); xpf.setXPathFunctionResolver(funcResolver); xpf.setXPathVariableResolver(varResolver); XPath xpe = xpf.newXPath(); xpe.setNamespaceContext(oxpath20.namespaceCtx); XPathExpression expr = xpe.compile(((OXPath10Expression) cexp).xpath); Node contextNode = ctx.getRootNode() == null ? DOMUtils.newDocument() : ctx.getRootNode(); // Create step nodes in XPath in case it is incompletely instantiated if (oxpath20.insertMissingData) { XPath20ExpressionModifier modifier = new XPath20ExpressionModifier(oxpath20.namespaceCtx, ((XPathFactoryImpl) xpf).getConfiguration().getNamePool()); Node temp = ctx.getRootNode(); if (temp.getLocalName().equals("message") && temp.getNamespaceURI() == null && temp.getFirstChild() != null && temp.getFirstChild().getFirstChild() != null) { modifier.insertMissingData(expr, temp.getFirstChild().getFirstChild()); } else { modifier.insertMissingData(expr, temp); } } Object evalResult = expr.evaluate(contextNode, type); if (evalResult != null && __log.isDebugEnabled()) { __log.debug("Expression " + cexp.toString() + " generated result " + evalResult + " - type=" + evalResult.getClass().getName()); if (ctx.getRootNode() != null) __log.debug("Was using context node " + DOMUtils.domToString(ctx.getRootNode())); } return evalResult; } catch (XPathExpressionException e) { // Extracting the real cause from all this wrapping isn't a simple task Throwable cause = e.getCause() != null ? e.getCause() : e; if (cause instanceof DynamicError) { Throwable th = ((DynamicError) cause).getException(); if (th != null) { cause = th; if (cause.getCause() != null) cause = cause.getCause(); } } throw new FaultException(cexp.getOwner().constants.qnSubLanguageExecutionFault, cause.getMessage(), cause); } catch (WrappedFaultException wre) { __log.debug("Could not evaluate expression because of ", wre); throw (FaultException) wre.getCause(); } catch (Throwable t) { __log.debug("Could not evaluate expression because of ", t); throw new FaultException(cexp.getOwner().constants.qnSubLanguageExecutionFault, t.getMessage(), t); } }