Example usage for javax.xml.namespace QName equals

List of usage examples for javax.xml.namespace QName equals

Introduction

In this page you can find the example usage for javax.xml.namespace QName equals.

Prototype

public final boolean equals(Object objectToTest) 

Source Link

Document

Test this QName for equality with another Object.

If the Object to be tested is not a QName or is null, then this method returns false.

Two QNames are considered equal if and only if both the Namespace URI and local part are equal.

Usage

From source file:org.apache.ode.bpel.elang.xpath10.runtime.JaxenContexts.java

/**
 * @see org.jaxen.FunctionContext#getFunction(java.lang.String,
 *      java.lang.String, java.lang.String)
 *//*from w  ww  . j a va  2 s .  c  o  m*/
public Function getFunction(String namespaceURI, String prefix, String localName) throws UnresolvableException {
    if (__log.isDebugEnabled()) {
        __log.debug("getFunction(" + namespaceURI + "," + prefix + "," + localName);
    }

    if ((namespaceURI != null)) {
        QName fnQName = new QName(namespaceURI, localName);

        if (fnQName.equals(_oxpath.qname_getVariableProperty))
            return _getVariableProperty;
        if (fnQName.equals(_oxpath.qname_getVariableData))
            return _getVariableData;
        if (fnQName.equals(_oxpath.qname_getLinkStatus))
            return _getLinkStatus;
        if (_oxpath instanceof OXPath10ExpressionBPEL20) {
            OXPath10ExpressionBPEL20 oxpath20 = (OXPath10ExpressionBPEL20) _oxpath;
            if (fnQName.equals(oxpath20.qname_doXslTransform)) {
                return _doXslTransform;
            }
        }
        Function f = (Function) _extensionFunctions.get(localName);

        if (f != null) {
            return f;
        }
    }

    // Defer to the default XPath context.
    return __defaultXPathFunctions.getFunction(null, prefix, localName);
}

From source file:org.apache.ode.bpel.engine.BpelProcess.java

public ReplacementMap getReplacementMap(QName processName) {
    try {/*from ww w .ja  v a 2  s.  c om*/
        _hydrationLatch.latch(1);

        if (processName.equals(_pid))
            return _replacementMap;
        else
            try {
                // We're asked for an older version of this process, fetching it
                OProcess oprocess = _engine.getOProcess(processName);
                if (oprocess == null) {
                    String errmsg = "The process " + _pid + " is not available anymore.";
                    __log.error(errmsg);
                    throw new InvalidProcessException(errmsg, InvalidProcessException.RETIRED_CAUSE_CODE);
                }
                // Older versions may ventually need more expression languages
                registerExprLang(oprocess);

                return new ReplacementMapImpl(oprocess);
            } catch (Exception e) {
                String errmsg = "The process " + _pid + " is not available anymore.";
                __log.error(errmsg, e);
                throw new InvalidProcessException(errmsg, InvalidProcessException.RETIRED_CAUSE_CODE);
            }
    } finally {
        _hydrationLatch.release(1);
    }
}

From source file:org.apache.ode.bpel.epr.EndpointFactory.java

/**
 * Convert an EPR element into another EPR using the provided target type.
 * The target type is actually the qualified name of the root element for
 * the target EPR (i.e wsa:MutableEndpoint, wsdl:service) or null to convert
 * to a simple URL.// www .j a  v a  2s  . c o m
 *
 * @param targetElmtType
 *            QName to convert to
 * @param sourceEndpoint
 * @return the converted MutableEndpoint
 */
