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.compiler.v1.WSDLRegistry.java

public Property getProperty(QName name) {
    ArrayList<Definition4BPEL> defs = _definitions.get(name.getNamespaceURI());
    if (defs == null)
        return null;
    for (Definition4BPEL definition4BPEL : defs) {
        if (definition4BPEL != null && definition4BPEL.getProperty(name) != null)
            return definition4BPEL.getProperty(name);
    }/*from   w w w  .  j a va2  s  . com*/
    return null;
}

From source file:org.apache.ode.bpel.compiler.v1.WSDLRegistry.java

public PropertyAlias getPropertyAlias(QName propertyName, QName messageType) {
    ArrayList<Definition4BPEL> defs = _definitions.get(propertyName.getNamespaceURI());
    if (defs == null)
        return null;
    for (Definition4BPEL definition4BPEL : defs) {
        if (definition4BPEL != null && definition4BPEL.getPropertyAlias(propertyName, messageType) != null)
            return definition4BPEL.getPropertyAlias(propertyName, messageType);
    }//from   w w  w .  j  ava  2s.  c om
    return null;
}

From source file:org.apache.ode.bpel.compiler.v1.WSDLRegistry.java

public PartnerLinkType getPartnerLinkType(QName partnerLinkType) {
    ArrayList<Definition4BPEL> defs = _definitions.get(partnerLinkType.getNamespaceURI());
    if (defs == null)
        return null;
    for (Definition4BPEL definition4BPEL : defs) {
        if (definition4BPEL != null && definition4BPEL.getPartnerLinkType(partnerLinkType) != null)
            return definition4BPEL.getPartnerLinkType(partnerLinkType);
    }/*from  w w w. j  ava  2s. c  om*/
    return null;
}

From source file:org.apache.ode.bpel.compiler.v1.WSDLRegistry.java

public PortType getPortType(QName portType) {
    ArrayList<Definition4BPEL> defs = _definitions.get(portType.getNamespaceURI());
    if (defs == null)
        return null;
    for (Definition4BPEL definition4BPEL : defs) {
        if (definition4BPEL != null && definition4BPEL.getPortType(portType) != null)
            return definition4BPEL.getPortType(portType);
    }// w ww.j  a va  2 s.  c  o  m
    return null;
}

From source file:org.apache.ode.bpel.compiler.v1.WSDLRegistry.java

public Message getMessage(QName msgType) {
    ArrayList<Definition4BPEL> defs = _definitions.get(msgType.getNamespaceURI());
    if (defs == null)
        return null;
    for (Definition4BPEL definition4BPEL : defs) {
        if (definition4BPEL != null && definition4BPEL.getMessage(msgType) != null)
            return definition4BPEL.getMessage(msgType);
    }//from w ww  .  j  av  a  2 s.c o m
    return null;
}

From source file:org.apache.ode.bpel.compiler.v1.xpath10.jaxp.JaxpFunctionResolver.java

public XPathFunction resolveFunction(QName functionName, int arity) {
    __log.debug("JAXP compiler: Resolving function " + functionName);
    if (functionName.getNamespaceURI() == null) {
        throw new WrappedResolverException("Undeclared namespace for " + functionName);
    } else if (functionName.getNamespaceURI().equals(_bpelNS)) {
        String localName = functionName.getLocalPart();
        if (Constants.EXT_FUNCTION_GETVARIABLEDATA.equals(localName)) {
            return new GetVariableData();
        }//  w  w  w .j  av a2 s.c o m
        if (Constants.EXT_FUNCTION_GETVARIABLEPROPERTY.equals(localName)) {
            return new GetVariableProperty();
        }
        if (Constants.EXT_FUNCTION_GETLINKSTATUS.equals(localName)) {
            return new GetLinkStatus();
        }
        if (Constants.EXT_FUNCTION_DOXSLTRANSFORM.equals(localName)) {
            return new DoXslTransform();
        }
        throw new WrappedResolverException(__msgs.errUnknownBpelFunction(localName));
    }

    return null;
}

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

