Search in sources :

Example 66 with PACKAGE

use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE in project carbon-business-process by wso2.

the class BPELApplicationAdmin method getBPELAppData.

/**
 * Gives a BPELAppMetadata object with all bpel packages deployed through the
 * given app.
 *
 * @param appName - input app name
 * @return - BPELAppMetadata object with found artifact info
 * @throws Exception - error on retrieving metadata
 */
public BPELAppMetadata getBPELAppData(String appName) throws Exception {
    BPELAppMetadata data = new BPELAppMetadata();
    String tenantId = AppDeployerUtils.getTenantIdString(getAxisConfig());
    // Check whether there is an application in the system from the given name
    ArrayList<CarbonApplication> appList = BPELAppMgtServiceComponent.getAppManager().getCarbonApps(tenantId);
    CarbonApplication currentApplication = null;
    for (CarbonApplication application : appList) {
        if (appName.equals(application.getAppNameWithVersion())) {
            currentApplication = application;
            break;
        }
    }
    // If the app not found, throw an exception
    if (currentApplication == null) {
        String msg = "No Carbon Application found of the name : " + appName;
        log.error(msg);
        throw new Exception(msg);
    }
    // get all dependent artifacts of the cApp
    List<Artifact.Dependency> deps = currentApplication.getAppConfig().getApplicationArtifact().getDependencies();
    // we use the bpel backend admin service to get processes from a bpel package
    BPELPackageManagementServiceSkeleton bpelAdmin = new BPELPackageManagementServiceSkeleton();
    // package list to return
    List<PackageMetadata> packageList = new ArrayList<PackageMetadata>();
    String packageName;
    String versionLessPackageName;
    Artifact artifact;
    for (Artifact.Dependency dep : deps) {
        artifact = dep.getArtifact();
        versionLessPackageName = artifact.getName() + "-" + artifact.getVersion();
        packageName = versionLessPackageName + "-" + bpelAdmin.getLatestVersionInPackage(versionLessPackageName);
        if (packageName == null) {
            continue;
        }
        if (BPELAppDeployer.BPEL_TYPE.equals(artifact.getType())) {
            PackageMetadata packageMetadata = new PackageMetadata();
            packageMetadata.setPackageName(packageName);
            // get the list of processes
            List<String> processList = new ArrayList<String>();
            PackageType packageType = bpelAdmin.listProcessesInPackage(packageName);
            for (Version_type0 packageVersion : packageType.getVersions().getVersion()) {
                if (packageVersion.getName().equals(packageName)) {
                    for (LimitedProcessInfoType process : packageVersion.getProcesses().getProcess()) {
                        processList.add(process.getPid());
                    }
                }
            }
            String[] processes = new String[processList.size()];
            packageMetadata.setProcessList(processList.toArray(processes));
            packageList.add(packageMetadata);
        }
    }
    // convert the List into an array
    data.setPackages(packageList.toArray(new PackageMetadata[packageList.size()]));
    return data;
}
Also used : Version_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Version_type0) ArrayList(java.util.ArrayList) CarbonApplication(org.wso2.carbon.application.deployer.CarbonApplication) LimitedProcessInfoType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.LimitedProcessInfoType) Artifact(org.wso2.carbon.application.deployer.config.Artifact) BPELPackageManagementServiceSkeleton(org.wso2.carbon.bpel.core.ode.integration.mgt.services.BPELPackageManagementServiceSkeleton) PackageType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.PackageType)

Example 67 with PACKAGE

use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE in project carbon-business-process by wso2.

the class BPELDeployer method undeploy.

public void undeploy(String bpelArchivePath) throws DeploymentException {
    File bpelArchiveFile = new File(bpelArchivePath);
    if (bpelArchiveFile.exists()) {
        if (log.isTraceEnabled()) {
            log.trace("Assumption: this as an update of the bpel package: " + bpelArchivePath + ", Therefore no need to do undeploy");
        }
        // here
        return;
    }
    log.info("Undeploying BPEL archive " + bpelArchivePath);
    try {
        String archiveName = bpelArchivePath.substring(bpelArchivePath.lastIndexOf(File.separator) + 1);
        String bpelPackageName = archiveName.substring(0, archiveName.lastIndexOf("." + BPELConstants.BPEL_PACKAGE_EXTENSION));
        tenantProcessStore.undeploy(bpelPackageName);
    } catch (Exception e) {
        String errMsg = "BPEL Package: " + bpelArchivePath + " undeployment failed.";
        log.error(errMsg, e);
        throw new DeploymentException(errMsg, e);
    }
}
Also used : DeploymentException(org.apache.axis2.deployment.DeploymentException) File(java.io.File) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) DeploymentException(org.apache.axis2.deployment.DeploymentException)

