Package org.apache.ode.axis2

Examples of org.apache.ode.axis2.ODEConfigProperties


                    OMElement namePart = messageContext.getEnvelope().getBody().getFirstElement().getFirstElement();
                    OMElement zipPart = (OMElement) namePart.getNextOMSibling();
                    OMElement zip = zipPart.getFirstElement();
                    if (!zipPart.getQName().getLocalPart().equals("package") ||
                            !zip.getQName().getLocalPart().equals("zip"))
                        throw new OdeFault("Your message should contain a part named 'package' with a zip element");

                    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, namePart.getText() + "-" + _store.getCurrentVersion());
                        dest.mkdir();
                        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");
                        deployedMarker.createNewFile();

                        // 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", null);
                      d.setText(dest.getName());
                      response.addChild(d);

                      for (QName pid : deployed) {
                          if (__log.isDebugEnabled()) __log.debug("Deployed PID: "+pid);
                          d = factory.createOMElement("id", null);
                          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();

                    String pkg = part.getText();
                    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 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();

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

                        File deployedMarker = new File(_deployPath, pkg + ".deployed");
                        deployedMarker.delete();
                        FileUtils.deepDelete(new File(_deployPath, pkg));

                        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", null);
                        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", null);
                        nameElmt.setText(qname);
                        response.addChild(nameElmt);
                    }
                    sendResponse(factory, messageContext, "listProcessResponse", 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


                    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

    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

    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);
    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

        _serviceName = serviceName;
        _portName = portName;

        _serviceDef = _def.getService(serviceName);
        if (_serviceDef == null)
            throw new OdeFault(__msgs.msgServiceDefinitionNotFound(serviceName));
        _port = _serviceDef.getPort(portName);
        if (_port == null)
            throw new OdeFault(__msgs.msgPortDefinitionNotFound(serviceName, portName));
        _binding = _port.getBinding();
        if (_binding == null)
            throw new OdeFault(__msgs.msgBindingNotFound(serviceName, portName));


        Collection<SOAPBinding> soapBindings = CollectionsX.filter(_binding.getExtensibilityElements(), SOAPBinding.class);
        if (soapBindings.isEmpty())
            throw new OdeFault(__msgs.msgNoSOAPBindingForPort(_portName));
        else if (soapBindings.size() > 1) {
            throw new OdeFault(__msgs.msgMultipleSoapBindingsForPort(_portName));
        }

        _soapBinding = (SOAPBinding) soapBindings.iterator().next();
        String style = _soapBinding.getStyle();
        _isRPC = style != null && style.equals("rpc");
View Full Code Here

            throw new NullPointerException("Null msgCtx");

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

        if (bop == null)
            throw new OdeFault(__msgs.msgBindingOperationNotFound(_serviceName, _portName, op.getName()));

        BindingInput bi = bop.getBindingInput();
        if (bi == null)
            throw new OdeFault(__msgs.msgBindingInputNotFound(_serviceName, _portName, op.getName()));

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

            throw new NullPointerException("Null msgCtx");

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

        if (bop == null)
            throw new OdeFault(__msgs.msgBindingOperationNotFound(_serviceName, _portName, op.getName()));

        BindingOutput bo = bop.getBindingOutput();
        if (bo == null)
            throw new OdeFault(__msgs.msgBindingOutputNotFound(_serviceName, _portName, op.getName()));

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

        if (headerdef.getPart() == null)
            return;

        if (payloadMessageHeader && msgdef.getPart(headerdef.getPart()) == null)
            throw new OdeFault(__msgs.msgSoapHeaderReferencesUnkownPart(headerdef.getPart()));

        Element srcPartEl = null;
        // Message can be null if the operation message has no part
        if (message != null) {
            if (payloadMessageHeader)
                srcPartEl = DOMUtils.findChildByName(message, new QName(null, headerdef.getPart()));
            else {
                Element fho = DOMUtils.findChildByName(message, FOREIGN_HEADER_OUT);
                if (fho != null) {
                    srcPartEl = DOMUtils.findChildByName(fho, headerdef.getElementType());
                }
            }
        }

        // We don't complain about missing header data unless they are part of the message payload. This is
        // because AXIS may be providing these headers.
        if (srcPartEl == null && payloadMessageHeader)
            throw new OdeFault(__msgs.msgOdeMessageMissingRequiredPart(headerdef.getPart()));

        if (srcPartEl == null)
            return;

        org.apache.axiom.soap.SOAPHeader soaphdr = soapEnv.getHeader();
View Full Code Here

    public void parseSoapRequest(Element odeMessage, SOAPEnvelope envelope, Operation op) throws AxisFault {
        BindingOperation bop = _binding.getBindingOperation(op.getName(), null, null);

        if (bop == null)
            throw new OdeFault(__msgs.msgBindingOperationNotFound(_serviceName, _portName, op.getName()));

        BindingInput bi = bop.getBindingInput();
        if (bi == null)
            throw new OdeFault(__msgs.msgBindingInputNotFound(_serviceName, _portName, op.getName()));

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

    public void parseSoapResponse(Element odeMessage, SOAPEnvelope envelope, Operation op) throws AxisFault {
        BindingOperation bop = _binding.getBindingOperation(op.getName(), null, null);

        if (bop == null)
            throw new OdeFault(__msgs.msgBindingOperationNotFound(_serviceName, _portName, op.getName()));

        BindingOutput bo = bop.getBindingOutput();
        if (bo == null)
            throw new OdeFault(__msgs.msgBindingInputNotFound(_serviceName, _portName, op.getName()));

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

TOP

Related Classes of org.apache.ode.axis2.ODEConfigProperties

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.