Search in sources :

Example 11 with HumanTaskRuntimeException

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

the class CarbonUserManagerBasedPeopleQueryEvaluator method createGHRForRoleName.

public GenericHumanRoleDAO createGHRForRoleName(String roleName, GenericHumanRoleDAO.GenericHumanRoleType type) {
    if (isExistingRole(roleName)) {
        List<String> userNames = getUserNameListForRole(roleName);
        GenericHumanRoleDAO ghr = getConnection().createNewGHRObject(type);
        List<OrganizationalEntityDAO> orgEntities = new ArrayList<OrganizationalEntityDAO>();
        for (String userName : userNames) {
            OrganizationalEntityDAO orgEntity = getConnection().createNewOrgEntityObject(userName, OrganizationalEntityDAO.OrganizationalEntityType.USER);
            orgEntity.addGenericHumanRole(ghr);
            orgEntities.add(orgEntity);
        }
        ghr.setOrgEntities(orgEntities);
        return ghr;
    } else {
        throw new HumanTaskRuntimeException(String.format("The role name[%s] does not exist.", roleName));
    }
}
Also used : OrganizationalEntityDAO(org.wso2.carbon.humantask.core.dao.OrganizationalEntityDAO) ArrayList(java.util.ArrayList) GenericHumanRoleDAO(org.wso2.carbon.humantask.core.dao.GenericHumanRoleDAO) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Example 12 with HumanTaskRuntimeException

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

the class CarbonUserManagerBasedPeopleQueryEvaluator method getRoleNameListForUser.

public List<String> getRoleNameListForUser(String userName) {
    String tUserName = userName;
    List<String> matchingRoleNames = new ArrayList<String>();
    if (StringUtils.isNotEmpty(tUserName)) {
        tUserName = tUserName.trim();
        if (cachingEnabled) {
            Cache<String, List<String>> roleNameListForUserCache = getRoleNameListForUserCache();
            if (roleNameListForUserCache != null && roleNameListForUserCache.containsKey(tUserName)) {
                return roleNameListForUserCache.get(tUserName);
            }
        }
        if (isExistingUser(tUserName)) {
            try {
                matchingRoleNames.addAll(Arrays.asList(getUserRealm().getUserStoreManager().getRoleListOfUser(tUserName)));
                if (cachingEnabled) {
                    getRoleNameListForUserCache().put(tUserName, matchingRoleNames);
                    Cache<String, Boolean> roleNameListCache = getRoleNameListCache();
                    if (roleNameListCache != null) {
                        for (String roleName : matchingRoleNames) {
                            roleNameListCache.put(roleName, true);
                        }
                    }
                }
            } catch (UserStoreException ex) {
                throw new HumanTaskRuntimeException("Error occurred while calling" + " to realm service for operation isExistingRole", ex);
            }
        }
    }
    return matchingRoleNames;
}
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)

Example 13 with HumanTaskRuntimeException

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

the class HumanTaskStore method removeAxisServiceForTaskConfiguration.

/**
 * Remove the service associated with the task configuration.
 *
 * @param removableConfiguration : The task configuration.
 */
public void removeAxisServiceForTaskConfiguration(HumanTaskBaseConfiguration removableConfiguration) {
    try {
        // If there are matching axis services we remove them.
        if (removableConfiguration.getServiceName() != null && StringUtils.isNotEmpty(removableConfiguration.getServiceName().getLocalPart())) {
            String axisServiceName = removableConfiguration.getServiceName().getLocalPart();
            AxisService axisService = getTenantAxisConfig().getService(axisServiceName);
            if (axisService != null) {
                axisService.releaseSchemaList();
                getTenantAxisConfig().stopService(axisServiceName);
                getTenantAxisConfig().removeServiceGroup(axisServiceName);
                if (log.isDebugEnabled()) {
                    log.debug("Un deployed axis2 service " + axisServiceName);
                }
            } else {
                log.warn("Could not find matching AxisService in " + "Tenant AxisConfiguration for service name :" + axisServiceName);
            }
        } else {
            log.warn(String.format("Could not find a associated service name for " + "[%s] configuration [%s]", removableConfiguration.getConfigurationType(), removableConfiguration.getName().toString()));
        }
    } catch (AxisFault axisFault) {
        String error = "Error occurred while removing the axis service " + removableConfiguration.getServiceName();
        log.error(error);
        throw new HumanTaskRuntimeException(error, axisFault);
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) AxisService(org.apache.axis2.description.AxisService) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Example 14 with HumanTaskRuntimeException

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

the class JaxpFunctionResolver method generateFrequencyMap.

/**
 * Generates a HashMap containing string items and it's frequency in a given NodeList
 * logic : create a HashMap where key:textContent value:frequency of the textContent in the list
 * @param list : NodeList
 * @return  : Map<String,Integer> map of string occurrence frequencies
 */
private Map<String, Integer> generateFrequencyMap(ArrayList list) throws HumanTaskRuntimeException {
    Map<String, Integer> frequencyMap = new HashMap<String, Integer>();
    for (int i = 0; i < list.size(); i++) {
        try {
            String item = ((Element) list.get(i)).getTextContent();
            if (frequencyMap.containsKey(item)) {
                int frequency = frequencyMap.get(item) + 1;
                frequencyMap.put(item, frequency);
            } else {
                frequencyMap.put(item, 1);
            }
        } catch (DOMException e) {
            throw new HumanTaskRuntimeException("Invalid arguments:" + list, e);
        } catch (ClassCastException e) {
            throw new HumanTaskRuntimeException("Invalid arguments:" + list, e);
        }
    }
    return frequencyMap;
}
Also used : HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Example 15 with HumanTaskRuntimeException

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

the class HumanTaskCoordinationProtocolManagementSkeleton method getCaller.

private String getCaller() {
    // TODO - remove hard coded user name value once moved to task view page.
    String userName = "admin";
    PeopleQueryEvaluator pqe = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getPeopleQueryEvaluator();
    if (StringUtils.isNotEmpty(pqe.getLoggedInUser())) {
        userName = pqe.getLoggedInUser();
    }
    // logged in user.
    if (StringUtils.isEmpty(userName)) {
        throw new HumanTaskRuntimeException("Cannot determine the user name of the user " + "performing the task operation!");
    }
    return userName;
}
Also used : PeopleQueryEvaluator(org.wso2.carbon.humantask.core.engine.PeopleQueryEvaluator)

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