Example usage for javax.xml.namespace QName getNamespaceURI

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

Introduction

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

Prototype

public String getNamespaceURI() 

Source Link

Document

Get the Namespace URI of this QName.

Usage

From source file:org.apache.ode.bpel.rtrep.v1.xpath10.jaxp.JaxpVariableResolver.java

public Object resolveVariable(QName variableName) {
    __log.debug("JAXP runtime: Resolving variable " + variableName);

    if (!(_oxpath instanceof OXPath10ExpressionBPEL20)) {
        throw new IllegalStateException("XPath variables not supported for bpel 1.1");
    }/*from   ww w.j av a  2 s  .c  o  m*/

    // Custom variables
    if (variableName.getNamespaceURI().equals(Namespaces.ODE_EXTENSION_NS)) {
        if ("pid".equals(variableName.getLocalPart())) {
            return _ectx.getProcessId();
        }
    }

    if (_oxpath instanceof OXPath10ExpressionBPEL20 && ((OXPath10ExpressionBPEL20) _oxpath).isJoinExpression) {
        OLink olink = _oxpath.links.get(variableName.getLocalPart());
        try {
            return _ectx.isLinkActive(olink) ? Boolean.TRUE : Boolean.FALSE;
        } catch (FaultException e) {
            throw new WrappedFaultException(e);
        }
    } else {
        String varName;
        String partName;
        int dotloc = variableName.getLocalPart().indexOf('.');
        if (dotloc == -1) {
            varName = variableName.getLocalPart();
            partName = null;
        } else {
            varName = variableName.getLocalPart().substring(0, dotloc);
            partName = variableName.getLocalPart().substring(dotloc + 1);
        }
        OScope.Variable variable = _oxpath.vars.get(varName);
        OMessageVarType.Part part = partName == null ? null
                : ((OMessageVarType) variable.type).parts.get(partName);

        try {
            Node variableNode = _ectx.readVariable(variable, part);
            if (variableNode == null)
                throw new FaultException(variable.getOwner().constants.qnSelectionFailure,
                        "Unknown variable " + variableName.getLocalPart());
            if (_ectx.narrowTypes()) {
                if (variable.type instanceof OXsdTypeVarType && ((OXsdTypeVarType) variable.type).simple)
                    return getSimpleContent(variableNode, ((OXsdTypeVarType) variable.type).xsdType);
                if (part != null && part.type instanceof OXsdTypeVarType
                        && ((OXsdTypeVarType) part.type).simple)
                    return getSimpleContent(variableNode, ((OXsdTypeVarType) part.type).xsdType);
            }

            // Saxon expects a node list, this nodelist should contain exactly one item, the attribute
            // value
            return new SingletonNodeList(variableNode);

        } catch (FaultException e) {
            throw new WrappedFaultException(e);
        }
    }
}

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

public XPathFunction resolveFunction(QName functionName, int arity) {
    __log.debug("Resolving function " + functionName);
    if (functionName.getNamespaceURI() == null) {
        throw new NullPointerException("Undeclared namespace for " + functionName);
    } else if (functionName.getNamespaceURI().equals(Namespaces.WS_BPEL_20_NS)
            || functionName.getNamespaceURI().equals(Namespaces.WSBPEL2_0_FINAL_EXEC)) {
        String localName = functionName.getLocalPart();
        if (Constants.EXT_FUNCTION_GETVARIABLEDATA.equals(localName)) {
            return new GetVariableData();
        } else if (Constants.EXT_FUNCTION_GETVARIABLEPROPERTY.equals(localName)) {
            return new GetVariableProperty();
        } else if (Constants.EXT_FUNCTION_GETLINKSTATUS.equals(localName)) {
            return new GetLinkStatus();
        } else if (Constants.EXT_FUNCTION_DOXSLTRANSFORM.equals(localName)) {
            return new DoXslTransform();
        } else {/* ww w. j  a  va2  s. c  om*/
            throw new NullPointerException("Unknown BPEL function: " + functionName);
        }
    } else if (functionName.getNamespaceURI().equals(Namespaces.ODE_EXTENSION_NS)) {
        String localName = functionName.getLocalPart();
        if (Constants.NON_STDRD_FUNCTION_SPLIT_TO_ELEMENTS.equals(localName)
                || Constants.NON_STDRD_FUNCTION_DEPRECATED_SPLIT_TO_ELEMENTS.equals(localName)) {
            return new SplitToElements();
        } else if (Constants.NON_STDRD_FUNCTION_COMBINE_URL.equals(localName)
                || Constants.NON_STDRD_FUNCTION_DEPRECATED_COMBINE_URL.equals(localName)) {
            return new CombineUrl();
        } else if (Constants.NON_STDRD_FUNCTION_COMPOSE_URL.equals(localName)
                || Constants.NON_STDRD_FUNCTION_DEPRECATED_COMPOSE_URL.equals(localName)) {
            return new ComposeUrl();
        } else if (Constants.NON_STDRD_FUNCTION_EXPAND_TEMPLATE.equals(localName)
                || Constants.NON_STDRD_FUNCTION_DEPRECATED_EXPAND_TEMPLATE.equals(localName)) {
            return new ComposeUrl(true, "expandTemplateInvalidSource");
        } else if (Constants.NON_STDRD_FUNCTION_DOM_TO_STRING.equals(localName)
                || Constants.NON_STDRD_FUNCTION_DEPRECATED_DOM_TO_STRING.equals(localName)) {
            return new DomToString();
        } else if (Constants.NON_STDRD_FUNCTION_INSERT_AFTER.equals(localName)) {
            return new InsertAfter();
        } else if (Constants.NON_STDRD_FUNCTION_INSERT_AS_FIRST_INTO.equals(localName)) {
            return new InsertAsFirstInto();
        } else if (Constants.NON_STDRD_FUNCTION_INSERT_AS_LAST_INTO.equals(localName)) {
            return new InsertAsLastInto();
        } else if (Constants.NON_STDRD_FUNCTION_INSERT_BEFORE.equals(localName)) {
            return new InsertBefore();
        } else if (Constants.NON_STDRD_FUNCTION_DELETE.equals(localName)) {
            return new Delete();
        } else if (Constants.NON_STDRD_FUNCTION_RENAME.equals(localName)) {
            return new Rename();
        } else if (Constants.NON_STDRD_FUNCTION_PROCESS_PROPERTY.equals(localName)) {
            return new ProcessProperty();
        }
    }

    return null;
}

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

