Package org.apache.ode.bpel.common

Examples of org.apache.ode.bpel.common.FaultException


        try {
            return ISO8601DateParser.parseCal(literal);
        } catch (Exception ex) {
            String errmsg = "Invalid date: " + literal;
            __log.error(errmsg, ex);
            throw new FaultException(cexp.getOwner().constants.qnInvalidExpressionValue, errmsg);
        }
    }
View Full Code Here


            Duration duration = new org.apache.ode.utils.xsd.Duration(literal);
            return duration;
        } catch (Exception ex) {
            String errmsg = "Invalid duration: " + literal;
            __log.error(errmsg, ex);
            throw new FaultException(cexp.getOwner().constants.qnInvalidExpressionValue, errmsg);
        }
    }
View Full Code Here

    }

    public class DomToString implements XPathFunction {
        public Object evaluate(List args) throws XPathFunctionException {
            if (args.size() != 1)
                throw new XPathFunctionException(new FaultException(new QName(Namespaces.ODE_EXTENSION_NS, "domToStringInvalidSource"), "Invalid arguments"));

            if (__log.isDebugEnabled()) {
                __log.debug("domToString call(context=" + _ectx + " args=" + args + ")");
            }

            Element varElmt;
            try {
                if (args.get(0) instanceof List) {
                    List elmts = (List) args.get(0);
                    if (elmts.size() != 1) throw new XPathFunctionException(
                            new FaultException(_oxpath.getOwner().constants.qnXsltInvalidSource,
                                    "The bpws:domToString function MUST be passed a single " +
                                            "element node."));
                    varElmt = (Element) elmts.get(0);
                } else if (args.get(0) instanceof NodeWrapper) {
                    varElmt = (Element) ((NodeWrapper) args.get(0)).getUnderlyingNode();
                } else if (args.get(0) instanceof Element) {
                    varElmt = (Element) args.get(0);
                } else {
                    throw new XPathFunctionException("Unexpected argument type: "+args.get(0).getClass());
                }
            } catch (ClassCastException e) {
                throw new XPathFunctionException(
                        new FaultException(_oxpath.getOwner().constants.qnXsltInvalidSource,
                                "The bpws:domToString function MUST be passed a single " +
                                        "element node."));
            }
            String result= DOMUtils.domToString(varElmt);
            return result;
View Full Code Here

     * Compile time checking for the non standard ode:splitToElements function.
     */
    public class SplitToElements implements XPathFunction {
        public Object evaluate(List args) throws XPathFunctionException {
            if (args.size() <= 2 || args.size() >= 5)
                throw new XPathFunctionException(new FaultException(new QName(Namespaces.ODE_EXTENSION_NS, "splitInvalidSource"), "Invalid arguments"));

            if (__log.isDebugEnabled()) {
                __log.debug("splitToElements call(context=" + _ectx + " args=" + args + ")");
            }

            String strToSplit;
            try {
                strToSplit = Helper.extractString(args.get(0));
            } catch (IllegalArgumentException e) {
                throw new XPathFunctionException(new FaultException(new QName(Namespaces.ODE_EXTENSION_NS, "splitInvalidSource"), e));
            }

            // Other parameters
            String separator = (String) args.get(1);
            String localName = (String) args.get(2);
View Full Code Here

    }

    public class Rename implements XPathFunction {
        public Object evaluate(List args) throws XPathFunctionException {
            if (args.size() < 2)
                throw new XPathFunctionException(new FaultException(new QName(Namespaces.ODE_EXTENSION_NS, "renameInvalidSource"), "Invalid arguments"));

            if (__log.isDebugEnabled()) {
                __log.debug("rename call(context=" + _ectx + " args=" + args + ")");
            }

            Element targetElmt;
            QName elementQName = null, elementTypeQName = null;
            try {
                if (args.get(0) instanceof List) {
                    List elmts = (List) args.get(0);
                    if (elmts.size() != 1) throw new XPathFunctionException(
                            new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
                                    "The bpws:rename function MUST be passed a single " +
                                            "element node."));
                    targetElmt = (Element) elmts.get(0);
                } else if (args.get(0) instanceof NodeWrapper) {
                    targetElmt = (Element) ((NodeWrapper) args.get(0)).getUnderlyingNode();
                } else if (args.get(0) instanceof Element) {
                    targetElmt = (Element) args.get(0);
                } else {
                    throw new XPathFunctionException("Unexpected argument type: "+args.get(0).getClass());
                }
                String localName = null, namespaceUri = null, prefix = null;
                if (args.get(1) instanceof QNameValue) {
                    QNameValue qNameValue = (QNameValue) args.get(1);
                    namespaceUri = qNameValue.getNamespaceURI();
                    localName = qNameValue.getLocalName();
                    prefix = qNameValue.getPrefix();
                } else if (args.get(1) instanceof List) {
                    List elmts = (List) args.get(1);
                    if (elmts.size() != 1) throw new XPathFunctionException(
                            new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
                                    "The bpws:rename function MUST be passed a single " +
                                            "element node."));
                    Element nameElmt = (Element) elmts.get(0);
                    namespaceUri = nameElmt.getNamespaceURI();
                    localName = nameElmt.getLocalName();
                    prefix = nameElmt.getPrefix();
                } else if (args.get(1) instanceof NodeWrapper) {
                    Element nameElmt = (Element) ((NodeWrapper) args.get(1)).getUnderlyingNode();
                    namespaceUri = nameElmt.getNamespaceURI();
                    localName = nameElmt.getLocalName();
                    prefix = nameElmt.getPrefix();
                } else if (args.get(1) instanceof Element) {
                    Element nameElmt = (Element) args.get(1);
                    namespaceUri = nameElmt.getNamespaceURI();
                    localName = nameElmt.getLocalName();
                    prefix = nameElmt.getPrefix();
                } else if (args.get(1) instanceof String)  {
                    String qName = (String) args.get(1);
                    if (qName.contains(":")) {
                        int index = qName.indexOf(":");
                        prefix = qName.substring(0, index);
                        localName = qName.substring(index + 1);
                    } else {
                        localName = qName;
                    }
                } else if (args.get(1) instanceof QName) {
                    QName qName = (QName) args.get(1);
                    namespaceUri = qName.getNamespaceURI();
                    localName = qName.getLocalPart();
                    prefix = qName.getPrefix();
                } else {
                    throw new XPathFunctionException("Unexpected argument type: "+args.get(1).getClass());
                }
                if (namespaceUri == null) {
                    namespaceUri = targetElmt.lookupNamespaceURI(prefix);
                }
                elementQName = new QName(namespaceUri, localName, prefix);
                if (args.size() > 2) {
                    if (args.get(2) instanceof QNameValue) {
                        QNameValue qNameValue = (QNameValue) args.get(2);
                        namespaceUri = qNameValue.getNamespaceURI();
                        localName = qNameValue.getLocalName();
                        prefix = qNameValue.getPrefix();
                    } else if (args.get(2) instanceof NodeWrapper) {
                        Element nameElmt = (Element) ((NodeWrapper) args.get(2)).getUnderlyingNode();
                        namespaceUri = nameElmt.getNamespaceURI();
                        localName = nameElmt.getLocalName();
                        prefix = nameElmt.getPrefix();
                    } else if (args.get(2) instanceof Element) {
                        Element nameElmt = (Element) args.get(2);
                        namespaceUri = nameElmt.getNamespaceURI();
                        localName = nameElmt.getLocalName();
                        prefix = nameElmt.getPrefix();
                    } else if (args.get(2) instanceof String)  {
                        String qName = (String) args.get(2);
                        if (qName.contains(":")) {
                            int index = qName.indexOf(":");
                            prefix = qName.substring(0, index);
                            localName = qName.substring(index + 1);
                        } else {
                            localName = qName;
                        }
                    } else {
                        throw new XPathFunctionException("Unexpected argument type: "+args.get(2).getClass());
                    }
                    if (namespaceUri == null) {
                        namespaceUri = targetElmt.lookupNamespaceURI(prefix);
                    }
                    elementTypeQName = new QName(namespaceUri, localName, prefix);;
                }
            } catch (IllegalArgumentException e) {
                throw new XPathFunctionException(
                        new FaultException(_oxpath.getOwner().constants.qnInvalidExpressionValue,
                                "Invalid argument: URI Template expected. " + args.get(0), e));
            } catch (ClassCastException e) {
                throw new XPathFunctionException(
                        new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
                                "The bpws:rename function MUST be passed a single " +
                                        "element node."));
            }
            Element parentElmt = (Element) targetElmt.getParentNode();
            NodeList children = parentElmt.getChildNodes();
View Full Code Here

            sender.setOptions(options);
            OMElement response = sender.sendReceive(payload);
            corId = getCorrelationValue(response);
            if (corId == null) {
                log.error("Correlation value is null");
                context.completeWithFault(cid, new FaultException(new QName(LongRunningExtensionBundle.NS, "Correlation value is null")));
                return;
            }

        } catch (FaultException e) {
            context.completeWithFault(cid, e);
        } catch (XMLStreamException e) {
            context.completeWithFault(cid, e);
        } catch (AxisFault axisFault) {
            context.completeWithFault(cid, axisFault);
        } finally {
            if (sender != null) {
                try {
                    //To release http connections to connection pool
                    sender.cleanupTransport();
                } catch (AxisFault axisFault) {
                    axisFault.printStackTrace();
                    context.completeWithFault(cid, axisFault);
                }
            }
        }

        correlationValues = new String[]{corId};
        context.setCorrelationValues(correlationValues);
        String correlatorId = genCorrelatorId();
        if (correlatorId == null) {
            context.completeWithFault(cid, new FaultException(new QName(LongRunningExtensionBundle.NS, "Null correlatorId")));
            return;
        }

        context.setCorrelatorId(correlatorId);
View Full Code Here

        try {
            plink = extensionContext.getPartnerLinkInstance(longRunningActivity.getPartnerLink());
            return plink.partnerLink.getName() + "." + operation;
        } catch (FaultException e) {
            e.printStackTrace();
            extensionContext.completeWithFault(cid, new FaultException(new QName(LongRunningExtensionBundle.NS, "Error reading partnerlink to get correlation values")));
        }
        return null;
    }
