Search in sources :

Example 1 with BPELPackageInfo

use of org.wso2.carbon.bpel.core.ode.integration.store.repository.BPELPackageInfo in project carbon-business-process by wso2.

the class BPELPackageRepository method getBPELPackageInfo.

public BPELPackageInfo getBPELPackageInfo(String packageLocationInRegistry) throws RegistryException {
    BPELPackageInfo bpelPackage = new BPELPackageInfo();
    String name = packageLocationInRegistry.substring(packageLocationInRegistry.lastIndexOf('/') + 1);
    bpelPackage.setName(name);
    bpelPackage.setPackageLocationInRegistry(packageLocationInRegistry);
    Resource packageResource = configRegistry.get(packageLocationInRegistry);
    bpelPackage.setLatestVersion(packageResource.getProperty(BPELConstants.BPEL_PACKAGE_PROP_LATEST_VERSION));
    bpelPackage.setChecksum(packageResource.getProperty(BPELConstants.BPEL_PACKAGE_PROP_LATEST_CHECKSUM));
    BPELPackageInfo.Status status = getStatus(packageResource.getProperty(BPELConstants.BPEL_PACKAGE_PROP_STATUS));
    bpelPackage.setStatus(status);
    if (status.equals(BPELPackageInfo.Status.FAILED)) {
        bpelPackage.setCauseForDeploymentFailure(packageResource.getProperty(BPELConstants.BPEL_PACKAGE_PROP_DEPLOYMENT_ERROR_LOG));
    }
    bpelPackage.setAvailableVersions(getVersionsOfPackage(packageLocationInRegistry));
    return bpelPackage;
}
Also used : Resource(org.wso2.carbon.registry.core.Resource)

Example 2 with BPELPackageInfo

use of org.wso2.carbon.bpel.core.ode.integration.store.repository.BPELPackageInfo 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 3 with BPELPackageInfo

use of org.wso2.carbon.bpel.core.ode.integration.store.repository.BPELPackageInfo 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)

Example 4 with BPELPackageInfo

use of org.wso2.carbon.bpel.core.ode.integration.store.repository.BPELPackageInfo in project carbon-business-process by wso2.

the class BPELPackageManagementServiceSkeleton method getPackageInfo.

private PackageType getPackageInfo(BPELPackageInfo packageInfo, int maxRemainingPackages) throws PackageManagementException {
    PackageType bpelPackage = new PackageType();
    bpelPackage.setName(packageInfo.getName());
    bpelPackage.setState(convertToPackageStatusType(packageInfo.getStatus()));
    bpelPackage.setVersions(getAllVersionsOfPackage(packageInfo, maxRemainingPackages));
    bpelPackage.setErrorLog(packageInfo.getCauseForDeploymentFailure());
    return bpelPackage;
}
Also used : PackageType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.PackageType)

Example 5 with BPELPackageInfo

use of org.wso2.carbon.bpel.core.ode.integration.store.repository.BPELPackageInfo 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

BPELPackageInfo (org.wso2.carbon.bpel.core.ode.integration.store.repository.BPELPackageInfo)3 PackageType (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.PackageType)3 BPELUIException (org.wso2.carbon.bpel.core.ode.integration.store.BPELUIException)2 TenantProcessStoreImpl (org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl)2 BPELPackageRepository (org.wso2.carbon.bpel.core.ode.integration.store.repository.BPELPackageRepository)2 PackageManagementException (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.PackageManagementException)2 DeployedPackagesPaginated (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.DeployedPackagesPaginated)2 Resource (org.wso2.carbon.registry.core.Resource)2 ArrayList (java.util.ArrayList)1 Version_type0 (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Version_type0)1 Versions_type0 (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Versions_type0)1 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)1