Examples of OdeFault


Examples of org.apache.ode.axis2.OdeFault

        // Is this header part of the "payload" messsage?
        boolean payloadMessageHeader = headerdef.getMessage() == null || headerdef.getMessage().equals(msgType.getQName());
        boolean requiredHeader = payloadMessageHeader || (headerdef.getRequired() != null && headerdef.getRequired());

        if (requiredHeader && header == null)
            throw new OdeFault(__msgs.msgSoapHeaderMissingRequiredElement(headerdef.getElementType()));

        if (header == null)
            return;

        Message hdrMsg = _def.getMessage(headerdef.getMessage());
        if (hdrMsg == null)
            return;
        Part p = hdrMsg.getPart(headerdef.getPart());
        if (p == null || p.getElementName() == null)
            return;

        OMElement headerEl = header.getFirstChildWithName(p.getElementName());
        if (requiredHeader && headerEl == null)
            throw new OdeFault(__msgs.msgSoapHeaderMissingRequiredElement(headerdef.getElementType()));

        if (headerEl == null) return;

        odeMessage.setHeaderPart(p.getName(), OMUtils.toDOM(headerEl));
    }
View Full Code Here

Examples of org.apache.ode.axis2.OdeFault

    private static String extractServiceName(Definition wsdlDefinition, QName wsdlServiceName, String portName)
            throws AxisFault {
        String url = null;
        Service service = wsdlDefinition.getService(wsdlServiceName);
        if (service == null) {
            throw new OdeFault("Unable to find service " + wsdlServiceName + " from service WSDL definition "
                    + wsdlDefinition.getDocumentBaseURI());
        }
        Port port = service.getPort(portName);
        if (port == null) {
            throw new OdeFault("Couldn't find port " + portName + " in definition " + wsdlServiceName);
        }
        for (Object oext : port.getExtensibilityElements()) {
            if (oext instanceof SOAPAddress)
                url = ((SOAPAddress) oext).getLocationURI();
        }
        if (url == null) {
            throw new OdeFault("Could not extract any soap:address from service WSDL definition " + wsdlServiceName
                    + " (necessary to establish the process target address)!");
        }
        String serviceName = parseURLForService(url);
        if (serviceName == null) {
            throw new OdeFault("The soap:address used for service WSDL definition " + wsdlServiceName + " and port "
                    + portName + " should be of the form http://hostname:port/ode/processes/myProcessEndpointName");
        }
        return serviceName;
    }
View Full Code Here