public Object resolveVariable(QName variableName) {
    __log.debug("Resolving variable " + variableName);

    if (!(_oxpath instanceof OXPath10ExpressionBPEL20)) {
        throw new IllegalStateException("XPath variables not supported for bpel 1.1");
    }//from   w  w  w  . j a va 2  s .c om

    // Custom variables
    if (variableName.getNamespaceURI().equals(Namespaces.ODE_EXTENSION_NS)) {
        if ("pid".equals(variableName.getLocalPart())) {
            return _ectx.getProcessId();
        }
    }

    OXPath10ExpressionBPEL20 expr = _oxpath;
    if (expr.isJoinExpression) {
        OLink olink = _oxpath.links.get(variableName.getLocalPart());

        try {
            return _ectx.isLinkActive(olink) ? Boolean.TRUE : Boolean.FALSE;
        } catch (FaultException e) {
            throw new WrappedFaultException(e);
        }
    } else {
        String varName;
        String partName;
        int dotloc = variableName.getLocalPart().indexOf('.');
        if (dotloc == -1) {
            varName = variableName.getLocalPart();
            partName = null;
        } else {
            varName = variableName.getLocalPart().substring(0, dotloc);
            partName = variableName.getLocalPart().substring(dotloc + 1);
        }
        OScope.Variable variable = _oxpath.vars.get(varName);
        OMessageVarType.Part part = partName == null ? null
                : ((OMessageVarType) variable.type).parts.get(partName);

        try {
            final Node variableNode = _ectx.readVariable(variable, part);
            if (variableNode == null)
                throw new FaultException(variable.getOwner().constants.qnSelectionFailure,
                        "Unknown variable " + variableName.getLocalPart());
            if (_ectx.narrowTypes()) {
                if (variable.type instanceof OXsdTypeVarType && ((OXsdTypeVarType) variable.type).simple)
                    return getSimpleContent(variableNode, ((OXsdTypeVarType) variable.type).xsdType);
                if (part != null && part.type instanceof OXsdTypeVarType
                        && ((OXsdTypeVarType) part.type).simple)
                    return getSimpleContent(variableNode, ((OXsdTypeVarType) part.type).xsdType);
            }

            // Saxon used to expect a node list, but now a regular node will suffice.
            return variableNode;
        } catch (FaultException e) {
            throw new WrappedFaultException(e);
        }
    }
}

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