public static MutableEndpoint convert(QName targetElmtType, Element sourceEndpoint) {
    MutableEndpoint targetEpr;
    MutableEndpoint sourceEpr = EndpointFactory.createEndpoint(sourceEndpoint);
    Map transfoMap = sourceEpr.toMap();
    if (targetElmtType == null) {
        targetEpr = new URLEndpoint();
    } else if (targetElmtType.equals(EndpointFactory.WSDL20_ELMT_QNAME)) {
        targetEpr = new WSDL20Endpoint();
    } else if (targetElmtType.equals(EndpointFactory.WSDL11_ELMT_QNAME)) {
        targetEpr = new WSDL11Endpoint();
    } else if (targetElmtType.equals(EndpointFactory.WSA_ELMT_QNAME)) {
        targetEpr = new WSAEndpoint();
    } else if (targetElmtType.equals(EndpointFactory.SOAP_ADDR_ELMT_QNAME)) {
        targetEpr = new URLEndpoint();
    } else {
        // When everything fails, shooting for the most simple EPR format
        targetEpr = new URLEndpoint();
    }

    targetEpr.fromMap(transfoMap);
    if (__log.isDebugEnabled()) {
        __log.debug("Converted endpoint to type " + targetElmtType);
        __log.debug("Source endpoint " + DOMUtils.domToString(sourceEndpoint));
        __log.debug("Destination endpoint " + DOMUtils.domToString(targetEpr.toXML()));
    }
    return targetEpr;
}

From source file:org.apache.ode.bpel.rtrep.v1.PICK.java

@SuppressWarnings("unchecked")
private void initVariable(String mexId, OPickReceive.OnMessage onMessage) {
    // This is allowed, if there is no parts in the message for example.
    if (onMessage.variable == null)
        return;//from w w  w  . j a v a2 s.  co  m

    Element msgEl;
    try {
        // At this point, not being able to get the request is most probably
        // a mex that hasn't properly replied to (process issue).
        msgEl = getBpelRuntime().getMyRequest(mexId);
    } catch (BpelEngineException e) {
        __log.error("The message exchange seems to be in an unconsistent state, you're "
                + "probably missing a reply on a request/response interaction.");
        _self.parent.failure(e.toString(), null);
        return;
    }

    Collection<String> partNames = (Collection<String>) onMessage.operation.getInput().getMessage().getParts()
            .keySet();

    // Let's do some sanity checks here so that we don't get weird errors in assignment later.
    // The engine should have checked to make sure that the messages that are  delivered conform 
    // to the correct format; but you know what they say, don't trust anyone.  
    if (!(onMessage.variable.type instanceof OMessageVarType)) {
        String errmsg = "Non-message variable for receive: should have been picked up by static analysis.";
        __log.fatal(errmsg);
        throw new InvalidProcessException(errmsg);
    }

    OMessageVarType vartype = (OMessageVarType) onMessage.variable.type;

    // Check that each part contains what we expect. 
    for (String pName : partNames) {
        QName partName = new QName(null, pName);
        Element msgPart = DOMUtils.findChildByName(msgEl, partName);
        Part part = vartype.parts.get(pName);
        if (part == null) {
            String errmsg = "Inconsistent WSDL, part " + pName + " not found in message type "
                    + vartype.messageType;
            __log.fatal(errmsg);
            throw new InvalidProcessException(errmsg);
        }
        if (msgPart == null) {
            String errmsg = "Message missing part: " + pName;
            __log.fatal(errmsg);
            throw new InvalidContextException(errmsg);
        }

        if (part.type instanceof OElementVarType) {
            OElementVarType ptype = (OElementVarType) part.type;
            Element e = DOMUtils.getFirstChildElement(msgPart);
            if (e == null) {
                String errmsg = "Message (element) part " + pName + " did not contain child element.";
                __log.fatal(errmsg);
                throw new InvalidContextException(errmsg);
            }

            QName qn = new QName(e.getNamespaceURI(), e.getLocalName());
            if (!qn.equals(ptype.elementType)) {
                String errmsg = "Message (element) part " + pName
                        + " did not contain correct child element: expected " + ptype.elementType + " but got "
                        + qn;
                __log.fatal(errmsg);
                throw new InvalidContextException(errmsg);
            }
        }

    }

    VariableInstance vinst = _scopeFrame.resolve(onMessage.variable);

    try {
        initializeVariable(vinst, msgEl);
    } catch (ExternalVariableModuleException e) {
        __log.error("Exception while initializing external variable", e);
        _self.parent.failure(e.toString(), null);
        return;
    }

    // Generating event
    VariableModificationEvent se = new VariableModificationEvent(vinst.declaration.name);
    se.setNewValue(msgEl);
    if (_opick.debugInfo != null)
        se.setLineNo(_opick.debugInfo.startLine);
    sendEvent(se);
}

