Search in sources :

Example 1 with BPELPackageManagementServiceSkeleton

use of org.wso2.carbon.bpel.core.ode.integration.mgt.services.BPELPackageManagementServiceSkeleton 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)

Aggregations

ArrayList (java.util.ArrayList)1 CarbonApplication (org.wso2.carbon.application.deployer.CarbonApplication)1 Artifact (org.wso2.carbon.application.deployer.config.Artifact)1 BPELPackageManagementServiceSkeleton (org.wso2.carbon.bpel.core.ode.integration.mgt.services.BPELPackageManagementServiceSkeleton)1 LimitedProcessInfoType (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.LimitedProcessInfoType)1 PackageType (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.PackageType)1 Version_type0 (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Version_type0)1