View Full Code Here

                    break;
                }
            }

            if (myProcess == null) {
                throw new FaultException(new QName(LongRunningExtensionBundle.NS, "related process not found"));
            }

            List<TInvoke> tInvokeList = myProcess.getInvokeList();
            for (TInvoke tInvoke : tInvokeList) {
                if (tInvoke.getPartnerLink().equals(getPartnerLink())) {
                    serviceName = tInvoke.getService().getName();
                    servicePort = tInvoke.getService().getPort();
                    break;
                }
            }

            if (serviceName == null || servicePort == null) {
                log.error("service and port for human interaction is not found in the deploy.xml");
                throw new FaultException(new QName(LongRunningExtensionBundle.NS,
                        "service and port for human interaction is not found in the deploy.xml"));
            }

            //get the callback information
            List<TProvide> tProvideList = myProcess.getProvideList();
            for (TProvide tProvide : tProvideList) {
                if (tProvide.getPartnerLink().equals(getPartnerLink())) {
                    callbackServiceName = tProvide.getService().getName();
                    callbackServicePort = tProvide.getService().getPort();
                    break;
                }
            }
//            if (callbackServiceName == null || callbackServicePort == null) {
//                throw new FaultException(new QName(LongRunningExtensionBundle.NS,
//                        "service and port for human task callback is not found in the deploy.xml"));
//            }

            Definition serviceWSDL;
            serviceWSDL = du.getDefinitionForService(serviceName);

            Service service = serviceWSDL.getService(serviceName);
            Port port = service.getPort(servicePort);
            List extList = port.getExtensibilityElements();
            for (Object extEle : extList) {
                 if (extEle instanceof SOAPAddressImpl) {
                     SOAPAddressImpl soapAddress = (SOAPAddressImpl)extEle;
                     serviceURI = soapAddress.getLocationURI();
                     break;
                 }
            }

            if (serviceURI == null) {
                throw new FaultException(new QName(LongRunningExtensionBundle.NS, "Service URI is not available"));
            }

            return serviceURI;
        }
