Search in sources :

Example 11 with RegistryService

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;
}
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 12 with RegistryService

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;
}
Also used : ScriptException(org.jaggeryjs.scriptengine.exceptions.ScriptException) UserRegistry(org.wso2.carbon.registry.core.session.UserRegistry) RegistryService(org.wso2.carbon.registry.core.service.RegistryService) RegistryException(org.wso2.carbon.registry.api.RegistryException) IndexerException(org.wso2.carbon.registry.indexing.indexer.IndexerException) UserStoreException(org.wso2.carbon.user.core.UserStoreException) CarbonException(org.wso2.carbon.CarbonException) ScriptException(org.jaggeryjs.scriptengine.exceptions.ScriptException)

Aggregations

RegistryService (org.wso2.carbon.registry.core.service.RegistryService)8 RegistryException (org.wso2.carbon.registry.api.RegistryException)6 Registry (org.wso2.carbon.registry.api.Registry)5 RegistryService (org.wso2.carbon.registry.api.RegistryService)4 File (java.io.File)3 ProcessEngine (org.activiti.engine.ProcessEngine)3 RepositoryService (org.activiti.engine.RepositoryService)3 BPSFault (org.wso2.carbon.bpmn.core.BPSFault)3 Resource (org.wso2.carbon.registry.api.Resource)3 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)3 UserRealm (org.wso2.carbon.user.core.UserRealm)3 UserStoreException (org.wso2.carbon.user.core.UserStoreException)3 Deployment (org.activiti.engine.repository.Deployment)2 CarbonException (org.wso2.carbon.CarbonException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 ZipInputStream (java.util.zip.ZipInputStream)1