List of usage examples for org.w3c.dom Element getNamespaceURI
public String getNamespaceURI();
null
if it is unspecified (see ). From source file:org.apache.ode.axis2.httpbinding.HttpMethodConverter.java
public Object[] parseFault(PartnerRoleMessageExchange odeMex, HttpMethod method) { Operation opDef = odeMex.getOperation(); BindingOperation opBinding = binding.getBindingOperation(opDef.getName(), opDef.getInput().getName(), opDef.getOutput().getName()); final String body; try {/*from ww w. ja v a2s . c o m*/ body = method.getResponseBodyAsString(); } catch (IOException e) { throw new RuntimeException("Unable to get the request body : " + e.getMessage(), e); } Header h = method.getResponseHeader("Content-Type"); String receivedType = h != null ? h.getValue() : null; if (opDef.getFaults().isEmpty()) { throw new RuntimeException("Operation [" + opDef.getName() + "] has no fault. This " + method.getStatusCode() + " error will be considered as a failure."); } else if (opBinding.getBindingFaults().isEmpty()) { throw new RuntimeException( "No fault binding. This " + method.getStatusCode() + " error will be considered as a failure."); } else if (StringUtils.isEmpty(body)) { throw new RuntimeException("No body in the response. This " + method.getStatusCode() + " error will be considered as a failure."); } else if (receivedType != null && !HttpUtils.isXml(receivedType)) { throw new RuntimeException("Response Content-Type [" + receivedType + "] does not describe XML entities. Faults must be XML. This " + method.getStatusCode() + " error will be considered as a failure."); } else { if (receivedType == null) { if (log.isWarnEnabled()) log.warn("[Service: " + serviceName + ", Port: " + portName + ", Operation: " + opDef.getName() + "] Received Response with a body but no 'Content-Type' header! Will try to parse nevertheless."); } // try to parse body final Element bodyElement; try { bodyElement = DOMUtils.stringToDOM(body); } catch (Exception e) { throw new RuntimeException("Unable to parse the response body as xml. This " + method.getStatusCode() + " error will be considered as a failure.", e); } // Guess which fault it is QName bodyName = new QName(bodyElement.getNamespaceURI(), bodyElement.getNodeName()); Fault faultDef = WsdlUtils.inferFault(opDef, bodyName); if (faultDef == null) { throw new RuntimeException("Unknown Fault Type [" + bodyName + "] This " + method.getStatusCode() + " error will be considered as a failure."); } else if (!WsdlUtils.isOdeFault(opBinding.getBindingFault(faultDef.getName()))) { // is this fault bound with ODE extension? throw new RuntimeException("Fault [" + bodyName + "] is not bound with " + new QName(Namespaces.ODE_HTTP_EXTENSION_NS, "fault") + ". This " + method.getStatusCode() + " error will be considered as a failure."); } else { // a fault has only one part Part partDef = (Part) faultDef.getMessage().getParts().values().iterator().next(); QName faultName = new QName(definition.getTargetNamespace(), faultDef.getName()); QName faultType = faultDef.getMessage().getQName(); // create the ODE Message now that we know the fault org.apache.ode.bpel.iapi.Message response = odeMex.createMessage(faultType); // build the element to be sent back Element partElement = createPartElement(partDef, bodyElement); response.setPart(partDef.getName(), partElement); // extract and set headers extractHttpResponseHeaders(response, method, opDef); return new Object[] { faultName, response }; } } }
From source file:org.apache.ode.axis2.ODEService.java
/** * Create-and-copy a service-ref element. * * @param elmt/*from w ww .j a v a2s.c o m*/ * @return wrapped element */ public static MutableEndpoint createServiceRef(Element elmt) { Document doc = DOMUtils.newDocument(); QName elQName = new QName(elmt.getNamespaceURI(), elmt.getLocalName()); // If we get a service-ref, just copy it, otherwise make a service-ref // wrapper if (!EndpointReference.SERVICE_REF_QNAME.equals(elQName)) { Element serviceref = doc.createElementNS(EndpointReference.SERVICE_REF_QNAME.getNamespaceURI(), EndpointReference.SERVICE_REF_QNAME.getLocalPart()); serviceref.appendChild(doc.importNode(elmt, true)); doc.appendChild(serviceref); } else { doc.appendChild(doc.importNode(elmt, true)); } return EndpointFactory.createEndpoint(doc.getDocumentElement()); }
From source file:org.apache.ode.bpel.compiler.bom.BpelObjectFactory.java
public BpelObject createBpelObject(Element el, URI uri) { QName type = new QName(el.getNamespaceURI(), el.getLocalName()); Class cls = _mappings.get(type); if (cls == null) { __log.warn("Unrecognized element in BPEL dom: " + type); return new BpelObject(el); }/*from w w w .j a v a 2s . c o m*/ try { Constructor ctor = cls.getConstructor(__CTOR); BpelObject bo = (BpelObject) ctor.newInstance(new Object[] { el }); bo.setURI(uri); return bo; } catch (Exception ex) { throw new RuntimeException("Internal compiler error", ex); } }
From source file:org.apache.ode.bpel.compiler.v2.AssignGenerator.java
public void compile(OActivity dest, Activity source) { OAssign oassign = (OAssign) dest;// ww w .j a v a 2 s .co m AssignActivity ad = (AssignActivity) source; for (AssignOperation operation : ad.getOperations()) { if (operation instanceof Copy) { Copy scopy = (Copy) operation; OAssign.Copy ocopy = new OAssign.Copy(_context.getOProcess()); ocopy.keepSrcElementName = scopy.isKeepSrcElement(); ocopy.ignoreMissingFromData = scopy.isIgnoreMissingFromData(); ocopy.insertMissingToData = scopy.isInsertMissingToData(); ocopy.ignoreUninitializedFromVariable = scopy.isIgnoreUninitializedFromVariable(); ocopy.debugInfo = new DebugInfo(_context.getSourceLocation(), scopy.getLineNo(), source.getExtensibilityElements()); try { if (scopy.getFrom() == null) throw new CompilationException(__cmsgs.errMissingFromSpec().setSource(scopy)); ocopy.from = compileFrom(scopy.getFrom()); if (scopy.getTo() == null) throw new CompilationException(__cmsgs.errMissingToSpec().setSource(scopy)); ocopy.to = compileTo(scopy.getTo()); verifyCopy(ocopy); oassign.operations.add(ocopy); } catch (CompilationException ce) { _context.recoveredFromError(scopy, ce); } } else if (operation instanceof ExtensionAssignOperation) { ExtensionAssignOperation sop = (ExtensionAssignOperation) operation; OAssign.ExtensionAssignOperation oext = new OAssign.ExtensionAssignOperation( _context.getOProcess()); oext.debugInfo = new DebugInfo(_context.getSourceLocation(), sop.getLineNo(), source.getExtensibilityElements()); try { if (source.is20Draft()) { throw new CompilationException(__cmsgs.errExtensibleAssignNotSupported()); } Element el = sop.getNestedElement(); if (el == null) { throw new CompilationException( __cmsgs.errMissingExtensionAssignOperationElement().setSource(sop)); } if (!_context.isExtensionDeclared(el.getNamespaceURI())) { throw new CompilationException( __cmsgs.errUndeclaredExtensionAssignOperation().setSource(sop)); } ExtensionValidator validator = _context.getExtensionValidator(DOMUtils.getElementQName(el)); if (validator != null) { validator.validate(_context, sop); } oext.extensionName = DOMUtils.getElementQName(el); oext.nestedElement = new SerializableElement(el); oassign.operations.add(oext); } catch (CompilationException ce) { _context.recoveredFromError(sop, ce); } } } }
From source file:org.apache.ode.bpel.epr.WSAEndpoint.java
public boolean accept(Node node) { if (node.getNodeType() == Node.ELEMENT_NODE) { Element elmt = (Element) node; if (elmt.getLocalName().equals(SERVICE_REF_QNAME.getLocalPart()) && elmt.getNamespaceURI().equals(SERVICE_REF_QNAME.getNamespaceURI())) elmt = DOMUtils.getFirstChildElement(elmt); if (elmt != null && elmt.getLocalName().equals("EndpointReference") && elmt.getNamespaceURI().equals(Namespaces.WS_ADDRESSING_NS)) return true; }// w w w . j a v a2 s .c om return false; }
From source file:org.apache.ode.bpel.rtrep.v1.ASSIGN.java
private Element replaceElement(Element lval, Element ptr, Element src, boolean keepSrcElement) { Document doc = ptr.getOwnerDocument(); Node parent = ptr.getParentNode(); if (keepSrcElement) { Element replacement = (Element) doc.importNode(src, true); parent.replaceChild(replacement, ptr); return (lval == ptr) ? replacement : lval; }//from ww w . j a v a2s . c o m Element replacement = doc.createElementNS(ptr.getNamespaceURI(), ptr.getLocalName()); NodeList nl = src.getChildNodes(); for (int i = 0; i < nl.getLength(); ++i) replacement.appendChild(doc.importNode(nl.item(i), true)); NamedNodeMap attrs = src.getAttributes(); for (int i = 0; i < attrs.getLength(); ++i) { Attr attr = (Attr) attrs.item(i); if (!attr.getName().startsWith("xmlns")) { replacement.setAttributeNodeNS((Attr) doc.importNode(attrs.item(i), true)); // Case of qualified attribute values, we're forced to add corresponding namespace declaration manually int colonIdx = attr.getValue().indexOf(":"); if (colonIdx > 0) { String prefix = attr.getValue().substring(0, colonIdx); String attrValNs = src.lookupPrefix(prefix); if (attrValNs != null) replacement.setAttributeNS(DOMUtils.NS_URI_XMLNS, "xmlns:" + prefix, attrValNs); } } } parent.replaceChild(replacement, ptr); DOMUtils.copyNSContext(ptr, replacement); return (lval == ptr) ? replacement : lval; }
From source file:org.apache.ode.bpel.rtrep.v2.ASSIGN.java
private Element replaceElement(Element lval, Element ptr, Element src, boolean keepSrcElement) { Document doc = ptr.getOwnerDocument(); Node parent = ptr.getParentNode(); if (keepSrcElement) { Element replacement = (Element) doc.importNode(src, true); parent.replaceChild(replacement, ptr); return (lval == ptr) ? replacement : lval; }/*from ww w .j av a2 s . c o m*/ Element replacement = doc.createElementNS(ptr.getNamespaceURI(), ptr.getLocalName()); if (ptr.getPrefix() != null) { replacement.setPrefix(ptr.getPrefix()); } NodeList nl = src.getChildNodes(); for (int i = 0; i < nl.getLength(); ++i) replacement.appendChild(doc.importNode(nl.item(i), true)); NamedNodeMap attrs = src.getAttributes(); for (int i = 0; i < attrs.getLength(); ++i) { Attr attr = (Attr) attrs.item(i); if (!attr.getName().startsWith("xmlns")) { replacement.setAttributeNodeNS((Attr) doc.importNode(attrs.item(i), true)); // Case of qualified attribute values, we're forced to add corresponding namespace declaration manually int colonIdx = attr.getValue().indexOf(":"); if (colonIdx > 0) { String prefix = attr.getValue().substring(0, colonIdx); String attrValNs = src.lookupPrefix(prefix); if (attrValNs != null) replacement.setAttributeNS(DOMUtils.NS_URI_XMLNS, "xmlns:" + prefix, attrValNs); } } } parent.replaceChild(replacement, ptr); DOMUtils.copyNSContext(ptr, replacement); return (lval == ptr) ? replacement : lval; }
From source file:org.apache.ode.bpel.rtrep.v2.AssignHelper.java
/** * madars.vitolins _at gmail.com - 2009.04.17 - moved from ASSIGN here *//*from www . j a v a2s. c o m*/ public Element replaceElement(Element lval, Element ptr, Element src, boolean keepSrcElement) { Document doc = ptr.getOwnerDocument(); Node parent = ptr.getParentNode(); if (keepSrcElement) { Element replacement = (Element) doc.importNode(src, true); parent.replaceChild(replacement, ptr); return (lval == ptr) ? replacement : lval; } Element replacement = doc.createElementNS(ptr.getNamespaceURI(), ptr.getLocalName()); NodeList nl = src.getChildNodes(); for (int i = 0; i < nl.getLength(); ++i) replacement.appendChild(doc.importNode(nl.item(i), true)); NamedNodeMap attrs = src.getAttributes(); for (int i = 0; i < attrs.getLength(); ++i) { Attr attr = (Attr) attrs.item(i); if (!attr.getName().startsWith("xmlns")) { replacement.setAttributeNodeNS((Attr) doc.importNode(attrs.item(i), true)); // Case of qualified attribute values, we're forced to add corresponding namespace declaration manually int colonIdx = attr.getValue().indexOf(":"); if (colonIdx > 0) { String prefix = attr.getValue().substring(0, colonIdx); String attrValNs = src.lookupPrefix(prefix); if (attrValNs != null) replacement.setAttributeNS(DOMUtils.NS_URI_XMLNS, "xmlns:" + prefix, attrValNs); } } } parent.replaceChild(replacement, ptr); DOMUtils.copyNSContext(ptr, replacement); return (lval == ptr) ? replacement : lval; }
From source file:org.apache.ode.bpel.runtime.ASSIGN.java
private Element replaceElement(Element lval, Element ptr, Element src, boolean keepSrcElement) { Document doc = ptr.getOwnerDocument(); Node parent = ptr.getParentNode(); if (keepSrcElement) { Element replacement = (Element) doc.importNode(src, true); parent.replaceChild(replacement, ptr); return (lval == ptr) ? replacement : lval; }/*from w w w . j a va 2 s .c o m*/ Element replacement = doc.createElementNS(ptr.getNamespaceURI(), ptr.getTagName()); NodeList nl = src.getChildNodes(); for (int i = 0; i < nl.getLength(); ++i) replacement.appendChild(doc.importNode(nl.item(i), true)); copyAttributes(doc, ptr, replacement); copyAttributes(doc, src, replacement); parent.replaceChild(replacement, ptr); DOMUtils.copyNSContext(ptr, replacement); return (lval == ptr) ? replacement : lval; }
From source file:org.apache.ode.bpel.runtime.AssignHelper.java
private Element replaceElement(Element lval, Element ptr, Element src, boolean keepSrcElement) { Document doc = ptr.getOwnerDocument(); Node parent = ptr.getParentNode(); if (keepSrcElement) { Element replacement = (Element) doc.importNode(src, true); parent.replaceChild(replacement, ptr); return (lval == ptr) ? replacement : lval; }// w w w . j av a 2s . c o m Element replacement = doc.createElementNS(ptr.getNamespaceURI(), ptr.getTagName()); NodeList nl = src.getChildNodes(); for (int i = 0; i < nl.getLength(); ++i) replacement.appendChild(doc.importNode(nl.item(i), true)); NamedNodeMap attrs = src.getAttributes(); for (int i = 0; i < attrs.getLength(); ++i) { Attr attr = (Attr) attrs.item(i); if (!attr.getName().startsWith("xmlns")) { replacement.setAttributeNodeNS((Attr) doc.importNode(attrs.item(i), true)); // Case of qualified attribute values, we're forced to add corresponding namespace declaration manually int colonIdx = attr.getValue().indexOf(":"); if (colonIdx > 0) { String prefix = attr.getValue().substring(0, colonIdx); String attrValNs = src.lookupPrefix(prefix); if (attrValNs != null) replacement.setAttributeNS(DOMUtils.NS_URI_XMLNS, "xmlns:" + prefix, attrValNs); } } } parent.replaceChild(replacement, ptr); DOMUtils.copyNSContext(ptr, replacement); return (lval == ptr) ? replacement : lval; }