From source file:org.apache.ode.bpel.rtrep.v1.SCOPE.java

private static OCatch findCatch(OFaultHandler fh, QName faultName, OVarType faultType) {
    OCatch bestMatch = null;//from  ww  w .j a  v a  2 s  .c o m
    for (OCatch c : fh.catchBlocks) {
        // First we try to eliminate this catch block based on fault-name mismatches:
        if (c.faultName != null) {
            if (faultName == null)
                continue;
            if (!faultName.equals(c.faultName))
                continue;
        }

        // Then we try to eliminate this catch based on type incompatibility:
        if (c.faultVariable != null) {
            if (faultType == null)
                continue;
            else if (c.faultVariable.type instanceof OMessageVarType) {
                if (faultType instanceof OMessageVarType
                        && ((OMessageVarType) faultType).equals(c.faultVariable.type)) {
                    // Don't eliminate.
                } else if (faultType instanceof OElementVarType
                        && ((OMessageVarType) c.faultVariable.type).docLitType != null
                        && !((OMessageVarType) c.faultVariable.type).docLitType.equals(faultType)) {
                    // Don't eliminate.
                } else {
                    continue; // Eliminate.
                }
            } else if (c.faultVariable.type instanceof OElementVarType) {
                if (faultType instanceof OElementVarType && faultType.equals(c.faultVariable.type)) {
                    // Don't eliminate
                } else if (faultType instanceof OMessageVarType
                        && ((OMessageVarType) faultType).docLitType != null
                        && ((OMessageVarType) faultType).docLitType.equals(c.faultVariable.type)) {
                    // Don't eliminate
                } else {
                    continue; // eliminate
                }
            } else {
                continue; // Eliminate
            }
        }

        // If we got to this point we did not eliminate this catch block. However, we don't just
        // use the first non-eliminated catch, we instead try to find the best match.
        if (bestMatch == null) {
            // Obviously something is better then nothing.
            bestMatch = c;
        } else {
            // Otherwise we prefer name and variable matches but prefer name-only matches to
            // variable-only matches. 
            int existingScore = (bestMatch.faultName == null ? 0 : 2)
                    + (bestMatch.faultVariable == null ? 0 : 1);
            int currentScore = (c.faultName == null ? 0 : 2) + (c.faultVariable == null ? 0 : 1);
            if (currentScore > existingScore) {
                bestMatch = c;
            }
        }
    }
    return bestMatch;
}

From source file:org.apache.ode.bpel.rtrep.v2.PICK.java

