Search in sources :

Example 51 with Registry

use of org.wso2.carbon.registry.core.Registry in project carbon-business-process by wso2.

the class BPELPackageRepository method createCollectionWithBPELPackageWithoutContentForCurrentVersion.

/**
 * This repository persist the BPEL package versions inside the BPEL Package collection
 * under the child collection 'versions'. The collection name is same as directory with version
 * attached to it's name(Example: HelloWorld-3).
 * <p/>
 * For the 'HelloWorld' BPEL package, extracted BPEL package will be stored in a registry
 * location like '<config_registry_root>/bpel/packages/HelloWorld/versions/HelloWorld-3'.
 *
 * @param deploymentContext containing information on current BPEL deployment.
 * @throws RegistryException if an error occurred during import of file system content to
 *                           registry.
 */
private void createCollectionWithBPELPackageWithoutContentForCurrentVersion(BPELDeploymentContext deploymentContext) throws RegistryException {
    String collectionLocation = BPELPackageRepositoryUtils.getResourcePathForBPELPackageContent(deploymentContext);
    Collection collection = configRegistry.newCollection();
    configRegistry.put(collectionLocation, collection);
}
Also used : Collection(org.wso2.carbon.registry.core.Collection)

Example 52 with Registry

use of org.wso2.carbon.registry.core.Registry 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 53 with Registry

use of org.wso2.carbon.registry.core.Registry in project carbon-business-process by wso2.

the class TenantProcessStoreImpl method handleUndeployOnSlaveNode.

/**
 * Undeployment scenario in a worker node( Slave ) in the clustered setup
 * When the BPELDeployer get called for undeploying the bpel package, following has already taken place.
 * The package information stored in the registry as well as the zip archive is deleted
 * Process, Instance information have been removed from the ODE database
 * However, on the slave node, the bpel process and the web services associated with the bpel process
 * is still in memory. We need to unload the bpel process and the associated web services
 *
 * @param bpelPackageName bpel package name
 * @return
 */
private int handleUndeployOnSlaveNode(String bpelPackageName) {
    List<String> packageList = findMatchingProcessByPackageName(bpelPackageName);
    if (packageList.size() < 1) {
        log.debug("Handling un-deploy operation on salve (worker) node : package list is empty");
        return -1;
    }
    for (String packageName : packageList) {
        // location for extracted BPEL package
        String bpelPackageLocation = parentProcessStore.getLocalDeploymentUnitRepo().getAbsolutePath() + File.separator + tenantId + File.separator + packageName;
        File bpelPackage = new File(bpelPackageLocation);
        // removing extracted bpel package at repository/bpel/tenantID/
        deleteBpelPackageFromRepo(bpelPackage);
        for (QName pid : getProcessesInPackage(packageName)) {
            ProcessConfigurationImpl processConf = (ProcessConfigurationImpl) getProcessConfiguration(pid);
            // This property is read when we removing the axis service for this process.
            // So that we can decide whether we should persist service QOS configs
            processConf.setUndeploying(true);
        }
    }
    Collection<QName> undeployedProcesses = new ArrayList<QName>();
    for (String nameWithVersion : packageList) {
        undeploySpecificVersionOfBPELPackage(nameWithVersion, undeployedProcesses);
    }
    BPELServerImpl instance = BPELServerImpl.getInstance();
    BpelServerImpl odeBpelServer = instance.getODEBPELServer();
    for (QName pid : undeployedProcesses) {
        odeBpelServer.unregister(pid);
        ProcessConf pConf = parentProcessStore.getProcessConfiguration(pid);
        if (pConf != null) {
            if (log.isDebugEnabled()) {
                log.debug("Cancelling all cron scheduled jobs for process " + pid);
            }
            odeBpelServer.getContexts().cronScheduler.cancelProcessCronJobs(pid, true);
        }
        log.info("Process " + pid + " un-deployed.");
    }
    parentProcessStore.updateProcessAndDUMapsForSalve(tenantId, bpelPackageName, undeployedProcesses);
    return 0;
}
Also used : BpelServerImpl(org.apache.ode.bpel.engine.BpelServerImpl) QName(javax.xml.namespace.QName) BPELServerImpl(org.wso2.carbon.bpel.core.ode.integration.BPELServerImpl) ProcessConf(org.apache.ode.bpel.iapi.ProcessConf) ArrayList(java.util.ArrayList) File(java.io.File)

