Search in sources :

Example 1 with PackageManagementException

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

the class HumanTaskPackageManagementSkeleton method fillTaskDefinitionInfo.

private TaskDefinitionInfo fillTaskDefinitionInfo(HumanTaskBaseConfiguration taskConf) throws PackageManagementException {
    TaskDefinitionInfo taskDefInfo = new TaskDefinitionInfo();
    taskDefInfo.setTaskName(taskConf.getName());
    HumanTaskDefinition taskDefinition = new HumanTaskDefinition();
    taskDefinition.setExtraElement(createTaskDefOMElement(taskConf.getHumanTaskDefinitionFile()));
    taskDefInfo.setDefinition(taskDefinition);
    return taskDefInfo;
}
Also used : SimpleTaskDefinitionInfo(org.wso2.carbon.humantask.core.deployment.SimpleTaskDefinitionInfo)

Example 2 with PackageManagementException

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

the class HumanTaskPackageManagementSkeleton method getTaskConfigInfo.

/**
 * +     * Check the configuration type and return the configuration information for a given task ID
 * +     * @param taskId
 * +     * @return  TaskConfigInfoResponse response
 * +     * @throws  PackageManagementException
 * +
 */
public TaskConfigInfoResponse getTaskConfigInfo(QName taskId) throws PackageManagementException {
    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    TaskConfigInfoResponse response = null;
    HumanTaskBaseConfiguration taskConf = HumanTaskServiceComponent.getHumanTaskServer().getTaskStoreManager().getHumanTaskStore(tenantId).getTaskConfiguration(taskId);
    if (taskConf != null) {
        response = new TaskConfigInfoResponse();
        if (taskConf.getConfigurationType() == HumanTaskBaseConfiguration.ConfigurationType.TASK) {
            response.setTaskName(taskConf.getName());
            response.setServiceName(taskConf.getServiceName());
            response.setPortName(taskConf.getPortName());
            response.setCallbackServiceName(((TaskConfiguration) taskConf).getCallbackServiceName());
            response.setCallbackPortName(((TaskConfiguration) taskConf).getCallbackPortName());
        } else if (taskConf.getConfigurationType() == HumanTaskBaseConfiguration.ConfigurationType.NOTIFICATION) {
            response.setTaskName(((NotificationConfiguration) taskConf).getName());
            response.setServiceName(taskConf.getServiceName());
            response.setPortName(taskConf.getPortName());
        }
    }
    return response;
}
Also used : NotificationConfiguration(org.wso2.carbon.humantask.core.store.NotificationConfiguration) HumanTaskBaseConfiguration(org.wso2.carbon.humantask.core.store.HumanTaskBaseConfiguration)

Example 3 with PackageManagementException

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

the class HumanTaskPackageManagementSkeleton method createTaskDefOMElement.

private OMElement createTaskDefOMElement(File humanTaskDefFile) throws PackageManagementException {
    XMLStreamReader reader;
    FileInputStream fis = null;
    OMElement humanTaskDefinition;
    try {
        fis = new FileInputStream(humanTaskDefFile);
        XMLInputFactory xif = XMLInputFactory.newInstance();
        reader = xif.createXMLStreamReader(fis);
        StAXOMBuilder builder = new StAXOMBuilder(reader);
        humanTaskDefinition = builder.getDocumentElement();
        humanTaskDefinition.build();
    } catch (XMLStreamException e) {
        String errMsg = "XML stream reader exception: " + humanTaskDefFile.getAbsolutePath();
        log.error(errMsg, e);
        throw new PackageManagementException(errMsg, e);
    } catch (FileNotFoundException e) {
        String errMsg = "HT File reading exception: " + humanTaskDefFile.getAbsolutePath();
        log.error(errMsg, e);
        throw new PackageManagementException(errMsg, e);
    } finally {
        if (fis != null) {
            try {
                fis.close();
            } catch (IOException e) {
                log.warn("Cannot close file input stream.", e);
            }
        }
    }
    return humanTaskDefinition;
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) XMLStreamException(javax.xml.stream.XMLStreamException) FileNotFoundException(java.io.FileNotFoundException) OMElement(org.apache.axiom.om.OMElement) StAXOMBuilder(org.apache.axiom.om.impl.builder.StAXOMBuilder) IOException(java.io.IOException) PackageManagementException(org.wso2.carbon.humantask.skeleton.mgt.services.PackageManagementException) FileInputStream(java.io.FileInputStream) XMLInputFactory(javax.xml.stream.XMLInputFactory)

