Search in sources :

Example 1 with Version_type0

use of org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Version_type0 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 2 with Version_type0

use of org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Version_type0 in project carbon-business-process by wso2.

the class BPELPackageManagementServiceSkeleton method getAllVersionsOfPackage.

private Versions_type0 getAllVersionsOfPackage(BPELPackageInfo packageInfo, int maxRemainingPackages) throws PackageManagementException {
    Versions_type0 versionsList = new Versions_type0();
    List<String> versions = packageInfo.getAvailableVersions();
    Collections.reverse(versions);
    int count = 0;
    int startIndex = maxRemainingPackages < 0 ? versions.size() + maxRemainingPackages : 0;
    int endIndex = versions.size() - 1;
    for (int i = startIndex; i <= endIndex && Math.abs(maxRemainingPackages) > count; i++) {
        String version = versions.get(i);
        Version_type0 packageVersion = new Version_type0();
        packageVersion.setName(version);
        packageVersion.setProcesses(getProcessesForPackage(version));
        if (version.equals(packageInfo.getName() + "-" + packageInfo.getLatestVersion())) {
            packageVersion.setIsLatest(true);
        } else {
            packageVersion.setIsLatest(false);
        }
        versionsList.addVersion(packageVersion);
        count++;
    }
    return versionsList;
}
Also used : Version_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Version_type0) Versions_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Versions_type0)

Aggregations

Version_type0 (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Version_type0)2 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 Versions_type0 (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Versions_type0)1