Search in sources :

Example 6 with RegistryException

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

the class BPELPackageRepository method getVersionsOfPackage.

private List<String> getVersionsOfPackage(String packageLocation) throws RegistryException {
    List<String> versions = new ArrayList<String>();
    String versionsLocation = packageLocation + BPELConstants.BPEL_PACKAGE_VERSIONS;
    // version
    if (configRegistry.resourceExists(versionsLocation)) {
        Resource versionsResource = configRegistry.get(versionsLocation);
        // The above registry resource we retrieve only contains set of child collections.
        // So we can directly cast the returned object to a string array.
        String[] children = (String[]) versionsResource.getContent();
        for (String child : children) {
            versions.add(child.substring(child.lastIndexOf("/") + 1));
        }
        Collections.sort(versions, Utils.BY_VERSION);
    }
    return versions;
}
Also used : ArrayList(java.util.ArrayList) Resource(org.wso2.carbon.registry.core.Resource)

Example 7 with RegistryException

use of org.wso2.carbon.registry.core.exceptions.RegistryException 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)

Example 8 with RegistryException

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

the class TenantProcessStoreImpl method findBPELPackageInFileSystem.

private File findBPELPackageInFileSystem(DeploymentUnitDAO dudao) {
    String duName = dudao.getName();
    // Done: Fix the logic to handle registry
    log.info("Looking for BPEL package in file system for deployment unit " + duName);
    File bpelDUDirectory = new File(bpelDURepo, duName);
    if (bpelDUDirectory.exists()) {
        return bpelDUDirectory;
    } else {
        String registryCollectionPath = dudao.getDeploymentUnitDir();
        try {
            if (tenantConfigRegistry.resourceExists(registryCollectionPath)) {
                if (!bpelDUDirectory.exists() && !bpelDUDirectory.mkdirs()) {
                    String errMsg = "Error creating BPEL deployment unit repository for " + "tenant " + tenantId;
                    log.error(errMsg);
                    log.error("Failed to load BPEL deployment unit " + duName + " due to above error.");
                    throw new BPELDeploymentException(errMsg);
                }
                boolean deployedOnCarbon310 = false;
                // Check whether the registry repo is of type carbon 3.1.0
                if (tenantConfigRegistry.resourceExists(registryCollectionPath + RegistryConstants.PATH_SEPARATOR + duName)) {
                    registryCollectionPath += RegistryConstants.PATH_SEPARATOR + duName;
                    deployedOnCarbon310 = true;
                    if (log.isDebugEnabled()) {
                        log.debug("Found a carbon 3.1.0 compatible deployment unit at " + registryCollectionPath);
                    }
                }
                RegistryClientUtils.exportFromRegistry(bpelDUDirectory, registryCollectionPath, tenantConfigRegistry);
                if (deployedOnCarbon310) {
                    if (log.isDebugEnabled()) {
                        log.debug("Recompiling the carbon 3.1.0 compatible deployment unit at " + bpelDUDirectory);
                    }
                    // Re-compiling to get rid of binary compatibility issues.
                    DeploymentUnitDir du = new DeploymentUnitDir(bpelDUDirectory);
                    for (File file : du.allFiles()) {
                        if (file.getAbsolutePath().endsWith(".cbp") && !file.delete()) {
                            log.warn("Unable to delete " + file);
                        }
                    }
                    du.compile();
                }
                return bpelDUDirectory;
            } else {
                String errMsg = "Expected resource: " + registryCollectionPath + " not found in the registry";
                log.error(errMsg);
                throw new BPELDeploymentException(errMsg);
            }
        } catch (RegistryException re) {
            String errMsg = "Error while exporting deployment unit: " + duName + " to file system from the registry.";
            log.error(errMsg, re);
            throw new BPELDeploymentException(errMsg, re);
        }
    }
}
Also used : DeploymentUnitDir(org.apache.ode.store.DeploymentUnitDir) File(java.io.File) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException)

Example 9 with RegistryException

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

the class EndpointConfiguration method getEndpointElementFromRegistry.

