Search in sources :

Example 1 with DeployDocument

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

the class BPELUploadExecutor method validateBPELPackage.

public void validateBPELPackage(String directoryPath) throws Exception {
    DeploymentUnitDir du;
    try {
        du = new DeploymentUnitDir(new File(directoryPath));
    } catch (IllegalArgumentException iae) {
        log.error("BPEL Package Validation Failure.", iae);
        throw new Exception("BPEL Package Validation Failure.", iae);
    }
    // check package for illegal charactors which registry does not support. (~!@#$;%^*()+={}[]|\<>)
    List<File> packageFiles = du.allFiles();
    for (File packageFile : packageFiles) {
        if (!packageFile.getName().matches("[^\\~\\!\\@\\#\\$\\;\\%\\^\\*\\(\\)\\+ " + "/\\=\\{\\}\\[\\]\\\\|\\<\\>\"\\'\\`]+")) {
            log.error("BPEL Package Validation Failure: one or many of the following illegal characters are in " + "the package.\n ~!@#$;%^*()+={}[]| \\<>\"'`");
            throw new Exception("BPEL Package Validation Failure: one or many of the following illegal characters" + " " + "are in the package. ~!@#$;%^*()+={}[]| \\<>\"'`");
        }
    }
    try {
        du.compile();
    } catch (RuntimeException ce) {
        log.error("BPEL Process Compilation Failure.", ce);
        throw new Exception("BPEL Compilation Failure!", ce);
    } catch (Exception e) {
        log.error("BPEL Process Compilation Failure.", e);
        throw new Exception("BPEL Compilation Failure!", e);
    }
    du.scan();
    DeployDocument dd = du.getDeploymentDescriptor();
    for (TDeployment.Process processDD : dd.getDeploy().getProcessList()) {
        QName processType = processDD.getType() != null ? processDD.getType() : processDD.getName();
        DeploymentUnitDir.CBPInfo cbpInfo = du.getCBPInfo(processType);
        if (cbpInfo == null) {
            // removeDeploymentArtifacts(deploymentContext, du);
            String logMessage = "Aborting deployment. Cannot find Process definition for type " + processType + ".";
            log.error(logMessage);
            throw new Exception(logMessage);
        }
        for (TProvide tProvide : processDD.getProvideList()) {
            if (tProvide.getService() == null) {
                String errMsg = "Service element missing for the provide element in deploy.xml";
                log.error(errMsg);
                throw new Exception(errMsg);
            }
        }
        for (TInvoke tInvoke : processDD.getInvokeList()) {
            if (tInvoke.getService() == null) {
                String errMsg = "Service element missing for the invoke element in deploy.xml";
                log.error(errMsg);
                throw new Exception(errMsg);
            }
        }
    }
}
Also used : QName(javax.xml.namespace.QName) DeploymentUnitDir(org.apache.ode.store.DeploymentUnitDir) IOException(java.io.IOException) CarbonException(org.wso2.carbon.CarbonException) TDeployment(org.apache.ode.bpel.dd.TDeployment) TInvoke(org.apache.ode.bpel.dd.TInvoke) DeployDocument(org.apache.ode.bpel.dd.DeployDocument) TProvide(org.apache.ode.bpel.dd.TProvide) File(java.io.File)

Example 2 with DeployDocument

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

the class PeopleActivity method deriveServiceEPR.