public Object resolveVariable(QName variableName) {
    __log.debug("Resolving variable " + variableName);

    if (!(_oxpath instanceof OXPath10ExpressionBPEL20)) {
        throw new IllegalStateException("XPath variables not supported for bpel 1.1");
    }//  w  w w  .j a  v a2  s.c  o  m

    // Custom variables
    if (variableName.getNamespaceURI().equals(Namespaces.ODE_EXTENSION_NS)) {
        if ("pid".equals(variableName.getLocalPart())) {
            return _ectx.getProcessId();
        }
    }

    OXPath10ExpressionBPEL20 expr = _oxpath;
    if (expr.isJoinExpression) {
        OLink olink = _oxpath.links.get(variableName.getLocalPart());
        try {
            return _ectx.isLinkActive(olink) ? Boolean.TRUE : Boolean.FALSE;
        } catch (FaultException e) {
            throw new WrappedFaultException(e);
        }
    } else {
        String varName;
        String partName;
        int dotloc = variableName.getLocalPart().indexOf('.');
        if (dotloc == -1) {
            varName = variableName.getLocalPart();
            partName = null;
        } else {
            varName = variableName.getLocalPart().substring(0, dotloc);
            partName = variableName.getLocalPart().substring(dotloc + 1);
        }
        OScope.Variable variable = _oxpath.vars.get(varName);
        OMessageVarType.Part part = partName == null ? null
                : ((OMessageVarType) variable.type).parts.get(partName);

        try {
            final Node variableNode = _ectx.readVariable(variable, part);
            if (variableNode == null)
                throw new FaultException(variable.getOwner().constants.qnSelectionFailure,
                        "Unknown variable " + variableName.getLocalPart());
            if (_ectx.narrowTypes()) {
                if (variable.type instanceof OXsdTypeVarType && ((OXsdTypeVarType) variable.type).simple)
                    return getSimpleContent(variableNode, ((OXsdTypeVarType) variable.type).xsdType);
                if (part != null && part.type instanceof OXsdTypeVarType
                        && ((OXsdTypeVarType) part.type).simple)
                    return getSimpleContent(variableNode, ((OXsdTypeVarType) part.type).xsdType);
            }

            // Saxon expects a node list, this nodelist should contain exactly one item, the attribute
            // value
            // return new SingletonNodeList(variableNode);

            // Saxon used to expect a node list, but now a regular node will suffice.
            return variableNode;
        } catch (FaultException e) {
            throw new WrappedFaultException(e);
        }
    }
}

From source file:org.apache.ode.daohib.bpel.BpelDAOConnectionImpl.java

public ProcessDAO createProcess(QName pid, QName type, String guid, long version) {
    HProcess process = new HProcess();
    process.setProcessId(pid.toString());
    process.setTypeName(type.getLocalPart());
    process.setTypeNamespace(type.getNamespaceURI());
    process.setDeployDate(new Date());
    process.setGuid(guid);//  w ww  .  j a v  a 2 s .c om
    process.setVersion(version);
    getSession().save(process);
    return new ProcessDaoImpl(_sm, process);
}

From source file:org.apache.ode.il.epr.WSAEndpoint.java

public void fromMap(Map eprMap) {
    Document doc = DOMUtils.newDocument();
    Element serviceRef = doc.createElementNS(SERVICE_REF_QNAME.getNamespaceURI(),
            SERVICE_REF_QNAME.getLocalPart());
    doc.appendChild(serviceRef);//from w  ww.  j ava2s. c o m
    _eprElmt = doc.createElementNS(Namespaces.WS_ADDRESSING_NS, "EndpointReference");
    serviceRef.appendChild(_eprElmt);
    Element addrElmt = doc.createElementNS(Namespaces.WS_ADDRESSING_NS, "Address");
    addrElmt.setTextContent((String) eprMap.get(ADDRESS));
    if (eprMap.get(SESSION) != null) {
        Element sessElmt = doc.createElementNS(Namespaces.ODE_SESSION_NS, "session");
        sessElmt.setTextContent((String) eprMap.get(SESSION));
        _eprElmt.appendChild(sessElmt);
    }
    if (eprMap.get(SERVICE_QNAME) != null) {
        Element metadataElmt = doc.createElementNS(Namespaces.WS_ADDRESSING_NS, "Metadata");
        _eprElmt.appendChild(metadataElmt);
        Element serviceElmt = doc.createElementNS(Namespaces.WS_ADDRESSING_WSDL_NS, "ServiceName");
        metadataElmt.appendChild(serviceElmt);
        QName serviceQName = (QName) eprMap.get(SERVICE_QNAME);
        serviceElmt.setAttribute("xmlns:servicens", serviceQName.getNamespaceURI());
        serviceElmt.setTextContent("servicens:" + serviceQName.getLocalPart());
        serviceElmt.setAttribute("EndpointName", (String) eprMap.get(PORT_NAME));
    }
    _eprElmt.appendChild(addrElmt);
    if (__log.isDebugEnabled())
        __log.debug("Constructed a new WSAEndpoint: " + DOMUtils.domToString(_eprElmt));
}

From source file:org.apache.ode.il.OMUtils.java

/**
 * Axiom is supposed to handle this properly however this method is buggy and doesn't work (whereas setting a QName as text
 * works)./*from   ww w.  jav  a  2s .c  om*/
 *
 * @param elmt
 * @return text qname
 */