Example 4 with PackageManagementException

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

the class HumanTaskPackageManagementSkeleton method listTasksInPackage.

/**
 * Lists the tasks in the given package name.
 *
 * @param packageName : The name of the package to list task definitions.
 * @return : The Task_type0 array containing the task definition information.
 */
public Task_type0[] listTasksInPackage(String packageName) throws PackageManagementException {
    if (StringUtils.isEmpty(packageName)) {
        throw new IllegalArgumentException("The provided package name is empty!");
    }
    try {
        List<SimpleTaskDefinitionInfo> taskDefsInPackage = getTenantTaskStore().getTaskConfigurationInfoListForPackage(packageName);
        Task_type0[] taskDefArray = new Task_type0[taskDefsInPackage.size()];
        int i = 0;
        for (SimpleTaskDefinitionInfo taskDefinitionInfo : taskDefsInPackage) {
            taskDefArray[i] = createTaskTypeObject(taskDefinitionInfo);
            i++;
        }
        return taskDefArray;
    } catch (Exception ex) {
        String errMsg = "listTasksInPackage operation failed";
        log.error(errMsg, ex);
        throw new PackageManagementException(errMsg, ex);
    }
}
Also used : SimpleTaskDefinitionInfo(org.wso2.carbon.humantask.core.deployment.SimpleTaskDefinitionInfo) PackageManagementException(org.wso2.carbon.humantask.skeleton.mgt.services.PackageManagementException) XMLStreamException(javax.xml.stream.XMLStreamException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) PackageManagementException(org.wso2.carbon.humantask.skeleton.mgt.services.PackageManagementException)

Example 5 with PackageManagementException

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

Aggregations

BPELUIException (org.wso2.carbon.bpel.core.ode.integration.store.BPELUIException)4 TenantProcessStoreImpl (org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl)4 BPELPackageRepository (org.wso2.carbon.bpel.core.ode.integration.store.repository.BPELPackageRepository)4 PackageManagementException (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.PackageManagementException)4 FileNotFoundException (java.io.FileNotFoundException)3 IOException (java.io.IOException)3 XMLStreamException (javax.xml.stream.XMLStreamException)3 PackageType (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.PackageType)3 SimpleTaskDefinitionInfo (org.wso2.carbon.humantask.core.deployment.SimpleTaskDefinitionInfo)3 PackageManagementException (org.wso2.carbon.humantask.skeleton.mgt.services.PackageManagementException)3 BPELPackageInfo (org.wso2.carbon.bpel.core.ode.integration.store.repository.BPELPackageInfo)2 DeployedPackagesPaginated (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.DeployedPackagesPaginated)2 HumanTaskBaseConfiguration (org.wso2.carbon.humantask.core.store.HumanTaskBaseConfiguration)2 NotificationConfiguration (org.wso2.carbon.humantask.core.store.NotificationConfiguration)2 FileInputStream (java.io.FileInputStream)1 XMLInputFactory (javax.xml.stream.XMLInputFactory)1 XMLStreamReader (javax.xml.stream.XMLStreamReader)1 OMElement (org.apache.axiom.om.OMElement)1 StAXOMBuilder (org.apache.axiom.om.impl.builder.StAXOMBuilder)1 Version_type0 (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Version_type0)1