public Object resolveVariable(QName variableName) {
    __log.debug("JAXP compiler: Resolving variable " + variableName);
    // Custom variables
    if ("ode".equals(variableName.getPrefix())
            || Namespaces.ODE_EXTENSION_NS.equals(variableName.getNamespaceURI())) {
        if ("pid".equals(variableName.getLocalPart()))
            return "";
    }//from  www  .j a  v a  2s  .com

    try {
        String name = variableName.getLocalPart();
        if (_oxpath instanceof OXPath10ExpressionBPEL20
                && ((OXPath10ExpressionBPEL20) _oxpath).isJoinExpression) {
            // these resolve to links
            OLink olink = _cctx.resolveLink(name);
            _oxpath.links.put(name, olink);
            return Boolean.TRUE;
        } else {
            int dot = name.indexOf('.');
            if (dot != -1)
                name = name.substring(0, dot);
            OScope.Variable var = _cctx.resolveVariable(name);
            _oxpath.vars.put(name, var);
            return extractValue(var, var.type);
        }
    } catch (CompilationException e) {
        throw new WrappedResolverException(e);
    }
}

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

private Object generateFromType(QName typeName) {
    if (typeName.getNamespaceURI().equals(Namespaces.XML_SCHEMA)) {
        if (typeName.getLocalPart().equals("int") || typeName.getLocalPart().equals("integer")
                || typeName.getLocalPart().equals("short") || typeName.getLocalPart().equals("long")
                || typeName.getLocalPart().equals("byte") || typeName.getLocalPart().equals("float")
                || typeName.getLocalPart().equals("double")
                || typeName.getLocalPart().equals("nonPositiveInteger")
                || typeName.getLocalPart().equals("nonNegativeInteger")
                || typeName.getLocalPart().equals("negativeInteger")
                || typeName.getLocalPart().equals("unsignedLong")
                || typeName.getLocalPart().equals("unsignedInt")
                || typeName.getLocalPart().equals("unsignedShort")
                || typeName.getLocalPart().equals("unsignedByte"))
            return 0;
        if (typeName.getLocalPart().equals("boolean"))
            return Boolean.TRUE;
        if (typeName.getLocalPart().equals("string"))
            return "";
    }/*  w  w  w . ja va 2s  .c o  m*/
    Document doc = DOMUtils.newDocument();
    doc.appendChild(doc.createElement("empty"));
    return doc.getDocumentElement();
}

From source file:org.apache.ode.bpel.compiler.v2.WSDLRegistry.java

public org.apache.ode.bpel.compiler.bom.Property getProperty(QName name) {
    ArrayList<Definition4BPEL> defs = _definitions.get(name.getNamespaceURI());
    if (defs == null)
        return null;
    for (Definition4BPEL definition4BPEL : defs) {
        if (definition4BPEL != null && definition4BPEL.getProperty(name) != null)
            return definition4BPEL.getProperty(name);
    }//w  w  w  .j a v  a2 s  . com
    return null;
}

From source file:org.apache.ode.bpel.compiler.v2.xquery10.compiler.XQuery10ExpressionCompilerImpl.java