@SuppressWarnings("unchecked")
private void initVariable(String mexId, OPickReceive.OnMessage onMessage) {
    // This is allowed, if there is no parts in the message for example.
    if (onMessage.variable == null)
        return;/*from w w w.j a v a  2s  .co m*/

    Element msgEl;
    try {
        // At this point, not being able to get the request is most probably
        // a mex that hasn't properly replied to (process issue).
        msgEl = getBpelRuntime().getMyRequest(mexId);
    } catch (BpelEngineException e) {
        __log.error("The message exchange seems to be in an unconsistent state, you're "
                + "probably missing a reply on a request/response interaction.");
        _self.parent.failure(e.toString(), null);
        return;
    }

    Collection<String> partNames = (Collection<String>) onMessage.operation.getInput().getMessage().getParts()
            .keySet();

    // Let's do some sanity checks here so that we don't get weird errors in assignment later.
    // The engine should have checked to make sure that the messages that are  delivered conform 
    // to the correct format; but you know what they say, don't trust anyone.  
    if (!(onMessage.variable.type instanceof OMessageVarType)) {
        String errmsg = "Non-message variable for receive: should have been picked up by static analysis.";
        __log.fatal(errmsg);
        throw new InvalidProcessException(errmsg);
    }

    OMessageVarType vartype = (OMessageVarType) onMessage.variable.type;

    // Check that each part contains what we expect. 
    for (String pName : partNames) {
        QName partName = new QName(null, pName);
        Element msgPart = DOMUtils.findChildByName(msgEl, partName);
        OMessageVarType.Part part = vartype.parts.get(pName);
        if (part == null) {
            String errmsg = "Inconsistent WSDL, part " + pName + " not found in message type "
                    + vartype.messageType;
            __log.fatal(errmsg);
            throw new InvalidProcessException(errmsg);
        }
        if (msgPart == null) {
            String errmsg = "Message missing part: " + pName;
            __log.fatal(errmsg);
            throw new InvalidContextException(errmsg);
        }

        if (part.type instanceof OElementVarType) {
            OElementVarType ptype = (OElementVarType) part.type;
            Element e = DOMUtils.getFirstChildElement(msgPart);
            if (e == null) {
                String errmsg = "Message (element) part " + pName + " did not contain child element.";
                __log.fatal(errmsg);
                throw new InvalidContextException(errmsg);
            }

            // Relaxing that check a bit for SimPEL
            if (!ptype.elementType.getLocalPart().equals("simpelWrapper")) {
                QName qn = new QName(e.getNamespaceURI(), e.getLocalName());
                if (!qn.equals(ptype.elementType)) {
                    String errmsg = "Message (element) part " + pName
                            + " did not contain correct child element: expected " + ptype.elementType
                            + " but got " + qn;
                    __log.fatal(errmsg);
                    throw new InvalidContextException(errmsg);
                }
            }
        }

    }

    VariableInstance vinst = _scopeFrame.resolve(onMessage.variable);

    try {
        initializeVariable(vinst, msgEl);
    } catch (ExternalVariableModuleException e) {
        __log.error("Exception while initializing external variable", e);
        _self.parent.failure(e.toString(), null);
        return;
    }

    // Generating event
    VariableModificationEvent se = new VariableModificationEvent(vinst.declaration.name);
    se.setNewValue(msgEl);
    if (_opick.debugInfo != null)
        se.setLineNo(_opick.debugInfo.startLine);
    sendEvent(se);
}

From source file:org.apache.ode.bpel.rtrep.v2.SCOPE.java

private static OCatch findCatch(OFaultHandler fh, QName faultName, OVarType faultType) {
    OCatch bestMatch = null;/*from   w ww  . ja v  a  2 s  .  co m*/
    for (OCatch c : fh.catchBlocks) {
        // First we try to eliminate this catch block based on fault-name mismatches:
        if (c.faultName != null) {
            if (faultName == null)
                continue;
            if (!faultName.equals(c.faultName))
                continue;
        }

        // Then we try to eliminate this catch based on type incompatibility:
        if (c.faultVariable != null) {
            if (faultType == null)
                continue;
            else if (c.faultVariable.type instanceof OMessageVarType) {
                if (faultType instanceof OMessageVarType && faultType.equals(c.faultVariable.type)) {
                    // Don't eliminate.
                } else if (faultType instanceof OElementVarType
                        && ((OMessageVarType) c.faultVariable.type).docLitType != null
                        && !((OMessageVarType) c.faultVariable.type).docLitType.equals(faultType)) {
                    // Don't eliminate.
                } else {
                    continue; // Eliminate.
                }
            } else if (c.faultVariable.type instanceof OElementVarType) {
                if (faultType instanceof OElementVarType && faultType.equals(c.faultVariable.type)) {
                    // Don't eliminate
                } else if (faultType instanceof OMessageVarType
                        && ((OMessageVarType) faultType).docLitType != null
                        && ((OMessageVarType) faultType).docLitType.equals(c.faultVariable.type)) {
                    // Don't eliminate
                } else {
                    continue; // eliminate
                }
            } else {
                continue; // Eliminate
            }
        }

        // If we got to this point we did not eliminate this catch block. However, we don't just
        // use the first non-eliminated catch, we instead try to find the best match.
        if (bestMatch == null) {
            // Obviously something is better then nothing.
            bestMatch = c;
        } else {
            // Otherwise we prefer name and variable matches but prefer name-only matches to
            // variable-only matches. 
            int existingScore = (bestMatch.faultName == null ? 0 : 2)
                    + (bestMatch.faultVariable == null ? 0 : 1);
            int currentScore = (c.faultName == null ? 0 : 2) + (c.faultVariable == null ? 0 : 1);
            if (currentScore > existingScore) {
                bestMatch = c;
            }
        }
    }
    return bestMatch;
}