Examples of org.apache.ode.axis2.OdeFault

            throw new NullPointerException("Null msgCtx");

        BindingOperation bop = binding.getBindingOperation(op.getName(), null, null);

        if (bop == null)
            throw new OdeFault("BindingOperation not found.");

        BindingInput bi = bop.getBindingInput();
        if (bi == null)
            throw new OdeFault("BindingInput not found.");

        SOAPEnvelope soapEnv = msgCtx.getEnvelope();
        if (soapEnv == null) {
            soapEnv = soapFactory.getDefaultEnvelope();
            msgCtx.setEnvelope(soapEnv);
View Full Code Here

Examples of org.apache.ode.axis2.OdeFault

        if (op == null)
            op = responseOperation;
        BindingOperation bop = binding.getBindingOperation(op.getName(), null, null);

        if (bop == null)
            throw new OdeFault("Binding Operation not found.");

        BindingOutput bo = bop.getBindingOutput();
        if (bo == null)
            throw new OdeFault("Binding Output not found.");

        SOAPBody soapBody = getSOAPBody(bo);
        if (soapBody != null)
             extractSoapBodyParts(odeMessage, envelope.getBody(), soapBody, op.getInput().getMessage(),
                     op.getName() + "Response");
View Full Code Here

Examples of org.apache.ode.axis2.OdeFault

        if (isRPC) {
            QName rpcWrapQName = new QName(bodyDef.getNamespaceURI(), rpcWrapper);
            OMElement partWrapper = soapBody.getFirstChildWithName(rpcWrapQName);
            if (partWrapper == null)
                throw new OdeFault("Message body doesn't contain expected part wrapper.");
            // In RPC the body element is the operation name, wrapping parts. Order doesn't really matter as far as
            // we're concerned. All we need to do is copy the soap:body children, since doc-lit rpc looks the same
            // in ode and soap.
            for (Part pdef : bodyParts) {
                OMElement srcPart = partWrapper.getFirstChildWithName(new QName(null, pdef.getName()));
                if (srcPart == null)
                    throw new OdeFault("SOAP body doesn't contain required part.");
                message.setPart(srcPart.getLocalName(), OMUtils.toDOM(srcPart));
            }

        } else {
            // In doc-literal style, we expect the elements in the body to correspond (in order) to the
            // parts defined in the binding. All the parts should be element-typed, otherwise it is a mess.
            Iterator<OMElement> srcParts = soapBody.getChildElements();
            for (Part partDef : bodyParts) {
                if (!srcParts.hasNext())
                    throw new OdeFault("SOAP Mesaage body doesn't contain required part.");

                OMElement srcPart = srcParts.next();
                if (partDef.getElementName() == null)
                    throw new OdeFault("Binding defines non element doc list parts.");
                if (!srcPart.getQName().equals(partDef.getElementName()))
                    throw new OdeFault("Unexpected element in SOAP body");
                Document doc = DOMUtils.newDocument();
                Element destPart = doc.createElementNS(null, partDef.getName());
                destPart.appendChild(doc.importNode(OMUtils.toDOM(srcPart), true));
                message.setPart(partDef.getName(), destPart);
            }
View Full Code Here

Examples of org.apache.ode.axis2.OdeFault

        * */
        Iterator<OMElement> srcParts = soapBody.getChildElements();
        if (srcParts.hasNext()) {
            OMElement srcPart = srcParts.next();
            if (!srcPart.getQName().equals(new QName(null, "part")))
                throw new OdeFault("Unexpected element in SOAP body");
            OMElement hifb = srcPart.getFirstChildWithName(new QName("http://wso2.org/humantask/feedback", "HIFeedback"));
            if (hifb == null) {
                throw new OdeFault("Unexpected element in SOAP body");
            }
            OMElement taskIDele = hifb.getFirstChildWithName(new QName("http://wso2.org/humantask/feedback", "TaskID"));
            if (taskIDele == null) {
                throw new OdeFault("Unexpected element in SOAP body");
            }
            String taskID = taskIDele.getText();
            return taskID;
//            Document doc = DOMUtils.newDocument();
//            Element destPart = doc.createElementNS(null, "part");
//            destPart.appendChild(doc.importNode(OMUtils.toDOM(srcPart), true));
//            message.setPart("part", destPart);
        }
        throw new OdeFault("TaskID not found in the feedback message");
    }
View Full Code Here

Examples of org.apache.ode.axis2.OdeFault

        // Is this header part of the "payload" messsage?
        boolean payloadMessageHeader = headerdef.getMessage() == null || headerdef.getMessage().equals(msgType.getQName());
        boolean requiredHeader = payloadMessageHeader || (headerdef.getRequired() != null && headerdef.getRequired());

        if (requiredHeader && header == null)
            throw new OdeFault("SOAP Header missing required element.");

        if (header == null)
            return;

        Message hdrMsg =wsdlDefintion.getMessage(headerdef.getMessage());
        if (hdrMsg == null)
            return;
        Part p = hdrMsg.getPart(headerdef.getPart());
        if (p == null || p.getElementName() == null)
            return;

        OMElement headerEl = header.getFirstChildWithName(p.getElementName());
        if (requiredHeader && headerEl == null)
            throw new OdeFault("SOAP Header missing required element.");

        if (headerEl == null) return;

        odeMessage.setHeaderPart(p.getName(), OMUtils.toDOM(headerEl));
    }
View Full Code Here

