Search in sources :

Example 6 with HumanTaskRuntimeException

use of org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException in project carbon-business-process by wso2.

the class HumanTaskStore method removeMatchingPackageAfterTaskObsoletion.

private boolean removeMatchingPackageAfterTaskObsoletion(String packageName) {
    final HumanTaskEngine taskEngine = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine();
    boolean matchingPackagesFound = false;
    final int tId = this.tenantId;
    List<HumanTaskBaseConfiguration> matchingTaskConfigurations = new ArrayList<HumanTaskBaseConfiguration>();
    for (final HumanTaskBaseConfiguration configuration : this.getTaskConfigurations()) {
        if (configuration.getPackageName().equals(packageName)) {
            matchingTaskConfigurations.add(configuration);
            try {
                taskEngine.getScheduler().execTransaction(new Callable<Object>() {

                    public Object call() throws Exception {
                        taskEngine.getDaoConnectionFactory().getConnection().obsoleteTasks(configuration.getName().toString(), tId);
                        return null;
                    }
                });
            } catch (Exception e) {
                String errMsg = "Error occurred while making tasks obsolete";
                log.error(errMsg);
                throw new HumanTaskRuntimeException(errMsg, e);
            }
            // we don't want the associated service once the task configuration is removed!
            removeAxisServiceForTaskConfiguration(configuration);
            matchingPackagesFound = true;
        }
    }
    // remove the task configurations with the matching package name.
    for (HumanTaskBaseConfiguration removableConfiguration : matchingTaskConfigurations) {
        this.getTaskConfigurations().remove(removableConfiguration);
    }
    return matchingPackagesFound;
}
Also used : HumanTaskEngine(org.wso2.carbon.humantask.core.engine.HumanTaskEngine) ArrayList(java.util.ArrayList) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) HumanTaskDeploymentException(org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Example 7 with HumanTaskRuntimeException

use of org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException in project carbon-business-process by wso2.

the class XPathExpressionRuntime method evaluateAsPart.

/**
 * Evaluate the expression returns an OMElement
 *
 * @param exp      Expresion
 * @param partName Name of the part
 * @param evalCtx  EvaluationContext
 * @return Part as an Node
 */
@Override
public Node evaluateAsPart(String exp, String partName, EvaluationContext evalCtx) {
    Document document = DOMUtils.newDocument();
    Node node = document.createElement(partName);
    List<Node> nodeList = evaluate(exp, evalCtx);
    if (nodeList.size() == 0) {
        String errMsg = "0 nodes selected for the expression: " + exp;
        log.error(errMsg);
        throw new HumanTaskRuntimeException(errMsg);
    } else if (nodeList.size() > 1) {
        String errMsg = "More than one nodes are selected for the expression: " + exp;
        log.error(errMsg);
        throw new HumanTaskRuntimeException(errMsg);
    }
    Node partNode = nodeList.get(0);
    replaceElement((Element) node, (Element) partNode);
    return node;
}
Also used : HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Example 8 with HumanTaskRuntimeException

use of org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException in project carbon-business-process by wso2.

the class CommonTaskUtil method getAssignableUserNameList.

/**
 * Returns the list of assignable user name list.
 *
 * @param task               : The task object.
 * @param excludeActualOwner : Whether to exclude the actual owner from the returned list.
 * @return : the list of assignable user name list.
 */
public static List<String> getAssignableUserNameList(TaskDAO task, boolean excludeActualOwner) {
    List<String> allPotentialOwners = new ArrayList<String>();
    GenericHumanRoleDAO ghr = task.getGenericHumanRole(GenericHumanRole.GenericHumanRoleType.POTENTIAL_OWNERS);
    RegistryService registryService = HumanTaskServiceComponent.getRegistryService();
    for (OrganizationalEntityDAO orgEntity : ghr.getOrgEntities()) {
        if (OrganizationalEntityDAO.OrganizationalEntityType.GROUP.equals(orgEntity.getOrgEntityType())) {
            String roleName = orgEntity.getName();
            UserRealm userRealm;
            try {
                userRealm = registryService.getUserRealm(task.getTenantId());
                String[] assignableUsersArray = userRealm.getUserStoreManager().getUserListOfRole(roleName);
                allPotentialOwners.addAll(Arrays.asList(assignableUsersArray));
            } catch (RegistryException e) {
                throw new HumanTaskRuntimeException("Cannot locate user realm for tenant id " + task.getTenantId());
            } catch (UserStoreException e) {
                throw new HumanTaskRuntimeException("Error retrieving the UserStoreManager " + task.getTenantId(), e);
            }
        } else if (OrganizationalEntityDAO.OrganizationalEntityType.USER.equals(orgEntity.getOrgEntityType())) {
            allPotentialOwners.add(orgEntity.getName());
        }
    }
    OrganizationalEntityDAO actualOwner = getActualOwner(task);
    if (excludeActualOwner && actualOwner != null) {
        allPotentialOwners.remove(actualOwner.getName());
    }
    return allPotentialOwners;
}
Also used : UserRealm(org.wso2.carbon.user.core.UserRealm) UserStoreException(org.wso2.carbon.user.core.UserStoreException) RegistryService(org.wso2.carbon.registry.core.service.RegistryService) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException)

