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