private OMElement getEndpointElementFromRegistry(String uepConfPath) throws AxisFault {
    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    RegistryService registryService = BPELCommonServiceComponent.getRegistryService();
    Registry registry = null;
    OMElement uepOMContent = null;
    String location;
    try {
        if (uepConfPath.startsWith(UnifiedEndpointConstants.VIRTUAL_CONF_REG)) {
            registry = registryService.getConfigSystemRegistry(tenantId);
            location = uepConfPath.substring(uepConfPath.indexOf(UnifiedEndpointConstants.VIRTUAL_CONF_REG) + UnifiedEndpointConstants.VIRTUAL_CONF_REG.length());
            uepOMContent = loadUEPOMFromRegistry(registry, location);
        } else if (uepConfPath.startsWith(UnifiedEndpointConstants.VIRTUAL_GOV_REG)) {
            registry = registryService.getGovernanceSystemRegistry(tenantId);
            location = uepConfPath.substring(uepConfPath.indexOf(UnifiedEndpointConstants.VIRTUAL_GOV_REG) + UnifiedEndpointConstants.VIRTUAL_GOV_REG.length());
            uepOMContent = loadUEPOMFromRegistry(registry, location);
        } else if (uepConfPath.startsWith(UnifiedEndpointConstants.VIRTUAL_REG)) {
            registry = registryService.getLocalRepository(tenantId);
            location = uepConfPath.substring(uepConfPath.indexOf(UnifiedEndpointConstants.VIRTUAL_REG) + UnifiedEndpointConstants.VIRTUAL_REG.length());
            uepOMContent = loadUEPOMFromRegistry(registry, location);
        }
    } catch (RegistryException ex) {
        String error = "Error occurred while getting registry service" + ex.getLocalizedMessage();
        handleError(error);
    }
    return uepOMContent;
}
Also used : OMElement(org.apache.axiom.om.OMElement) Registry(org.wso2.carbon.registry.core.Registry) RegistryService(org.wso2.carbon.registry.core.service.RegistryService) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) UnifiedEndpoint(org.wso2.carbon.unifiedendpoint.core.UnifiedEndpoint)

Example 10 with RegistryException

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

the class HumanTaskDeployer method init.

public void init(ConfigurationContext configurationContext) {
    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    log.info("Initializing HumanTask Deployer for tenant " + tenantId + ".");
    try {
        HumanTaskDeployerServiceComponent.getTenantRegistryLoader().loadTenantRegistry(tenantId);
        createHumanTaskRepository(configurationContext);
        HumanTaskServer humantaskServer = HumanTaskDeployerServiceComponent.getHumanTaskServer();
        humanTaskStore = humantaskServer.getTaskStoreManager().createHumanTaskStoreForTenant(tenantId, configurationContext);
    } catch (DeploymentException e) {
        log.warn(String.format("Human Task Repository creation failed for tenant id [%d]", tenantId), e);
    } catch (RegistryException e) {
        log.warn("Initializing HumanTask Deployer failed for tenant " + tenantId, e);
    }
}
Also used : HumanTaskServer(org.wso2.carbon.humantask.core.HumanTaskServer) DeploymentException(org.apache.axis2.deployment.DeploymentException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException)

Aggregations

RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)235 Resource (org.wso2.carbon.registry.core.Resource)196 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)167 UserRegistry (org.wso2.carbon.registry.core.session.UserRegistry)145 GenericArtifact (org.wso2.carbon.governance.api.generic.dataobjects.GenericArtifact)104 Registry (org.wso2.carbon.registry.core.Registry)95 Test (org.junit.Test)81 GenericArtifactManager (org.wso2.carbon.governance.api.generic.GenericArtifactManager)81 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)75 APIProductResource (org.wso2.carbon.apimgt.api.model.APIProductResource)70 APIIdentifier (org.wso2.carbon.apimgt.api.model.APIIdentifier)67 APIPersistenceException (org.wso2.carbon.apimgt.persistence.exceptions.APIPersistenceException)61 UserStoreException (org.wso2.carbon.user.api.UserStoreException)60 API (org.wso2.carbon.apimgt.api.model.API)58 IOException (java.io.IOException)57 ArrayList (java.util.ArrayList)55 QName (javax.xml.namespace.QName)42 APIResource (org.wso2.carbon.apimgt.api.doc.model.APIResource)40 SubscribedAPI (org.wso2.carbon.apimgt.api.model.SubscribedAPI)40 GovernanceException (org.wso2.carbon.governance.api.exception.GovernanceException)40