Example 9 with HumanTaskRuntimeException

use of org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException in project carbon-business-process by wso2.

the class CommonTaskUtil method hasPotentialOwners.

/**
 * Checks whether the given TaskDAO has potential owners.
 *
 * @param task : The task to be checked for potential owners.
 * @return : true if the task has potential owners.
 */
public static boolean hasPotentialOwners(TaskDAO task) {
    PeopleQueryEvaluator pqe = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getPeopleQueryEvaluator();
    boolean hasPotentialOwners = false;
    for (GenericHumanRoleDAO humanRoleDAO : task.getHumanRoles()) {
        if (GenericHumanRoleDAO.GenericHumanRoleType.POTENTIAL_OWNERS.equals(humanRoleDAO.getType()) && humanRoleDAO.getOrgEntities() != null && humanRoleDAO.getOrgEntities().size() > 0) {
            try {
                pqe.checkOrgEntitiesExist(humanRoleDAO.getOrgEntities());
                hasPotentialOwners = true;
            } catch (HumanTaskRuntimeException ex) {
                hasPotentialOwners = false;
            }
        }
    }
    return hasPotentialOwners;
}
Also used : PeopleQueryEvaluator(org.wso2.carbon.humantask.core.engine.PeopleQueryEvaluator) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Example 10 with HumanTaskRuntimeException

use of org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException in project carbon-business-process by wso2.

the class CarbonUserManagerBasedPeopleQueryEvaluator method getUserNameListForRole.

public List<String> getUserNameListForRole(String roleName) {
    if (isExistingRole(roleName)) {
        if (cachingEnabled) {
            Cache<String, List<String>> userNameListForRoleCache = getUserNameListForRoleCache();
            if (userNameListForRoleCache != null && userNameListForRoleCache.containsKey(roleName)) {
                return getUserNameListForRoleCache().get(roleName);
            }
        }
        try {
            ArrayList<String> usernameList = new ArrayList<String>(Arrays.asList(getUserRealm().getUserStoreManager().getUserListOfRole(roleName)));
            if (cachingEnabled) {
                Cache<String, List<String>> userNameListForRoleCache = getUserNameListForRoleCache();
                if (userNameListForRoleCache != null) {
                    getUserNameListForRoleCache().put(roleName, usernameList);
                }
                Cache<String, Boolean> userNameListCache = getUserNameListCache();
                if (userNameListCache != null) {
                    for (String userName : usernameList) {
                        userNameListCache.put(userName, true);
                    }
                }
            }
            return usernameList;
        } catch (UserStoreException e) {
            throw new HumanTaskRuntimeException("Error occurred while calling" + " to realm service for operation isExistingRole", e);
        }
    } else {
        throw new HumanTaskRuntimeException(String.format("The role name[%s] does not exist.", roleName));
    }
}
Also used : ArrayList(java.util.ArrayList) UserStoreException(org.wso2.carbon.user.core.UserStoreException) ArrayList(java.util.ArrayList) List(java.util.List) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Aggregations

HumanTaskRuntimeException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)20 ArrayList (java.util.ArrayList)7 PeopleQueryEvaluator (org.wso2.carbon.humantask.core.engine.PeopleQueryEvaluator)4 OrganizationalEntityDAO (org.wso2.carbon.humantask.core.dao.OrganizationalEntityDAO)3 UserStoreException (org.wso2.carbon.user.core.UserStoreException)3 Calendar (java.util.Calendar)2 List (java.util.List)2 URI (org.apache.axis2.databinding.types.URI)2 GenericHumanRoleDAO (org.wso2.carbon.humantask.core.dao.GenericHumanRoleDAO)2 TaskDAO (org.wso2.carbon.humantask.core.dao.TaskDAO)2 HumanTaskEngine (org.wso2.carbon.humantask.core.engine.HumanTaskEngine)2 TaskConfiguration (org.wso2.carbon.humantask.core.store.TaskConfiguration)2 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)2 Date (java.util.Date)1 AxisFault (org.apache.axis2.AxisFault)1 AxisService (org.apache.axis2.description.AxisService)1 TArgument (org.wso2.carbon.humantask.TArgument)1 HumanTaskServerConfiguration (org.wso2.carbon.humantask.core.configuration.HumanTaskServerConfiguration)1 HumanTaskDAOConnection (org.wso2.carbon.humantask.core.dao.HumanTaskDAOConnection)1 SimpleQueryCriteria (org.wso2.carbon.humantask.core.dao.SimpleQueryCriteria)1