Search in sources :

Example 6 with TProvide

use of org.apache.ode.bpel.dd.TProvide in project carbon-business-process by wso2.

the class ProcessConfigurationImpl method initPartnerLinks.

/**
 * Initialize partner link details of the BPEL process. Details about partner link's service and
 * port is in the deploy.xml file. This can be used to initialize partner links information in
 * registry. After that we can co-relate this partner links with carbon endpoints. This will
 * help us to dynamically configure endpoint properties like security, RM.
 */
private void initPartnerLinks() {
    if (processInfo.getInvokeList() != null) {
        for (TInvoke invoke : processInfo.getInvokeList()) {
            String plinkName = invoke.getPartnerLink();
            TService service = invoke.getService();
            // configure this value
            if (service == null) {
                continue;
            }
            if (log.isDebugEnabled()) {
                log.debug("Processing <invoke> element for process " + processInfo.getName() + ": partnerlink" + plinkName + " -->" + service);
            }
            QName serviceName = service.getName();
            /* Validating configuration with package content before putting partner role endpoints to map */
            Definition wsdlDef = getDefinitionForService(serviceName);
            if (wsdlDef == null) {
                String errMsg = "Cannot find WSDL definition for invoke service " + serviceName + ". Required resources not found in the BPEL package " + du.getName() + ".";
                log.error(errMsg);
                throw new ContextException(errMsg);
            }
            Service serviceDef = wsdlDef.getService(serviceName);
            if (serviceDef.getPort(service.getPort()) == null) {
                String errMsg = "Cannot find  port for invoking service for the given name " + serviceName + ". Error in deploy.xml.";
                log.error(errMsg);
                throw new ContextException(errMsg);
            }
            partnerRoleInitialValues.put(plinkName, new Endpoint(service.getName(), service.getPort()));
            // TODO add proper variable names
            {
                OFailureHandling g = null;
                if (invoke.isSetFailureHandling()) {
                    FailureHandlingDocument.FailureHandling fh = invoke.getFailureHandling();
                    g = new OFailureHandling();
                    if (fh.isSetFaultOnFailure()) {
                        g.faultOnFailure = fh.getFaultOnFailure();
                    }
                    if (fh.isSetRetryDelay()) {
                        g.retryDelay = fh.getRetryDelay();
                    }
                    if (fh.isSetRetryFor()) {
                        g.retryFor = fh.getRetryFor();
                    }
                }
                PartnerRoleConfig c = new PartnerRoleConfig(g, invoke.getUsePeer2Peer());
                if (log.isDebugEnabled()) {
                    log.debug("PartnerRoleConfig for " + plinkName + " " + c.failureHandling + " usePeer2Peer: " + c.usePeer2Peer);
                }
                partnerRoleConfigurations.put(plinkName, c);
            }
        }
    }
    if (processInfo.getProvideList() != null) {
        for (TProvide proivde : processInfo.getProvideList()) {
            String plinkName = proivde.getPartnerLink();
            TService service = proivde.getService();
            if (proivde.getCorrelationFilter() != null) {
                if (B4P_NAMESPACE.equals(proivde.getCorrelationFilter().getNamespaceURI())) {
                    isB4PTaskIncluded = true;
                }
            }
            /* NOTE:Service cannot be null for provider partner link*/
            if (service == null) {
                String errorMsg = "Error in <provide> element for process " + processInfo.getName() + ";partnerlink" + plinkName + "did not identify an endpoint";
                log.error(errorMsg);
                throw new ContextException(errorMsg);
            }
            if (log.isDebugEnabled()) {
                log.debug("Processing <provide> element for process " + processInfo.getName() + ": partnerlink " + plinkName + " --> " + service.getName() + " : " + service.getPort());
            }
            QName serviceName = service.getName();
            /* Validating configuration with package content before putting myRole endpoints to map */
            Definition wsdlDef = getDefinitionForService(serviceName);
            if (wsdlDef == null) {
                String errMsg = "Cannot find WSDL definition for provide service " + serviceName + ". Required resources not found in the BPEL " + "package " + du.getName() + ".";
                log.error(errMsg);
                throw new ContextException(errMsg);
            }
            Service serviceDef = wsdlDef.getService(serviceName);
            if (serviceDef.getPort(service.getPort()) == null) {
                String errMsg = "Cannot find provide port in the given service " + serviceName + ". Error in deploy.xml.";
                log.error(errMsg);
                throw new ContextException(errMsg);
            }
            myRoleEndpoints.put(plinkName, new Endpoint(service.getName(), service.getPort()));
            if (proivde.isSetEnableSharing()) {
                sharedServices.add(service.getName());
            }
        }
    }
}
Also used : Endpoint(org.apache.ode.bpel.iapi.Endpoint) UnifiedEndpoint(org.wso2.carbon.unifiedendpoint.core.UnifiedEndpoint) OFailureHandling(org.apache.ode.bpel.o.OFailureHandling) QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) Service(javax.wsdl.Service) TService(org.apache.ode.bpel.dd.TService) TProvide(org.apache.ode.bpel.dd.TProvide) TInvoke(org.apache.ode.bpel.dd.TInvoke) TService(org.apache.ode.bpel.dd.TService) ContextException(org.apache.ode.bpel.iapi.ContextException) OFailureHandling(org.apache.ode.bpel.o.OFailureHandling)