Examples of org.apache.ode.axis2.OdeFault

                    OMElement namePart = deployElement.getFirstChildWithName(new QName(null, "name"));
                    // "be liberal in what you accept from others"
                    if (namePart == null) {
                       namePart = OMUtils.getFirstChildWithName(deployElement, "name");
                       if( namePart == null ) {
                               throw new OdeFault("The name part is missing");
                       } else if (__log.isWarnEnabled()) {
                            __log.warn("Invalid incoming request detected for operation " + messageContext.getAxisOperation().getName() + ". Name part should have no namespace but has " + namePart.getQName().getNamespaceURI());
                        }
                    }

                    OMElement packagePart = deployElement.getFirstChildWithName(new QName(null, "package"));

                    // "be liberal in what you accept from others"
                    if (packagePart == null) {
                        packagePart = OMUtils.getFirstChildWithName(deployElement, "package");
                        if (packagePart != null && __log.isWarnEnabled()) {
                            __log.warn("Invalid incoming request detected for operation " + messageContext.getAxisOperation().getName() + ". Package part should have no namespace but has " + packagePart.getQName().getNamespaceURI());
                        }
                    }

                    OMElement zip = null;
                    if (packagePart != null) {
                        zip = packagePart.getFirstChildWithName(new QName(Namespaces.ODE_DEPLOYAPI_NS, "zip"));
                        // "be liberal in what you accept from others"
                        if (zip == null) {
                            zip = OMUtils.getFirstChildWithName(packagePart, "zip");
                            if (zip != null && __log.isWarnEnabled()) {
                                String ns = zip.getQName().getNamespaceURI() == null || zip.getQName().getNamespaceURI().length() == 0 ? "empty" : zip.getQName().getNamespaceURI();
                                __log.warn("Invalid incoming request detected for operation " + messageContext.getAxisOperation().getName() + ". <zip/> element namespace should be " + Namespaces.ODE_DEPLOYAPI_NS + " but was " + ns);
                            }
                        }
                    }

                    if (zip == null || packagePart == null)
                        throw new OdeFault("Your message should contain an element named 'package' with a 'zip' element");

                    String bundleName = namePart.getText().trim();
                    if (!validBundleName(namePart.getText()))
                        throw new OdeFault("Invalid bundle name, only non empty alpha-numerics and _ strings are allowed.");

                    OMText binaryNode = (OMText) zip.getFirstOMChild();
                    if (binaryNode == null) {
                        throw new OdeFault("Empty binary node under <zip> element");
                    }
                    binaryNode.setOptimize(true);
                    try {
                        // We're going to create a directory under the deployment root and put
                        // files in there. The poller shouldn't pick them up so we're asking
                        // it to hold on for a while.
                        _poller.hold();

                        File dest = new File(_deployPath, bundleName + "-" + _store.getCurrentVersion());
                        boolean createDir = dest.mkdir();
                        if(!createDir){
                          throw new OdeFault("Error while creating file " + dest.getName());
                        }
                        unzip(dest, (DataHandler) binaryNode.getDataHandler());

                        // Check that we have a deploy.xml
                        File deployXml = new File(dest, "deploy.xml");
                        if (!deployXml.exists())
                            throw new OdeFault("The deployment doesn't appear to contain a deployment " +
                                    "descriptor in its root directory named deploy.xml, aborting.");

                        Collection<QName> deployed = _store.deploy(dest);

                        File deployedMarker = new File(_deployPath, dest.getName() + ".deployed");
                        if(!deployedMarker.createNewFile()) {
                          throw new OdeFault("Error while creating file " + deployedMarker.getName() + "deployment failed");
                        }

                        // Telling the poller what we deployed so that it doesn't try to deploy it again
                        _poller.markAsDeployed(dest);
                        __log.info("Deployment of artifact " + dest.getName() + " successful.");

                        OMElement response = factory.createOMElement("response", null);

                        if (__log.isDebugEnabled()) __log.debug("Deployed package: "+dest.getName());
                        OMElement d = factory.createOMElement("name", _deployapi);
                        d.setText(dest.getName());
                        response.addChild(d);

                        for (QName pid : deployed) {
                            if (__log.isDebugEnabled()) __log.debug("Deployed PID: "+pid);
                            d = factory.createOMElement("id", _deployapi);
                            d.setText(pid);
                            response.addChild(d);
                        }
                        sendResponse(factory, messageContext, "deployResponse", response);
                    } finally {
                        _poller.release();
                    }
                } else if (operation.equals("undeploy")) {
                    OMElement part = messageContext.getEnvelope().getBody().getFirstElement().getFirstElement();
                    if (part == null) throw new OdeFault("Missing bundle name in undeploy message.");

                    String pkg = part.getText().trim();
                    if (!validBundleName(pkg)) {
                        throw new OdeFault("Invalid bundle name, only non empty alpha-numerics and _ strings are allowed.");
                    }

                    File deploymentDir = new File(_deployPath, pkg);
                    if (!deploymentDir.exists())
                        throw new OdeFault("Couldn't find deployment package " + pkg + " in directory " + _deployPath);

                    try {
                        // We're going to delete files & directories under the deployment root.
                        // Put the poller on hold to avoid undesired side effects
                        _poller.hold();

                        Collection<QName> undeployed = _store.undeploy(deploymentDir);

                        File deployedMarker = new File(deploymentDir + ".deployed");
                        boolean isDeleted = deployedMarker.delete();

                        if (!isDeleted)
                            __log.error("Error while deleting file " + deployedMarker.getName());

                        FileUtils.deepDelete(deploymentDir);

                        OMElement response = factory.createOMElement("response", null);
                        response.setText("" + (undeployed.size() > 0));
                        sendResponse(factory, messageContext, "undeployResponse", response);
                        _poller.markAsUndeployed(deploymentDir);
                    } finally {
                        _poller.release();
                    }
                } else if (operation.equals("listDeployedPackages")) {
                    Collection<String> packageNames = _store.getPackages();
                    OMElement response = factory.createOMElement("deployedPackages", null);
                    for (String name : packageNames) {
                        OMElement nameElmt = factory.createOMElement("name", _deployapi);
                        nameElmt.setText(name);
                        response.addChild(nameElmt);
                    }
                    sendResponse(factory, messageContext, "listDeployedPackagesResponse", response);
                } else if (operation.equals("listProcesses")) {
                    OMElement namePart = messageContext.getEnvelope().getBody().getFirstElement().getFirstElement();
                    List<QName> processIds = _store.listProcesses(namePart.getText());
                    OMElement response = factory.createOMElement("processIds", null);
                    for (QName qname : processIds) {
                        OMElement nameElmt = factory.createOMElement("id", _deployapi);
                        nameElmt.setText(qname);
                        response.addChild(nameElmt);
                    }
                    sendResponse(factory, messageContext, "listProcessesResponse", response);
                } else if (operation.equals("getProcessPackage")) {
                    OMElement qnamePart = messageContext.getEnvelope().getBody().getFirstElement().getFirstElement();
                    ProcessConf process = _store.getProcessConfiguration(OMUtils.getTextAsQName(qnamePart));
                    if (process == null) {
                        throw new OdeFault("Could not find process: " + qnamePart.getTextAsQName());
                    }
                    String packageName = _store.getProcessConfiguration(OMUtils.getTextAsQName(qnamePart)).getPackage();
                    OMElement response = factory.createOMElement("packageName", null);
                    response.setText(packageName);
                    sendResponse(factory, messageContext, "getProcessPackageResponse", response);
                } else unknown = true;
            } catch (Throwable t) {
                // Trying to extract a meaningful message
                Throwable source = t;
                while (source.getCause() != null && source.getCause() != source) source = source.getCause();
                __log.warn("Invocation of operation " + operation + " failed", t);
                throw new OdeFault("Invocation of operation " + operation + " failed: " + source.toString(), t);
            }
            if (unknown) throw new OdeFault("Unknown operation: '"
                    + messageContext.getAxisOperation().getName() + "'");
        }