private void doJaxpCompile(OXQuery10ExpressionBPEL20 out, Expression source) throws CompilationException {
    String xqueryStr;/*from w w w.  j  a va 2  s.  c  o  m*/
    Node node = source.getExpression();
    if (node == null) {
        throw new IllegalStateException("XQuery string and xpath node are both null");
    }
    if (node.getNodeType() != Node.TEXT_NODE && node.getNodeType() != Node.ELEMENT_NODE
            && node.getNodeType() != Node.CDATA_SECTION_NODE) {
        throw new CompilationException(__msgs.errUnexpectedNodeTypeForXPath(DOMUtils.domToString(node)));
    }
    xqueryStr = DOMUtils.domToString(node);
    xqueryStr = xqueryStr.trim();
    if (xqueryStr.length() == 0) {
        throw new CompilationException(__msgs.warnXPath20Syntax(DOMUtils.domToString(node), "empty string"));
    }

    try {
        XQDataSource xqds = new SaxonXQDataSource();
        XQConnection xqconn = xqds.getConnection();

        __log.debug("Compiling expression " + xqueryStr);
        Configuration configuration = ((SaxonXQConnection) xqconn).getConfiguration();
        configuration.setAllNodesUntyped(true);
        configuration.setHostLanguage(Configuration.XQUERY);

        XQStaticContext staticContext = xqconn.getStaticContext();
        JaxpFunctionResolver funcResolver = new JaxpFunctionResolver(_compilerContext, out,
                source.getNamespaceContext(), _bpelNS);
        JaxpVariableResolver variableResolver = new JaxpVariableResolver(_compilerContext, out);

        XQueryDeclarations declarations = new XQueryDeclarations();
        NSContext nsContext = source.getNamespaceContext();
        Set<String> prefixes = nsContext.getPrefixes();
        if (!nsContext.getUriSet().contains(Namespaces.ODE_EXTENSION_NS)) {
            nsContext.register("ode", Namespaces.ODE_EXTENSION_NS);
        }
        for (String prefix : prefixes) {
            String uri = nsContext.getNamespaceURI(prefix);
            staticContext.declareNamespace(prefix, uri);
            if ("".equals(prefix)) {
                declarations.declareDefaultElementNamespace(uri);
            } else if ("bpws".equals(prefix)) {
                declarations.declareNamespace("bpws", "java:" + Constants.XQUERY_FUNCTION_HANDLER_COMPILER);
            } else {
                declarations.declareNamespace(prefix, uri);
            }
        }
        declarations.declareVariable(getQName(nsContext, Namespaces.ODE_EXTENSION_NS, "pid"),
                getQName(nsContext, Namespaces.XML_SCHEMA, "integer"));
        Map<URI, Source> schemaDocuments = _compilerContext.getSchemaSources();
        for (URI schemaUri : schemaDocuments.keySet()) {
            Source schemaSource = schemaDocuments.get(schemaUri);
            // Don't add schema sources, since our Saxon library is not schema-aware. 
            // configuration.addSchemaSource(schemaSource);
        }
        configuration.setSchemaValidationMode(Validation.SKIP);
        List<OScope.Variable> variables = _compilerContext.getAccessibleVariables();
        Map<QName, QName> variableTypes = new HashMap<QName, QName>();
        for (String variableName : getVariableNames(xqueryStr)) {
            OScope.Variable variable = getVariable(variables, variableName);
            if (variable == null) {
                continue;
            }
            OVarType type = variable.type;
            QName nameQName = getNameQName(variableName);
            QName typeQName = getTypeQName(variableName, type);
            variableTypes.put(nameQName, typeQName);
            String prefix = typeQName.getPrefix();
            if (prefix == null || "".equals(prefix.trim())) {
                prefix = getPrefixForUri(nsContext, typeQName.getNamespaceURI());
            }
            // don't declare typed variables, as our engine is not schema-aware
            // declarations.declareVariable(variable.name, typeQName);
            declarations.declareVariable(variableName);
        }

        // Add implicit declarations as prolog to the user-defined XQuery
        out.xquery = declarations.toString() + xqueryStr;

        // Check the XQuery for compilation errors 
        xqconn.setStaticContext(staticContext);
        XQPreparedExpression exp = xqconn.prepareExpression(out.xquery);

        // Pre-evaluate variables and functions by executing query  
        node.setUserData(XQuery10BpelFunctions.USER_DATA_KEY_FUNCTION_RESOLVER, funcResolver, null);
        exp.bindItem(XQConstants.CONTEXT_ITEM, xqconn.createItemFromNode(node, xqconn.createNodeType()));
        // Bind external variables to dummy runtime values
        for (QName variable : exp.getAllUnboundExternalVariables()) {
            QName typeQName = variableTypes.get(variable);
            Object value = variableResolver.resolveVariable(variable);
            if (typeQName != null) {
                if (value.getClass().getName().startsWith("java.lang")) {
                    exp.bindAtomicValue(variable, value.toString(),
                            xqconn.createAtomicType(XQItemType.XQBASETYPE_ANYATOMICTYPE));
                } else if (value instanceof Node) {
                    exp.bindNode(variable, (Node) value, xqconn.createNodeType());
                } else if (value instanceof NodeList) {
                    NodeList nodeList = (NodeList) value;
                    ArrayList nodeArray = new ArrayList();
                    for (int i = 0; i < nodeList.getLength(); i++) {
                        nodeArray.add(nodeList.item(i));
                    }
                    XQSequence sequence = xqconn.createSequence(nodeArray.iterator());
                    exp.bindSequence(variable, sequence);
                }
            }
        }
        // evaluate the expression so as to initialize the variables
        try {
            exp.executeQuery();
        } catch (XQException xpee) {
            // swallow errors caused by uninitialized variables 
        }
    } catch (XQException xqe) {
        __log.debug(xqe);
        __log.info("Couldn't validate properly expression " + xqueryStr);
    } catch (WrappedResolverException wre) {
        if (wre._compilationMsg != null)
            throw new CompilationException(wre._compilationMsg, wre);
        if (wre.getCause() instanceof CompilationException)
            throw (CompilationException) wre.getCause();
        throw wre;
    }
}