use of org.wso2.carbon.registry.api.RegistryService 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.registry.api.RegistryService in project jaggery by wso2.
the class RegistryHostObject method getRegistry.
private static UserRegistry getRegistry(String username, String password) throws ScriptException {
UserRegistry registry;
RegistryService registryService = RegistryHostObjectContext.getRegistryService();
String tDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(false);
try {
int tId = RegistryHostObjectContext.getRealmService().getTenantManager().getTenantId(tDomain);
registry = registryService.getGovernanceUserRegistry(username, password, tId);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new ScriptException(e);
}
if (registry == null) {
String msg = "User governance registry cannot be retrieved";
throw new ScriptException(msg);
}
return registry;
}
Aggregations