View Full Code Here

Examples of org.apache.ode.axis2.OdeFault

                    copyInputStream(zis, new BufferedOutputStream(
                            new FileOutputStream(destFile)));
                }
                zis.close();
            } catch (IOException e) {
                throw new OdeFault("An error occured on deployment.", e);
            }
        }
View Full Code Here

Examples of org.apache.ode.axis2.OdeFault

            throws AxisFault {
        Definition wsdlDefinition = pconf.getDefinitionForService(wsdlServiceName);
        String url = null;
        Service service = wsdlDefinition.getService(wsdlServiceName);
        if (service == null) {
            throw new OdeFault("Unable to find service " + wsdlServiceName + " from service WSDL definition "
                    + wsdlDefinition.getDocumentBaseURI());
        }
        Port port = service.getPort(portName);
        if (port == null) {
            throw new OdeFault("Couldn't find port " + portName + " in definition " + wsdlServiceName);
        }
        for (Object oext : port.getExtensibilityElements()) {
            if (oext instanceof SOAPAddress)
                url = ((SOAPAddress) oext).getLocationURI();
        }
        if (url == null) {
            throw new OdeFault("Could not extract any soap:address from service WSDL definition " + wsdlServiceName
                    + " (necessary to establish the process target address)!");
        }
        return url;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.