public static QName getTextAsQName(OMElement elmt) {
    QName qname = elmt.getTextAsQName();
    // The getTextAsQName is buggy, it sometimes return the full text without extracting namespace
    if (qname == null || qname.getNamespaceURI().length() == 0) {
        int colonIdx = elmt.getText().indexOf(":");
        String localpart = elmt.getText().substring(colonIdx + 1, elmt.getText().length());
        String prefix = elmt.getText().substring(0, colonIdx);
        String ns = elmt.findNamespaceURI(prefix).getNamespaceURI();
        qname = new QName(ns, localpart, prefix);
    }
    return qname;
}

From source file:org.apache.ode.jbi.util.WSDLFlattener.java

private Definition flattenDefinition(QName name) throws Exception {
    // Check that schemas have been loaded
    initialize();//from  w ww  .j  ava  2  s.  c om
    // Create new definition
    Definition flat = WSDLFactory.newInstance().newDefinition();
    flat.setTargetNamespace(name.getNamespaceURI());
    addNamespaces(flat, _definition);
    // Create port type
    PortType defPort = _definition.getPortType(name);
    PortType flatPort = flat.createPortType();
    flatPort.setQName(defPort.getQName());
    flatPort.setUndefined(false);
    // Import all operations and related messages
    for (Iterator itOper = defPort.getOperations().iterator(); itOper.hasNext();) {
        Operation defOper = (Operation) itOper.next();
        Operation flatOper = flat.createOperation();
        flatOper.setName(defOper.getName());
        flatOper.setStyle(defOper.getStyle());
        flatOper.setUndefined(false);
        if (defOper.getInput() != null) {
            Input flatInput = flat.createInput();
            flatInput.setName(defOper.getInput().getName());
            if (defOper.getInput().getMessage() != null) {
                Message flatInputMsg = copyMessage(defOper.getInput().getMessage(), flat);
                flatInput.setMessage(flatInputMsg);
                flat.addMessage(flatInputMsg);
            }
            flatOper.setInput(flatInput);
        }
        if (defOper.getOutput() != null) {
            Output flatOutput = flat.createOutput();
            flatOutput.setName(defOper.getOutput().getName());
            if (defOper.getOutput().getMessage() != null) {
                Message flatOutputMsg = copyMessage(defOper.getOutput().getMessage(), flat);
                flatOutput.setMessage(flatOutputMsg);
                flat.addMessage(flatOutputMsg);
            }
            flatOper.setOutput(flatOutput);
        }
        for (Iterator itFault = defOper.getFaults().values().iterator(); itFault.hasNext();) {
            Fault defFault = (Fault) itFault.next();
            Fault flatFault = flat.createFault();
            flatFault.setName(defFault.getName());
            if (defFault.getMessage() != null) {
                Message flatFaultMsg = copyMessage(defFault.getMessage(), flat);
                flatFault.setMessage(flatFaultMsg);
                flat.addMessage(flatFaultMsg);
            }
            flatOper.addFault(flatFault);
        }
        flatPort.addOperation(flatOper);
    }

    // Import schemas in definition
    if (_schemas.getSize() > 0) {
        Types types = flat.createTypes();
        for (Iterator it = _schemas.getSchemas().iterator(); it.hasNext();) {
            javax.wsdl.extensions.schema.Schema imp = new SchemaImpl();
            imp.setElement(((Schema) it.next()).getRoot());
            imp.setElementType(new QName("http://www.w3.org/2001/XMLSchema", "schema"));
            types.addExtensibilityElement(imp);
        }
        flat.setTypes(types);
    }

    flat.addPortType(flatPort);
    return flat;
}

From source file:org.apache.ode.store.DocumentRegistry.java

/**
 * Obtains an WSDL definition based on its target namespace.
 *
 * @param serviceName/*from   w  w  w. j av a  2s. com*/
 *
 * @return WSDL definition or <code>null</code> if unavailable.
 */
public Definition4BPEL getDefinition(QName serviceName) {
    for (Definition4BPEL definition4BPEL : _definitions) {
        if (definition4BPEL.getTargetNamespace().equals(serviceName.getNamespaceURI())) {
            if (definition4BPEL.getService(serviceName) != null)
                return definition4BPEL;
        }
    }
    return null;
}

From source file:org.apache.ode.store.DocumentRegistry.java

/**
 * Obtains an WSDL definition based on its target namespace.
 *
 * @param serviceName/* ww  w .  jav a2 s  . c om*/
 *
 * @return WSDL definition or <code>null</code> if unavailable.
 */
public Definition4BPEL getDefinitionForPortType(QName serviceName) {
    for (Definition4BPEL definition4BPEL : _definitions) {
        if (definition4BPEL.getTargetNamespace().equals(serviceName.getNamespaceURI())) {
            if (definition4BPEL.getPortType(serviceName) != null)
                return definition4BPEL;
        }
    }
    return null;
}