Example 68 with PACKAGE

use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE in project carbon-business-process by wso2.

the class BPELPackageManagementServiceSkeleton method listDeployedPackagesPaginated.

public DeployedPackagesPaginated listDeployedPackagesPaginated(int page, String packageSearchString) throws PackageManagementException {
    int tPage = page;
    List<BPELPackageInfo> packages;
    DeployedPackagesPaginated paginatedPackages = new DeployedPackagesPaginated();
    TenantProcessStoreImpl tenantProcessStore = getTenantProcessStore();
    BPELPackageRepository packageRepo = tenantProcessStore.getBPELPackageRepository();
    try {
        // Can return null and we should handle that
        packages = packageRepo.getBPELPackages();
    } catch (Exception e) {
        String errorMessage = "Cannot get the BPEL Package list from repository.";
        log.error(errorMessage, e);
        throw new PackageManagementException(errorMessage, e);
    }
    if (packages != null) {
        // Calculating pagination information
        if (tPage < 0 || tPage == Integer.MAX_VALUE) {
            tPage = 0;
        }
        int startIndex = tPage * BPELConstants.ITEMS_PER_PAGE;
        int endIndex = (tPage + 1) * BPELConstants.ITEMS_PER_PAGE;
        int numberOfPackages = packages.size();
        int totalPackages = 0;
        BPELPackageInfo[] packagesArray = packages.toArray(new BPELPackageInfo[numberOfPackages]);
        for (int i = 0; i < numberOfPackages; i++) {
            if (!packagesArray[i].getName().toLowerCase().contains(packageSearchString.toLowerCase())) {
                continue;
            }
            int count = getPackageVersionCount(packagesArray[i]);
            if (totalPackages + count > startIndex && totalPackages < endIndex) {
                // In-order to get the total number of packages count
                // if (totalPackages >= endIndex) {
                // break;
                // }
                int maxRemainingPackages = totalPackages < startIndex && (totalPackages + count) > startIndex ? startIndex - (totalPackages + count) : endIndex - totalPackages;
                PackageType packageType = getPackageInfo(packagesArray[i], maxRemainingPackages);
                paginatedPackages.add_package(packageType);
            }
            totalPackages += count;
        }
        int pages = (int) Math.ceil((double) totalPackages / BPELConstants.ITEMS_PER_PAGE);
        paginatedPackages.setPages(pages);
    } else {
        // Returning empty result set with pages equal to zero for cases where null is returned from
        // BPEL repo.
        paginatedPackages.setPages(0);
    }
    return paginatedPackages;
}
Also used : PackageType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.PackageType) DeployedPackagesPaginated(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.DeployedPackagesPaginated) BPELPackageRepository(org.wso2.carbon.bpel.core.ode.integration.store.repository.BPELPackageRepository) PackageManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.PackageManagementException) TenantProcessStoreImpl(org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl) PackageManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.PackageManagementException) BPELUIException(org.wso2.carbon.bpel.core.ode.integration.store.BPELUIException) BPELPackageInfo(org.wso2.carbon.bpel.core.ode.integration.store.repository.BPELPackageInfo)

Example 69 with PACKAGE

use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE in project carbon-business-process by wso2.

the class BPELPackageManagementServiceSkeleton method listProcessesInPackage.

public PackageType listProcessesInPackage(String packageName) throws PackageManagementException {
    TenantProcessStoreImpl tenantProcessStore = getTenantProcessStore();
    BPELPackageRepository packageRepo = tenantProcessStore.getBPELPackageRepository();
    try {
        return getPackageInfo(packageRepo.getBPELPackageInfoForPackage(packageName.substring(0, packageName.lastIndexOf("-"))));
    } catch (Exception e) {
        String errMsg = "BPEL package: " + packageName + " failed to load from registry.";
        log.error(errMsg, e);
        throw new PackageManagementException(errMsg, e);
    }
}
Also used : BPELPackageRepository(org.wso2.carbon.bpel.core.ode.integration.store.repository.BPELPackageRepository) PackageManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.PackageManagementException) TenantProcessStoreImpl(org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl) PackageManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.PackageManagementException) BPELUIException(org.wso2.carbon.bpel.core.ode.integration.store.BPELUIException)

