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;
}
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;
}
Aggregations