From source file:org.apache.ode.bpel.runtime.PICK.java

@SuppressWarnings("unchecked")
private void initVariable(String mexId, OPickReceive.OnMessage onMessage) {
    // This is allowed, if there is no parts in the message for example.
    if (onMessage.variable == null)
        return;//from w ww.jav a 2 s  .c o m

    Element msgEl;
    try {
        // At this point, not being able to get the request is most probably
        // a mex that hasn't properly replied to (process issue).
        msgEl = getBpelRuntimeContext().getMyRequest(mexId);
    } catch (BpelEngineException e) {
        __log.error("The message exchange seems to be in an unconsistent state, you're "
                + "probably missing a reply on a request/response interaction.");
        _self.parent.failure(e.toString(), null);
        return;
    }

    Collection<String> partNames = (Collection<String>) onMessage.operation.getInput().getMessage().getParts()
            .keySet();

    // Let's do some sanity checks here so that we don't get weird errors in assignment later.
    // The engine should have checked to make sure that the messages that are  delivered conform
    // to the correct format; but you know what they say, don't trust anyone.
    if (!(onMessage.variable.type instanceof OMessageVarType)) {
        String errmsg = "Non-message variable for receive: should have been picked up by static analysis.";
        __log.fatal(errmsg);
        throw new InvalidProcessException(errmsg);
    }

    OMessageVarType vartype = (OMessageVarType) onMessage.variable.type;

    // Check that each part contains what we expect.
    for (String pName : partNames) {
        QName partName = new QName(null, pName);
        Element msgPart = DOMUtils.findChildByName(msgEl, partName);
        Part part = vartype.parts.get(pName);
        if (part == null) {
            String errmsg = "Inconsistent WSDL, part " + pName + " not found in message type "
                    + vartype.messageType;
            __log.fatal(errmsg);
            throw new InvalidProcessException(errmsg);
        }
        if (msgPart == null) {
            String errmsg = "Message missing part: " + pName;
            __log.fatal(errmsg);
            throw new InvalidContextException(errmsg);
        }

        if (part.type instanceof OElementVarType) {
            OElementVarType ptype = (OElementVarType) part.type;
            Element e = DOMUtils.getFirstChildElement(msgPart);
            if (e == null) {
                String errmsg = "Message (element) part " + pName + " did not contain child element.";
                __log.fatal(errmsg);
                throw new InvalidContextException(errmsg);
            }

            QName qn = new QName(e.getNamespaceURI(), e.getLocalName());
            if (!qn.equals(ptype.elementType)) {
                String errmsg = "Message (element) part " + pName
                        + " did not contain correct child element: expected " + ptype.elementType + " but got "
                        + qn;
                __log.fatal(errmsg);
                throw new InvalidContextException(errmsg);
            }
        }

    }

    VariableInstance vinst = _scopeFrame.resolve(onMessage.variable);

    try {
        initializeVariable(vinst, msgEl);
    } catch (ExternalVariableModuleException e) {
        __log.error("Exception while initializing external variable", e);
        _self.parent.failure(e.toString(), null);
        return;
    }

    // Generating event
    VariableModificationEvent se = new VariableModificationEvent(vinst.declaration.name);
    se.setNewValue(msgEl);
    if (_opick.debugInfo != null)
        se.setLineNo(_opick.debugInfo.startLine);
    sendEvent(se);
}

