Search in sources :

Example 1 with BPELUIException

use of org.wso2.carbon.bpel.core.ode.integration.store.BPELUIException in project carbon-business-process by wso2.

the class TenantProcessStoreImpl method undeploy.

/**
 * Undeploying BPEL package.
 *
 * @param bpelPackageName Name of the BPEL package which going to be undeployed
 */
public void undeploy(String bpelPackageName) throws RegistryException, BPELUIException {
    if (log.isDebugEnabled()) {
        log.debug("Un-deploying BPEL package " + bpelPackageName + " ....");
    }
    if (!repository.isExistingBPELPackage(bpelPackageName)) {
        // This can be a situation where we un-deploy the archive through management console,
        // so that, the archive is deleted from the repo. As a result this method get invoked.
        // to handle this case we just log the message but does not throw an exception.
        final String warningMsg = "Cannot find BPEL package with name " + bpelPackageName + " in the repository. If the bpel package is un-deployed through the management" + " console or if this node is a member of a cluster, please ignore this warning.";
        if (isConfigRegistryReadOnly()) {
            // This is for the deployment synchronizer scenarios where package un-deployment on a worker node
            // has to remove the deployed bpel package from the memory and remove associated services
            handleUndeployOnSlaveNode(bpelPackageName);
        } else {
            log.warn(warningMsg);
        }
        return;
    }
    if (repository.isExistingBPELPackage(bpelPackageName) && isConfigRegistryReadOnly()) {
        log.warn("This node seems to be a slave, since the configuration registry is in read-only mode, hence " + "processes cannot be directly undeployed from this node. Please undeploy the process in Master " + "node first.");
        return;
    }
    List<String> versionsOfThePackage;
    try {
        versionsOfThePackage = repository.getAllVersionsForPackage(bpelPackageName);
    } catch (RegistryException re) {
        String errMessage = "Cannot get all versions of the package " + bpelPackageName + " from registry.";
        log.error(errMessage);
        throw re;
    }
    // check the instance count to be deleted
    long instanceCount = getInstanceCountForPackage(versionsOfThePackage);
    if (instanceCount > BPELServerImpl.getInstance().getBpelServerConfiguration().getBpelInstanceDeletionLimit()) {
        throw new BPELUIException("Instance deletion limit reached.");
    }
    for (String nameWithVersion : versionsOfThePackage) {
        parentProcessStore.deleteDeploymentUnitDataFromDB(nameWithVersion);
        Utils.deleteInstances(getProcessesInPackage(nameWithVersion));
        // location for extracted BPEL package
        String bpelPackageLocation = parentProcessStore.getLocalDeploymentUnitRepo().getAbsolutePath() + File.separator + tenantId + File.separator + nameWithVersion;
        File bpelPackage = new File(bpelPackageLocation);
        // removing extracted bpel package at repository/bpel/0/
        deleteBpelPackageFromRepo(bpelPackage);
        for (QName pid : getProcessesInPackage(nameWithVersion)) {
            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);
        }
    }
    try {
        repository.handleBPELPackageUndeploy(bpelPackageName);
    } catch (RegistryException re) {
        String errMessage = "Cannot update the BPEL package repository for undeployment of" + "package " + bpelPackageName + ".";
        log.error(errMessage);
        throw re;
    }
    updateLocalInstanceWithUndeployment(bpelPackageName, versionsOfThePackage);
// We should use the deployment synchronizer, instead of the code below.
// parentProcessStore.sendProcessDeploymentNotificationsToCluster(
// new BPELPackageUndeployedCommand(versionsOfThePackage, bpelPackageName, tenantId),
// configurationContext);
}
Also used : QName(javax.xml.namespace.QName) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) File(java.io.File)

Aggregations

File (java.io.File)1 QName (javax.xml.namespace.QName)1 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)1