View Full Code Here

    }

    public class ProcessProperty implements XPathFunction {
        public Object evaluate(List args) throws XPathFunctionException {
            if (args.size() != 1)
                throw new XPathFunctionException(new FaultException(new QName(Namespaces.ODE_EXTENSION_NS, "processPropertyInvalidSource"), "Invalid arguments"));

            if (__log.isDebugEnabled()) {
                __log.debug("process-property call(context=" + _ectx + " args=" + args + ")");
            }

            QName propertyName = null;
            Element targetElmt = null;
            try {
                if (args.get(0) instanceof List) {
                    List elmts = (List) args.get(0);
                    if (elmts.size() != 1) throw new XPathFunctionException(
                            new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
                                    "The bpws:process-property function MUST be passed a single " +
                                            "element node."));
                    if (elmts.get(0) instanceof Element) {
                        targetElmt = (Element) elmts.get(0);
                    } else if (elmts.get(0) instanceof String) {
                        propertyName = new QName((String) elmts.get(0));
                    }
                } else if (args.get(0) instanceof NodeWrapper) {
                    targetElmt = (Element) ((NodeWrapper) args.get(0)).getUnderlyingNode();
                } else if (args.get(0) instanceof Element) {
                    targetElmt = (Element) args.get(0);
                } else if (args.get(0) instanceof QNameValue) {
                    QNameValue qNameValue = (QNameValue) args.get(0);
                    propertyName = new QName(qNameValue.getNamespaceURI(), qNameValue.getLocalName(), qNameValue.getPrefix());
                } else if (args.get(0) instanceof String)  {
                    String stringValue = (String) args.get(0);
                    if (stringValue.indexOf(":") > 0) {
                        String prefix = stringValue.substring(0, stringValue.indexOf(":"));
                        String localPart = stringValue.substring(stringValue.indexOf(":") + 1);
                        String namespaceUri = _oxpath.namespaceCtx.getNamespaceURI(prefix);
                        propertyName = new QName(namespaceUri, localPart, prefix);
                    } else {
                        propertyName = new QName(stringValue);
                    }
                } else if (args.get(0) instanceof QName) {
                    propertyName = (QName) args.get(0);
                } else {
                    throw new XPathFunctionException("Unexpected argument type: "+args.get(0).getClass());
                }
                if (propertyName == null) {
                    if (targetElmt != null) {
                        propertyName = new QName(targetElmt.getTextContent());
                    }
                }
            } catch (IllegalArgumentException e) {
                throw new XPathFunctionException(
                        new FaultException(_oxpath.getOwner().constants.qnInvalidExpressionValue,
                                "Invalid argument: URI Template expected. " + args.get(0), e));
            } catch (ClassCastException e) {
                throw new XPathFunctionException(
                        new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
                                "The bpws:process-property function MUST be passed a single " +
                                        "element node."));
            }
            return _ectx.getPropertyValue(propertyName);
        }