Example 7 with TProvide

use of org.apache.ode.bpel.dd.TProvide in project carbon-business-process by wso2.

the class TenantProcessStoreImpl method validateBPELPackage.

private boolean validateBPELPackage(BPELDeploymentContext bpelDeploymentContext, boolean isExistingPackage) {
    DeploymentUnitDir du;
    try {
        du = new DeploymentUnitDir(bpelDeploymentContext.getBPELPackageContent());
    } catch (IllegalArgumentException e) {
        bpelDeploymentContext.setDeploymentFailureCause(e.getMessage());
        bpelDeploymentContext.setStackTrace(e);
        return false;
    }
    if (!isExistingPackage) {
        DeployDocument deployDocument = du.getDeploymentDescriptor();
        List<TDeployment.Process> processList = deployDocument.getDeploy().getProcessList();
        for (TDeployment.Process process : processList) {
            List<TProvide> provideList = process.getProvideList();
            for (TProvide provide : provideList) {
                if (getDeployedServices().containsKey(provide.getService().getName())) {
                    String errMsg = "Service: " + provide.getService().getName() + " already " + "used by another process. Try again with a different " + "service name";
                    bpelDeploymentContext.setDeploymentFailureCause(errMsg);
                    return false;
                }
            }
        }
    }
    return true;
}
Also used : DeployDocument(org.apache.ode.bpel.dd.DeployDocument) DeploymentUnitDir(org.apache.ode.store.DeploymentUnitDir) TProvide(org.apache.ode.bpel.dd.TProvide) TDeployment(org.apache.ode.bpel.dd.TDeployment)

Aggregations

TProvide (org.apache.ode.bpel.dd.TProvide)7 QName (javax.xml.namespace.QName)5 TInvoke (org.apache.ode.bpel.dd.TInvoke)5 TDeployment (org.apache.ode.bpel.dd.TDeployment)4 DeployDocument (org.apache.ode.bpel.dd.DeployDocument)3 File (java.io.File)2 Service (javax.wsdl.Service)2 TService (org.apache.ode.bpel.dd.TService)2 DeploymentUnitDir (org.apache.ode.store.DeploymentUnitDir)2 SOAPAddressImpl (com.ibm.wsdl.extensions.soap.SOAPAddressImpl)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Definition (javax.wsdl.Definition)1 Port (javax.wsdl.Port)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 OMElement (org.apache.axiom.om.OMElement)1 AxisFault (org.apache.axis2.AxisFault)1