Example 54 with Registry

use of org.wso2.carbon.registry.core.Registry in project carbon-business-process by wso2.

the class TenantProcessStoreImpl method reloadExistingVersionsOfBPELPackage.

/**
 * Reload old versions of BPEL package. This is used to handle restart of BPS server.
 * At restart based on the last modified time of the BPEL archives we'll reload all the versions
 * of that BPEL archive.
 *
 * @param deploymentContext information about current deployment
 * @throws RegistryException                                                                     on error loading
 * resources from registry.
 * @throws org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.ProcessManagementException
 */
private void reloadExistingVersionsOfBPELPackage(BPELDeploymentContext deploymentContext) throws RegistryException, ProcessManagementException {
    BPELPackageInfo bpelPackage = repository.getBPELPackageInfo(deploymentContext);
    String lastActivePackageName = null;
    for (String packageName : bpelPackage.getAvailableVersions()) {
        if (deploymentUnits.containsKey(packageName)) {
            lastActivePackageName = packageName;
        } else {
            // version of the package
            if (null != lastActivePackageName && isConfigRegistryReadOnly()) {
                loadExistingBPELPackage(lastActivePackageName);
            }
            loadExistingBPELPackage(packageName);
        }
    }
}
Also used : BPELPackageInfo(org.wso2.carbon.bpel.core.ode.integration.store.repository.BPELPackageInfo)

Example 55 with Registry

use of org.wso2.carbon.registry.core.Registry in project ballerina by ballerina-lang.

the class CodeGenerator method createStringLiteral.

/**
 * Creates a string literal expression, generate the code and returns the registry index.
 *
 * @param value    String value to generate the string literal
 * @param regIndex String literal expression's reg index
 * @param env      Environment
 * @return String registry index of the generated string
 */
private RegIndex createStringLiteral(String value, RegIndex regIndex, SymbolEnv env) {
    BLangLiteral prefixLiteral = (BLangLiteral) TreeBuilder.createLiteralExpression();
    prefixLiteral.value = value;
    prefixLiteral.typeTag = TypeTags.STRING;
    prefixLiteral.type = symTable.stringType;
    prefixLiteral.regIndex = regIndex;
    genNode(prefixLiteral, env);
    return prefixLiteral.regIndex;
}
Also used : BLangLiteral(org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral)

Aggregations

RegistryException (org.wso2.carbon.registry.api.RegistryException)18 Registry (org.wso2.carbon.registry.api.Registry)12 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)12 Resource (org.wso2.carbon.registry.api.Resource)10 File (java.io.File)8 IOException (java.io.IOException)8 Resource (org.wso2.carbon.registry.core.Resource)8 OMElement (org.apache.axiom.om.OMElement)7 ScriptException (org.jaggeryjs.scriptengine.exceptions.ScriptException)7 Collection (org.wso2.carbon.registry.core.Collection)7 ArrayList (java.util.ArrayList)5 FileNotFoundException (java.io.FileNotFoundException)4 QName (javax.xml.namespace.QName)4 XMLStreamException (javax.xml.stream.XMLStreamException)4 RegistryService (org.wso2.carbon.registry.api.RegistryService)4 ResourceData (org.wso2.carbon.registry.common.ResourceData)4 RegistryService (org.wso2.carbon.registry.core.service.RegistryService)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 FileInputStream (java.io.FileInputStream)3 ProcessEngine (org.activiti.engine.ProcessEngine)3