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