Search in sources :

Example 6 with ContextException

use of org.apache.ode.bpel.iapi.ContextException 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 ContextException

use of org.apache.ode.bpel.iapi.ContextException in project carbon-business-process by wso2.

the class TenantProcessStoreImpl method deployBPELPackageInODE.

/**
 * Deploy BPEL package in ODE and add process configuration objects to necessary maps in process
 * store.
 *
 * @param deploymentContext information about current deployment
 * @throws Exception in case of duplicate deployment unit or if error occurred during deploying package in ODE
 */
private void deployBPELPackageInODE(BPELDeploymentContext deploymentContext) throws Exception {
    File bpelPackage = deploymentContext.getBPELPackageContent();
    log.info("Starting deployment of processes from directory " + bpelPackage.getAbsolutePath());
    final Date deployDate = new Date();
    // Create the DU and compile/scan it before doing any other work.
    final DeploymentUnitDir deploymentUnitDir = new DeploymentUnitDir(bpelPackage);
    // Before coming to this stage, we create the bpel package directory with the static version
    // so we don't need to get the version from database. We can directly use static version
    // calculated from bpel package directory name.
    deploymentUnitDir.setVersion(deploymentUnitDir.getStaticVersion());
    try {
        deploymentUnitDir.compile();
    } catch (CompilationException ce) {
        String logMessage = "Deployment failed due to compilation issues. " + ce.getMessage();
        log.error(logMessage, ce);
        deploymentContext.setFailed(true);
        deploymentContext.setDeploymentFailureCause(logMessage);
        deploymentContext.setStackTrace(ce);
        handleDeploymentError(deploymentContext);
        throw new BPELDeploymentException(logMessage, ce);
    }
    deploymentUnitDir.scan();
    DeployDocument deployDocument = deploymentUnitDir.getDeploymentDescriptor();
    List<ProcessConfigurationImpl> processConfs = new ArrayList<ProcessConfigurationImpl>();
    List<QName> processIds = new ArrayList<QName>();
    if (deploymentUnits.containsKey(deploymentUnitDir.getName())) {
        String logMessage = "Aborting deployment. Duplicate Deployment unit " + deploymentUnitDir.getName() + ".";
        log.error(logMessage);
        deploymentContext.setFailed(true);
        deploymentContext.setDeploymentFailureCause(logMessage);
        handleDeploymentError(deploymentContext);
        throw new BPELDeploymentException(logMessage);
    }
    // Validate BPEL package partially before retiring old versions.
    validateBPELPackage(deploymentUnitDir);
    if (deploymentContext.isExistingPackage()) {
        reloadExistingVersionsOfBPELPackage(deploymentContext);
    }
    // Before updating a BPEL package we need to retire processes in old version
    retirePreviousPackageVersions(deploymentUnitDir);
    for (TDeployment.Process processDD : deployDocument.getDeploy().getProcessList()) {
        QName processId = Utils.toPid(processDD.getName(), deploymentUnitDir.getVersion());
        ProcessConfigurationImpl processConf = new ProcessConfigurationImpl(tenantId, processDD, deploymentUnitDir, deployDate, parentProcessStore.getEndpointReferenceContext(), tenantConfigContext);
        processConf.setAbsolutePathForBpelArchive(deploymentContext.getBpelArchive().getAbsolutePath());
        processIds.add(processId);
        processConfs.add(processConf);
        readAnalyticsServerProfiles(processDD, deploymentUnitDir);
    }
    deploymentUnits.put(deploymentUnitDir.getName(), deploymentUnitDir);
    processesInDeploymentUnit.put(deploymentUnitDir.getName(), processIds);
    for (ProcessConfigurationImpl processConf : processConfs) {
        processConfigMap.put(processConf.getProcessId(), processConf);
        deploymentContext.addProcessId(processConf.getProcessId());
    }
    try {
        parentProcessStore.onBPELPackageDeployment(tenantId, deploymentUnitDir.getName(), BPELPackageRepositoryUtils.getResourcePathForBPELPackageContent(deploymentContext), processConfs);
    } catch (ContextException ce) {
        deploymentContext.setDeploymentFailureCause("BPEL Package deployment failed at " + "ODE layer. Possible cause: " + ce.getMessage());
        deploymentContext.setStackTrace(ce);
        deploymentContext.setFailed(true);
        handleDeploymentError(deploymentContext);
        throw ce;
    }
}
Also used : CompilationException(org.apache.ode.bpel.compiler.api.CompilationException) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) DeploymentUnitDir(org.apache.ode.store.DeploymentUnitDir) Date(java.util.Date) TDeployment(org.apache.ode.bpel.dd.TDeployment) ContextException(org.apache.ode.bpel.iapi.ContextException) DeployDocument(org.apache.ode.bpel.dd.DeployDocument) File(java.io.File)

Example 8 with ContextException

use of org.apache.ode.bpel.iapi.ContextException in project carbon-business-process by wso2.

the class ProcessStoreImpl method setState.

public void setState(final QName pid, final ProcessState processState) {
    validateMethodParameters(pid, processState);
    final String duName = getDeploymentUnitForProcess(pid);
    validateDeploymentUnitForTheProcess(duName, pid);
    ProcessState old = exec(new Callable<ProcessState>() {

        public ProcessState call(ConfStoreConnection conn) {
            DeploymentUnitDAO duDao = conn.getDeploymentUnit(duName);
            if (duDao == null) {
                String errMsg = "Deployment unit " + duName + " not found.";
                log.error(errMsg);
                throw new ContextException(errMsg);
            }
            ProcessConfDAO pConfDao = duDao.getProcess(pid);
            if (pConfDao == null) {
                String errMsg = "Process " + pid + " not found in deployment unit " + duName + ".";
                log.error(errMsg);
                throw new ContextException(errMsg);
            }
            ProcessState old = pConfDao.getState();
            pConfDao.setState(processState);
            return old;
        }
    });
    ProcessConfigurationImpl pConf = (ProcessConfigurationImpl) getProcessConfiguration(pid);
    pConf.setState(processState);
    if (old != null && !old.equals(processState)) {
        fireStateChange(pid, processState, duName);
    }
}
Also used : ProcessState(org.apache.ode.bpel.iapi.ProcessState) DeploymentUnitDAO(org.apache.ode.store.DeploymentUnitDAO) ConfStoreConnection(org.apache.ode.store.ConfStoreConnection) ProcessConfDAO(org.apache.ode.store.ProcessConfDAO) ContextException(org.apache.ode.bpel.iapi.ContextException)

Aggregations

ContextException (org.apache.ode.bpel.iapi.ContextException)8 Definition (javax.wsdl.Definition)3 File (java.io.File)2 QName (javax.xml.namespace.QName)2 ProcessConf (org.apache.ode.bpel.iapi.ProcessConf)2 ProcessStore (org.apache.ode.bpel.iapi.ProcessStore)2 ConfStoreConnection (org.apache.ode.store.ConfStoreConnection)2 DeploymentUnitDAO (org.apache.ode.store.DeploymentUnitDAO)2 DeploymentUnitDir (org.apache.ode.store.DeploymentUnitDir)2 ProcessConfDAO (org.apache.ode.store.ProcessConfDAO)2 TenantProcessStore (org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStore)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Service (javax.wsdl.Service)1 AxisFault (org.apache.axis2.AxisFault)1 DeploymentException (org.apache.axis2.deployment.DeploymentException)1 CompilationException (org.apache.ode.bpel.compiler.api.CompilationException)1 DeployDocument (org.apache.ode.bpel.dd.DeployDocument)1 TDeployment (org.apache.ode.bpel.dd.TDeployment)1