Example 70 with PACKAGE

use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE in project carbon-business-process by wso2.

the class BPELPackageManagementServiceSkeleton method listDeployedPackagesPaginated.

public DeployedPackagesPaginated listDeployedPackagesPaginated(int page) throws PackageManagementException {
    int tPage = page;
    List<BPELPackageInfo> packages;
    DeployedPackagesPaginated paginatedPackages = new DeployedPackagesPaginated();
    TenantProcessStoreImpl tenantProcessStore = getTenantProcessStore();
    BPELPackageRepository packageRepo = tenantProcessStore.getBPELPackageRepository();
    try {
        // Can return null and we should handle that
        packages = packageRepo.getBPELPackages();
    } catch (Exception e) {
        String errorMessage = "Cannot get the BPEL Package list from repository.";
        log.error(errorMessage, e);
        throw new PackageManagementException(errorMessage, e);
    }
    if (packages != null) {
        // Calculating pagination information
        if (tPage < 0 || tPage == Integer.MAX_VALUE) {
            tPage = 0;
        }
        int startIndex = tPage * BPELConstants.ITEMS_PER_PAGE;
        int endIndex = (tPage + 1) * BPELConstants.ITEMS_PER_PAGE;
        int numberOfPackages = packages.size();
        int totalPackages = 0;
        BPELPackageInfo[] packagesArray = packages.toArray(new BPELPackageInfo[numberOfPackages]);
        for (int i = 0; i < numberOfPackages; i++) {
            int count = getPackageVersionCount(packagesArray[i]);
            if (totalPackages + count > startIndex && totalPackages < endIndex) {
                // In-order to get the total number of packages count
                // if (totalPackages >= endIndex) {
                // break;
                // }
                int maxRemainingPackages = totalPackages < startIndex && (totalPackages + count) > startIndex ? startIndex - (totalPackages + count) : endIndex - totalPackages;
                PackageType packageType = getPackageInfo(packagesArray[i], maxRemainingPackages);
                paginatedPackages.add_package(packageType);
            }
            totalPackages += count;
        }
        int pages = (int) Math.ceil((double) totalPackages / BPELConstants.ITEMS_PER_PAGE);
        paginatedPackages.setPages(pages);
    } else {
        // Returning empty result set with pages equal to zero for cases where null is returned from
        // BPEL repo.
        paginatedPackages.setPages(0);
    }
    return paginatedPackages;
}
Also used : PackageType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.PackageType) DeployedPackagesPaginated(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.DeployedPackagesPaginated) BPELPackageRepository(org.wso2.carbon.bpel.core.ode.integration.store.repository.BPELPackageRepository) PackageManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.PackageManagementException) TenantProcessStoreImpl(org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl) PackageManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.PackageManagementException) BPELUIException(org.wso2.carbon.bpel.core.ode.integration.store.BPELUIException) BPELPackageInfo(org.wso2.carbon.bpel.core.ode.integration.store.repository.BPELPackageInfo)

Aggregations

BLangPackage (org.wso2.ballerinalang.compiler.tree.BLangPackage)49 ArrayList (java.util.ArrayList)34 Test (org.testng.annotations.Test)29 Page (org.ballerinalang.docgen.model.Page)18 File (java.io.File)16 CompilerContext (org.wso2.ballerinalang.compiler.util.CompilerContext)16 IOException (java.io.IOException)15 Path (java.nio.file.Path)13 List (java.util.List)13 BLangStruct (org.wso2.ballerinalang.compiler.tree.BLangStruct)11 PackageID (org.ballerinalang.model.elements.PackageID)10 Compiler (org.wso2.ballerinalang.compiler.Compiler)10 BLangFunction (org.wso2.ballerinalang.compiler.tree.BLangFunction)10 CompilerOptions (org.wso2.ballerinalang.compiler.util.CompilerOptions)10 Collectors (java.util.stream.Collectors)9 Arrays (java.util.Arrays)8 CompilerPhase (org.ballerinalang.compiler.CompilerPhase)7 BInvokableSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol)6 BPackageSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol)6 BLangNode (org.wso2.ballerinalang.compiler.tree.BLangNode)6