From source file:org.apache.ode.bpel.runtime.SCOPE.java

private static OCatch findCatch(OFaultHandler fh, QName faultName, OVarType faultType) {
    OCatch bestMatch = null;//from   ww w .j  a v a 2 s. com
    for (OCatch c : fh.catchBlocks) {
        // First we try to eliminate this catch block based on fault-name mismatches:
        if (c.faultName != null) {
            if (faultName == null)
                continue;
            if (!faultName.equals(c.faultName))
                continue;
        }

        // Then we try to eliminate this catch based on type incompatibility:
        if (c.faultVariable != null) {
            if (faultType == null)
                continue;
            else if (c.faultVariable.type instanceof OMessageVarType) {
                if (faultType instanceof OMessageVarType
                        && ((OMessageVarType) faultType).equals(c.faultVariable.type)) {
                    // Don't eliminate.
                } else if (faultType instanceof OElementVarType
                        && ((OMessageVarType) c.faultVariable.type).docLitType != null
                        && !((OMessageVarType) c.faultVariable.type).docLitType.equals(faultType)) {
                    // Don't eliminate.
                } else {
                    continue; // Eliminate.
                }
            } else if (c.faultVariable.type instanceof OElementVarType) {
                if (faultType instanceof OElementVarType && faultType.equals(c.faultVariable.type)) {
                    // Don't eliminate
                } else if (faultType instanceof OMessageVarType
                        && ((OMessageVarType) faultType).docLitType != null
                        && ((OMessageVarType) faultType).docLitType.equals(c.faultVariable.type)) {
                    // Don't eliminate
                } else {
                    continue; // eliminate
                }
            } else {
                continue; // Eliminate
            }
        }

        // If we got to this point we did not eliminate this catch block. However, we don't just
        // use the first non-eliminated catch, we instead try to find the best match.
        if (bestMatch == null) {
            // Obviously something is better then nothing.
            bestMatch = c;
        } else {
            // Otherwise we prefer name and variable matches but prefer name-only matches to
            // variable-only matches.
            int existingScore = (bestMatch.faultName == null ? 0 : 2)
                    + (bestMatch.faultVariable == null ? 0 : 1);
            int currentScore = (c.faultName == null ? 0 : 2) + (c.faultVariable == null ? 0 : 1);
            if (currentScore > existingScore) {
                bestMatch = c;
            }
        }
    }
    return bestMatch;
}

From source file:org.apache.ode.jbi.EndpointReferenceContextImpl.java

public EndpointReference resolveEndpointReference(Element epr) {
    QName elname = new QName(epr.getNamespaceURI(), epr.getLocalName());

    if (__log.isDebugEnabled()) {
        __log.debug("resolveEndpointReference:\n" + prettyPrint(epr));
    }/*from w ww . j  a  v a 2s.co  m*/
    if (!elname.equals(EndpointReference.SERVICE_REF_QNAME))
        throw new IllegalArgumentException(
                "EPR root element " + elname + " should be " + EndpointReference.SERVICE_REF_QNAME);

    Document doc = DOMUtils.newDocument();
    DocumentFragment fragment = doc.createDocumentFragment();
    NodeList children = epr.getChildNodes();
    for (int i = 0; i < children.getLength(); ++i)
        if (children.item(i) instanceof Element)
            fragment.appendChild(doc.importNode(children.item(i), true));
    ServiceEndpoint se = _ode.getContext().resolveEndpointReference(fragment);
    if (se == null)
        return null;
    return new JbiEndpointReference(se);
}