View Full Code Here

    }

    public class DayTimeDuration implements XPathFunction {
        public Object evaluate(List args) throws XPathFunctionException {
            if (args.size() != 1)
                throw new XPathFunctionException(new FaultException(new QName(Namespaces.ODE_EXTENSION_NS, "dayTimeDurationPropertyInvalidSource"), "Invalid arguments"));

            if (__log.isDebugEnabled()) {
                __log.debug("dayTimeDuration call(context=" + _ectx + " args=" + args + ")");
            }

            String argument = null;
            Element targetElmt = null;
            try {
                if (args.get(0) instanceof List) {
                    List elmts = (List) args.get(0);
                    if (elmts.size() != 1) throw new XPathFunctionException(
                            new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
                                    "The bpws:dayTimeDuration function MUST be passed a single " +
                                            "element node."));
                    if (elmts.get(0) instanceof Element) {
                        targetElmt = (Element) elmts.get(0);
                    } else if (elmts.get(0) instanceof String) {
                        argument = (String) elmts.get(0);
                    }
                } else if (args.get(0) instanceof NodeWrapper) {
                    targetElmt = (Element) ((NodeWrapper) args.get(0)).getUnderlyingNode();
                } else if (args.get(0) instanceof Element) {
                    targetElmt = (Element) args.get(0);
                } else if (args.get(0) instanceof String)  {
                    argument = (String) args.get(0);
                } else {
                    throw new XPathFunctionException("Unexpected argument type: "+args.get(0).getClass());
                }
                if (argument == null) {
                    if (targetElmt != null) {
                        argument = targetElmt.getTextContent();
                    }
                }
            } catch (IllegalArgumentException e) {
                throw new XPathFunctionException(
                        new FaultException(_oxpath.getOwner().constants.qnInvalidExpressionValue,
                                "Invalid argument: URI Template expected. " + args.get(0), e));
            } catch (ClassCastException e) {
                throw new XPathFunctionException(
                        new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
                                "The bpws:dayTimeDuration function MUST be passed a single " +
                                        "element node."));
            }
            return DayTimeDurationValue.makeDayTimeDurationValue(argument);
        }
View Full Code Here

TOP

Related Classes of org.apache.ode.bpel.common.FaultException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.