private void deriveServiceEPR(DeploymentUnitDir du, ExtensionContext extensionContext) throws FaultException {
    DeployDocument deployDocument = du.getDeploymentDescriptor();
    BpelRuntimeContext runTimeContext = extensionContext.getInternalInstance();
    // TODO neeed to extend ExtentionContext
    OProcess oProcess = runTimeContext.getProcessModel();
    TDeployment.Process hiProcess = null;
    List<TDeployment.Process> processList = deployDocument.getDeploy().getProcessList();
    for (TDeployment.Process process : processList) {
        if (process.getName().equals(oProcess.getQName())) {
            hiProcess = process;
            break;
        }
    }
    if (hiProcess == null) {
        throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "Related process: " + oProcess.getQName() + " not found");
    }
    List<TInvoke> tInvokeList = hiProcess.getInvokeList();
    for (TInvoke tInvoke : tInvokeList) {
        if (tInvoke.getPartnerLink().equals(partnerLinkName)) {
            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(BPEL4PeopleConstants.B4P_FAULT, "Service or port for human interaction is not found in the deploy.xml");
    }
    // get the callback information for the TASK
    if (activityType.equals(InteractionType.TASK)) {
        List<TProvide> tProvideList = hiProcess.getProvideList();
        for (TProvide tProvide : tProvideList) {
            if (tProvide.getPartnerLink().equals(partnerLinkName)) {
                callbackServiceName = tProvide.getService().getName();
                callbackServicePort = tProvide.getService().getPort();
                break;
            }
        }
        if (callbackServiceName == null || callbackServicePort == null) {
            throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "Service or port for human task callback is not found in the deploy.xml");
        }
    }
    hiWSDL = du.getDefinitionForService(serviceName);
    Service service = hiWSDL.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(BPEL4PeopleConstants.B4P_FAULT, "Service URI is not available");
    }
}
Also used : SOAPAddressImpl(com.ibm.wsdl.extensions.soap.SOAPAddressImpl) OProcess(org.apache.ode.bpel.o.OProcess) Port(javax.wsdl.Port) Service(javax.wsdl.Service) OProcess(org.apache.ode.bpel.o.OProcess) TDeployment(org.apache.ode.bpel.dd.TDeployment) TInvoke(org.apache.ode.bpel.dd.TInvoke) FaultException(org.apache.ode.bpel.common.FaultException) DeployDocument(org.apache.ode.bpel.dd.DeployDocument) BpelRuntimeContext(org.apache.ode.bpel.runtime.BpelRuntimeContext) List(java.util.List) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) TProvide(org.apache.ode.bpel.dd.TProvide)

Example 3 with DeployDocument

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

the class TenantProcessStoreImpl method validateBPELPackage.

/**
 * Check whether processes in this package are already available in the process store or check
 * whether processes are correctly compiled.
 *
 * @param du BPEL deployment unit
 * @throws BPELDeploymentException if there's a error in BPEL package
 */
private void validateBPELPackage(DeploymentUnitDir du) throws BPELDeploymentException {
    DeployDocument dd = du.getDeploymentDescriptor();
    for (TDeployment.Process processDD : dd.getDeploy().getProcessList()) {
        QName processId = Utils.toPid(processDD.getName(), du.getVersion());
        if (processConfigMap.containsKey(processId)) {
            String logMessage = "Aborting deployment. Duplicate process ID " + processId + ".";
            log.error(logMessage);
            throw new BPELDeploymentException(logMessage);
        }
        QName processType = Utils.getProcessType(processDD);
        DeploymentUnitDir.CBPInfo cbpInfo = du.getCBPInfo(processType);
        if (cbpInfo == null) {
            // removeDeploymentArtifacts(deploymentContext, du);
            String logMessage = "Aborting deployment. Cannot find Process definition for type " + processType + ".";
            log.error(logMessage);
            throw new BPELDeploymentException(logMessage);
        }
    }
}
Also used : DeployDocument(org.apache.ode.bpel.dd.DeployDocument) QName(javax.xml.namespace.QName) DeploymentUnitDir(org.apache.ode.store.DeploymentUnitDir) TDeployment(org.apache.ode.bpel.dd.TDeployment)

Example 4 with DeployDocument

use of org.apache.ode.bpel.dd.DeployDocument 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)

Example 5 with DeployDocument

use of org.apache.ode.bpel.dd.DeployDocument 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)

Aggregations

DeployDocument (org.apache.ode.bpel.dd.DeployDocument)5 TDeployment (org.apache.ode.bpel.dd.TDeployment)5 DeploymentUnitDir (org.apache.ode.store.DeploymentUnitDir)4 QName (javax.xml.namespace.QName)3 TProvide (org.apache.ode.bpel.dd.TProvide)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 TInvoke (org.apache.ode.bpel.dd.TInvoke)2 SOAPAddressImpl (com.ibm.wsdl.extensions.soap.SOAPAddressImpl)1 IOException (java.io.IOException)1 Date (java.util.Date)1 List (java.util.List)1 Port (javax.wsdl.Port)1 Service (javax.wsdl.Service)1 FaultException (org.apache.ode.bpel.common.FaultException)1 CompilationException (org.apache.ode.bpel.compiler.api.CompilationException)1 ContextException (org.apache.ode.bpel.iapi.ContextException)1 OProcess (org.apache.ode.bpel.o.OProcess)1 BpelRuntimeContext (org.apache.ode.bpel.runtime.BpelRuntimeContext)1 NodeList (org.w3c.dom.NodeList)1